perfecto
This commit is contained in:
parent
2ea676adae
commit
cf90143b77
@ -15,9 +15,14 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
$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, IReader::READ_DATA_ONLY);
|
$spreadsheet = IOFactory::load($file);
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
$arr_info = $worksheet->toArray();
|
$arr_info = $worksheet->toArray();
|
||||||
|
|
||||||
|
// remove empty rows
|
||||||
|
$arr_info = array_filter($arr_info, function($row) {
|
||||||
|
return count(array_filter($row)) > 0;
|
||||||
|
});
|
||||||
|
|
||||||
$productsRefNumber_excelName = '';
|
$productsRefNumber_excelName = '';
|
||||||
$reportsNumberLab_excelName = '';
|
$reportsNumberLab_excelName = '';
|
||||||
@ -76,7 +81,7 @@ if(isset($_FILES['f_csv'])) {
|
|||||||
$verify_flag = false;
|
$verify_flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($verify_flag) {
|
if($verify_flag) {
|
||||||
//check result_TestName field
|
//check result_TestName field
|
||||||
|
|||||||
21
public/userarea/importify/get_laboratories.php
Normal file
21
public/userarea/importify/get_laboratories.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php include('../include/headscript.php'); ?>
|
||||||
|
<?php include("../class/company.php");
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
$query = " SELECT `idlab`,
|
||||||
|
`name`,
|
||||||
|
`description`,
|
||||||
|
`reflab`
|
||||||
|
FROM `laboratories`";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
|
||||||
|
$laboratories = [];
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$laboratories[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'code' => "success",
|
||||||
|
'laboratories' => $laboratories));
|
||||||
|
}
|
||||||
@ -37,6 +37,7 @@ function post_async($url, array $params)
|
|||||||
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'];
|
||||||
|
$idLabs = $_POST['lab_id']; // get lab id
|
||||||
|
|
||||||
//get template associate data
|
//get template associate data
|
||||||
$arr_associate_data = new WA_MySQLi_RS("rsl", $repnew, 0);
|
$arr_associate_data = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||||
@ -158,7 +159,8 @@ if (isset($_FILES['f_csv'])) {
|
|||||||
'importcode' => $importcode,
|
'importcode' => $importcode,
|
||||||
'productsRefNumber_excelName' => $productsRefNumber_excelName,
|
'productsRefNumber_excelName' => $productsRefNumber_excelName,
|
||||||
'reportsNumberLab_excelName' => $reportsNumberLab_excelName,
|
'reportsNumberLab_excelName' => $reportsNumberLab_excelName,
|
||||||
'partsCode_excelName' => $partsCode_excelName
|
'partsCode_excelName' => $partsCode_excelName,
|
||||||
|
'idLabs' => $idLabs
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//insert to products table
|
//insert to products table
|
||||||
|
|||||||
@ -14,6 +14,7 @@ $importcode = $_POST['importcode'];
|
|||||||
$productsRefNumber_excelName = $_POST['productsRefNumber_excelName'];
|
$productsRefNumber_excelName = $_POST['productsRefNumber_excelName'];
|
||||||
$reportsNumberLab_excelName = $_POST['reportsNumberLab_excelName'];
|
$reportsNumberLab_excelName = $_POST['reportsNumberLab_excelName'];
|
||||||
$partsCode_excelName = $_POST['partsCode_excelName'];
|
$partsCode_excelName = $_POST['partsCode_excelName'];
|
||||||
|
$idLabs = $_POST['idLabs'];
|
||||||
|
|
||||||
$sample_code_po_column_name = array_search("products_refnumber", $arr_associate);
|
$sample_code_po_column_name = array_search("products_refnumber", $arr_associate);
|
||||||
|
|
||||||
@ -120,6 +121,7 @@ foreach ($arr_total_products as $product) {
|
|||||||
$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");
|
||||||
|
$InsertQuery->bindColumn("idLabs", "i", "" . $idLabs . "", "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,6 +142,8 @@
|
|||||||
<ol class="breadcrumb hide-phone p-0 m-0">
|
<ol class="breadcrumb hide-phone p-0 m-0">
|
||||||
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
|
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
|
||||||
<li class="breadcrumb-item active">Importify</li>
|
<li class="breadcrumb-item active">Importify</li>
|
||||||
|
<!-- hidden input for lab id -->
|
||||||
|
<input type="hidden" id="labor_id" value="">
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="page-title">Importify</h4>
|
<h4 class="page-title">Importify</h4>
|
||||||
@ -263,10 +265,10 @@
|
|||||||
formdata.append("f_csv", $(this).prop('files')[0]);
|
formdata.append("f_csv", $(this).prop('files')[0]);
|
||||||
formdata.append("template_id", tmp_id_template_importify);
|
formdata.append("template_id", tmp_id_template_importify);
|
||||||
|
|
||||||
|
// ask user to choose which lab wants to associate from get_laboratories.php
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'check_vocabulary.php',
|
url: 'get_laboratories.php',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: formdata,
|
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
@ -280,32 +282,77 @@
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
$('#ajax_preloader').fadeOut();
|
$('#ajax_preloader').fadeOut();
|
||||||
if(data.indexOf("success") > -1) {
|
if(data.indexOf("success") > -1) {
|
||||||
let arr_data = JSON.parse(data);
|
let arr_labs = JSON.parse(data);
|
||||||
let arr_analysisvoc = arr_data['arr_analysis_data'];
|
let str_arr_option = '';
|
||||||
console.log(arr_analysisvoc);
|
for(let i=0; i<arr_labs['laboratories'].length; i++) {
|
||||||
let arr_compundsvoc = arr_data['arr_compunds_data'];
|
str_arr_option += '<option value="' + arr_labs['laboratories'][i]['idlab'] + '">' + arr_labs['laboratories'][i]['name'] +' - '+arr_labs['laboratories'][i]['description'] + '</option>';
|
||||||
console.log(arr_compundsvoc);
|
}
|
||||||
|
|
||||||
tmp_analyvoc_idx = 0;
|
Swal.fire({
|
||||||
tmp_compundsvoc_idx = 0;
|
title: 'Which lab wants you to associate?',
|
||||||
arr_total_analysisvoc = arr_analysisvoc;
|
html: `<select class="form-control" id="sel_lab">${str_arr_option}</select>`,
|
||||||
arr_total_compundsvoc = arr_compundsvoc;
|
showCancelButton: true,
|
||||||
tmp_str_arr_compunds_kind_option = '';
|
confirmButtonColor: '#3085d6',
|
||||||
tmp_str_arr_kind_option = '';
|
cancelButtonColor: '#d33',
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
allowOutsideClick: false,
|
||||||
|
}).then((result) => {
|
||||||
|
if(result.isConfirmed) {
|
||||||
|
let lab_id = $('#sel_lab').val();
|
||||||
|
formdata.append("lab_id", lab_id);
|
||||||
|
$("#labor_id").val(lab_id);
|
||||||
|
|
||||||
show_analysis_add_pop();
|
$.ajax({
|
||||||
}else if(data.indexOf("none_define_column_error") > -1) {
|
url: 'check_vocabulary.php',
|
||||||
$('#f_csv').val("");
|
type: 'POST',
|
||||||
showWarningPopup("The Associate Columns did not define yet!");
|
data: formdata,
|
||||||
} else if(data.indexOf("invalid_excel_data_format_error") > -1) {
|
processData: false,
|
||||||
$('#f_csv').val("");
|
contentType: false,
|
||||||
showWarningPopup("Excel data format is not valid!")
|
beforeSend: function() {
|
||||||
|
$('#ajax_preloader').fadeIn();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#f_csv').val("");
|
||||||
|
$('#ajax_preloader').fadeOut();
|
||||||
|
showWarningAlert("Server Error");
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('#ajax_preloader').fadeOut();
|
||||||
|
if(data.indexOf("success") > -1) {
|
||||||
|
let arr_data = JSON.parse(data);
|
||||||
|
let arr_analysisvoc = arr_data['arr_analysis_data'];
|
||||||
|
console.log(arr_analysisvoc);
|
||||||
|
let arr_compundsvoc = arr_data['arr_compunds_data'];
|
||||||
|
console.log(arr_compundsvoc);
|
||||||
|
|
||||||
|
tmp_analyvoc_idx = 0;
|
||||||
|
tmp_compundsvoc_idx = 0;
|
||||||
|
arr_total_analysisvoc = arr_analysisvoc;
|
||||||
|
arr_total_compundsvoc = arr_compundsvoc;
|
||||||
|
tmp_str_arr_compunds_kind_option = '';
|
||||||
|
tmp_str_arr_kind_option = '';
|
||||||
|
|
||||||
|
show_analysis_add_pop();
|
||||||
|
}else if(data.indexOf("none_define_column_error") > -1) {
|
||||||
|
$('#f_csv').val("");
|
||||||
|
showWarningPopup("The Associate Columns did not define yet!");
|
||||||
|
} else if(data.indexOf("invalid_excel_data_format_error") > -1) {
|
||||||
|
$('#f_csv').val("");
|
||||||
|
showWarningPopup("Excel data format is not valid!")
|
||||||
|
} else {
|
||||||
|
$('#f_csv').val("");
|
||||||
|
showWarningAlert("Server Error.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$('#f_csv').val("");
|
$('#f_csv').val("");
|
||||||
showWarningAlert("Server Error.")
|
showWarningAlert("Server Error.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -522,6 +569,7 @@
|
|||||||
if($('#f_csv').prop('files').length > 0) {
|
if($('#f_csv').prop('files').length > 0) {
|
||||||
formdata.append("f_csv", $('#f_csv').prop('files')[0]);
|
formdata.append("f_csv", $('#f_csv').prop('files')[0]);
|
||||||
formdata.append("template_id", tmp_id_template_importify);
|
formdata.append("template_id", tmp_id_template_importify);
|
||||||
|
formdata.append("lab_id", $('#labor_id').val());
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'import_auto_script.php',
|
url: 'import_auto_script.php',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user