commit milestone3 source
This commit is contained in:
parent
c566d10928
commit
75bfc55c26
@ -10,6 +10,10 @@ function showWarningAlert(str) {
|
||||
alertify.logPosition("top right").error("<i class='ion-alert-circled'><i> " + str + "");
|
||||
}
|
||||
|
||||
function showSuccessAlert(str) {
|
||||
alertify.logPosition("top right").success("<i class='ion-alert-circled'><i> " + str + "");
|
||||
}
|
||||
|
||||
function showWarningPopup(str, callback = null, confirm_str = "Confirm") {
|
||||
Swal.fire({
|
||||
title: 'Warning!',
|
||||
|
||||
66
public/userarea/importify/add_analysis_voc.php
Normal file
66
public/userarea/importify/add_analysis_voc.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php include('../include/headscript.php'); ?>
|
||||
<?php
|
||||
$type = $_POST['type'];
|
||||
$str_name = $_POST['str_name'];
|
||||
$str_kind = $_POST['str_kind'];
|
||||
|
||||
if($type == 0) {
|
||||
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||
$InsertQuery->Action = "insert";
|
||||
$InsertQuery->Table = "`analysisvocabulary`";
|
||||
$InsertQuery->bindColumn("nameanalysisvoc", "s", "" . $str_name, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("kindanalysisvoc", "s", "" .$str_kind, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("refid", "i", "0", "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("preferred", "s", "Y", "WA_DEFAULT");
|
||||
$InsertQuery->saveInSession("");
|
||||
$InsertQuery->execute();
|
||||
|
||||
$inserted_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||
$inserted_query->setQuery("SELECT * FROM analysisvocabulary WHERE nameanalysisvoc like '$str_name' and preferred like 'Y' and refid=0");
|
||||
$inserted_query->execute();
|
||||
|
||||
$inserted_data = $inserted_query->Results;
|
||||
$ref_id = 0;
|
||||
if(count($inserted_data) > 0) {
|
||||
$ref_id = $inserted_data[0]['idanalysisvocabulary'];
|
||||
}
|
||||
|
||||
if($ref_id > 0) {
|
||||
$UpdateQuery = new WA_MySQLi_Query($repnew);
|
||||
$UpdateQuery->Action = "update";
|
||||
$UpdateQuery->Table = "`analysisvocabulary`";
|
||||
|
||||
$UpdateQuery->bindColumn("refid", "i", "" . $ref_id . "", "WA_DEFAULT");
|
||||
$UpdateQuery->addFilter("idanalysisvocabulary", "=", "i", "" . ($ref_id) . "");
|
||||
$UpdateQuery->execute();
|
||||
|
||||
die(json_encode(array(
|
||||
'code' => "success",
|
||||
'info' => array(
|
||||
'name' => $str_name,
|
||||
'kind' => $str_kind,
|
||||
'ref_id' => $ref_id,
|
||||
)
|
||||
)));
|
||||
} else {
|
||||
die("error");
|
||||
}
|
||||
} else {
|
||||
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||
$InsertQuery->Action = "insert";
|
||||
$InsertQuery->Table = "`analysisvocabulary`";
|
||||
$InsertQuery->bindColumn("nameanalysisvoc", "s", "" . $str_name, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("refid", "i", $type, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("preferred", "s", "N", "WA_DEFAULT");
|
||||
$InsertQuery->saveInSession("");
|
||||
$InsertQuery->execute();
|
||||
|
||||
die(json_encode(array(
|
||||
'code' => "success",
|
||||
'info' => array(
|
||||
'name' => $str_name,
|
||||
'kind' => $str_kind,
|
||||
'ref_id' => $type,
|
||||
)
|
||||
)));
|
||||
}
|
||||
79
public/userarea/importify/add_compunds_voc.php
Normal file
79
public/userarea/importify/add_compunds_voc.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php include('../include/headscript.php'); ?>
|
||||
<?php
|
||||
$type = $_POST['type'];
|
||||
$analysis_name = $_POST['analysis_name'];
|
||||
$str_name = $_POST['str_name'];
|
||||
$str_kind = $_POST['str_kind'];
|
||||
|
||||
$analysis_refid = 0;
|
||||
if($analysis_name != "") {
|
||||
$arr_analysis_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||
$arr_analysis_refdata->setQuery("SELECT * FROM analysisvocabulary where nameanalysisvoc like '$analysis_name'");
|
||||
$arr_analysis_refdata->execute();
|
||||
$arr_analysis_ref = $arr_analysis_refdata->Results;
|
||||
if(count($arr_analysis_ref) == 0) {
|
||||
$analysis_refid = $arr_analysis_ref[0]['refid'];
|
||||
}
|
||||
}
|
||||
|
||||
if($type == 0) {
|
||||
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||
$InsertQuery->Action = "insert";
|
||||
$InsertQuery->Table = "`compundsvocabulary`";
|
||||
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("cascompoundvocabulary", "s", "" .$str_kind, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("analysisrefid", "i", "".$analysis_refid, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("refid", "i", "0", "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("preferred", "s", "Y", "WA_DEFAULT");
|
||||
$InsertQuery->saveInSession("");
|
||||
$InsertQuery->execute();
|
||||
|
||||
$inserted_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||
$inserted_query->setQuery("SELECT * FROM compundsvocabulary WHERE namecompoundsvocabulary like '$str_name' and preferred like 'Y' and refid=0");
|
||||
$inserted_query->execute();
|
||||
|
||||
$inserted_data = $inserted_query->Results;
|
||||
$ref_id = 0;
|
||||
if(count($inserted_data) > 0) {
|
||||
$ref_id = $inserted_data[0]['idcompoundsvocabulary'];
|
||||
}
|
||||
|
||||
if($ref_id > 0) {
|
||||
$UpdateQuery = new WA_MySQLi_Query($repnew);
|
||||
$UpdateQuery->Action = "update";
|
||||
$UpdateQuery->Table = "`compundsvocabulary`";
|
||||
$UpdateQuery->bindColumn("refid", "i", "" . $ref_id . "", "WA_DEFAULT");
|
||||
$UpdateQuery->addFilter("idcompoundsvocabulary", "=", "i", "" . ($ref_id) . "");
|
||||
$UpdateQuery->execute();
|
||||
|
||||
die(json_encode(array(
|
||||
'code' => "success",
|
||||
'info' => array(
|
||||
'name' => $str_name,
|
||||
'kind' => $str_kind,
|
||||
'ref_id' => $ref_id,
|
||||
)
|
||||
)));
|
||||
} else {
|
||||
die("error");
|
||||
}
|
||||
} else {
|
||||
$InsertQuery = new WA_MySQLi_Query($repnew);
|
||||
$InsertQuery->Action = "insert";
|
||||
$InsertQuery->Table = "`compundsvocabulary`";
|
||||
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("analysisrefid", "i", "".$analysis_refid, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("refid", "i", $type, "WA_DEFAULT");
|
||||
$InsertQuery->bindColumn("preferred", "s", "N", "WA_DEFAULT");
|
||||
$InsertQuery->saveInSession("");
|
||||
$InsertQuery->execute();
|
||||
|
||||
die(json_encode(array(
|
||||
'code' => "success",
|
||||
'info' => array(
|
||||
'name' => $str_name,
|
||||
'kind' => $str_kind,
|
||||
'ref_id' => $type,
|
||||
)
|
||||
)));
|
||||
}
|
||||
143
public/userarea/importify/check_vocabulary.php
Normal file
143
public/userarea/importify/check_vocabulary.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?php include('../include/headscript.php'); ?>
|
||||
<?php
|
||||
require '../../vendor/autoload.php';
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
||||
|
||||
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, IReader::READ_DATA_ONLY);
|
||||
$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.");
|
||||
|
||||
$result_testNameHeaderFile = ""; //for analysisvocabulary
|
||||
$result_AnalytsNameHeaderFile = ""; //for compundsvocabulary
|
||||
|
||||
foreach($arr_associate as $item) {
|
||||
array_push($arr_need_columns, $item['headerfile']);
|
||||
|
||||
if($item['column_name'] == 'result_TestName') {
|
||||
$result_testNameHeaderFile = $item['headerfile'];
|
||||
}
|
||||
|
||||
if($item['column_name'] == 'result_AnalytsName') {
|
||||
$result_AnalytsNameHeaderFile = $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) {
|
||||
//check result_TestName field
|
||||
$arr_anaysisvoc_words = array();
|
||||
if($result_testNameHeaderFile != "") {
|
||||
$arr_diff_anaysisvoc_words = array();
|
||||
$idx_resultTestName_po = array_search($result_testNameHeaderFile, $arr_excel_columns);
|
||||
|
||||
for($i=1; $i<count($arr_info); $i++) {
|
||||
if(!in_array($arr_info[$i][$idx_resultTestName_po], $arr_diff_anaysisvoc_words)) {
|
||||
array_push($arr_diff_anaysisvoc_words, $arr_info[$i][$idx_resultTestName_po]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($arr_diff_anaysisvoc_words as $item) {
|
||||
$arr_analysis_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||
$arr_analysis_refdata->setQuery("SELECT * FROM analysisvocabulary where nameanalysisvoc like '$item'");
|
||||
$arr_analysis_refdata->execute();
|
||||
$arr_analysis_ref = $arr_analysis_refdata->Results;
|
||||
if(count($arr_analysis_ref) == 0) {
|
||||
//check kind
|
||||
$arr_analysiskind_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||
$arr_analysiskind_refdata->setQuery("SELECT * FROM analysisvocabulary where preferred like 'Y'");
|
||||
$arr_analysiskind_refdata->execute();
|
||||
$arr_analysiskind_ref = $arr_analysiskind_refdata->Results;
|
||||
array_push($arr_anaysisvoc_words, array(
|
||||
'word' => $item,
|
||||
'arr_similary' => $arr_analysiskind_ref
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check result_AnalytsName field
|
||||
$arr_compundsvoc_words = array();
|
||||
if($result_AnalytsNameHeaderFile != "") {
|
||||
$arr_diff_compundsvoc_words = array();
|
||||
$arr_tmp_diff_compundsvoc_words = array();
|
||||
$idx_resultAnalytsName_po = array_search($result_AnalytsNameHeaderFile, $arr_excel_columns);
|
||||
$idx_resultTestName_po = $result_testNameHeaderFile != "" ? array_search($result_testNameHeaderFile, $arr_excel_columns) : 0;
|
||||
|
||||
for($i=1; $i<count($arr_info); $i++) {
|
||||
if(!in_array($arr_info[$i][$idx_resultAnalytsName_po], $arr_tmp_diff_compundsvoc_words)) {
|
||||
array_push($arr_tmp_diff_compundsvoc_words, $arr_info[$i][$idx_resultAnalytsName_po]);
|
||||
array_push($arr_diff_compundsvoc_words, array(
|
||||
'word' => $arr_info[$i][$idx_resultAnalytsName_po],
|
||||
'analysis_word' => $result_testNameHeaderFile != "" ? $arr_info[$i][$idx_resultTestName_po] : ""
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach($arr_diff_compundsvoc_words as $item) {
|
||||
$arr_compunds_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||
$compund_word = $item['word'];
|
||||
$arr_compunds_refdata->setQuery("SELECT * FROM compundsvocabulary where namecompoundsvocabulary like '$compund_word' or cascompoundvocabulary like '$compund_word'");
|
||||
$arr_compunds_refdata->execute();
|
||||
$arr_compunds_ref = $arr_compunds_refdata->Results;
|
||||
if(count($arr_compunds_ref) == 0) {
|
||||
//check kind
|
||||
$arr_compundskind_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
|
||||
$arr_compundskind_refdata->setQuery("SELECT * FROM compundsvocabulary where preferred like 'Y'");
|
||||
$arr_compundskind_refdata->execute();
|
||||
$arr_compundskind_ref = $arr_compundskind_refdata->Results;
|
||||
array_push($arr_compundsvoc_words, array(
|
||||
'word' => $compund_word,
|
||||
'anaysis_word' => $item['analysis_word'],
|
||||
'arr_similary' => $arr_compundskind_ref
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'code' => "success",
|
||||
'arr_analysis_data' => $arr_anaysisvoc_words,
|
||||
'arr_compunds_data' => $arr_compundsvoc_words,
|
||||
)));
|
||||
} 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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -216,7 +216,36 @@ foreach($arr_total_products as $product) {
|
||||
$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)));
|
||||
if($arr_associate[$i]->column_name == "result_TestName") {
|
||||
$tmp_val = $result_project[array_search($arr_associate[$i]->headerfile, $arr_excel_columns)];
|
||||
$analysis_query = new WA_MySQLi_RS("getquery", $repnew, 0);
|
||||
$analysis_query->setQuery("SELECT * FROM analysisvocabulary WHERE nameanalysisvoc like '$tmp_val'");
|
||||
$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)];
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -238,7 +267,11 @@ foreach($arr_total_products as $product) {
|
||||
$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");
|
||||
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();
|
||||
|
||||
@ -23,6 +23,23 @@
|
||||
|
||||
<script src="../assets/js/jquery.min.js"></script>
|
||||
<style>
|
||||
.width-100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flex_center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mg_none {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.table-custom tr {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
@ -73,6 +90,10 @@
|
||||
padding: 2px 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.padding_none {
|
||||
padding: 0 !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -232,9 +253,10 @@
|
||||
});
|
||||
|
||||
let tmp_id_template_importify = 0;
|
||||
|
||||
function onRunImport(id_template_importify) {
|
||||
tmp_id_template_importify = id_template_importify;
|
||||
$('#f_csv').trigger("click");
|
||||
$('#f_csv').trigger("click");
|
||||
}
|
||||
|
||||
$('#f_csv').change(function(){
|
||||
@ -243,6 +265,262 @@
|
||||
formdata.append("f_csv", $(this).prop('files')[0]);
|
||||
formdata.append("template_id", tmp_id_template_importify);
|
||||
|
||||
$.ajax({
|
||||
url: 'check_vocabulary.php',
|
||||
type: 'POST',
|
||||
data: formdata,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
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.")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
let arr_total_analysisvoc = Array();
|
||||
let tmp_analyvoc_idx = 0;
|
||||
let arr_total_compundsvoc = Array();
|
||||
let tmp_compundsvoc_idx = 0;
|
||||
function show_analysis_add_pop() {
|
||||
if(tmp_analyvoc_idx < arr_total_analysisvoc.length) {
|
||||
show_analysis_add_popup(arr_total_analysisvoc[tmp_analyvoc_idx], function() {
|
||||
tmp_analyvoc_idx++;
|
||||
show_analysis_add_pop();
|
||||
})
|
||||
} else {
|
||||
show_compunds_add_pop();
|
||||
}
|
||||
}
|
||||
|
||||
function show_compunds_add_pop() {
|
||||
if(tmp_compundsvoc_idx < arr_total_compundsvoc.length) {
|
||||
show_compunds_add_popup(arr_total_compundsvoc[tmp_compundsvoc_idx], function() {
|
||||
tmp_compundsvoc_idx++;
|
||||
show_compunds_add_pop();
|
||||
})
|
||||
} else {
|
||||
import_auto_script();
|
||||
}
|
||||
}
|
||||
|
||||
let tmp_str_arr_kind_option = '';
|
||||
function show_analysis_add_popup(voc_info, callback) {
|
||||
let str_word = voc_info['word'];
|
||||
let arr_similary = voc_info['arr_similary'];
|
||||
|
||||
let str_arr_option = '';
|
||||
for(let i=0; i<arr_similary.length; i++) {
|
||||
str_arr_option += '<option value="' + arr_similary[i]['refid'] + '">' + arr_similary[i]['nameanalysisvoc'] + '</option>';
|
||||
}
|
||||
str_arr_option += tmp_str_arr_kind_option;
|
||||
|
||||
let swal_html = `<div class="row">
|
||||
<div class="col-md-12">
|
||||
<select class="form-control ipt_type">`;
|
||||
swal_html += str_arr_option;
|
||||
|
||||
swal_html += `<option value="0">Add new</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Name</label>
|
||||
<input class="form-control ipt_name ipt_val" ` + (str_arr_option != "" ? "" : "readonly") + ` placeholder="Please input name." value="` + str_word + `">
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Kind</label>
|
||||
<input class="form-control ipt_kind ipt_val" placeholder="Please input kind.">
|
||||
</div>
|
||||
</div>`;
|
||||
Swal.fire({
|
||||
html: swal_html,
|
||||
title: 'Which analysis wants you to associate?<br><span>"' + str_word + '"</span>',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Confirm',
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
$('.swal2-popup .ipt_type').bind("click", function() {
|
||||
if($(this).val() == 0) {
|
||||
$('.div_input').removeClass("hidden");
|
||||
$('.ipt_val').val("");
|
||||
$('.swal2-popup .ipt_name').val(str_word);
|
||||
$('.swal2-popup .ipt_name').attr("readonly", "readonly");
|
||||
} else {
|
||||
$('.div_input').addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
$('.swal2-popup .ipt_type').trigger("change");
|
||||
},
|
||||
}).then((result) => {
|
||||
let type = $('.swal2-popup .ipt_type').val();
|
||||
let str_name = $('.swal2-popup .ipt_name').val();
|
||||
let str_kind = $('.swal2-popup .ipt_kind').val();
|
||||
|
||||
$.ajax({
|
||||
url: 'add_analysis_voc.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
type: type,
|
||||
str_name: str_name,
|
||||
str_kind: str_kind,
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#ajax_preloader').fadeIn();
|
||||
},
|
||||
error: function() {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
showSuccessAlert("Successfully added!");
|
||||
},
|
||||
success: function(data) {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if(data.indexOf("success") > -1) {
|
||||
if(type == 0) {
|
||||
let inserted_info = JSON.parse(data)['info'];
|
||||
tmp_str_arr_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
let tmp_str_arr_compunds_kind_option = '';
|
||||
function show_compunds_add_popup(voc_info, callback) {
|
||||
let str_word = voc_info['word'];
|
||||
let str_analysis_word = voc_info['anaysis_word'];
|
||||
let arr_similary = voc_info['arr_similary'];
|
||||
|
||||
let str_arr_option = '';
|
||||
for(let i=0; i<arr_similary.length; i++) {
|
||||
str_arr_option += '<option value="' + arr_similary[i]['refid'] + '">' + arr_similary[i]['namecompoundsvocabulary'] + '</option>';
|
||||
}
|
||||
str_arr_option += tmp_str_arr_compunds_kind_option;
|
||||
|
||||
let swal_html = `<div class="row">
|
||||
<div class="col-md-12">
|
||||
<select class="form-control ipt_type">`;
|
||||
swal_html += str_arr_option;
|
||||
|
||||
swal_html += `<option value="0">Add new</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Name</label>
|
||||
<input class="form-control ipt_name ipt_val" ` + (str_arr_option != "" ? "" : "readonly") + ` placeholder="Please input component name." value="` + str_word + `">
|
||||
</div>
|
||||
<div class="col-md-12 flex_center div_input ` + (str_arr_option != "" ? "hidden" : "") + `" style="margin-top: 5px">
|
||||
<label class="mg_none" style="min-width: 70px">Cascompound</label>
|
||||
<input class="form-control ipt_kind ipt_val" placeholder="Please input cascompound.">
|
||||
</div>
|
||||
</div>`;
|
||||
Swal.fire({
|
||||
html: swal_html,
|
||||
title: 'Which component wants you to associate?<br><span>"' + str_word + '"</span>',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Confirm',
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
$('.swal2-popup .ipt_type').bind("click", function() {
|
||||
if($(this).val() == 0) {
|
||||
$('.div_input').removeClass("hidden");
|
||||
$('.ipt_val').val("");
|
||||
$('.swal2-popup .ipt_name').val(str_word);
|
||||
$('.swal2-popup .ipt_name').attr("readonly", "readonly");
|
||||
} else {
|
||||
$('.div_input').addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
$('.swal2-popup .ipt_type').trigger("change");
|
||||
},
|
||||
}).then((result) => {
|
||||
let type = $('.swal2-popup .ipt_type').val();
|
||||
let str_name = $('.swal2-popup .ipt_name').val();
|
||||
let str_kind = $('.swal2-popup .ipt_kind').val();
|
||||
|
||||
$.ajax({
|
||||
url: 'add_compunds_voc.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
type: type,
|
||||
analysis_name: str_analysis_word,
|
||||
str_name: str_name,
|
||||
str_kind: str_kind,
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#ajax_preloader').fadeIn();
|
||||
},
|
||||
error: function() {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
showSuccessAlert("Successfully added!");
|
||||
},
|
||||
success: function(data) {
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if(data.indexOf("success") > -1) {
|
||||
if(type == 0) {
|
||||
let inserted_info = JSON.parse(data)['info'];
|
||||
tmp_str_arr_compunds_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function import_auto_script() {
|
||||
let formdata = new FormData();
|
||||
if($('#f_csv').prop('files').length > 0) {
|
||||
formdata.append("f_csv", $('#f_csv').prop('files')[0]);
|
||||
formdata.append("template_id", tmp_id_template_importify);
|
||||
|
||||
$.ajax({
|
||||
url: 'import_auto_script.php',
|
||||
type: 'POST',
|
||||
@ -272,7 +550,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user