diff --git a/public/declarationtd.php b/public/declarationtd.php index e153aad..71842eb 100644 --- a/public/declarationtd.php +++ b/public/declarationtd.php @@ -2,24 +2,33 @@ include('include/headscript.php'); ?> prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); + +if (!$rowtd) { + die('Dossier non trovato'); } +$statustd = $rowtd['statustd']; +$trfmod = $rowtd['trfmod']; +$idtrftd = (int)$rowtd['idtrf']; +$idtrf = $idtrftd; // stesso valore: usato nei form di invio + if (isset($_POST["contactsendmail"])) { $contactsendmail = $_POST["contactsendmail"]; @@ -41,21 +50,7 @@ $pdfdomanda = $trfnumberfinal->getColumnVal("pdffilename"); $certname = new WA_MySQLi_RS("certname", $cmctrfdb, 1); $certname->setQuery("SELECT * FROM certificationtype WHERE certificationtype.idcertificationtype='$idcert'"); $certname->execute(); ?> -prepare($sql); -$stmt->bind_param("i", $idtd); // "i" indica che l'id è un intero -$stmt->execute(); -$result = $stmt->get_result(); -$row = $result->fetch_assoc(); -$statustd = $row['statustd']; -$idtrftd = $row['idtrf']; -$trfmod = $row['trfmod']; -$stmt->close(); -$conn->close(); -?> + close(); +
+
+
+

getColumnVal("sample_description")); ?> - TF: -Rev.

+
+
+
-
-
-
- -
- -
-
diff --git a/public/sendtd.php b/public/sendtd.php index 8891b54..8f37c69 100644 --- a/public/sendtd.php +++ b/public/sendtd.php @@ -16,26 +16,30 @@ if (isset($companyData["logoimage"]) && !empty($companyData["logoimage"])) { $companylogo = $companyData["logoimage"]; $_SESSION['companylogo'] = $companylogo; } -// pickup the get variable -if (isset($_POST["idtrf"])) { - $idtrf = $_POST["idtrf"]; -} -if (isset($_GET["idtrf"])) { - $idtrf = $_GET["idtrf"]; +$idtd = (int)($_POST['idtd'] ?? $_GET['idtd'] ?? 0); +if ($idtd <= 0) { + die('ID dossier mancante'); } -if (isset($_GET["idtrftd"])) { - $idtrftd = $_GET["idtrftd"]; -} -if (isset($_POST["idtrftd"])) { - $idtrftd = $_GET["idtrftd"]; -} -if (isset($_GET["idtd"])) { - $idtd = $_GET["idtd"]; -} -if (isset($_POST["idtd"])) { - $idtd = $_POST["idtd"]; +// query data_td +$conn = new mysqli($servername, $username, $password, $dbname); +$stmt = $conn->prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); + +if (!$rowtd) { + die('Dossier non trovato'); } + +$statustd = $rowtd['statustd']; +$idtrftd = (int)$rowtd['idtrf']; +$idtrf = $idtrftd; +$tdnumber = $rowtd['tdnumber']; +$tdrev = $rowtd['td_rev']; +$trfmod = $rowtd['trfmod']; if (isset($_POST["tokensignatureon"])) { $tokensignatureon = $_POST["tokensignatureon"]; } @@ -61,7 +65,8 @@ if (isset($_POST["adminconfirm"])) { present()->signaturecode; if ($tokenid != $tokensignatureon) { - header("Location: declaration.php?idtrf=$idtrf&tokenresult=ko"); + header("Location: declarationtd.php?idtd=$idtd&tokenresult=ko"); + exit; } else { // update trf details` if (isset($_POST["formdeclaration"])) { @@ -92,23 +97,7 @@ if ($tokenid != $tokensignatureon) { $revnumb = $trfnumberfinal->getColumnVal("revtrf"); ?> getColumnVal("idcertification") ?> - prepare($sql); - $stmt->bind_param("i", $idtd); // "i" indica che l'id è un intero - $stmt->execute(); - $result = $stmt->get_result(); - $row = $result->fetch_assoc(); - $statustd = $row['statustd']; - $idtrftd = $row['idtrf']; - $tdnumber = $row['tdnumber']; - $tdrev = $row['td_rev']; - $trfmod = $row['trfmod']; - $stmt->close(); - $conn->close(); - ?> + setQuery("SELECT * FROM certificationtype WHERE certificationtype.idcertificationtype='$idcert'"); @@ -317,7 +306,7 @@ if ($tokenid != $tokensignatureon) { $mail->addAddress($emailuser); // Add a recipient $mail->addAttachment($file1); // Add attachments // Optional name - $mail->Subject = "Technical File:" . $tdnumber; + $mail->Subject = "Technical File: " . $tdnumber . " Rev." . $tdrev; $mail->Body = $htmlContent; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if ($adminconfirm == 'N') { @@ -343,7 +332,7 @@ if ($tokenid != $tokensignatureon) { $mail_cs->addAddress('d.dondena@cimac.it'); $mail_cs->addAddress('c.boscaino@cimac.it'); $mail_cs->addAddress('a.boscaino@cimac.it'); - $mail_cs->Subject = "Nuovo Fascicolo Tecnico Inserito: $tdnumber da $companyname"; + $mail_cs->Subject = "Nuovo Fascicolo Tecnico Inserito: $tdnumber Rev.$tdrev da $companyname"; $mail_cs->Body = "Buongiorno,\n\nla presente mail per segnalare l'inserimento di un nuovo fascicolo tecnico da parte dell'azienda " . $companyname . ". Fascicolo tecnico numero " . $tdnumber . "."; $mail_cs->AltBody = "Buongiorno,\n\nla presente mail per segnalare l'inserimento di un nuovo fascicolo tecnico da parte dell'azienda " . $companyname . ". Fascicolo tecnico numero " . $tdnumber . "."; if ($adminconfirm == 'N') { diff --git a/public/techdossier_adddocument.php b/public/techdossier_adddocument.php index d5f7472..aa62cff 100644 --- a/public/techdossier_adddocument.php +++ b/public/techdossier_adddocument.php @@ -3,24 +3,32 @@ include('include/headscript.php'); include('languages/' . $_SESSION['langselect'] . '/tdgen.php'); ?> -prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); + +if (!$rowtd) { + die('Dossier non trovato'); +} + +$idtrftd = (int)$rowtd['idtrf']; +$idcompany = (int)$rowtd['idcompany']; + +// descrizione articolo (dal TRF) per il titolo +$stmt = $conn->prepare("SELECT sample_description FROM `trf-details` WHERE idtrfdetails = ?"); +$stmt->bind_param("i", $idtrftd); +$stmt->execute(); +$description = $stmt->get_result()->fetch_assoc()['sample_description'] ?? ''; +$stmt->close(); +$conn->close(); ?> close();
+
+
+
+

- TF: -Rev.

+
+
+
- - - - - - diff --git a/public/techdossier_start.php b/public/techdossier_start.php index 9d28f25..12ec26b 100644 --- a/public/techdossier_start.php +++ b/public/techdossier_start.php @@ -905,7 +905,7 @@ $conn->close();
- + diff --git a/public/techdossier_step2.php b/public/techdossier_step2.php index fb66535..90be59b 100644 --- a/public/techdossier_step2.php +++ b/public/techdossier_step2.php @@ -4,18 +4,26 @@ include 'include/headscript.php'; include('languages/' . $_SESSION['langselect'] . '/tdgen.php'); ?> -prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$row = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); + +if (!$row) { + die('Dossier non trovato'); } + +$idtrftd = (int)$row['idtrf']; +$idcompany = (int)$row['idcompany']; ?> close(); */ ?> prepare($sql); -$stmt->bind_param("i", $idtd); // "i" indica che l'id è un intero -$stmt->execute(); -$result = $stmt->get_result(); -$row = $result->fetch_assoc(); -$stmt->close(); -$conn->close(); -?> -setQuery("SELECT * FROM `trf-details` WHERE `trf-details`.idtrfdetails='$idtrftd'"); $tdquery->execute(); @@ -173,12 +169,6 @@ $trfn = $tdquery->getColumnVal("trfnumber"); $trfrev = $tdquery->getColumnVal("revtrf"); $trfnumb = $trfn . ' VER.' . $trfrev; ?> -setQuery("SELECT * FROM `trf-details` LEFT JOIN auth_users ON `trf-details`.iduser=auth_users.id LEFT JOIN article_type ON `trf-details`.idarticletype=article_type.idarticletype LEFT JOIN certificationtype ON certificationtype.idcertificationtype=`trf-details`.idcertification WHERE `trf-details`.idcompany='$idcompany' AND `trf-details`.signedon <>'' ORDER BY `trf-details`.trfnumber"); -$archivetrflist->execute(); ?> - @@ -352,7 +342,7 @@ $archivetrflist->execute(); ?>
-

- TRF:

+

- TF: -Rev.

diff --git a/public/techdossier_step3.php b/public/techdossier_step3.php index 264cc3e..425918d 100644 --- a/public/techdossier_step3.php +++ b/public/techdossier_step3.php @@ -4,115 +4,28 @@ include 'include/headscript.php'; include('languages/' . $_SESSION['langselect'] . '/tdgen.php'); ?> - $value) { - } - } else { - // Ci sono stati errori, ad esempio alcuni campi potrebbero essere vuoti - // Puoi gestire gli errori qui, ad esempio stampandoli - foreach ($errors as $key => $message) { - echo "Errore nel campo $key: $message
"; - } - } +$idtd = (int)($_GET['idtd'] ?? $_POST['iddata_td'] ?? 0); +if ($idtd <= 0) { + die('ID dossier mancante'); } -?> -prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); - - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($idtrftd)) { - // Preparazione della parte iniziale della query di aggiornamento - $updateQuery = "UPDATE data_td SET "; - $updateParts = []; - $queryParams = []; - - // Iterazione sui campi sanificati per costruire la query di aggiornamento - foreach ($sanitizedPost as $key => $value) { - // Escludi idtrftd dalla parte di aggiornamento della query - if ($key !== 'idtrftd') { - $updateParts[] = "$key = ?"; - $queryParams[] = $value; - } - } - - // Controllo se ci sono campi da aggiornare - if (count($updateParts) > 0) { - $updateQuery .= join(', ', $updateParts) . " WHERE idtrf = ?"; - $queryParams[] = $idtrftd; // Aggiungi l'ID alla fine dei parametri della query - - // Preparazione della query - $stmt = $conn->prepare($updateQuery); - - // Costruzione del tipo di parametri (stringhe, in questo caso) - $types = str_repeat('s', count($queryParams)); - - // Aggiunta dei parametri alla statement - $stmt->bind_param($types, ...$queryParams); - - // Esecuzione della query - if ($stmt->execute()) { - } - - // Chiusura dello statement - $stmt->close(); - } +if (!$rowtd) { + die('Dossier non trovato'); } + +$idtrftd = (int)$rowtd['idtrf']; +$idcompany = (int)$rowtd['idcompany']; ?> + close(); */ ?> -prepare($sql); -$stmt->bind_param("i", $idtd); // "i" indica che l'id è un intero -$stmt->execute(); -$result = $stmt->get_result(); -$row = $result->fetch_assoc(); -$stmt->close(); -$conn->close(); -?> setQuery("SELECT * FROM `trf-details` WHERE `trf-details`.idtrfdetails='$idtrftd'"); @@ -227,12 +128,6 @@ switch ($idart) { ?> -setQuery("SELECT * FROM `trf-details` LEFT JOIN auth_users ON `trf-details`.iduser=auth_users.id LEFT JOIN article_type ON `trf-details`.idarticletype=article_type.idarticletype LEFT JOIN certificationtype ON certificationtype.idcertificationtype=`trf-details`.idcertification WHERE `trf-details`.idcompany='$idcompany' AND `trf-details`.signedon <>'' ORDER BY `trf-details`.trfnumber"); -$archivetrflist->execute(); ?> - @@ -400,7 +295,7 @@ $archivetrflist->execute(); ?>
-

- TRF:

+

- TF: -Rev.

diff --git a/public/techdossier_stepsummarynew.php b/public/techdossier_stepsummarynew.php index bebb7a1..591997a 100644 --- a/public/techdossier_stepsummarynew.php +++ b/public/techdossier_stepsummarynew.php @@ -3,123 +3,29 @@ - $value) { - } - } else { - // Ci sono stati errori, ad esempio alcuni campi potrebbero essere vuoti - // Puoi gestire gli errori qui, ad esempio stampandoli - foreach ($errors as $key => $message) { - echo "Errore nel campo $key: $message
"; - } - } +$idtd = (int)($_GET['idtd'] ?? $_GET['iddata_td'] ?? $_POST['iddata_td'] ?? $_POST['idtd'] ?? 0); +if ($idtd <= 0) { + die('ID dossier mancante'); } -?> -prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); - - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($idtrftd)) { - // Preparazione della parte iniziale della query di aggiornamento - $updateQuery = "UPDATE data_td SET "; - $updateParts = []; - $queryParams = []; - - // Iterazione sui campi sanificati per costruire la query di aggiornamento - foreach ($sanitizedPost as $key => $value) { - // Escludi idtrftd dalla parte di aggiornamento della query - if ($key !== 'idtrftd') { - $updateParts[] = "$key = ?"; - $queryParams[] = $value; - } - } - - // Controllo se ci sono campi da aggiornare - if (count($updateParts) > 0) { - $updateQuery .= join(', ', $updateParts) . " WHERE idtrf = ?"; - $queryParams[] = $idtrftd; // Aggiungi l'ID alla fine dei parametri della query - - // Preparazione della query - $stmt = $conn->prepare($updateQuery); - - // Costruzione del tipo di parametri (stringhe, in questo caso) - $types = str_repeat('s', count($queryParams)); - - // Aggiunta dei parametri alla statement - $stmt->bind_param($types, ...$queryParams); - - // Esecuzione della query - if ($stmt->execute()) { - } - - // Chiusura dello statement - $stmt->close(); - } +if (!$rowtd) { + die('Dossier non trovato'); } + +$idtrftd = (int)$rowtd['idtrf']; +$idcompany = (int)$rowtd['idcompany']; ?> + setQuery("SELECT * FROM trfstandards LEFT JOIN standards ON trfstan $tdquerystd->execute(); ?> -setQuery("SELECT * FROM `trf-details` LEFT JOIN auth_users ON `trf-details`.iduser=auth_users.id LEFT JOIN article_type ON `trf-details`.idarticletype=article_type.idarticletype LEFT JOIN certificationtype ON certificationtype.idcertificationtype=`trf-details`.idcertification WHERE `trf-details`.idcompany='$idcompany' AND `trf-details`.signedon <>'' ORDER BY `trf-details`.trfnumber"); -$archivetrflist->execute(); ?> @@ -499,7 +401,7 @@ $archivetrflist->execute(); ?>
-

- TRF:

+

- TF: -Rev.

Preview

diff --git a/public/techdossier_stepsummarypreview.php b/public/techdossier_stepsummarypreview.php index 41ce144..22d5eea 100644 --- a/public/techdossier_stepsummarypreview.php +++ b/public/techdossier_stepsummarypreview.php @@ -23,118 +23,28 @@ require_once '../webassist/mysqli/rsobj.php'; include('languages/' . $_SESSION['langselect'] . '/tdgen.php'); include('languages/' . $_SESSION['langselect'] . '/general.php'); -$idcompany = $_SESSION["compid"]; -if (isset($_GET['idtrftd'])) { - $idtrftd = $_GET['idtrftd']; +$idtd = (int)($_GET['idtd'] ?? $_GET['iddata_td'] ?? $_POST['iddata_td'] ?? 0); +if ($idtd <= 0) { + die('ID dossier mancante'); } -if (isset($_POST['idtrftd'])) { - $idtrftd = $_POST['idtrftd']; -} -if (isset($_POST['iddata_td'])) { - $idtd = $_POST['iddata_td']; -} -if (isset($_GET['iddata_td'])) { - $idtd = $_GET['iddata_td']; -} -if (isset($_GET['idtd'])) { - $idtd = $_GET['idtd']; + +$conn = new mysqli($servername, $username, $password, $dbname); +$stmt = $conn->prepare("SELECT * FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowtd = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); + +if (!$rowtd) { + die('Dossier non trovato'); } + +$idtrftd = (int)$rowtd['idtrf']; +$idcompany = (int)$rowtd['idcompany']; $base_url = "https://www.cimac.it/modulo_certificazione/public/"; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - // Preparazione di un array per contenere i valori sanificati - $sanitizedPost = []; - $errors = []; - // Lista dei campi da sanificare e controllare se sono piene - $fields = [ - 'productionplace_same', - 'classificationshoes', - 'destinationuseppe', - 'manufacutringprocess', - 'ppeageing', - 'obsolescencedeadline', - 'localisationppemarking', - 'manufacturerlogoid', - 'sizeexamplecemark', - 'monthyearprod', - 'serialbatchnumber', - 'standarduse', - 'symbolsaddreq', - 'proddescription', - 'packaging', - 'declarconformity', - 'webaddress', - 'techspecificationapplied' - ]; - - foreach ($fields as $field) { - if (!empty($_POST[$field])) { - // Utilizzo FILTER_SANITIZE_STRING per rimuovere i tag e sanificare il testo - $sanitizedPost[$field] = filter_input(INPUT_POST, $field, FILTER_SANITIZE_STRING); - } - } - - // Controllo se ci sono stati errori - if (count($errors) === 0) { - // Tutti i campi sono stati compilati e sanificati - // Qui puoi procedere con l'elaborazione dei dati - // Ad esempio, stampare i valori o salvarli in un database - foreach ($sanitizedPost as $key => $value) { - } - } else { - // Ci sono stati errori, ad esempio alcuni campi potrebbero essere vuoti - // Puoi gestire gli errori qui, ad esempio stampandoli - foreach ($errors as $key => $message) { - echo "Errore nel campo $key: $message
"; - } - } -} - -// *: update data_td -// Assicurati che la richiesta sia di tipo POST e che l'ID sia stato fornito - -$conn = mysqli_connect($servername, $username, $password, $dbname); - - - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($idtrftd)) { - // Preparazione della parte iniziale della query di aggiornamento - $updateQuery = "UPDATE data_td SET "; - $updateParts = []; - $queryParams = []; - - // Iterazione sui campi sanificati per costruire la query di aggiornamento - foreach ($sanitizedPost as $key => $value) { - // Escludi idtrftd dalla parte di aggiornamento della query - if ($key !== 'idtrftd') { - $updateParts[] = "$key = ?"; - $queryParams[] = $value; - } - } - - // Controllo se ci sono campi da aggiornare - if (count($updateParts) > 0) { - $updateQuery .= join(', ', $updateParts) . " WHERE idtrf = ?"; - $queryParams[] = $idtrftd; // Aggiungi l'ID alla fine dei parametri della query - - // Preparazione della query - $stmt = $conn->prepare($updateQuery); - - // Costruzione del tipo di parametri (stringhe, in questo caso) - $types = str_repeat('s', count($queryParams)); - - // Aggiunta dei parametri alla statement - $stmt->bind_param($types, ...$queryParams); - - // Esecuzione della query - if ($stmt->execute()) { - } - - // Chiusura dello statement - $stmt->close(); - } -} $conn = new mysqli($servername, $username, $password, $dbname); @@ -203,7 +113,7 @@ $description = $tdquery->getColumnVal("sample_description"); $trfn = $tdquery->getColumnVal("trfnumber"); $trfrev = $tdquery->getColumnVal("revtrf"); $mandat = $tdquery->getColumnVal("otherclient"); -$tdrev = $tdquery->getColumnVal("td_rev"); +$tdrev = (int)$rowtd['td_rev']; $tdnumber = $row['tdnumber']; $trfnumb = $trfn . ' VER.' . $trfrev; $trftdnumber = $trfn . 'TF'; @@ -323,9 +233,7 @@ $tdquerystd = new WA_MySQLi_RS("tdquerystd", $cmctrfdb, 1); $tdquerystd->setQuery("SELECT * FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards LEFT JOIN protectioncategory ON protectioncategory.idprotectioncategory=trfstandards.idprotectioncategory LEFT JOIN dpicategory ON dpicategory.iddpicategory=trfstandards.iddpicategory WHERE trfstandards.idtrfdetails='$idtrftd'"); $tdquerystd->execute(); -$archivetrflist = new WA_MySQLi_RS("archivetrflist", $cmctrfdb, 0); -$archivetrflist->setQuery("SELECT * FROM `trf-details` LEFT JOIN auth_users ON `trf-details`.iduser=auth_users.id LEFT JOIN article_type ON `trf-details`.idarticletype=article_type.idarticletype LEFT JOIN certificationtype ON certificationtype.idcertificationtype=`trf-details`.idcertification WHERE `trf-details`.idcompany='$idcompany' AND `trf-details`.signedon <>'' ORDER BY `trf-details`.trfnumber"); -$archivetrflist->execute(); + // query prod place @@ -430,7 +338,7 @@ $html = << -

File Tecnico n./ Technical File N.: $tdnumber

+

File Tecnico n./ Technical File N.: $tdnumber - Rev. $tdrev

diff --git a/public/tf_pdfcreation.php b/public/tf_pdfcreation.php index e1dba58..0417461 100644 --- a/public/tf_pdfcreation.php +++ b/public/tf_pdfcreation.php @@ -27,117 +27,27 @@ require_once '../webassist/mysqli/rsobj.php'; include('languages/' . $_SESSION['langselect'] . '/tdgen.php'); include('languages/' . $_SESSION['langselect'] . '/general.php'); -$idcompany = $_SESSION["compid"]; -if (isset($_GET['idtrftd'])) { - $idtrftd = $_GET['idtrftd']; +// usa $idtd già impostato da sendtd.php, altrimenti dalla richiesta +$idtd = (int)($idtd ?? $_POST['idtd'] ?? $_GET['idtd'] ?? 0); +if ($idtd <= 0) { + die('ID dossier mancante'); } -if (isset($_POST['idtrftd'])) { - $idtrftd = $_POST['idtrftd']; -} -if (isset($_POST['iddata_td'])) { - $idtd = $_POST['iddata_td']; -} -if (isset($_GET['iddata_td'])) { - $idtd = $_GET['iddata_td']; -} -if (isset($_GET['idtd'])) { - $idtd = $_GET['idtd']; + +$conn = new mysqli($servername, $username, $password, $dbname); +$stmt = $conn->prepare("SELECT idtrf, idcompany FROM data_td WHERE iddata_td = ?"); +$stmt->bind_param("i", $idtd); +$stmt->execute(); +$rowids = $stmt->get_result()->fetch_assoc(); +$stmt->close(); +$conn->close(); + +if (!$rowids) { + die('Dossier non trovato'); } + +$idtrftd = (int)$rowids['idtrf']; +$idcompany = (int)$rowids['idcompany']; $base_url = "https://www.cimac.it/modulo_certificazione/public/"; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - // Preparazione di un array per contenere i valori sanificati - $sanitizedPost = []; - $errors = []; - - // Lista dei campi da sanificare e controllare se sono piene - $fields = [ - 'productionplace_same', - 'classificationshoes', - 'destinationuseppe', - 'manufacutringprocess', - 'ppeageing', - 'obsolescencedeadline', - 'localisationppemarking', - 'manufacturerlogoid', - 'sizeexamplecemark', - 'monthyearprod', - 'serialbatchnumber', - 'standarduse', - 'symbolsaddreq', - 'proddescription', - 'packaging', - 'declarconformity', - 'webaddress', - 'techspecificationapplied' - ]; - - foreach ($fields as $field) { - if (!empty($_POST[$field])) { - // Utilizzo FILTER_SANITIZE_STRING per rimuovere i tag e sanificare il testo - $sanitizedPost[$field] = filter_input(INPUT_POST, $field, FILTER_SANITIZE_STRING); - } - } - - // Controllo se ci sono stati errori - if (count($errors) === 0) { - // Tutti i campi sono stati compilati e sanificati - // Qui puoi procedere con l'elaborazione dei dati - // Ad esempio, stampare i valori o salvarli in un database - foreach ($sanitizedPost as $key => $value) { - } - } else { - // Ci sono stati errori, ad esempio alcuni campi potrebbero essere vuoti - // Puoi gestire gli errori qui, ad esempio stampandoli - foreach ($errors as $key => $message) { - echo "Errore nel campo $key: $message
"; - } - } -} - -// *: update data_td -// Assicurati che la richiesta sia di tipo POST e che l'ID sia stato fornito - -$conn = mysqli_connect($servername, $username, $password, $dbname); - - - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($idtrftd)) { - // Preparazione della parte iniziale della query di aggiornamento - $updateQuery = "UPDATE data_td SET "; - $updateParts = []; - $queryParams = []; - - // Iterazione sui campi sanificati per costruire la query di aggiornamento - foreach ($sanitizedPost as $key => $value) { - // Escludi idtrftd dalla parte di aggiornamento della query - if ($key !== 'idtrftd') { - $updateParts[] = "$key = ?"; - $queryParams[] = $value; - } - } - - // Controllo se ci sono campi da aggiornare - if (count($updateParts) > 0) { - $updateQuery .= join(', ', $updateParts) . " WHERE idtrf = ?"; - $queryParams[] = $idtrftd; // Aggiungi l'ID alla fine dei parametri della query - - // Preparazione della query - $stmt = $conn->prepare($updateQuery); - - // Costruzione del tipo di parametri (stringhe, in questo caso) - $types = str_repeat('s', count($queryParams)); - - // Aggiunta dei parametri alla statement - $stmt->bind_param($types, ...$queryParams); - - // Esecuzione della query - if ($stmt->execute()) { - } - - // Chiusura dello statement - $stmt->close(); - } -} $conn = new mysqli($servername, $username, $password, $dbname); @@ -327,9 +237,7 @@ $tdquerystd = new WA_MySQLi_RS("tdquerystd", $cmctrfdb, 1); $tdquerystd->setQuery("SELECT * FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards LEFT JOIN protectioncategory ON protectioncategory.idprotectioncategory=trfstandards.idprotectioncategory LEFT JOIN dpicategory ON dpicategory.iddpicategory=trfstandards.iddpicategory WHERE trfstandards.idtrfdetails='$idtrftd'"); $tdquerystd->execute(); -$archivetrflist = new WA_MySQLi_RS("archivetrflist", $cmctrfdb, 0); -$archivetrflist->setQuery("SELECT * FROM `trf-details` LEFT JOIN auth_users ON `trf-details`.iduser=auth_users.id LEFT JOIN article_type ON `trf-details`.idarticletype=article_type.idarticletype LEFT JOIN certificationtype ON certificationtype.idcertificationtype=`trf-details`.idcertification WHERE `trf-details`.idcompany='$idcompany' AND `trf-details`.signedon <>'' ORDER BY `trf-details`.trfnumber"); -$archivetrflist->execute(); + // query prod place @@ -445,7 +353,7 @@ $html = << -

File Tecnico numero: $tdnumber

+

File Tecnico numero: $tdnumber - Rev. $tdrev

@@ -743,7 +651,7 @@ $hasPhotos = false; // Check for photocover if (!empty($photocover)) { $coverPath = $base_url . "uploadimages/" . htmlspecialchars($photocover); - $localCoverPath = $_SERVER['DOCUMENT_ROOT'] . "/modulo_certificazione/public/uploadimages/" . htmlspecialchars($photocover); + $localCoverPath = __DIR__ . "/uploadimages/" . htmlspecialchars($photocover); if (file_exists($localCoverPath)) { $imageData = base64_encode(file_get_contents($localCoverPath)); $mimeType = mime_content_type($localCoverPath); @@ -961,7 +869,7 @@ $partsquery->execute(); while (!$partsquery->atEnd()) { // Decodifica e sanitizza ogni valore del database $partsidnumber = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('partsidnumber'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); - $description = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('description_identificationparts'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); + $partdescription = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('description_identificationparts'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); $article = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('article_identificationparts'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); $color = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('color_identificationparts'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); $material = htmlspecialchars(html_entity_decode($partsquery->getColumnVal('material_identificationparts'), ENT_QUOTES | ENT_HTML5, 'UTF-8')); @@ -971,7 +879,7 @@ while (!$partsquery->atEnd()) { // Costruisci la riga HTML $html .= " - + @@ -1026,10 +934,10 @@ $html .= << HTML; -if ($cemarkup == 'Y') { +if ($cemarkup == 'Y' && $fileUploaded) { // $filePathdoc = '{$base_url}uploadtddocuments/' . htmlspecialchars($fileDetails['filename_fileattached']); $filePathdoc = $base_url . "uploadtddocuments/" . htmlspecialchars($fileDetails['filename_fileattached']); - $localFilePath = $_SERVER['DOCUMENT_ROOT'] . "/modulo_certificazione/public/uploadtddocuments/" . htmlspecialchars($fileDetails['filename_fileattached']); + $localFilePath = __DIR__ . "/uploadtddocuments/" . htmlspecialchars($fileDetails['filename_fileattached']); $fileDescription = htmlspecialchars($fileDetails['description_fileattached']); $fileExtension = strtolower(pathinfo($filePathdoc, PATHINFO_EXTENSION));
" . $partsidnumber . "" . $description . "" . $partdescription . " " . $article . " " . $color . " " . $material . "