Merge branch 'Lasha_Kapanadze_process_import_branch' of http://192.168.1.93:8418/solocla/Moncler-Portal
This commit is contained in:
commit
ee1c0c47a3
@ -5,7 +5,7 @@ header('Content-Type: application/json');
|
||||
$host = $servername;
|
||||
$db = $database;
|
||||
$user = $username;
|
||||
$pass = $password;
|
||||
$pass = $password;
|
||||
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
|
||||
@ -23,7 +23,8 @@ if (!isset($_POST['method'])) {
|
||||
else {
|
||||
$method = $_POST['method'];
|
||||
if($method == 'intervention'){
|
||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 2";
|
||||
$id = $_POST['id'];
|
||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 2 AND id = $id";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute();
|
||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
@ -34,7 +35,7 @@ foreach ($jsonEntries as $entry) {
|
||||
$data = json_decode($entry['json_data'], true);
|
||||
$uuid = $entry['uuid'];
|
||||
$analysisArr = array();
|
||||
$compoundsArr = array();
|
||||
$compoundsArr = array();
|
||||
|
||||
// check for result_TestName
|
||||
foreach ($data['product']['reports'] as $report) {
|
||||
@ -419,5 +420,5 @@ function markForIntervention($id, $pdo)
|
||||
$query = "INSERT INTO notifications (`title`,`description`) VALUES ('Intervention Required', 'Intervention required for JSON entry with ID $id')";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -70,6 +70,12 @@ function checkForUnAttachedAnalysis($decoded_json_data,$pdo){
|
||||
foreach($part['analyses'] as $analysis){
|
||||
$result_TestName = $analysis['result_TestName'];
|
||||
$analysisgroupcode = $analysis['analysisgroupcode'];
|
||||
|
||||
// validation for analysisgroupcode
|
||||
if($analysisgroupcode == '' || $analysisgroupcode == null || $analysisgroupcode == 'N/A' || $analysisgroupcode == '-'){
|
||||
$analysisgroupcode = 'NO_ANALYSIS_CODE_PROVIDED';
|
||||
}
|
||||
|
||||
$analysis_id = checkForAnalysisId($analysisgroupcode, $result_TestName, $pdo);
|
||||
if(!$analysis_id){
|
||||
|
||||
@ -99,6 +105,12 @@ function checkForUnAttachedCompounds($decoded_json_data, $pdo){
|
||||
foreach($analysis['results'] as $result){
|
||||
$cas = $result['cas'];
|
||||
$result_AnalytsName = $result['result_AnalytsName'];
|
||||
|
||||
// validation for cas
|
||||
if($cas == '' || $cas == null || $cas == 'N/A' || $cas == '-'){
|
||||
$cas = 'NO_CAS_PROVIDED';
|
||||
}
|
||||
|
||||
$compound_id = checkForCompoundId($cas, $result_AnalytsName, $pdo);
|
||||
if(!$compound_id){
|
||||
$arr_compoundkind_refdata = ("SELECT * FROM compundsvocabulary where preferred like 'Y'");
|
||||
@ -120,6 +132,12 @@ function checkForUnAttachedCompounds($decoded_json_data, $pdo){
|
||||
}
|
||||
|
||||
function checkForAnalysisId($analysisgroupcode, $result_TestName, $pdo){
|
||||
|
||||
// analysisgroupcode check
|
||||
if($analysisgroupcode == '' || $analysisgroupcode == null || $analysisgroupcode == 'N/A' || $analysisgroupcode == '-'){
|
||||
$analysisgroupcode = 'NO_ANALYSIS_CODE_PROVIDED';
|
||||
}
|
||||
|
||||
$sql = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
@ -144,6 +162,7 @@ function checkForCompoundId($cas, $result_AnalytsName, $pdo){
|
||||
if($cas == '' || $cas == null || $cas == 'N/A' || $cas == '-'){
|
||||
$cas = 'NO_CAS_PROVIDED';
|
||||
}
|
||||
|
||||
$sql = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE cascompoundvocabulary LIKE '%$cas%'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
tmp_str_arr_compunds_kind_option = '';
|
||||
tmp_str_arr_kind_option = '';
|
||||
|
||||
show_analysis_add_pop();
|
||||
show_analysis_add_pop(id);
|
||||
} else if (data.indexOf("none_define_column_error") > -1) {
|
||||
$('#f_csv').val("");
|
||||
showWarningPopup("The Associate Columns did not define yet!");
|
||||
@ -186,9 +186,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
function process_import() {
|
||||
function process_import(id) {
|
||||
formData = new FormData();
|
||||
formData.append('method', 'intervention');
|
||||
formData.append('id', id);
|
||||
$.ajax({
|
||||
url: '../apilogic/process_import.php',
|
||||
type: 'POST',
|
||||
@ -206,7 +207,15 @@
|
||||
$('#ajax_preloader').fadeOut();
|
||||
if (data.code == "success") {
|
||||
showSuccessAlert("Successfully imported!");
|
||||
refresh_table();
|
||||
swal.fire({
|
||||
title: 'Successfully imported!',
|
||||
text: 'The record has been imported successfully.',
|
||||
icon: 'success',
|
||||
showCancelButton: false,
|
||||
confirmButtonText: 'OK',
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
}
|
||||
@ -215,29 +224,30 @@
|
||||
})
|
||||
}
|
||||
|
||||
function show_analysis_add_pop() {
|
||||
function show_analysis_add_pop(id) {
|
||||
if (tmp_analyvoc_idx < arr_total_analysisvoc.length) {
|
||||
show_analysis_add_popup(arr_total_analysisvoc[tmp_analyvoc_idx], function() {
|
||||
show_analysis_add_popup(id,arr_total_analysisvoc[tmp_analyvoc_idx], function() {
|
||||
tmp_analyvoc_idx++;
|
||||
show_analysis_add_pop();
|
||||
show_analysis_add_pop(id);
|
||||
})
|
||||
} else {
|
||||
show_compunds_add_pop();
|
||||
show_compunds_add_pop(id);
|
||||
}
|
||||
}
|
||||
|
||||
function show_compunds_add_pop() {
|
||||
function show_compunds_add_pop(id) {
|
||||
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();
|
||||
show_compunds_add_pop(id);
|
||||
})
|
||||
} else {
|
||||
process_import(id);
|
||||
showSuccessAlert("Successfully added!");
|
||||
}
|
||||
}
|
||||
|
||||
function show_analysis_add_popup(voc_info, callback) {
|
||||
function show_analysis_add_popup(id,voc_info, callback) {
|
||||
let str_word = voc_info['word'];
|
||||
let arr_similary = voc_info['arr_similary'];
|
||||
|
||||
@ -315,9 +325,10 @@
|
||||
tmp_str_arr_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
process_import();
|
||||
if (callback) {
|
||||
callback();
|
||||
}else{
|
||||
process_import(id);
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
@ -408,9 +419,10 @@
|
||||
tmp_str_arr_compunds_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||
}
|
||||
showSuccessAlert("Successfully added!");
|
||||
process_import();
|
||||
if (callback) {
|
||||
callback();
|
||||
}else{
|
||||
process_import(id);
|
||||
}
|
||||
} else {
|
||||
showWarningAlert("Server Error.")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user