31 lines
903 B
PHP
31 lines
903 B
PHP
<?php
|
|
include('../include/headscript.php');
|
|
include("../class/company.php");
|
|
|
|
// Connessione al database
|
|
$conn = new mysqli($servername, $username, $password, $database);
|
|
|
|
// Controllo connessione
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
// Aggiorna le date in reports utilizzando i dati di reportsbydate
|
|
$updateQuery = "
|
|
UPDATE reports AS r
|
|
INNER JOIN reportsbydate AS rb
|
|
ON r.reportsNumberLab = rb.report_no
|
|
SET
|
|
r.reportDatein = IF(rb.in_date IS NOT NULL, rb.in_date, r.reportDatein),
|
|
r.reportsDateDue = IF(rb.due_date IS NOT NULL, rb.due_date, r.reportsDateDue),
|
|
r.reportsDateOut = IF(rb.out_date IS NOT NULL, rb.out_date, r.reportsDateOut)
|
|
";
|
|
|
|
if ($conn->query($updateQuery) === TRUE) {
|
|
echo "Reports updated successfully.";
|
|
} else {
|
|
echo "Error updating reports: " . $conn->error;
|
|
}
|
|
|
|
$conn->close();
|