fixed some issues
This commit is contained in:
parent
761bc9a441
commit
100397a953
@ -5,7 +5,7 @@ header('Content-Type: application/json');
|
|||||||
$host = $servername;
|
$host = $servername;
|
||||||
$db = $database;
|
$db = $database;
|
||||||
$user = $username;
|
$user = $username;
|
||||||
$pass = $password;
|
$pass = $password;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pdo = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
|
$pdo = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
|
||||||
@ -23,7 +23,8 @@ if (!isset($_POST['method'])) {
|
|||||||
else {
|
else {
|
||||||
$method = $_POST['method'];
|
$method = $_POST['method'];
|
||||||
if($method == 'intervention'){
|
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 = $pdo->prepare($query);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
@ -34,7 +35,7 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$data = json_decode($entry['json_data'], true);
|
$data = json_decode($entry['json_data'], true);
|
||||||
$uuid = $entry['uuid'];
|
$uuid = $entry['uuid'];
|
||||||
$analysisArr = array();
|
$analysisArr = array();
|
||||||
$compoundsArr = array();
|
$compoundsArr = array();
|
||||||
|
|
||||||
// check for result_TestName
|
// check for result_TestName
|
||||||
foreach ($data['product']['reports'] as $report) {
|
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')";
|
$query = "INSERT INTO notifications (`title`,`description`) VALUES ('Intervention Required', 'Intervention required for JSON entry with ID $id')";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,12 @@ function checkForUnAttachedAnalysis($decoded_json_data,$pdo){
|
|||||||
foreach($part['analyses'] as $analysis){
|
foreach($part['analyses'] as $analysis){
|
||||||
$result_TestName = $analysis['result_TestName'];
|
$result_TestName = $analysis['result_TestName'];
|
||||||
$analysisgroupcode = $analysis['analysisgroupcode'];
|
$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);
|
$analysis_id = checkForAnalysisId($analysisgroupcode, $result_TestName, $pdo);
|
||||||
if(!$analysis_id){
|
if(!$analysis_id){
|
||||||
|
|
||||||
@ -99,6 +105,12 @@ function checkForUnAttachedCompounds($decoded_json_data, $pdo){
|
|||||||
foreach($analysis['results'] as $result){
|
foreach($analysis['results'] as $result){
|
||||||
$cas = $result['cas'];
|
$cas = $result['cas'];
|
||||||
$result_AnalytsName = $result['result_AnalytsName'];
|
$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);
|
$compound_id = checkForCompoundId($cas, $result_AnalytsName, $pdo);
|
||||||
if(!$compound_id){
|
if(!$compound_id){
|
||||||
$arr_compoundkind_refdata = ("SELECT * FROM compundsvocabulary where preferred like 'Y'");
|
$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){
|
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'";
|
$sql = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@ -144,6 +162,7 @@ function checkForCompoundId($cas, $result_AnalytsName, $pdo){
|
|||||||
if($cas == '' || $cas == null || $cas == 'N/A' || $cas == '-'){
|
if($cas == '' || $cas == null || $cas == 'N/A' || $cas == '-'){
|
||||||
$cas = 'NO_CAS_PROVIDED';
|
$cas = 'NO_CAS_PROVIDED';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE cascompoundvocabulary LIKE '%$cas%'";
|
$sql = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE cascompoundvocabulary LIKE '%$cas%'";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
@ -171,7 +171,7 @@
|
|||||||
tmp_str_arr_compunds_kind_option = '';
|
tmp_str_arr_compunds_kind_option = '';
|
||||||
tmp_str_arr_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) {
|
} else if (data.indexOf("none_define_column_error") > -1) {
|
||||||
$('#f_csv').val("");
|
$('#f_csv').val("");
|
||||||
showWarningPopup("The Associate Columns did not define yet!");
|
showWarningPopup("The Associate Columns did not define yet!");
|
||||||
@ -186,9 +186,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_import() {
|
function process_import(id) {
|
||||||
formData = new FormData();
|
formData = new FormData();
|
||||||
formData.append('method', 'intervention');
|
formData.append('method', 'intervention');
|
||||||
|
formData.append('id', id);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '../apilogic/process_import.php',
|
url: '../apilogic/process_import.php',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -206,7 +207,15 @@
|
|||||||
$('#ajax_preloader').fadeOut();
|
$('#ajax_preloader').fadeOut();
|
||||||
if (data.code == "success") {
|
if (data.code == "success") {
|
||||||
showSuccessAlert("Successfully imported!");
|
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 {
|
} else {
|
||||||
showWarningAlert("Server Error.")
|
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) {
|
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++;
|
tmp_analyvoc_idx++;
|
||||||
show_analysis_add_pop();
|
show_analysis_add_pop(id);
|
||||||
})
|
})
|
||||||
} else {
|
} 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) {
|
if (tmp_compundsvoc_idx < arr_total_compundsvoc.length) {
|
||||||
show_compunds_add_popup(arr_total_compundsvoc[tmp_compundsvoc_idx], function() {
|
show_compunds_add_popup(arr_total_compundsvoc[tmp_compundsvoc_idx], function() {
|
||||||
tmp_compundsvoc_idx++;
|
tmp_compundsvoc_idx++;
|
||||||
show_compunds_add_pop();
|
show_compunds_add_pop(id);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
process_import(id);
|
||||||
showSuccessAlert("Successfully added!");
|
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 str_word = voc_info['word'];
|
||||||
let arr_similary = voc_info['arr_similary'];
|
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>';
|
tmp_str_arr_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||||
}
|
}
|
||||||
showSuccessAlert("Successfully added!");
|
showSuccessAlert("Successfully added!");
|
||||||
process_import();
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
}else{
|
||||||
|
process_import(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showWarningAlert("Server Error.")
|
showWarningAlert("Server Error.")
|
||||||
@ -408,9 +419,10 @@
|
|||||||
tmp_str_arr_compunds_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
tmp_str_arr_compunds_kind_option += '<option value="' + inserted_info['ref_id'] + '">' + inserted_info['name'] + '</option>';
|
||||||
}
|
}
|
||||||
showSuccessAlert("Successfully added!");
|
showSuccessAlert("Successfully added!");
|
||||||
process_import();
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
}else{
|
||||||
|
process_import(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showWarningAlert("Server Error.")
|
showWarningAlert("Server Error.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user