baseline 7.4 as-is produzione
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
if (session_status() == PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
//Including Database configuration file.
|
||||
include "../db.php";
|
||||
$iduserlog = $_SESSION["iduserlogin"];
|
||||
$idcompany = $_SESSION["compid"];
|
||||
|
||||
//Getting value of "search" variable from "script.js".
|
||||
if (isset($_POST['articlepartvalue'])) {
|
||||
// Recupera e decodifica il valore inviato
|
||||
$Name = urldecode($_POST['articlepartvalue']);
|
||||
|
||||
// Prepara la query con prepared statement
|
||||
$Query = "SELECT
|
||||
MIN(identificationparts.ididentificationparts) AS id,
|
||||
identificationparts.article_identificationparts,
|
||||
identificationparts.description_identificationparts,
|
||||
identificationparts.material_identificationparts,
|
||||
MAX(identificationparts.color_identificationparts) AS color_identificationparts,
|
||||
MAX(identificationparts.component_identificationparts) AS component_identificationparts,
|
||||
MAX(identificationparts.cmcreportnumber_identificationparts) AS cmcreportnumber_identificationparts,
|
||||
MAX(identificationparts.cmcreportdate_identificationparts) AS cmcreportdate_identificationparts,
|
||||
MAX(identificationparts.thirdlabreportnumber_identificationparts) AS thirdlabreportnumber_identificationparts,
|
||||
MAX(identificationparts.thirdlabreportdate_identificationparts) AS thirdlabreportdate_identificationparts,
|
||||
MAX(identificationparts.reportof) AS reportof,
|
||||
MAX(identificationparts.kindoftest) AS kindoftest,
|
||||
MAX(identificationparts.partsidnumber) AS partsidnumber,
|
||||
MAX(identificationparts.arttypeid) AS arttypeid,
|
||||
MAX(`trf-details`.idtrfdetails) AS idtrfdetails,
|
||||
`trf-details`.idcompany
|
||||
FROM
|
||||
identificationparts
|
||||
LEFT JOIN
|
||||
`trf-details`
|
||||
ON
|
||||
`trf-details`.idtrfdetails = identificationparts.idtrfdetails
|
||||
WHERE
|
||||
identificationparts.article_identificationparts LIKE ?
|
||||
AND `trf-details`.idcompany = ?
|
||||
GROUP BY
|
||||
identificationparts.article_identificationparts,
|
||||
identificationparts.description_identificationparts,
|
||||
identificationparts.material_identificationparts
|
||||
LIMIT 15";
|
||||
|
||||
// Prepara lo statement
|
||||
$stmt = $conn->prepare($Query);
|
||||
if ($stmt === false) {
|
||||
echo "Errore nella preparazione della query: " . $conn->error;
|
||||
exit;
|
||||
}
|
||||
|
||||
// Aggiungi wildcard per LIKE e parametri
|
||||
$search = "%$Name%";
|
||||
$stmt->bind_param("si", $search, $idcompany);
|
||||
|
||||
// Esegui la query
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Inizia la lista HTML
|
||||
echo '<ul>';
|
||||
|
||||
// Colori alternati
|
||||
$bgcolor = "#f2f2f2";
|
||||
|
||||
// Estrai i risultati
|
||||
while ($Result = $result->fetch_assoc()) {
|
||||
// Alterna il colore di sfondo
|
||||
$bgcolor = ($bgcolor == "#f2f2f2") ? "#e6f7ff" : "#f2f2f2";
|
||||
?>
|
||||
<li onclick='fill(
|
||||
<?php echo json_encode($Result['article_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['material_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['color_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['description_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['partsidnumber'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['arttypeid'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['cmcreportnumber_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['cmcreportdate_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['reportof'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>,
|
||||
<?php echo json_encode($Result['kindoftest'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>
|
||||
)' style="cursor: pointer; background-color: <?php echo $bgcolor; ?>; border: 1px solid #ccc; border-radius: 5px; padding: 10px; margin-bottom: 5px;">
|
||||
<span style="text-decoration: none; color: #333;">
|
||||
<?php echo htmlspecialchars($Result['article_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -
|
||||
<?php echo htmlspecialchars($Result['material_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -
|
||||
<?php echo htmlspecialchars($Result['color_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -
|
||||
[<?php echo htmlspecialchars($Result['description_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>]
|
||||
<?php if (!empty($Result['cmcreportnumber_identificationparts'])) { ?>
|
||||
- Rep. <?php echo htmlspecialchars($Result['cmcreportnumber_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php } ?>
|
||||
<?php if (!empty($Result['cmcreportdate_identificationparts'])) { ?>
|
||||
- Date: <?php echo htmlspecialchars($Result['cmcreportdate_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php } ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
echo '</ul>';
|
||||
|
||||
// Chiudi lo statement e la connessione
|
||||
$stmt->close();
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php␍
|
||||
if (session_status() == PHP_SESSION_NONE) {␍
|
||||
session_start();␍
|
||||
}␍
|
||||
␍
|
||||
//Including Database configuration file.␍
|
||||
include "../db.php";␍
|
||||
$iduserlog=$_SESSION["iduserlogin"];␍
|
||||
$idcompany = $_SESSION["compid"];␍
|
||||
//Getting value of "search" variable from "script.js".␍
|
||||
if (isset($_POST['articlepartvalue'])) {␍
|
||||
//Search box value assigning to $Name variable.␍
|
||||
$Name = $_POST['articlepartvalue'];␍
|
||||
//Search query.␍
|
||||
␍
|
||||
//Query execution␍
|
||||
/* $Query = "␍
|
||||
SELECT *␍
|
||||
FROM identificationparts ␍
|
||||
LEFT JOIN `trf-details` ON `trf-details`.idtrfdetails = identificationparts.idtrfdetails ␍
|
||||
WHERE identificationparts.article_identificationparts LIKE '%$Name%' ␍
|
||||
AND `trf-details`.idcompany = '$idcompany' ␍
|
||||
GROUP BY identificationparts.article_identificationparts, identificationparts.material_identificationparts␍
|
||||
LIMIT 5";␍
|
||||
*/␍
|
||||
␍
|
||||
$Query = "SELECT ␍
|
||||
MIN(identificationparts.ididentificationparts) AS id, ␍
|
||||
identificationparts.article_identificationparts, ␍
|
||||
identificationparts.description_identificationparts, ␍
|
||||
identificationparts.material_identificationparts,␍
|
||||
MAX(identificationparts.color_identificationparts) AS color_identificationparts,␍
|
||||
MAX(identificationparts.component_identificationparts) AS component_identificationparts,␍
|
||||
MAX(identificationparts.cmcreportnumber_identificationparts) AS cmcreportnumber_identificationparts,␍
|
||||
MAX(identificationparts.cmcreportdate_identificationparts) AS cmcreportdate_identificationparts,␍
|
||||
MAX(identificationparts.thirdlabreportnumber_identificationparts) AS thirdlabreportnumber_identificationparts,␍
|
||||
MAX(identificationparts.thirdlabreportdate_identificationparts) AS thirdlabreportdate_identificationparts,␍
|
||||
MAX(identificationparts.reportof) AS reportof,␍
|
||||
MAX(identificationparts.kindoftest) AS kindoftest,␍
|
||||
MAX(identificationparts.partsidnumber) AS partsidnumber,␍
|
||||
MAX(identificationparts.arttypeid) AS arttypeid,␍
|
||||
MAX(`trf-details`.idtrfdetails) AS idtrfdetails,␍
|
||||
`trf-details`.idcompany␍
|
||||
FROM ␍
|
||||
identificationparts ␍
|
||||
LEFT JOIN ␍
|
||||
`trf-details` ␍
|
||||
ON ␍
|
||||
`trf-details`.idtrfdetails = identificationparts.idtrfdetails ␍
|
||||
WHERE ␍
|
||||
identificationparts.article_identificationparts LIKE '%$Name%' ␍
|
||||
AND `trf-details`.idcompany = '$idcompany'␍
|
||||
GROUP BY ␍
|
||||
identificationparts.article_identificationparts, ␍
|
||||
identificationparts.description_identificationparts, ␍
|
||||
identificationparts.material_identificationparts␍
|
||||
LIMIT 15";␍
|
||||
␍
|
||||
␍
|
||||
␍
|
||||
//Query execution␍
|
||||
$ExecQuery = MySQLi_query($conn, $Query);␍
|
||||
//Creating unordered list to display result.␍
|
||||
echo '␍
|
||||
<ul>␍
|
||||
';␍
|
||||
//Fetching result from database.␍
|
||||
$bgcolor = "#f2f2f2";␍
|
||||
␍
|
||||
while ($Result = MySQLi_fetch_array($ExecQuery)) {␍
|
||||
//Switching background color.␍
|
||||
if ($bgcolor == "#f2f2f2") {␍
|
||||
$bgcolor = "#e6f7ff";␍
|
||||
} else {␍
|
||||
$bgcolor = "#f2f2f2";␍
|
||||
}␍
|
||||
?>␍
|
||||
<!-- Creating unordered list items.␍
|
||||
Calling javascript function named as "fill" found in "script.js" file.␍
|
||||
By passing fetched result as parameter. -->␍
|
||||
<li onclick='fill(␍
|
||||
<?php echo json_encode($Result['article_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['material_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['color_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['description_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['partsidnumber'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['arttypeid'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['cmcreportnumber_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['cmcreportdate_identificationparts'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['reportof'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>, ␍
|
||||
<?php echo json_encode($Result['kindoftest'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); ?>␍
|
||||
)' style="cursor: pointer; background-color: <?php echo $bgcolor; ?>; border: 1px solid #ccc; border-radius: 5px; padding: 10px; margin-bottom: 5px;">␍
|
||||
<span style="text-decoration: none; color: #333;">␍
|
||||
<?php echo htmlspecialchars($Result['article_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -␍
|
||||
<?php echo htmlspecialchars($Result['material_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -␍
|
||||
<?php echo htmlspecialchars($Result['color_identificationparts'], ENT_QUOTES, 'UTF-8'); ?> -␍
|
||||
[<?php echo htmlspecialchars($Result['description_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>]␍
|
||||
<?php if (!empty($Result['cmcreportnumber_identificationparts'])) { ?>␍
|
||||
- Rep. <?php echo htmlspecialchars($Result['cmcreportnumber_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>␍
|
||||
<?php } ?>␍
|
||||
<?php if (!empty($Result['cmcreportdate_identificationparts'])) { ?>␍
|
||||
- Date: <?php echo htmlspecialchars($Result['cmcreportdate_identificationparts'], ENT_QUOTES, 'UTF-8'); ?>␍
|
||||
<?php } ?>␍
|
||||
</span>␍
|
||||
</li>␍
|
||||
<!-- Below php code is just for closing parenthesis. Don't be confused. -->␍
|
||||
<?php␍
|
||||
}}␍
|
||||
?>␍
|
||||
</ul>
|
||||
@@ -0,0 +1,37 @@
|
||||
␍
|
||||
<?php␍
|
||||
if (session_status() == PHP_SESSION_NONE) {␍
|
||||
session_start();␍
|
||||
}␍
|
||||
␍
|
||||
//Including Database configuration file.␍
|
||||
include "../db.php";␍
|
||||
$iduserlog=$_SESSION["iduserlogin"];␍
|
||||
//Getting value of "search" variable from "script.js".␍
|
||||
if (isset($_POST['companynamevalue'])) {␍
|
||||
//Search box value assigning to $Name variable.␍
|
||||
$Name = $_POST['companynamevalue'];␍
|
||||
//Search query.␍
|
||||
$Query = "SELECT DISTINCT contacts.companyname FROM contacts LEFT JOIN `trf-details` ON `trf-details`.idtrfdetails=contacts.idtrf WHERE contacts.companyname LIKE '%$Name%' AND `trf-details`.iduser='$iduserlog' LIMIT 5";␍
|
||||
//Query execution␍
|
||||
$ExecQuery = MySQLi_query($conn, $Query);␍
|
||||
//Creating unordered list to display result.␍
|
||||
echo '␍
|
||||
<ul>␍
|
||||
';␍
|
||||
//Fetching result from database.␍
|
||||
while ($Result = MySQLi_fetch_array($ExecQuery)) {␍
|
||||
?>␍
|
||||
<!-- Creating unordered list items.␍
|
||||
Calling javascript function named as "fill" found in "script.js" file.␍
|
||||
By passing fetched result as parameter. -->␍
|
||||
<li onclick='fill("<?php echo $Result['companyname']; ?>")'>␍
|
||||
<a>␍
|
||||
<!-- Assigning searched result in "Search box" in "search.php" file. -->␍
|
||||
<?php echo $Result['companyname']; ?>␍
|
||||
</li></a>␍
|
||||
<!-- Below php code is just for closing parenthesis. Don't be confused. -->␍
|
||||
<?php␍
|
||||
}}␍
|
||||
?>␍
|
||||
</ul>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php␍
|
||||
if (session_status() == PHP_SESSION_NONE) {␍
|
||||
session_start();␍
|
||||
}␍
|
||||
␍
|
||||
//Including Database configuration file.␍
|
||||
include "../db.php";␍
|
||||
$iduserlog = $_SESSION["iduserlogin"];␍
|
||||
//Getting value of "search" variable from "script.js".␍
|
||||
if (isset($_POST['companynamevalue'])) {␍
|
||||
//Search box value assigning to $Name variable.␍
|
||||
$Name = $_POST['companynamevalue'];␍
|
||||
//Search query.␍
|
||||
$Query = "SELECT DISTINCT contacts.companyname FROM contacts LEFT JOIN `trf-details` ON `trf-details`.idtrfdetails=contacts.idtrf WHERE contacts.companyname LIKE '%$Name%' AND `trf-details`.iduser='$iduserlog' LIMIT 5";␍
|
||||
//Query execution␍
|
||||
$ExecQuery = MySQLi_query($conn, $Query);␍
|
||||
//Creating unordered list to display result.␍
|
||||
echo '␍
|
||||
<ul>␍
|
||||
';␍
|
||||
//Fetching result from database.␍
|
||||
while ($Result = MySQLi_fetch_array($ExecQuery)) {␍
|
||||
?>␍
|
||||
<!-- Creating unordered list items.␍
|
||||
Calling javascript function named as "fill" found in "script.js" file.␍
|
||||
By passing fetched result as parameter. -->␍
|
||||
<li onclick='fill("<?php echo $Result['companyname']; ?>")'>␍
|
||||
<a>␍
|
||||
<!-- Assigning searched result in "Search box" in "search.php" file. -->␍
|
||||
<?php echo $Result['companyname']; ?>␍
|
||||
</li></a>␍
|
||||
<!-- Below php code is just for closing parenthesis. Don't be confused. -->␍
|
||||
<?php␍
|
||||
}␍
|
||||
}␍
|
||||
?>␍
|
||||
</ul>
|
||||
@@ -0,0 +1,31 @@
|
||||
function fill(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
$('#articlepartvalue').val(Value);␍
|
||||
␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide();␍
|
||||
}␍
|
||||
function fill2(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
␍
|
||||
$('#materialpartvalue').val(Value);␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide()␍
|
||||
}␍
|
||||
function fill3(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
␍
|
||||
$('#colorvalue').val(Value);␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide()␍
|
||||
}␍
|
||||
function fill4(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
␍
|
||||
$('#descriptionpartvalue').val(Value);␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide()␍
|
||||
}␍
|
||||
␍
|
||||
li onclick='fill("<?php echo $Result['article_identificationparts']; ?>"); fill2("<?php echo $Result['material_identificationparts']; ?>"); fill3("<?php echo $Result['color_identificationparts']; ?>"); fill4("<?php echo $Result['description_identificationparts']; ?>");'> ␍
|
||||
<a>
|
||||
@@ -0,0 +1,59 @@
|
||||
//Getting value from "ajax.php".
|
||||
function fill(
|
||||
article,
|
||||
material,
|
||||
color,
|
||||
description,
|
||||
part,
|
||||
arttype,
|
||||
cmcreport,
|
||||
cmcreportdate,
|
||||
reportof,
|
||||
kindtest
|
||||
) {
|
||||
//Assigning values to corresponding input fields in "search.php" file.
|
||||
$('#articlepartvalue').val(article)
|
||||
$('#materialpartvalue').val(material)
|
||||
$('#colorvalue').val(color)
|
||||
$('#descriptionpartvalue').val(description)
|
||||
$('#partid').val(part)
|
||||
$('#arttypeid').val(arttype)
|
||||
$('#cmcreportnumber').val(cmcreport)
|
||||
$('#cmcdatereport').val(cmcreportdate)
|
||||
$('#reportof').val(reportof)
|
||||
$('#combo').val(kindtest).change()
|
||||
|
||||
//Hiding "display" div in "search.php" file.
|
||||
$('#display').hide()
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
//On pressing a key on "Search box" in "search.php" file. This function will be called.
|
||||
$('#articlepartvalue').keyup(function () {
|
||||
//Assigning search box value to javascript variable named as "name".
|
||||
var name = $('#articlepartvalue').val()
|
||||
//Validating, if "name" is empty.
|
||||
if (name == '') {
|
||||
//Assigning empty value to "display" div in "search.php" file.
|
||||
$('#display').html('')
|
||||
}
|
||||
//If name is not empty.
|
||||
else {
|
||||
//AJAX is called.
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'searchengine/ajaxsearch.php',
|
||||
data: {
|
||||
articlepartvalue: encodeURIComponent(name), // Codifica il valore
|
||||
},
|
||||
success: function (html) {
|
||||
$('#display').html(html).show()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.log('Errore AJAX: ' + status + ' - ' + error)
|
||||
$('#display').html('Errore durante la ricerca. Riprova.')
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,52 @@
|
||||
//Getting value from "ajax.php".␍
|
||||
function fill(article, material, color, description, part, arttype, cmcreport, cmcreportdate, reportof, kindtest) {␍
|
||||
//Assigning values to corresponding input fields in "search.php" file.␍
|
||||
$('#articlepartvalue').val(article);␍
|
||||
$('#materialpartvalue').val(material);␍
|
||||
$('#colorvalue').val(color);␍
|
||||
$('#descriptionpartvalue').val(description);␍
|
||||
$('#partid').val(part);␍
|
||||
$('#arttypeid').val(arttype);␍
|
||||
$('#cmcreportnumber').val(cmcreport);␍
|
||||
$('#cmcdatereport').val(cmcreportdate);␍
|
||||
$('#reportof').val(reportof);␍
|
||||
$('#combo').val(kindtest).change();␍
|
||||
␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide();␍
|
||||
}␍
|
||||
␍
|
||||
␍
|
||||
␍
|
||||
$(document).ready(function() {␍
|
||||
//On pressing a key on "Search box" in "search.php" file. This function will be called.␍
|
||||
$("#articlepartvalue").keyup(function() {␍
|
||||
//Assigning search box value to javascript variable named as "name".␍
|
||||
var name = $('#articlepartvalue').val();␍
|
||||
//Validating, if "name" is empty.␍
|
||||
if (name == "") {␍
|
||||
//Assigning empty value to "display" div in "search.php" file.␍
|
||||
$("#display").html("");␍
|
||||
}␍
|
||||
//If name is not empty.␍
|
||||
else {␍
|
||||
//AJAX is called.␍
|
||||
$.ajax({␍
|
||||
//AJAX type is "Post".␍
|
||||
type: "POST",␍
|
||||
//Data will be sent to "ajax.php".␍
|
||||
url: "searchengine/ajaxsearch.php",␍
|
||||
//Data, that will be sent to "ajax.php".␍
|
||||
data: {␍
|
||||
//Assigning value of "name" into "search" variable.␍
|
||||
articlepartvalue: name␍
|
||||
},␍
|
||||
//If result found, this funtion will be called.␍
|
||||
success: function(html) {␍
|
||||
//Assigning result to "display" div in "search.php" file.␍
|
||||
$("#display").html(html).show();␍
|
||||
}␍
|
||||
});␍
|
||||
}␍
|
||||
});␍
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
//Getting value from "ajax.php".␍
|
||||
function fill(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
$('#companynamevalue').val(Value);␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide();␍
|
||||
}␍
|
||||
$(document).ready(function() {␍
|
||||
//On pressing a key on "Search box" in "search.php" file. This function will be called.␍
|
||||
$("#companynamevalue").keyup(function() {␍
|
||||
//Assigning search box value to javascript variable named as "name".␍
|
||||
var name = $('#companynamevalue').val();␍
|
||||
//Validating, if "name" is empty.␍
|
||||
if (name == "") {␍
|
||||
//Assigning empty value to "display" div in "search.php" file.␍
|
||||
$("#display").html("");␍
|
||||
}␍
|
||||
//If name is not empty.␍
|
||||
else {␍
|
||||
//AJAX is called.␍
|
||||
$.ajax({␍
|
||||
//AJAX type is "Post".␍
|
||||
type: "POST",␍
|
||||
//Data will be sent to "ajax.php".␍
|
||||
url: "searchengine/ajaxsearchcontact.php",␍
|
||||
//Data, that will be sent to "ajax.php".␍
|
||||
data: {␍
|
||||
//Assigning value of "name" into "search" variable.␍
|
||||
companynamevalue: name␍
|
||||
},␍
|
||||
//If result found, this funtion will be called.␍
|
||||
success: function(html) {␍
|
||||
//Assigning result to "display" div in "search.php" file.␍
|
||||
$("#display").html(html).show();␍
|
||||
}␍
|
||||
});␍
|
||||
}␍
|
||||
});␍
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
//Getting value from "ajax.php".␍
|
||||
function fill(Value) {␍
|
||||
//Assigning value to "search" div in "search.php" file.␍
|
||||
$('#companynamevalue').val(Value)␍
|
||||
//Hiding "display" div in "search.php" file.␍
|
||||
$('#display').hide()␍
|
||||
}␍
|
||||
$(document).ready(function () {␍
|
||||
//On pressing a key on "Search box" in "search.php" file. This function will be called.␍
|
||||
$('#companynamevalue').keyup(function () {␍
|
||||
//Assigning search box value to javascript variable named as "name".␍
|
||||
var name = $('#companynamevalue').val()␍
|
||||
//Validating, if "name" is empty.␍
|
||||
if (name == '') {␍
|
||||
//Assigning empty value to "display" div in "search.php" file.␍
|
||||
$('#display').html('')␍
|
||||
}␍
|
||||
//If name is not empty.␍
|
||||
else {␍
|
||||
//AJAX is called.␍
|
||||
$.ajax({␍
|
||||
//AJAX type is "Post".␍
|
||||
type: 'POST',␍
|
||||
//Data will be sent to "ajax.php".␍
|
||||
url: 'searchengine/ajaxsearchcontact.php',␍
|
||||
//Data, that will be sent to "ajax.php".␍
|
||||
data: {␍
|
||||
//Assigning value of "name" into "search" variable.␍
|
||||
companynamevalue: name,␍
|
||||
},␍
|
||||
//If result found, this funtion will be called.␍
|
||||
success: function (html) {␍
|
||||
//Assigning result to "display" div in "search.php" file.␍
|
||||
$('#display').html(html).show()␍
|
||||
},␍
|
||||
})␍
|
||||
}␍
|
||||
})␍
|
||||
})␍
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php␍
|
||||
require '/../vendor/autoload.php';␍
|
||||
␍
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;␍
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;␍
|
||||
␍
|
||||
// Assumendo che $conn sia già stato configurato e che $idtrf sia già definito e sanificato per evitare SQL Injection␍
|
||||
require_once('../Connections/cmctrfdb.php');␍
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);␍
|
||||
␍
|
||||
$idtrf = isset($_GET['idtrf']) ? $conn->real_escape_string($_GET['idtrf']) : die('IDTRF non specificato.');␍
|
||||
␍
|
||||
␍
|
||||
// Preparazione della query␍
|
||||
$query = "␍
|
||||
SELECT␍
|
||||
identificationparts.description_identificationparts,␍
|
||||
identificationparts.article_identificationparts,␍
|
||||
identificationparts.color_identificationparts,␍
|
||||
identificationparts.component_identificationparts,␍
|
||||
identificationparts.material_identificationparts,␍
|
||||
identificationparts.cmcreportnumber_identificationparts,␍
|
||||
identificationparts.cmcreportdate_identificationparts,␍
|
||||
identificationparts.reportof,␍
|
||||
identificationparts.partsidnumber␍
|
||||
FROM identificationparts␍
|
||||
LEFT JOIN partsordercimac ON partsordercimac.arttypeid = identificationparts.arttypeid␍
|
||||
AND partsordercimac.partsidpicture = identificationparts.partsidnumber␍
|
||||
WHERE identificationparts.idtrfdetails = '$idtrf'␍
|
||||
ORDER BY ␍
|
||||
CASE␍
|
||||
WHEN partsordercimac.partsidcimac IS NULL THEN 9999␍
|
||||
ELSE partsordercimac.partsidcimac␍
|
||||
END␍
|
||||
";␍
|
||||
␍
|
||||
$result = $conn->query($query);␍
|
||||
␍
|
||||
if (!$result) {␍
|
||||
die("Errore nell'esecuzione della query: " . $conn->error);␍
|
||||
}␍
|
||||
␍
|
||||
$spreadsheet = new Spreadsheet();␍
|
||||
$sheet = $spreadsheet->getActiveSheet();␍
|
||||
␍
|
||||
// Intestazioni delle colonne␍
|
||||
$colonne = [␍
|
||||
'description_identificationparts',␍
|
||||
'article_identificationparts',␍
|
||||
'color_identificationparts',␍
|
||||
'component_identificationparts',␍
|
||||
'material_identificationparts',␍
|
||||
'cmcreportnumber_identificationparts',␍
|
||||
'cmcreportdate_identificationparts',␍
|
||||
'reportof',␍
|
||||
'partsidnumber'␍
|
||||
];␍
|
||||
␍
|
||||
// Imposta le intestazioni delle colonne nel foglio di lavoro␍
|
||||
$columnIndex = 'A';␍
|
||||
foreach ($colonne as $colonna) {␍
|
||||
$sheet->setCellValue($columnIndex . '1', $colonna);␍
|
||||
$columnIndex++;␍
|
||||
}␍
|
||||
␍
|
||||
// Inserimento dei dati nel foglio di lavoro␍
|
||||
$rowCount = 2;␍
|
||||
while ($row = $result->fetch_assoc()) {␍
|
||||
$columnIndex = 'A';␍
|
||||
foreach ($colonne as $colonna) {␍
|
||||
$sheet->setCellValue($columnIndex . $rowCount, $row[$colonna]);␍
|
||||
$columnIndex++;␍
|
||||
}␍
|
||||
$rowCount++;␍
|
||||
}␍
|
||||
␍
|
||||
// Impostazioni per il download del file XLSX␍
|
||||
$writer = new Xlsx($spreadsheet);␍
|
||||
$fileName = 'lista_parti.xlsx';␍
|
||||
␍
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');␍
|
||||
header('Content-Disposition: attachment; filename="' . urlencode($fileName) . '"');␍
|
||||
$writer->save('php://output');␍
|
||||
$conn->close();␍
|
||||
exit;␍
|
||||
Reference in New Issue
Block a user