added column selection and reorder in products
This commit is contained in:
@@ -0,0 +1,389 @@
|
|||||||
|
<?php include('../include/headscript.php'); ?>
|
||||||
|
<?php
|
||||||
|
require '../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
||||||
|
|
||||||
|
function post_async($url, array $params)
|
||||||
|
{
|
||||||
|
foreach ($params as $key => &$val) {
|
||||||
|
if (is_array($val)) $val = implode(',', $val);
|
||||||
|
$post_params[] = $key . '=' . urlencode($val);
|
||||||
|
}
|
||||||
|
$post_string = implode('&', $post_params);
|
||||||
|
|
||||||
|
$parts = parse_url($url);
|
||||||
|
|
||||||
|
$fp = fsockopen(
|
||||||
|
$parts['host'],
|
||||||
|
isset($parts['port']) ? $parts['port'] : 80,
|
||||||
|
$errno,
|
||||||
|
$errstr,
|
||||||
|
30
|
||||||
|
);
|
||||||
|
|
||||||
|
$out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
|
||||||
|
$out .= "Host: " . $parts['host'] . "\r\n";
|
||||||
|
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||||
|
$out .= "Content-Length: " . strlen($post_string) . "\r\n";
|
||||||
|
$out .= "Connection: Close\r\n\r\n";
|
||||||
|
if (isset($post_string)) $out .= $post_string;
|
||||||
|
|
||||||
|
fwrite($fp, $out);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_FILES['f_csv'])) {
|
||||||
|
$file = $_FILES['f_csv']['tmp_name'];
|
||||||
|
$template_id = $_POST['template_id'];
|
||||||
|
|
||||||
|
//get template associate data
|
||||||
|
$arr_associate_data = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||||
|
$arr_associate_data->setQuery("SELECT * FROM template_associate where template_importify_id=$template_id");
|
||||||
|
$arr_associate_data->execute();
|
||||||
|
$arr_associate = $arr_associate_data->Results;
|
||||||
|
|
||||||
|
if (count($arr_associate) > 0) { //check define columns
|
||||||
|
$spreadsheet = IOFactory::load($file);
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
$arr_info = $worksheet->toArray();
|
||||||
|
if (count($arr_info) > 1) { //check excel rows
|
||||||
|
$arr_excel_columns = $arr_info[0];
|
||||||
|
$arr_need_columns = array();
|
||||||
|
array_push($arr_need_columns, "Sample Code (PO#)");
|
||||||
|
array_push($arr_need_columns, "Report no.");
|
||||||
|
array_push($arr_need_columns, "Part No.");
|
||||||
|
|
||||||
|
// remove empty rows
|
||||||
|
$arr_info = array_filter($arr_info, function ($row) {
|
||||||
|
return !empty(array_filter($row));
|
||||||
|
});
|
||||||
|
|
||||||
|
// find date date in $arr_info formatted as m/d/yyyy and convert to yyyy-mm-dd
|
||||||
|
$rowCount = count($arr_info);
|
||||||
|
for ($i = 0; $i < $rowCount; $i++) {
|
||||||
|
$colCount = count($arr_info[$i]);
|
||||||
|
for ($j = 0; $j < $colCount; $j++) {
|
||||||
|
$value = $arr_info[$i][$j];
|
||||||
|
|
||||||
|
// Check if the value is a string that matches the m/d/yyyy format
|
||||||
|
if (is_string($value) && preg_match('/^\d{1,2}\/\d{1,2}\/\d{4}$/', $value)) {
|
||||||
|
// Convert to DateTime and format to Y-m-d
|
||||||
|
$dateTime = DateTime::createFromFormat('m/d/Y', $value);
|
||||||
|
if ($dateTime) {
|
||||||
|
$arr_info[$i][$j] = $dateTime->format('Y-m-d'); // Store the formatted date
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($arr_associate as $item) {
|
||||||
|
array_push($arr_need_columns, $item['headerfile']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//check excel data column with template associate data
|
||||||
|
$verify_flag = true;
|
||||||
|
for ($i = 0; $i < count($arr_need_columns); $i++) {
|
||||||
|
if (!in_array($arr_need_columns[$i], $arr_excel_columns)) {
|
||||||
|
$verify_flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($verify_flag) {
|
||||||
|
//separate by Sample Code (PO#) - product
|
||||||
|
$idx_sample_code_po = array_search("Sample Code (PO#)", $arr_excel_columns);
|
||||||
|
|
||||||
|
|
||||||
|
$arr_total_products = array();
|
||||||
|
$tmp_arr_child_products = array();
|
||||||
|
$tmp_sample_code_po = "";
|
||||||
|
for ($i = 1; $i < count($arr_info); $i++) {
|
||||||
|
if ($arr_info[$i][$idx_sample_code_po] == $tmp_sample_code_po) {
|
||||||
|
array_push($tmp_arr_child_products, $arr_info[$i]);
|
||||||
|
} else {
|
||||||
|
if ($tmp_sample_code_po != "") {
|
||||||
|
if (count($tmp_arr_child_products) > 0) {
|
||||||
|
array_push($arr_total_products, $tmp_arr_child_products);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tmp_sample_code_po = $arr_info[$i][$idx_sample_code_po];
|
||||||
|
$tmp_arr_child_products = array();
|
||||||
|
array_push($tmp_arr_child_products, $arr_info[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($tmp_arr_child_products) > 0) {
|
||||||
|
array_push($arr_total_products, $tmp_arr_child_products);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//define importcode (timestamp)
|
||||||
|
$importcode = time();
|
||||||
|
|
||||||
|
//insert import his
|
||||||
|
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$InsertQuery->Action = "insert";
|
||||||
|
$InsertQuery->Table = "`template_import_his`";
|
||||||
|
$InsertQuery->bindColumn("created_at", "s", date("Y-m-d H:i:s"), "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("user_id", "i", "" . $_SESSION['iduserlogin'], "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("importcode", "s", "" . $importcode, "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("f_status", "i", "0", "WA_DEFAULT");
|
||||||
|
$InsertQuery->saveInSession("");
|
||||||
|
$InsertQuery->execute();
|
||||||
|
|
||||||
|
// post_async("localhost:80/0_claudio/reportify_new/public/userarea/importify/importify_bg_script.php", [
|
||||||
|
// 'importcode' => $importcode
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
|
||||||
|
post_async($_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] . "/../importify_bg_script.php", [
|
||||||
|
'arr_project' => json_encode($arr_total_products),
|
||||||
|
'arr_excel_columns' => json_encode($arr_excel_columns),
|
||||||
|
'arr_associate' => json_encode($arr_associate),
|
||||||
|
'importcode' => $importcode
|
||||||
|
]);
|
||||||
|
|
||||||
|
//insert to products table
|
||||||
|
// foreach($arr_total_products as $product) {
|
||||||
|
// //check exist product item
|
||||||
|
// $sample_code_po = $product[0][$idx_sample_code_po];
|
||||||
|
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
|
// $product_query->execute();
|
||||||
|
//
|
||||||
|
// $product_info = $product_query->Results;
|
||||||
|
// $idproducts = "";
|
||||||
|
//
|
||||||
|
// if(count($product_info) > 0) {
|
||||||
|
// $idproducts = $product_info[0]['idproducts'];
|
||||||
|
// } else { // have to insert new
|
||||||
|
// $arr_product_need_idx = array();
|
||||||
|
// for($i=0; $i<count($arr_associate); $i++) {
|
||||||
|
// if($arr_associate[$i]['table_name'] == "products") {
|
||||||
|
// array_push($arr_product_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
// $InsertQuery->Action = "insert";
|
||||||
|
// $InsertQuery->Table = "`products`";
|
||||||
|
// $InsertQuery->bindColumn("products_refnumber", "s", $product[0][$idx_sample_code_po], "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode. "", "WA_DEFAULT");
|
||||||
|
// for($i=0; $i<count($arr_product_need_idx); $i++) {
|
||||||
|
// $InsertQuery->bindColumn($arr_product_need_idx[$i][0], "s", $product[0][$arr_product_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
// }
|
||||||
|
// $InsertQuery->saveInSession("");
|
||||||
|
// $InsertQuery->execute();
|
||||||
|
//
|
||||||
|
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
|
// $product_query->execute();
|
||||||
|
//
|
||||||
|
// $product_info = $product_query->Results;
|
||||||
|
// if(count($product_info) > 0) {
|
||||||
|
// $idproducts = $product_info[0]['idproducts'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if($idproducts == "") {
|
||||||
|
// die("server_error");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //----------- report table ------------------
|
||||||
|
// //separate reports table data
|
||||||
|
// $idx_report_no_po = array_search("Report no.", $arr_excel_columns);
|
||||||
|
//
|
||||||
|
// $arr_total_reports = array();
|
||||||
|
// $tmp_arr_child_reports = array();
|
||||||
|
// $tmp_report_no = "";
|
||||||
|
// for($i=0; $i<count($product); $i++) {
|
||||||
|
// if($product[$i][$idx_report_no_po] == $tmp_report_no) {
|
||||||
|
// array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
|
// } else {
|
||||||
|
// if($tmp_report_no != "") {
|
||||||
|
// if(count($tmp_arr_child_reports) > 0) {
|
||||||
|
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $tmp_report_no = $product[$i][$idx_report_no_po];
|
||||||
|
// $tmp_arr_child_reports = array();
|
||||||
|
// array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(count($tmp_arr_child_reports) > 0) {
|
||||||
|
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //insert to reports table
|
||||||
|
// foreach($arr_total_reports as $report) {
|
||||||
|
// //check exist reports item
|
||||||
|
// $report_no = $report[0][$idx_report_no_po];
|
||||||
|
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
|
// $report_query->execute();
|
||||||
|
//
|
||||||
|
// $report_info = $report_query->Results;
|
||||||
|
// $idreports = "";
|
||||||
|
//
|
||||||
|
// if (count($report_info) > 0) {
|
||||||
|
// $idreports = $report_info[0]['idreports'];
|
||||||
|
// } else { // have to insert new
|
||||||
|
// $arr_report_need_idx = array();
|
||||||
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
// if ($arr_associate[$i]['table_name'] == "reports") {
|
||||||
|
// array_push($arr_report_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
// $InsertQuery->Action = "insert";
|
||||||
|
// $InsertQuery->Table = "`reports`";
|
||||||
|
// $InsertQuery->bindColumn("reportsNumberLab", "s", $report[0][$idx_report_no_po]."", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts."", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
// for ($i = 0; $i < count($arr_report_need_idx); $i++) {
|
||||||
|
// $InsertQuery->bindColumn($arr_report_need_idx[$i][0], "s", $report[0][$arr_report_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
// }
|
||||||
|
// $InsertQuery->saveInSession("");
|
||||||
|
// $InsertQuery->execute();
|
||||||
|
//
|
||||||
|
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
|
// $report_query->execute();
|
||||||
|
//
|
||||||
|
// $report_info = $report_query->Results;
|
||||||
|
// if (count($report_info) > 0) {
|
||||||
|
// $idreports = $report_info[0]['idreports'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if ($idreports == "") {
|
||||||
|
// die("server_error");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //----------- parts table ------------------
|
||||||
|
// //separate parts table data
|
||||||
|
// $idx_part_no_po = array_search("Part No.", $arr_excel_columns);
|
||||||
|
//
|
||||||
|
// $arr_total_parts = array();
|
||||||
|
// $tmp_arr_child_parts = array();
|
||||||
|
// $tmp_part_no = "";
|
||||||
|
// for($i=0; $i<count($report); $i++) {
|
||||||
|
// if($report[$i][$idx_part_no_po] == $tmp_part_no) {
|
||||||
|
// array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
|
// } else {
|
||||||
|
// if($tmp_part_no != "") {
|
||||||
|
// if(count($tmp_arr_child_parts) > 0) {
|
||||||
|
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $tmp_part_no = $report[$i][$idx_part_no_po];
|
||||||
|
// $tmp_arr_child_parts = array();
|
||||||
|
// array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(count($tmp_arr_child_parts) > 0) {
|
||||||
|
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //insert to parts table
|
||||||
|
// foreach($arr_total_parts as $part) {
|
||||||
|
// //check exist parts item
|
||||||
|
// $part_no = $part[0][$idx_part_no_po];
|
||||||
|
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
|
// $part_query->execute();
|
||||||
|
//
|
||||||
|
// $part_info = $part_query->Results;
|
||||||
|
// $idparts = "";
|
||||||
|
//
|
||||||
|
// if (count($part_info) > 0) {
|
||||||
|
// $idparts = $part_info[0]['idParts'];
|
||||||
|
// } else { // have to insert new
|
||||||
|
// $arr_part_need_idx = array();
|
||||||
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
// if ($arr_associate[$i]['table_name'] == "parts") {
|
||||||
|
// array_push($arr_part_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
// $InsertQuery->Action = "insert";
|
||||||
|
// $InsertQuery->Table = "`parts`";
|
||||||
|
// $InsertQuery->bindColumn("partsCode", "s", $part[0][$idx_part_no_po] . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
// for ($i = 0; $i < count($arr_part_need_idx); $i++) {
|
||||||
|
// $InsertQuery->bindColumn($arr_part_need_idx[$i][0], "s", $part[0][$arr_part_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
// }
|
||||||
|
// $InsertQuery->saveInSession("");
|
||||||
|
// $InsertQuery->execute();
|
||||||
|
//
|
||||||
|
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
|
// $part_query->execute();
|
||||||
|
//
|
||||||
|
// $part_info = $part_query->Results;
|
||||||
|
// if (count($part_info) > 0) {
|
||||||
|
// $idparts = $part_info[0]['idParts'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if ($idparts == "") {
|
||||||
|
// die("server_error");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //----------- result_project table ------------------
|
||||||
|
// foreach($part as $result_project) {
|
||||||
|
// //check exist result_project item
|
||||||
|
//// $result_project_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
//// $sql_result_project_query = "SELECT * FROM result_project WHERE idPart='$idparts' and idreports='$idreports' and idproducts='$idproducts'";
|
||||||
|
////
|
||||||
|
// $arr_result_project_need_idx = array();
|
||||||
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
// if ($arr_associate[$i]['table_name'] == "result_project") {
|
||||||
|
// array_push($arr_result_project_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
////
|
||||||
|
//// foreach($arr_result_project_need_idx as $q) {
|
||||||
|
//// $sql_result_project_query .= " and ".$q[0]."='".$q[0]."'";
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// $result_project_query->setQuery($sql_result_project_query);
|
||||||
|
//// $result_project_query->execute();
|
||||||
|
////
|
||||||
|
//// $result_project_info = $result_project_query->Results;
|
||||||
|
////
|
||||||
|
//// if (count($result_project_info) == 0) {
|
||||||
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
// $InsertQuery->Action = "insert";
|
||||||
|
// $InsertQuery->Table = "`result_project`";
|
||||||
|
// $InsertQuery->bindColumn("idPart", "s", $idparts . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
// for ($i = 0; $i < count($arr_result_project_need_idx); $i++) {
|
||||||
|
// $InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $result_project[$arr_result_project_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
// }
|
||||||
|
// $InsertQuery->saveInSession("");
|
||||||
|
// $InsertQuery->execute();
|
||||||
|
//// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
die('success');
|
||||||
|
} else {
|
||||||
|
die("invalid_excel_data_format_error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("invalid_excel_data_format_error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("none_define_column_error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("file_empty_error");
|
||||||
|
}
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
<?php
|
||||||
|
define('BASE_PATH', realpath(__DIR__ . '/../../..'));
|
||||||
|
require_once(BASE_PATH . '\public\Connections\repnew.php');
|
||||||
|
?>
|
||||||
|
<?php require_once(BASE_PATH . '/public/webassist/mysqli/rsobj.php'); ?>
|
||||||
|
<?php require_once(BASE_PATH . '/public/webassist/mysqli/queryobj.php'); ?>
|
||||||
|
<?php require_once(BASE_PATH . "/public/webassist/form_validations/wavt_scripts_php.php"); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$arr_total_products = json_decode($_POST['arr_project']);
|
||||||
|
$arr_excel_columns = json_decode($_POST['arr_excel_columns']);
|
||||||
|
$arr_associate = json_decode($_POST['arr_associate']);
|
||||||
|
$importcode = $_POST['importcode'];
|
||||||
|
|
||||||
|
$idx_sample_code_po = array_search("Sample Code (PO#)", $arr_excel_columns);
|
||||||
|
|
||||||
|
//insert to products table
|
||||||
|
$idx = 0;
|
||||||
|
foreach ($arr_total_products as $product) {
|
||||||
|
//check exist product item
|
||||||
|
$sample_code_po = $product[0][$idx_sample_code_po];
|
||||||
|
$product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
|
$product_query->execute();
|
||||||
|
|
||||||
|
$product_info = $product_query->Results;
|
||||||
|
$idproducts = "";
|
||||||
|
|
||||||
|
if (count($product_info) > 0) {
|
||||||
|
$idproducts = $product_info[0]['idproducts'];
|
||||||
|
} else { // have to insert new
|
||||||
|
$arr_product_need_idx = array();
|
||||||
|
for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
if ($arr_associate[$i]->table_name == "products") {
|
||||||
|
array_push($arr_product_need_idx, array($arr_associate[$i]->column_name, array_search($arr_associate[$i]->headerfile, $arr_excel_columns)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$InsertQuery->Action = "insert";
|
||||||
|
$InsertQuery->Table = "`products`";
|
||||||
|
$InsertQuery->bindColumn("products_refnumber", "s", $product[0][$idx_sample_code_po], "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
for ($i = 0; $i < count($arr_product_need_idx); $i++) {
|
||||||
|
$InsertQuery->bindColumn($arr_product_need_idx[$i][0], "s", $product[0][$arr_product_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
}
|
||||||
|
$InsertQuery->saveInSession("");
|
||||||
|
$InsertQuery->execute();
|
||||||
|
|
||||||
|
$product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
|
$product_query->execute();
|
||||||
|
|
||||||
|
$product_info = $product_query->Results;
|
||||||
|
|
||||||
|
if (count($product_info) > 0) {
|
||||||
|
$idproducts = $product_info[0]['idproducts'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$idx++;
|
||||||
|
|
||||||
|
if ($idproducts == "") {
|
||||||
|
die("server_error");
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------- report table ------------------
|
||||||
|
//separate reports table data
|
||||||
|
$idx_report_no_po = array_search("Report no.", $arr_excel_columns);
|
||||||
|
|
||||||
|
$arr_total_reports = array();
|
||||||
|
$tmp_arr_child_reports = array();
|
||||||
|
$tmp_report_no = "";
|
||||||
|
for ($i = 0; $i < count($product); $i++) {
|
||||||
|
if ($product[$i][$idx_report_no_po] == $tmp_report_no) {
|
||||||
|
array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
|
} else {
|
||||||
|
if ($tmp_report_no != "") {
|
||||||
|
if (count($tmp_arr_child_reports) > 0) {
|
||||||
|
array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tmp_report_no = $product[$i][$idx_report_no_po];
|
||||||
|
$tmp_arr_child_reports = array();
|
||||||
|
array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($tmp_arr_child_reports) > 0) {
|
||||||
|
array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
|
}
|
||||||
|
|
||||||
|
//insert to reports table
|
||||||
|
foreach ($arr_total_reports as $report) {
|
||||||
|
//check exist reports item
|
||||||
|
$report_no = $report[0][$idx_report_no_po];
|
||||||
|
$report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
|
$report_query->execute();
|
||||||
|
|
||||||
|
$report_info = $report_query->Results;
|
||||||
|
$idreports = "";
|
||||||
|
|
||||||
|
if (count($report_info) > 0) {
|
||||||
|
$idreports = $report_info[0]['idreports'];
|
||||||
|
} else { // have to insert new
|
||||||
|
$arr_report_need_idx = array();
|
||||||
|
for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
if ($arr_associate[$i]->table_name == "reports") {
|
||||||
|
array_push($arr_report_need_idx, array($arr_associate[$i]->column_name, array_search($arr_associate[$i]->headerfile, $arr_excel_columns)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$InsertQuery->Action = "insert";
|
||||||
|
$InsertQuery->Table = "`reports`";
|
||||||
|
$InsertQuery->bindColumn("reportsNumberLab", "s", $report[0][$idx_report_no_po] . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
for ($i = 0; $i < count($arr_report_need_idx); $i++) {
|
||||||
|
$InsertQuery->bindColumn($arr_report_need_idx[$i][0], "s", $report[0][$arr_report_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
}
|
||||||
|
$InsertQuery->saveInSession("");
|
||||||
|
$InsertQuery->execute();
|
||||||
|
|
||||||
|
$report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
|
$report_query->execute();
|
||||||
|
|
||||||
|
$report_info = $report_query->Results;
|
||||||
|
if (count($report_info) > 0) {
|
||||||
|
$idreports = $report_info[0]['idreports'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($idreports == "") {
|
||||||
|
die("server_error");
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------- parts table ------------------
|
||||||
|
//separate parts table data
|
||||||
|
$idx_part_no_po = array_search("Part No.", $arr_excel_columns);
|
||||||
|
|
||||||
|
$arr_total_parts = array();
|
||||||
|
$tmp_arr_child_parts = array();
|
||||||
|
$tmp_part_no = "";
|
||||||
|
for ($i = 0; $i < count($report); $i++) {
|
||||||
|
if ($report[$i][$idx_part_no_po] == $tmp_part_no) {
|
||||||
|
array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
|
} else {
|
||||||
|
if ($tmp_part_no != "") {
|
||||||
|
if (count($tmp_arr_child_parts) > 0) {
|
||||||
|
array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tmp_part_no = $report[$i][$idx_part_no_po];
|
||||||
|
$tmp_arr_child_parts = array();
|
||||||
|
array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($tmp_arr_child_parts) > 0) {
|
||||||
|
array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
//insert to parts table
|
||||||
|
foreach ($arr_total_parts as $part) {
|
||||||
|
//check exist parts item
|
||||||
|
$part_no = $part[0][$idx_part_no_po];
|
||||||
|
$part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
|
$part_query->execute();
|
||||||
|
|
||||||
|
$part_info = $part_query->Results;
|
||||||
|
$idparts = "";
|
||||||
|
|
||||||
|
if (count($part_info) > 0) {
|
||||||
|
$idparts = $part_info[0]['idParts'];
|
||||||
|
} else { // have to insert new
|
||||||
|
$arr_part_need_idx = array();
|
||||||
|
for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
if ($arr_associate[$i]->table_name == "parts") {
|
||||||
|
array_push($arr_part_need_idx, array($arr_associate[$i]->column_name, array_search($arr_associate[$i]->headerfile, $arr_excel_columns)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$InsertQuery->Action = "insert";
|
||||||
|
$InsertQuery->Table = "`parts`";
|
||||||
|
$InsertQuery->bindColumn("partsCode", "s", $part[0][$idx_part_no_po] . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
for ($i = 0; $i < count($arr_part_need_idx); $i++) {
|
||||||
|
$InsertQuery->bindColumn($arr_part_need_idx[$i][0], "s", $part[0][$arr_part_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
}
|
||||||
|
$InsertQuery->saveInSession("");
|
||||||
|
$InsertQuery->execute();
|
||||||
|
|
||||||
|
$part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
|
$part_query->execute();
|
||||||
|
|
||||||
|
$part_info = $part_query->Results;
|
||||||
|
if (count($part_info) > 0) {
|
||||||
|
$idparts = $part_info[0]['idParts'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($idparts == "") {
|
||||||
|
die("server_error");
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------- result_project table ------------------
|
||||||
|
foreach ($part as $result_project) {
|
||||||
|
//check exist result_project item
|
||||||
|
// $result_project_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
// $sql_result_project_query = "SELECT * FROM result_project WHERE idPart='$idparts' and idreports='$idreports' and idproducts='$idproducts'";
|
||||||
|
//
|
||||||
|
$arr_result_project_need_idx = array();
|
||||||
|
for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
|
if ($arr_associate[$i]->table_name == "result_project") {
|
||||||
|
if ($arr_associate[$i]->column_name == "result_TestName") {
|
||||||
|
$tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)];
|
||||||
|
$trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val));
|
||||||
|
$analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$analysis_query->setQuery("SELECT * FROM analysisvocabulary WHERE nameanalysisvoc like '$trim_item'");
|
||||||
|
$analysis_query->execute();
|
||||||
|
|
||||||
|
$analysis_data = $analysis_query->Results;
|
||||||
|
$ref_id = 0;
|
||||||
|
if (count($analysis_data) > 0) {
|
||||||
|
$ref_id = $analysis_data[0]['idanalysisvocabulary'];
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($arr_result_project_need_idx, array($arr_associate[$i]->column_name, $ref_id, 1));
|
||||||
|
} else if ($arr_associate[$i]->column_name == "result_AnalytsName") {
|
||||||
|
$tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)];
|
||||||
|
$trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val));
|
||||||
|
$analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
|
$analysis_query->setQuery("SELECT * FROM compundsvocabulary WHERE namecompoundsvocabulary like '$tmp_val' or cascompoundvocabulary like '$tmp_val'");
|
||||||
|
$analysis_query->execute();
|
||||||
|
|
||||||
|
$analysis_data = $analysis_query->Results;
|
||||||
|
$ref_id = 0;
|
||||||
|
if (count($analysis_data) > 0) {
|
||||||
|
$ref_id = $analysis_data[0]['idcompoundsvocabulary'];
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($arr_result_project_need_idx, array($arr_associate[$i]->column_name, $ref_id, 1));
|
||||||
|
} else {
|
||||||
|
array_push($arr_result_project_need_idx, array($arr_associate[$i]->column_name, array_search($arr_associate[$i]->headerfile, $arr_excel_columns), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// foreach($arr_result_project_need_idx as $q) {
|
||||||
|
// $sql_result_project_query .= " and ".$q[0]."='".$q[0]."'";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $result_project_query->setQuery($sql_result_project_query);
|
||||||
|
// $result_project_query->execute();
|
||||||
|
//
|
||||||
|
// $result_project_info = $result_project_query->Results;
|
||||||
|
//
|
||||||
|
// if (count($result_project_info) == 0) {
|
||||||
|
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$InsertQuery->Action = "insert";
|
||||||
|
$InsertQuery->Table = "`result_project`";
|
||||||
|
$InsertQuery->bindColumn("idPart", "s", $idparts . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
|
$InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
|
for ($i = 0; $i < count($arr_result_project_need_idx); $i++) {
|
||||||
|
if ($arr_result_project_need_idx[$i][2] > 0) {
|
||||||
|
$InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $arr_result_project_need_idx[$i][1], "WA_DEFAULT");
|
||||||
|
} else {
|
||||||
|
$InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $result_project[$arr_result_project_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$InsertQuery->saveInSession("");
|
||||||
|
$InsertQuery->execute();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$UpdateQuery = new WA_MySQLi_Query($repnew);
|
||||||
|
$UpdateQuery->Action = "update";
|
||||||
|
$UpdateQuery->Table = "`template_import_his`";
|
||||||
|
$UpdateQuery->bindColumn("f_status", "i", "1", "WA_DEFAULT");
|
||||||
|
$UpdateQuery->addFilter("importcode", "=", "s", "" . $importcode . "");
|
||||||
|
$UpdateQuery->execute();
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php include('../include/headscript.php'); ?>
|
<?php include('../include/headscript.php'); ?>
|
||||||
<?php
|
<?php
|
||||||
require '../../vendor/autoload.php';
|
require '../../vendor/autoload.php';
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
||||||
|
|
||||||
@@ -8,28 +9,32 @@ function post_async($url, array $params)
|
|||||||
{
|
{
|
||||||
foreach ($params as $key => &$val) {
|
foreach ($params as $key => &$val) {
|
||||||
if (is_array($val)) $val = implode(',', $val);
|
if (is_array($val)) $val = implode(',', $val);
|
||||||
$post_params[] = $key.'='.urlencode($val);
|
$post_params[] = $key . '=' . urlencode($val);
|
||||||
}
|
}
|
||||||
$post_string = implode('&', $post_params);
|
$post_string = implode('&', $post_params);
|
||||||
|
|
||||||
$parts=parse_url($url);
|
$parts = parse_url($url);
|
||||||
|
|
||||||
$fp = fsockopen($parts['host'],
|
$fp = fsockopen(
|
||||||
isset($parts['port'])?$parts['port']:80,
|
$parts['host'],
|
||||||
$errno, $errstr, 30);
|
isset($parts['port']) ? $parts['port'] : 80,
|
||||||
|
$errno,
|
||||||
|
$errstr,
|
||||||
|
30
|
||||||
|
);
|
||||||
|
|
||||||
$out = "POST ".$parts['path']." HTTP/1.1\r\n";
|
$out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
|
||||||
$out.= "Host: ".$parts['host']."\r\n";
|
$out .= "Host: " . $parts['host'] . "\r\n";
|
||||||
$out.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||||
$out.= "Content-Length: ".strlen($post_string)."\r\n";
|
$out .= "Content-Length: " . strlen($post_string) . "\r\n";
|
||||||
$out.= "Connection: Close\r\n\r\n";
|
$out .= "Connection: Close\r\n\r\n";
|
||||||
if (isset($post_string)) $out.= $post_string;
|
if (isset($post_string)) $out .= $post_string;
|
||||||
|
|
||||||
fwrite($fp, $out);
|
fwrite($fp, $out);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_FILES['f_csv'])) {
|
if (isset($_FILES['f_csv'])) {
|
||||||
$file = $_FILES['f_csv']['tmp_name'];
|
$file = $_FILES['f_csv']['tmp_name'];
|
||||||
$template_id = $_POST['template_id'];
|
$template_id = $_POST['template_id'];
|
||||||
|
|
||||||
@@ -39,11 +44,11 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
$arr_associate_data->execute();
|
$arr_associate_data->execute();
|
||||||
$arr_associate = $arr_associate_data->Results;
|
$arr_associate = $arr_associate_data->Results;
|
||||||
|
|
||||||
if(count($arr_associate) > 0) { //check define columns
|
if (count($arr_associate) > 0) { //check define columns
|
||||||
$spreadsheet = IOFactory::load($file);
|
$spreadsheet = IOFactory::load($file);
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
$arr_info = $worksheet->toArray();
|
$arr_info = $worksheet->toArray();
|
||||||
if(count($arr_info) > 1) { //check excel rows
|
if (count($arr_info) > 1) { //check excel rows
|
||||||
$arr_excel_columns = $arr_info[0];
|
$arr_excel_columns = $arr_info[0];
|
||||||
$arr_need_columns = array();
|
$arr_need_columns = array();
|
||||||
array_push($arr_need_columns, "Sample Code (PO#)");
|
array_push($arr_need_columns, "Sample Code (PO#)");
|
||||||
@@ -51,7 +56,7 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
array_push($arr_need_columns, "Part No.");
|
array_push($arr_need_columns, "Part No.");
|
||||||
|
|
||||||
// remove empty rows
|
// remove empty rows
|
||||||
$arr_info = array_filter($arr_info, function($row) {
|
$arr_info = array_filter($arr_info, function ($row) {
|
||||||
return !empty(array_filter($row));
|
return !empty(array_filter($row));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,20 +78,20 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($arr_associate as $item) {
|
foreach ($arr_associate as $item) {
|
||||||
array_push($arr_need_columns, $item['headerfile']);
|
array_push($arr_need_columns, $item['headerfile']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check excel data column with template associate data
|
//check excel data column with template associate data
|
||||||
$verify_flag = true;
|
$verify_flag = true;
|
||||||
for($i=0; $i<count($arr_need_columns); $i++) {
|
for ($i = 0; $i < count($arr_need_columns); $i++) {
|
||||||
if(!in_array($arr_need_columns[$i], $arr_excel_columns)) {
|
if (!in_array($arr_need_columns[$i], $arr_excel_columns)) {
|
||||||
$verify_flag = false;
|
$verify_flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($verify_flag) {
|
if ($verify_flag) {
|
||||||
//separate by Sample Code (PO#) - product
|
//separate by Sample Code (PO#) - product
|
||||||
$idx_sample_code_po = array_search("Sample Code (PO#)", $arr_excel_columns);
|
$idx_sample_code_po = array_search("Sample Code (PO#)", $arr_excel_columns);
|
||||||
|
|
||||||
@@ -94,12 +99,12 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
$arr_total_products = array();
|
$arr_total_products = array();
|
||||||
$tmp_arr_child_products = array();
|
$tmp_arr_child_products = array();
|
||||||
$tmp_sample_code_po = "";
|
$tmp_sample_code_po = "";
|
||||||
for($i=1; $i<count($arr_info); $i++) {
|
for ($i = 1; $i < count($arr_info); $i++) {
|
||||||
if($arr_info[$i][$idx_sample_code_po] == $tmp_sample_code_po) {
|
if ($arr_info[$i][$idx_sample_code_po] == $tmp_sample_code_po) {
|
||||||
array_push($tmp_arr_child_products, $arr_info[$i]);
|
array_push($tmp_arr_child_products, $arr_info[$i]);
|
||||||
} else {
|
} else {
|
||||||
if($tmp_sample_code_po != "") {
|
if ($tmp_sample_code_po != "") {
|
||||||
if(count($tmp_arr_child_products) > 0) {
|
if (count($tmp_arr_child_products) > 0) {
|
||||||
array_push($arr_total_products, $tmp_arr_child_products);
|
array_push($arr_total_products, $tmp_arr_child_products);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +113,7 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
array_push($tmp_arr_child_products, $arr_info[$i]);
|
array_push($tmp_arr_child_products, $arr_info[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count($tmp_arr_child_products) > 0) {
|
if (count($tmp_arr_child_products) > 0) {
|
||||||
array_push($arr_total_products, $tmp_arr_child_products);
|
array_push($arr_total_products, $tmp_arr_child_products);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,17 +127,17 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
$InsertQuery->Table = "`template_import_his`";
|
$InsertQuery->Table = "`template_import_his`";
|
||||||
$InsertQuery->bindColumn("created_at", "s", date("Y-m-d H:i:s"), "WA_DEFAULT");
|
$InsertQuery->bindColumn("created_at", "s", date("Y-m-d H:i:s"), "WA_DEFAULT");
|
||||||
$InsertQuery->bindColumn("user_id", "i", "" . $_SESSION['iduserlogin'], "WA_DEFAULT");
|
$InsertQuery->bindColumn("user_id", "i", "" . $_SESSION['iduserlogin'], "WA_DEFAULT");
|
||||||
$InsertQuery->bindColumn("importcode", "s", "" .$importcode, "WA_DEFAULT");
|
$InsertQuery->bindColumn("importcode", "s", "" . $importcode, "WA_DEFAULT");
|
||||||
$InsertQuery->bindColumn("f_status", "i", "0", "WA_DEFAULT");
|
$InsertQuery->bindColumn("f_status", "i", "0", "WA_DEFAULT");
|
||||||
$InsertQuery->saveInSession("");
|
$InsertQuery->saveInSession("");
|
||||||
$InsertQuery->execute();
|
$InsertQuery->execute();
|
||||||
|
|
||||||
// post_async("localhost:80/0_claudio/reportify_new/public/userarea/importify/importify_bg_script.php", [
|
// post_async("localhost:80/0_claudio/reportify_new/public/userarea/importify/importify_bg_script.php", [
|
||||||
// 'importcode' => $importcode
|
// 'importcode' => $importcode
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
|
|
||||||
post_async($_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']."/../importify_bg_script.php", [
|
post_async($_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'] . "/../importify_bg_script.php", [
|
||||||
'arr_project' => json_encode($arr_total_products),
|
'arr_project' => json_encode($arr_total_products),
|
||||||
'arr_excel_columns' => json_encode($arr_excel_columns),
|
'arr_excel_columns' => json_encode($arr_excel_columns),
|
||||||
'arr_associate' => json_encode($arr_associate),
|
'arr_associate' => json_encode($arr_associate),
|
||||||
@@ -140,234 +145,234 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
//insert to products table
|
//insert to products table
|
||||||
// foreach($arr_total_products as $product) {
|
// foreach($arr_total_products as $product) {
|
||||||
// //check exist product item
|
// //check exist product item
|
||||||
// $sample_code_po = $product[0][$idx_sample_code_po];
|
// $sample_code_po = $product[0][$idx_sample_code_po];
|
||||||
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
// $product_query->execute();
|
// $product_query->execute();
|
||||||
//
|
//
|
||||||
// $product_info = $product_query->Results;
|
// $product_info = $product_query->Results;
|
||||||
// $idproducts = "";
|
// $idproducts = "";
|
||||||
//
|
//
|
||||||
// if(count($product_info) > 0) {
|
// if(count($product_info) > 0) {
|
||||||
// $idproducts = $product_info[0]['idproducts'];
|
// $idproducts = $product_info[0]['idproducts'];
|
||||||
// } else { // have to insert new
|
// } else { // have to insert new
|
||||||
// $arr_product_need_idx = array();
|
// $arr_product_need_idx = array();
|
||||||
// for($i=0; $i<count($arr_associate); $i++) {
|
// for($i=0; $i<count($arr_associate); $i++) {
|
||||||
// if($arr_associate[$i]['table_name'] == "products") {
|
// if($arr_associate[$i]['table_name'] == "products") {
|
||||||
// array_push($arr_product_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
// array_push($arr_product_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
// $InsertQuery->Action = "insert";
|
// $InsertQuery->Action = "insert";
|
||||||
// $InsertQuery->Table = "`products`";
|
// $InsertQuery->Table = "`products`";
|
||||||
// $InsertQuery->bindColumn("products_refnumber", "s", $product[0][$idx_sample_code_po], "WA_DEFAULT");
|
// $InsertQuery->bindColumn("products_refnumber", "s", $product[0][$idx_sample_code_po], "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode. "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode. "", "WA_DEFAULT");
|
||||||
// for($i=0; $i<count($arr_product_need_idx); $i++) {
|
// for($i=0; $i<count($arr_product_need_idx); $i++) {
|
||||||
// $InsertQuery->bindColumn($arr_product_need_idx[$i][0], "s", $product[0][$arr_product_need_idx[$i][1]], "WA_DEFAULT");
|
// $InsertQuery->bindColumn($arr_product_need_idx[$i][0], "s", $product[0][$arr_product_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
// }
|
// }
|
||||||
// $InsertQuery->saveInSession("");
|
// $InsertQuery->saveInSession("");
|
||||||
// $InsertQuery->execute();
|
// $InsertQuery->execute();
|
||||||
//
|
//
|
||||||
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $product_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
// $product_query->setQuery("SELECT * FROM products WHERE products_refnumber='$sample_code_po'");
|
||||||
// $product_query->execute();
|
// $product_query->execute();
|
||||||
//
|
//
|
||||||
// $product_info = $product_query->Results;
|
// $product_info = $product_query->Results;
|
||||||
// if(count($product_info) > 0) {
|
// if(count($product_info) > 0) {
|
||||||
// $idproducts = $product_info[0]['idproducts'];
|
// $idproducts = $product_info[0]['idproducts'];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if($idproducts == "") {
|
// if($idproducts == "") {
|
||||||
// die("server_error");
|
// die("server_error");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// //----------- report table ------------------
|
// //----------- report table ------------------
|
||||||
// //separate reports table data
|
// //separate reports table data
|
||||||
// $idx_report_no_po = array_search("Report no.", $arr_excel_columns);
|
// $idx_report_no_po = array_search("Report no.", $arr_excel_columns);
|
||||||
//
|
//
|
||||||
// $arr_total_reports = array();
|
// $arr_total_reports = array();
|
||||||
// $tmp_arr_child_reports = array();
|
// $tmp_arr_child_reports = array();
|
||||||
// $tmp_report_no = "";
|
// $tmp_report_no = "";
|
||||||
// for($i=0; $i<count($product); $i++) {
|
// for($i=0; $i<count($product); $i++) {
|
||||||
// if($product[$i][$idx_report_no_po] == $tmp_report_no) {
|
// if($product[$i][$idx_report_no_po] == $tmp_report_no) {
|
||||||
// array_push($tmp_arr_child_reports, $product[$i]);
|
// array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
// } else {
|
// } else {
|
||||||
// if($tmp_report_no != "") {
|
// if($tmp_report_no != "") {
|
||||||
// if(count($tmp_arr_child_reports) > 0) {
|
// if(count($tmp_arr_child_reports) > 0) {
|
||||||
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// $tmp_report_no = $product[$i][$idx_report_no_po];
|
// $tmp_report_no = $product[$i][$idx_report_no_po];
|
||||||
// $tmp_arr_child_reports = array();
|
// $tmp_arr_child_reports = array();
|
||||||
// array_push($tmp_arr_child_reports, $product[$i]);
|
// array_push($tmp_arr_child_reports, $product[$i]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if(count($tmp_arr_child_reports) > 0) {
|
// if(count($tmp_arr_child_reports) > 0) {
|
||||||
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
// array_push($arr_total_reports, $tmp_arr_child_reports);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //insert to reports table
|
// //insert to reports table
|
||||||
// foreach($arr_total_reports as $report) {
|
// foreach($arr_total_reports as $report) {
|
||||||
// //check exist reports item
|
// //check exist reports item
|
||||||
// $report_no = $report[0][$idx_report_no_po];
|
// $report_no = $report[0][$idx_report_no_po];
|
||||||
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
// $report_query->execute();
|
// $report_query->execute();
|
||||||
//
|
//
|
||||||
// $report_info = $report_query->Results;
|
// $report_info = $report_query->Results;
|
||||||
// $idreports = "";
|
// $idreports = "";
|
||||||
//
|
//
|
||||||
// if (count($report_info) > 0) {
|
// if (count($report_info) > 0) {
|
||||||
// $idreports = $report_info[0]['idreports'];
|
// $idreports = $report_info[0]['idreports'];
|
||||||
// } else { // have to insert new
|
// } else { // have to insert new
|
||||||
// $arr_report_need_idx = array();
|
// $arr_report_need_idx = array();
|
||||||
// for ($i = 0; $i < count($arr_associate); $i++) {
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
// if ($arr_associate[$i]['table_name'] == "reports") {
|
// if ($arr_associate[$i]['table_name'] == "reports") {
|
||||||
// array_push($arr_report_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
// array_push($arr_report_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
// $InsertQuery->Action = "insert";
|
// $InsertQuery->Action = "insert";
|
||||||
// $InsertQuery->Table = "`reports`";
|
// $InsertQuery->Table = "`reports`";
|
||||||
// $InsertQuery->bindColumn("reportsNumberLab", "s", $report[0][$idx_report_no_po]."", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("reportsNumberLab", "s", $report[0][$idx_report_no_po]."", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts."", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts."", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
// for ($i = 0; $i < count($arr_report_need_idx); $i++) {
|
// for ($i = 0; $i < count($arr_report_need_idx); $i++) {
|
||||||
// $InsertQuery->bindColumn($arr_report_need_idx[$i][0], "s", $report[0][$arr_report_need_idx[$i][1]], "WA_DEFAULT");
|
// $InsertQuery->bindColumn($arr_report_need_idx[$i][0], "s", $report[0][$arr_report_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
// }
|
// }
|
||||||
// $InsertQuery->saveInSession("");
|
// $InsertQuery->saveInSession("");
|
||||||
// $InsertQuery->execute();
|
// $InsertQuery->execute();
|
||||||
//
|
//
|
||||||
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $report_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
// $report_query->setQuery("SELECT * FROM reports WHERE reportsNumberLab='$report_no' and idproducts='$idproducts'");
|
||||||
// $report_query->execute();
|
// $report_query->execute();
|
||||||
//
|
//
|
||||||
// $report_info = $report_query->Results;
|
// $report_info = $report_query->Results;
|
||||||
// if (count($report_info) > 0) {
|
// if (count($report_info) > 0) {
|
||||||
// $idreports = $report_info[0]['idreports'];
|
// $idreports = $report_info[0]['idreports'];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if ($idreports == "") {
|
// if ($idreports == "") {
|
||||||
// die("server_error");
|
// die("server_error");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //----------- parts table ------------------
|
// //----------- parts table ------------------
|
||||||
// //separate parts table data
|
// //separate parts table data
|
||||||
// $idx_part_no_po = array_search("Part No.", $arr_excel_columns);
|
// $idx_part_no_po = array_search("Part No.", $arr_excel_columns);
|
||||||
//
|
//
|
||||||
// $arr_total_parts = array();
|
// $arr_total_parts = array();
|
||||||
// $tmp_arr_child_parts = array();
|
// $tmp_arr_child_parts = array();
|
||||||
// $tmp_part_no = "";
|
// $tmp_part_no = "";
|
||||||
// for($i=0; $i<count($report); $i++) {
|
// for($i=0; $i<count($report); $i++) {
|
||||||
// if($report[$i][$idx_part_no_po] == $tmp_part_no) {
|
// if($report[$i][$idx_part_no_po] == $tmp_part_no) {
|
||||||
// array_push($tmp_arr_child_parts, $report[$i]);
|
// array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
// } else {
|
// } else {
|
||||||
// if($tmp_part_no != "") {
|
// if($tmp_part_no != "") {
|
||||||
// if(count($tmp_arr_child_parts) > 0) {
|
// if(count($tmp_arr_child_parts) > 0) {
|
||||||
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// $tmp_part_no = $report[$i][$idx_part_no_po];
|
// $tmp_part_no = $report[$i][$idx_part_no_po];
|
||||||
// $tmp_arr_child_parts = array();
|
// $tmp_arr_child_parts = array();
|
||||||
// array_push($tmp_arr_child_parts, $report[$i]);
|
// array_push($tmp_arr_child_parts, $report[$i]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if(count($tmp_arr_child_parts) > 0) {
|
// if(count($tmp_arr_child_parts) > 0) {
|
||||||
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
// array_push($arr_total_parts, $tmp_arr_child_parts);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //insert to parts table
|
// //insert to parts table
|
||||||
// foreach($arr_total_parts as $part) {
|
// foreach($arr_total_parts as $part) {
|
||||||
// //check exist parts item
|
// //check exist parts item
|
||||||
// $part_no = $part[0][$idx_part_no_po];
|
// $part_no = $part[0][$idx_part_no_po];
|
||||||
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
// $part_query->execute();
|
// $part_query->execute();
|
||||||
//
|
//
|
||||||
// $part_info = $part_query->Results;
|
// $part_info = $part_query->Results;
|
||||||
// $idparts = "";
|
// $idparts = "";
|
||||||
//
|
//
|
||||||
// if (count($part_info) > 0) {
|
// if (count($part_info) > 0) {
|
||||||
// $idparts = $part_info[0]['idParts'];
|
// $idparts = $part_info[0]['idParts'];
|
||||||
// } else { // have to insert new
|
// } else { // have to insert new
|
||||||
// $arr_part_need_idx = array();
|
// $arr_part_need_idx = array();
|
||||||
// for ($i = 0; $i < count($arr_associate); $i++) {
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
// if ($arr_associate[$i]['table_name'] == "parts") {
|
// if ($arr_associate[$i]['table_name'] == "parts") {
|
||||||
// array_push($arr_part_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
// array_push($arr_part_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
// $InsertQuery->Action = "insert";
|
// $InsertQuery->Action = "insert";
|
||||||
// $InsertQuery->Table = "`parts`";
|
// $InsertQuery->Table = "`parts`";
|
||||||
// $InsertQuery->bindColumn("partsCode", "s", $part[0][$idx_part_no_po] . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("partsCode", "s", $part[0][$idx_part_no_po] . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
// for ($i = 0; $i < count($arr_part_need_idx); $i++) {
|
// for ($i = 0; $i < count($arr_part_need_idx); $i++) {
|
||||||
// $InsertQuery->bindColumn($arr_part_need_idx[$i][0], "s", $part[0][$arr_part_need_idx[$i][1]], "WA_DEFAULT");
|
// $InsertQuery->bindColumn($arr_part_need_idx[$i][0], "s", $part[0][$arr_part_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
// }
|
// }
|
||||||
// $InsertQuery->saveInSession("");
|
// $InsertQuery->saveInSession("");
|
||||||
// $InsertQuery->execute();
|
// $InsertQuery->execute();
|
||||||
//
|
//
|
||||||
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
// $part_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
// $part_query->setQuery("SELECT * FROM parts WHERE partsCode='$part_no' and idreports='$idreports' and idproducts='$idproducts'");
|
||||||
// $part_query->execute();
|
// $part_query->execute();
|
||||||
//
|
//
|
||||||
// $part_info = $part_query->Results;
|
// $part_info = $part_query->Results;
|
||||||
// if (count($part_info) > 0) {
|
// if (count($part_info) > 0) {
|
||||||
// $idparts = $part_info[0]['idParts'];
|
// $idparts = $part_info[0]['idParts'];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if ($idparts == "") {
|
// if ($idparts == "") {
|
||||||
// die("server_error");
|
// die("server_error");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //----------- result_project table ------------------
|
// //----------- result_project table ------------------
|
||||||
// foreach($part as $result_project) {
|
// foreach($part as $result_project) {
|
||||||
// //check exist result_project item
|
// //check exist result_project item
|
||||||
//// $result_project_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
//// $result_project_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||||
//// $sql_result_project_query = "SELECT * FROM result_project WHERE idPart='$idparts' and idreports='$idreports' and idproducts='$idproducts'";
|
//// $sql_result_project_query = "SELECT * FROM result_project WHERE idPart='$idparts' and idreports='$idreports' and idproducts='$idproducts'";
|
||||||
////
|
////
|
||||||
// $arr_result_project_need_idx = array();
|
// $arr_result_project_need_idx = array();
|
||||||
// for ($i = 0; $i < count($arr_associate); $i++) {
|
// for ($i = 0; $i < count($arr_associate); $i++) {
|
||||||
// if ($arr_associate[$i]['table_name'] == "result_project") {
|
// if ($arr_associate[$i]['table_name'] == "result_project") {
|
||||||
// array_push($arr_result_project_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
// array_push($arr_result_project_need_idx, array($arr_associate[$i]['column_name'], array_search($arr_associate[$i]['headerfile'], $arr_excel_columns)));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
////
|
////
|
||||||
//// foreach($arr_result_project_need_idx as $q) {
|
//// foreach($arr_result_project_need_idx as $q) {
|
||||||
//// $sql_result_project_query .= " and ".$q[0]."='".$q[0]."'";
|
//// $sql_result_project_query .= " and ".$q[0]."='".$q[0]."'";
|
||||||
//// }
|
//// }
|
||||||
////
|
////
|
||||||
//// $result_project_query->setQuery($sql_result_project_query);
|
//// $result_project_query->setQuery($sql_result_project_query);
|
||||||
//// $result_project_query->execute();
|
//// $result_project_query->execute();
|
||||||
////
|
////
|
||||||
//// $result_project_info = $result_project_query->Results;
|
//// $result_project_info = $result_project_query->Results;
|
||||||
////
|
////
|
||||||
//// if (count($result_project_info) == 0) {
|
//// if (count($result_project_info) == 0) {
|
||||||
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
// $InsertQuery = new WA_MySQLi_Query($repnew);
|
||||||
// $InsertQuery->Action = "insert";
|
// $InsertQuery->Action = "insert";
|
||||||
// $InsertQuery->Table = "`result_project`";
|
// $InsertQuery->Table = "`result_project`";
|
||||||
// $InsertQuery->bindColumn("idPart", "s", $idparts . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idPart", "s", $idparts . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idproducts", "i", "" . $idproducts . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("idreports", "i", "" . $idreports . "", "WA_DEFAULT");
|
||||||
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
// $InsertQuery->bindColumn("importcode", "i", "" . $importcode . "", "WA_DEFAULT");
|
||||||
// for ($i = 0; $i < count($arr_result_project_need_idx); $i++) {
|
// for ($i = 0; $i < count($arr_result_project_need_idx); $i++) {
|
||||||
// $InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $result_project[$arr_result_project_need_idx[$i][1]], "WA_DEFAULT");
|
// $InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $result_project[$arr_result_project_need_idx[$i][1]], "WA_DEFAULT");
|
||||||
// }
|
// }
|
||||||
// $InsertQuery->saveInSession("");
|
// $InsertQuery->saveInSession("");
|
||||||
// $InsertQuery->execute();
|
// $InsertQuery->execute();
|
||||||
//// }
|
//// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
die('success');
|
die('success');
|
||||||
} else {
|
} else {
|
||||||
@@ -382,7 +387,3 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
} else {
|
} else {
|
||||||
die("file_empty_error");
|
die("file_empty_error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
// Connessione al database
|
||||||
|
include('../include/headscript.php');
|
||||||
|
$tableName = 'products'; // Per la pagina products.php
|
||||||
|
|
||||||
|
// Verifica che i parametri necessari siano stati inviati
|
||||||
|
if (isset($_POST['user']) && isset($_POST['table'])) {
|
||||||
|
$userId = $_POST['user'];
|
||||||
|
$tablen = $tableName;
|
||||||
|
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
|
||||||
|
// Verifica della connessione
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query per verificare se il record esiste
|
||||||
|
$query = "SELECT * FROM user_table_settings WHERE iduser = ? AND page = ?";
|
||||||
|
$stmt = $conn->prepare($query);
|
||||||
|
$stmt->bind_param("is", $userId, $tablen);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
// Restituisci i dati esistenti
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
echo json_encode([
|
||||||
|
'column_visibility' => $row['column_visibility'],
|
||||||
|
'column_order' => $row['column_order']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Crea un record di default se non esiste
|
||||||
|
$defaultVisibility = json_encode([/* Impostazioni di visibilità predefinite */]);
|
||||||
|
$defaultOrder = json_encode([/* Ordine delle colonne predefinito */]);
|
||||||
|
|
||||||
|
$insertQuery = "INSERT INTO user_table_settings (iduser, page, column_visibility, column_order, created_at) VALUES (?, ?, ?, ?, NOW())";
|
||||||
|
$insertStmt = $conn->prepare($insertQuery);
|
||||||
|
$insertStmt->bind_param("isss", $userId, $tablen, $defaultVisibility, $defaultOrder);
|
||||||
|
$insertStmt->execute();
|
||||||
|
|
||||||
|
// Restituisci le impostazioni predefinite
|
||||||
|
echo json_encode([
|
||||||
|
'column_visibility' => $defaultVisibility,
|
||||||
|
'column_order' => $defaultOrder
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,22 @@
|
|||||||
<?php include('../include/headscript.php'); ?>
|
<?php
|
||||||
<?php include("../class/company.php"); ?>
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('../include/headscript.php'); ?>
|
||||||
|
<?php include("../class/company.php");
|
||||||
|
|
||||||
|
$page = 'products.php';
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
// Recupera le impostazioni delle colonne e dell'ordinamento dal database
|
||||||
|
$query = "SELECT column_visibility, column_order FROM user_table_settings WHERE iduser = ? AND page = ?";
|
||||||
|
$stmt = $conn->prepare($query);
|
||||||
|
$stmt->bind_param("is", $iduserlogin, $page);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($column_visibility, $column_order);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$conn = new mysqli($servername, $username, $password, $database);
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
@@ -21,11 +38,22 @@ $result = $conn->query($query);
|
|||||||
<!-- Includi prima jQuery -->
|
<!-- Includi prima jQuery -->
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
|
||||||
<!-- Includi DataTables CSS -->
|
<!-- DataTables CSS -->
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css">
|
||||||
|
<!-- DataTables Buttons CSS -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.3.1/css/buttons.dataTables.min.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/colreorder/1.5.6/css/colReorder.dataTables.min.css">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- DataTables JS -->
|
||||||
|
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
|
||||||
|
<!-- DataTables Buttons JS -->
|
||||||
|
<script src="https://cdn.datatables.net/buttons/2.3.1/js/dataTables.buttons.min.js"></script>
|
||||||
|
<!-- Buttons ColVis JS -->
|
||||||
|
<script src="https://cdn.datatables.net/buttons/2.3.1/js/buttons.colVis.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.datatables.net/colreorder/1.5.6/js/dataTables.colReorder.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- Includi DataTables JS -->
|
|
||||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
|
||||||
|
|
||||||
<!-- Altri riferimenti al CSS e JS -->
|
<!-- Altri riferimenti al CSS e JS -->
|
||||||
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||||
@@ -59,6 +87,41 @@ $result = $conn->query($query);
|
|||||||
.text-dark {
|
.text-dark {
|
||||||
color: black !important;
|
color: black !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-colvis-btn .dt-button {
|
||||||
|
background-color: #f8f9fa !important;
|
||||||
|
/* Colore di sfondo chiaro per i pulsanti */
|
||||||
|
color: #343a40 !important;
|
||||||
|
/* Testo scuro per il contrasto */
|
||||||
|
border: 1px solid #ced4da !important;
|
||||||
|
/* Bordo leggero */
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-colvis-btn .dt-button.active {
|
||||||
|
background-color: #007bff !important;
|
||||||
|
/* Colore di sfondo attivo (blu) */
|
||||||
|
color: white !important;
|
||||||
|
/* Testo bianco per il contrasto */
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-colvis-btn .dt-button:hover {
|
||||||
|
background-color: #0056b3 !important;
|
||||||
|
/* Colore al passaggio del mouse (blu più scuro) */
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Forza il contrasto per i pulsanti del selettore */
|
||||||
|
.dt-button-collection button.active {
|
||||||
|
background-color: #007bff !important;
|
||||||
|
/* Colore per il bottone selezionato */
|
||||||
|
color: #007bff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dt-button-collection button {
|
||||||
|
background-color: #f8f9fa !important;
|
||||||
|
/* Colore per i bottoni non attivi */
|
||||||
|
color: #000 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<body class="fixed-left">
|
<body class="fixed-left">
|
||||||
@@ -93,6 +156,19 @@ $result = $conn->query($query);
|
|||||||
<th>Color</th>
|
<th>Color</th>
|
||||||
<th>Season</th>
|
<th>Season</th>
|
||||||
<th>Market</th>
|
<th>Market</th>
|
||||||
|
<th>SKU</th>
|
||||||
|
<th>Order</th>
|
||||||
|
<th>Buyer</th>
|
||||||
|
<th>Fiber Content Result</th>
|
||||||
|
<th>Supplier</th>
|
||||||
|
<th>Department</th>
|
||||||
|
<th>Production Date</th>
|
||||||
|
<th>Date In Lab</th>
|
||||||
|
<th>Date Out Lab</th>
|
||||||
|
<th>Lab Service</th>
|
||||||
|
<th>Age Range</th>
|
||||||
|
<th>Division</th>
|
||||||
|
<th>Phase</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -105,6 +181,19 @@ $result = $conn->query($query);
|
|||||||
<td><?php echo $row['products_color']; ?></td>
|
<td><?php echo $row['products_color']; ?></td>
|
||||||
<td><?php echo $row['products_season']; ?></td>
|
<td><?php echo $row['products_season']; ?></td>
|
||||||
<td><?php echo $row['products_market']; ?></td>
|
<td><?php echo $row['products_market']; ?></td>
|
||||||
|
<td><?php echo $row['products_sku']; ?></td>
|
||||||
|
<td><?php echo $row['products_order']; ?></td>
|
||||||
|
<td><?php echo $row['product_buyer']; ?></td>
|
||||||
|
<td><?php echo $row['products_fibercontentresult']; ?></td>
|
||||||
|
<td><?php echo $row['namesupplier']; ?></td>
|
||||||
|
<td><?php echo $row['iddepartment']; ?></td>
|
||||||
|
<td><?php echo $row['dateprod']; ?></td>
|
||||||
|
<td><?php echo $row['dateinlab']; ?></td>
|
||||||
|
<td><?php echo $row['dateoutlab']; ?></td>
|
||||||
|
<td><?php echo $row['labservice']; ?></td>
|
||||||
|
<td><?php echo $row['agerange']; ?></td>
|
||||||
|
<td><?php echo $row['products_division']; ?></td>
|
||||||
|
<td><?php echo $row['products_phase']; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-info btn-sm show-reports">Reports</button>
|
<button class="btn btn-info btn-sm show-reports">Reports</button>
|
||||||
</td>
|
</td>
|
||||||
@@ -118,26 +207,36 @@ $result = $conn->query($query);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div><!-- container -->
|
</div><!-- container -->
|
||||||
</div><!-- Page content Wrapper -->
|
</div><!-- Page content Wrapper -->
|
||||||
</div><!-- content -->
|
</div><!-- content -->
|
||||||
<?php include('../include/footer.php'); ?>
|
<?php include('../include/footer.php'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Inizializza DataTables con filtri per le colonne
|
// Inizializza DataTables con ColReorder, filtri e ColVis
|
||||||
var table = $('#productsTable').DataTable({
|
var table = $('#productsTable').DataTable({
|
||||||
responsive: true,
|
responsive: true,
|
||||||
"pageLength": 50,
|
pageLength: 50,
|
||||||
"order": [
|
order: [
|
||||||
[1, 'asc']
|
[1, 'asc']
|
||||||
], // Ordina per descrizione
|
], // Ordina per descrizione
|
||||||
|
colReorder: true, // Abilita il riordinamento delle colonne
|
||||||
|
dom: 'Bfrtip', // Integra i bottoni
|
||||||
|
buttons: [{
|
||||||
|
extend: 'colvis', // ColVis per mostrare/nascondere colonne
|
||||||
|
collectionLayout: 'fixed four-column', // Layout del dropdown
|
||||||
|
text: 'Select Columns', // Testo del bottone dropdown
|
||||||
|
postfixButtons: ['colvisRestore'], // Pulsante per ripristinare la configurazione iniziale
|
||||||
|
columns: ':not(:last-child)' // Non nascondere l'ultima colonna (Actions)
|
||||||
|
}],
|
||||||
initComplete: function() {
|
initComplete: function() {
|
||||||
// Aggiungi i filtri per ogni colonna
|
// Aggiungi i filtri per ogni colonna (eccetto la colonna delle azioni)
|
||||||
this.api().columns().every(function() {
|
this.api().columns().every(function() {
|
||||||
var column = this;
|
var column = this;
|
||||||
|
if (column.index() !== 6) { // Escludi la colonna "Action"
|
||||||
var input = $('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
|
var input = $('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
|
||||||
.appendTo($(column.header()))
|
.appendTo($(column.header()))
|
||||||
.on('keyup change clear', function() {
|
.on('keyup change clear', function() {
|
||||||
@@ -145,38 +244,78 @@ $result = $conn->query($query);
|
|||||||
column.search(this.value).draw();
|
column.search(this.value).draw();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
// Recupera le impostazioni salvate dal server
|
||||||
|
stateSave: true,
|
||||||
|
stateSaveCallback: function(settings, data) {
|
||||||
|
// Salva le impostazioni sul server tramite AJAX
|
||||||
|
$.ajax({
|
||||||
|
url: 'save_user_table_settings.php', // PHP che salva i settaggi
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
user: "<?php echo $iduserlogin; ?>", // ID utente
|
||||||
|
table: 'products', // Nome della tabella
|
||||||
|
settings: JSON.stringify(data) // Impostazioni della tabella
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
console.log('Settings saved:', response);
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Error saving settings:', xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
stateLoadCallback: function(settings) {
|
||||||
|
var o;
|
||||||
|
// Carica le impostazioni salvate dal server tramite AJAX
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_user_table_settings.php', // PHP che recupera i settaggi
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
user: "<?php echo $iduserlogin; ?>", // ID utente
|
||||||
|
table: 'products' // Nome della tabella
|
||||||
|
},
|
||||||
|
async: false,
|
||||||
|
success: function(response) {
|
||||||
|
o = JSON.parse(response);
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Error loading settings:', xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Gestione del click su "Reports" per visualizzare la tabella report e analisi
|
// Gestione del click su "Reports" per visualizzare la tabella child con i report e le analisi
|
||||||
$('#productsTable').on('click', '.show-reports', function() {
|
$('#productsTable').on('click', '.show-reports', function() {
|
||||||
var tr = $(this).closest('tr');
|
var tr = $(this).closest('tr');
|
||||||
var productId = tr.data('productid');
|
var productId = tr.data('productid');
|
||||||
var row = $('#productsTable').DataTable().row(tr);
|
var row = $('#productsTable').DataTable().row(tr);
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
console.log('Loading reports and analysis for productId:', productId); // Debug
|
|
||||||
|
|
||||||
button.prop('disabled', true);
|
button.prop('disabled', true);
|
||||||
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
|
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
|
||||||
|
|
||||||
// Se la riga child è già visibile, non facciamo nulla
|
// Se la riga child è già visibile, nascondila
|
||||||
if (row.child.isShown()) {
|
if (row.child.isShown()) {
|
||||||
button.prop('disabled', false);
|
row.child.hide();
|
||||||
|
tr.removeClass('shown');
|
||||||
button.html('Reports');
|
button.html('Reports');
|
||||||
|
button.prop('disabled', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carica i report e le analisi insieme tramite AJAX
|
// Carica i report e le analisi tramite AJAX
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'get_reports_and_analysis.php', // Nuovo script PHP per ottenere sia i report che le analisi
|
url: 'get_reports_and_analysis.php',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
productId: productId
|
productId: productId
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log('Reports and Analysis data loaded:', data); // Debug
|
|
||||||
row.child(formatReportsAndAnalysis(data)).show();
|
row.child(formatReportsAndAnalysis(data)).show();
|
||||||
tr.addClass('shown');
|
tr.addClass('shown');
|
||||||
},
|
},
|
||||||
@@ -200,35 +339,33 @@ $result = $conn->query($query);
|
|||||||
html += '<thead><tr><th>Report Number</th><th>Report Date</th><th>Rating</th><th>Analysis (Name)</th><th>Final Rating</th><th>Action</th></tr></thead>';
|
html += '<thead><tr><th>Report Number</th><th>Report Date</th><th>Rating</th><th>Analysis (Name)</th><th>Final Rating</th><th>Action</th></tr></thead>';
|
||||||
html += '<tbody>';
|
html += '<tbody>';
|
||||||
|
|
||||||
// Per ogni report, aggiungi il report e le analisi associate
|
|
||||||
$.each(reports, function(index, report) {
|
$.each(reports, function(index, report) {
|
||||||
// Riga del report principale
|
|
||||||
html += '<tr>';
|
html += '<tr>';
|
||||||
html += '<td>' + report.reportsNumberLab + '</td>';
|
html += '<td>' + report.reportsNumberLab + '</td>';
|
||||||
html += '<td>' + report.reportDateIn + '</td>';
|
html += '<td>' + report.reportDateIn + '</td>';
|
||||||
html += '<td>' + report.reportsRating + '</td>';
|
html += '<td>' + report.reportsRating + '</td>';
|
||||||
html += '<td colspan="2"></td>'; // Righe vuote per mantenere l'allineamento
|
html += '<td colspan="2"></td>'; // Righe vuote per mantenere l'allineamento
|
||||||
html += '<td><button class="btn btn-primary btn-sm report-details" data-reportid="' + report.idreports + '">Details</button></td>'; // Aggiungi il bottone Details
|
html += '<td><button class="btn btn-primary btn-sm report-details" data-reportid="' + report.idreports + '">Details</button></td>';
|
||||||
|
|
||||||
// Se ci sono analisi associate al report, le aggiungi sotto lo stesso report
|
// Se ci sono analisi associate, aggiungi le righe per ciascuna analisi
|
||||||
if (report.analysis.length > 0) {
|
if (report.analysis.length > 0) {
|
||||||
$.each(report.analysis, function(i, analysis) {
|
$.each(report.analysis, function(i, analysis) {
|
||||||
var ratingClass = ''; // Classe CSS per la colorazione della cella
|
var ratingClass = '';
|
||||||
if (analysis.finalRating === 'FAIL') {
|
if (analysis.finalRating === 'FAIL') {
|
||||||
ratingClass = 'bg-danger text-white'; // Colore rosso per i fallimenti
|
ratingClass = 'bg-danger text-white';
|
||||||
} else if (analysis.finalRating === 'PASS') {
|
} else if (analysis.finalRating === 'PASS') {
|
||||||
ratingClass = 'bg-success text-white'; // Colore verde per i successi
|
ratingClass = 'bg-success text-white';
|
||||||
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
|
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
|
||||||
ratingClass = 'bg-warning text-dark'; // Colore giallo per risultati ambigui
|
ratingClass = 'bg-warning text-dark';
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '<tr>';
|
html += '<tr>';
|
||||||
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
|
html += '<td></td>';
|
||||||
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
|
html += '<td></td>';
|
||||||
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
|
html += '<td></td>';
|
||||||
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>'; // Nome dell'analisi
|
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>';
|
||||||
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
|
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
|
||||||
html += '<td></td>'; // Lascia vuoto per non aggiungere il bottone "Details" nella riga dell'analisi
|
html += '<td></td>';
|
||||||
html += '</tr>';
|
html += '</tr>';
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -241,16 +378,21 @@ $result = $conn->query($query);
|
|||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Funzione per la visualizzazione dei dettagli del report
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.report-details', function() {
|
$(document).on('click', '.report-details', function() {
|
||||||
var reportId = $(this).data('reportid'); // Ottieni l'id del report
|
var reportId = $(this).data('reportid');
|
||||||
window.location.href = 'reportdetails.php?idreports=' + reportId; // Reindirizza alla pagina reportdetails.php con idreports
|
window.location.href = 'reportdetails.php?idreports=' + reportId;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
// Connessione al database
|
||||||
|
include('../include/headscript.php');
|
||||||
|
|
||||||
|
// Recupera i dati dalla richiesta POST
|
||||||
|
$iduser = isset($_POST['iduser']) ? $_POST['iduser'] : 0;
|
||||||
|
$page = isset($_POST['page']) ? $_POST['page'] : '';
|
||||||
|
$column_visibility = isset($_POST['column_visibility']) ? $_POST['column_visibility'] : '';
|
||||||
|
$column_order = isset($_POST['column_order']) ? $_POST['column_order'] : '';
|
||||||
|
|
||||||
|
if ($iduser && $page && $column_visibility && $column_order) {
|
||||||
|
// Verifica se esistono già impostazioni per l'utente e la pagina
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM user_table_settings WHERE iduser = ? AND page_name = ?");
|
||||||
|
$stmt->bind_param("is", $iduser, $page);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
// Aggiorna le impostazioni esistenti
|
||||||
|
$stmt = $conn->prepare("UPDATE user_table_settings SET column_visibility = ?, column_order = ? WHERE iduser = ? AND page_name = ?");
|
||||||
|
$stmt->bind_param("ssis", $column_visibility, $column_order, $iduser, $page);
|
||||||
|
} else {
|
||||||
|
// Inserisci nuove impostazioni
|
||||||
|
$stmt = $conn->prepare("INSERT INTO user_table_settings (iduser, page_name, column_visibility, column_order) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt->bind_param("isss", $iduser, $page, $column_visibility, $column_order);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['error' => 'Failed to save settings']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Se non ci sono dati sufficienti, invia un errore
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'Invalid request']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user