API TO TEMP UPDATE
This commit is contained in:
parent
ca405f4bd2
commit
f9f9d45f08
@ -11,6 +11,9 @@ if ($conn->connect_error) {
|
||||
|
||||
// Check if POST request was received
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Array to collect messages about file processing
|
||||
$file_messages = [];
|
||||
|
||||
// Receive JSON from the laboratory via a field in the form (e.g., 'json_data')
|
||||
if (isset($_POST['json_data'])) {
|
||||
$json_data = $_POST['json_data'];
|
||||
@ -108,6 +111,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Handle file uploads if they exist
|
||||
if (!empty($_FILES)) {
|
||||
include('process_files.php'); // Include file processing logic here
|
||||
|
||||
// Retrieve any messages added in process_files.php for files
|
||||
if (!empty($GLOBALS['file_messages'])) {
|
||||
$file_messages = $GLOBALS['file_messages'];
|
||||
}
|
||||
}
|
||||
|
||||
// Set a session variable to notify the report import
|
||||
@ -124,7 +132,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
"product_refnumber" => $product_refnumber, // Product number
|
||||
"report_number" => $report_number, // Report number
|
||||
"rating" => $rating, // Report rating
|
||||
"saved_at" => $saved_at // Save date
|
||||
"saved_at" => $saved_at, // Save date
|
||||
"file_messages" => $file_messages // Include file messages
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
// Initialize an array to store file messages
|
||||
$GLOBALS['file_messages'] = [];
|
||||
|
||||
// Check if there are any files uploaded
|
||||
if (!empty($_FILES)) {
|
||||
// Define the directory where files will be stored
|
||||
@ -28,29 +31,16 @@ if (!empty($_FILES)) {
|
||||
$stmt = $conn->prepare("INSERT INTO report_files (uuid, original_filename, stored_filename, filepath, file_comment) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("sssss", $uuid, $original_filename, $stored_filename, $filepath, $file_comment);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Failed to save file information for $original_filename."
|
||||
]);
|
||||
continue;
|
||||
if ($stmt->execute()) {
|
||||
$GLOBALS['file_messages'][] = "File $original_filename uploaded and information saved.";
|
||||
} else {
|
||||
$GLOBALS['file_messages'][] = "Failed to save file information for $original_filename.";
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"message" => "File $original_filename uploaded and information saved."
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Failed to move file $original_filename."
|
||||
]);
|
||||
$GLOBALS['file_messages'][] = "Failed to move file $original_filename.";
|
||||
}
|
||||
} else {
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Error uploading file $original_filename. Error code: " . $file['error']
|
||||
]);
|
||||
$GLOBALS['file_messages'][] = "Error uploading file $original_filename. Error code: " . $file['error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
public/userarea/apilogic/report_files/672b418927d8e_details1.png
Normal file
BIN
public/userarea/apilogic/report_files/672b418927d8e_details1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/apilogic/report_files/672b418927d8e_details2.png
Normal file
BIN
public/userarea/apilogic/report_files/672b418927d8e_details2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
Binary file not shown.
BIN
public/userarea/report_files/672b42a9e4bf5_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/672b42a9e4bf5_TEST REPORT.pdf
Normal file
Binary file not shown.
BIN
public/userarea/report_files/672b42a9e4bf5_details1.png
Normal file
BIN
public/userarea/report_files/672b42a9e4bf5_details1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/672b42a9e4bf5_details2.png
Normal file
BIN
public/userarea/report_files/672b42a9e4bf5_details2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
BIN
public/userarea/report_files/672b42a9e4bf5_productjacket.png
Normal file
BIN
public/userarea/report_files/672b42a9e4bf5_productjacket.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/672b42a9e4bf5_reportdata.pdf
Normal file
BIN
public/userarea/report_files/672b42a9e4bf5_reportdata.pdf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user