added db dump in dbbackup on root

This commit is contained in:
2024-09-21 11:06:38 +02:00
parent 225d1f3531
commit 7a9608fe7f
2 changed files with 60482 additions and 45 deletions
File diff suppressed because it is too large Load Diff
@@ -16,7 +16,7 @@ $idx_sample_code_po = array_search("Sample Code (PO#)", $arr_excel_columns);
//insert to products table //insert to products table
$idx = 0; $idx = 0;
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);
@@ -26,13 +26,12 @@ foreach($arr_total_products as $product) {
$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)));
} }
} }
@@ -41,8 +40,8 @@ foreach($arr_total_products as $product) {
$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("");
@@ -54,13 +53,13 @@ foreach($arr_total_products as $product) {
$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'];
} }
} }
$idx++; $idx++;
if($idproducts == "") { if ($idproducts == "") {
die("server_error"); die("server_error");
} }
@@ -71,12 +70,12 @@ foreach($arr_total_products as $product) {
$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);
} }
} }
@@ -85,12 +84,12 @@ foreach($arr_total_products as $product) {
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);
@@ -113,8 +112,8 @@ foreach($arr_total_products as $product) {
$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");
@@ -142,12 +141,12 @@ foreach($arr_total_products as $product) {
$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);
} }
} }
@@ -156,12 +155,12 @@ foreach($arr_total_products as $product) {
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);
@@ -208,15 +207,15 @@ foreach($arr_total_products as $product) {
} }
//----------- 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") {
if($arr_associate[$i]->column_name == "result_TestName") { if ($arr_associate[$i]->column_name == "result_TestName") {
$tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)]; $tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)];
$trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val)); $trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val));
$analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0); $analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0);
@@ -225,12 +224,12 @@ foreach($arr_total_products as $product) {
$analysis_data = $analysis_query->Results; $analysis_data = $analysis_query->Results;
$ref_id = 0; $ref_id = 0;
if(count($analysis_data) > 0) { if (count($analysis_data) > 0) {
$ref_id = $analysis_data[0]['idanalysisvocabulary']; $ref_id = $analysis_data[0]['idanalysisvocabulary'];
} }
array_push($arr_result_project_need_idx, array($arr_associate[$i]->column_name, $ref_id, 1)); 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") { } else if ($arr_associate[$i]->column_name == "result_AnalytsName") {
$tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)]; $tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)];
$trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val)); $trim_item = str_replace("\n", "", str_replace("'", "\'", $tmp_val));
$analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0); $analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0);
@@ -239,7 +238,7 @@ foreach($arr_total_products as $product) {
$analysis_data = $analysis_query->Results; $analysis_data = $analysis_query->Results;
$ref_id = 0; $ref_id = 0;
if(count($analysis_data) > 0) { if (count($analysis_data) > 0) {
$ref_id = $analysis_data[0]['idcompoundsvocabulary']; $ref_id = $analysis_data[0]['idcompoundsvocabulary'];
} }
@@ -249,17 +248,17 @@ foreach($arr_total_products as $product) {
} }
} }
} }
// //
// 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`";
@@ -268,7 +267,7 @@ foreach($arr_total_products as $product) {
$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++) {
if($arr_result_project_need_idx[$i][2] > 0) { 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"); $InsertQuery->bindColumn($arr_result_project_need_idx[$i][0], "s", $arr_result_project_need_idx[$i][1], "WA_DEFAULT");
} else { } else {
$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");
@@ -276,7 +275,7 @@ foreach($arr_total_products as $product) {
} }
$InsertQuery->saveInSession(""); $InsertQuery->saveInSession("");
$InsertQuery->execute(); $InsertQuery->execute();
// } // }
} }
} }
} }
@@ -286,5 +285,5 @@ $UpdateQuery = new WA_MySQLi_Query($repnew);
$UpdateQuery->Action = "update"; $UpdateQuery->Action = "update";
$UpdateQuery->Table = "`template_import_his`"; $UpdateQuery->Table = "`template_import_his`";
$UpdateQuery->bindColumn("f_status", "i", "1", "WA_DEFAULT"); $UpdateQuery->bindColumn("f_status", "i", "1", "WA_DEFAULT");
$UpdateQuery->addFilter("importcode", "=", "s", "".$importcode . ""); $UpdateQuery->addFilter("importcode", "=", "s", "" . $importcode . "");
$UpdateQuery->execute(); $UpdateQuery->execute();