Merge branch 'Lasha_Kapanadze_process_import_branch' of http://192.168.1.93:8418/solocla/Moncler-Portal
This commit is contained in:
commit
9fba28d6d5
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include('../../Connections/repnew.php');
|
include('../../Connections/repnew.php');
|
||||||
|
header('Content-Type: application/json');
|
||||||
// Database connection
|
// Database connection
|
||||||
$host = $servername;
|
$host = $servername;
|
||||||
$db = $database;
|
$db = $database;
|
||||||
@ -13,17 +14,24 @@ try {
|
|||||||
die("Connection failed: " . $e->getMessage());
|
die("Connection failed: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch unprocessed JSON files
|
$method = $_POST['method'];
|
||||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 0";
|
if ($method == 'intervention') {
|
||||||
$stmt = $pdo->prepare($query);
|
$query = "SELECT * FROM temp_json_queue WHERE processed = 2";
|
||||||
$stmt->execute();
|
$stmt = $pdo->prepare($query);
|
||||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$stmt->execute();
|
||||||
|
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} else {
|
||||||
|
$query = "SELECT * FROM temp_json_queue WHERE processed = 0";
|
||||||
|
$stmt = $pdo->prepare($query);
|
||||||
|
$stmt->execute();
|
||||||
|
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($jsonEntries as $entry) {
|
foreach ($jsonEntries as $entry) {
|
||||||
$data = json_decode($entry['json_data'], true);
|
$data = json_decode($entry['json_data'], true);
|
||||||
$uuid = $entry['uuid'];
|
$uuid = $entry['uuid'];
|
||||||
$analysis = array();
|
$analysisArr = array();
|
||||||
$compounds = array();
|
$compoundsArr = array();
|
||||||
|
|
||||||
// check for result_TestName
|
// check for result_TestName
|
||||||
foreach ($data['product']['reports'] as $report) {
|
foreach ($data['product']['reports'] as $report) {
|
||||||
@ -32,7 +40,7 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$analysisgroupcode = $analysis['analysisgroupcode'];
|
$analysisgroupcode = $analysis['analysisgroupcode'];
|
||||||
$result_TestName = $analysis['result_TestName'];
|
$result_TestName = $analysis['result_TestName'];
|
||||||
// groupcode validation
|
// groupcode validation
|
||||||
if($analysisgroupcode == '-' || $analysisgroupcode == '' || $analysisgroupcode == ' '){
|
if ($analysisgroupcode == '-' || $analysisgroupcode == '' || $analysisgroupcode == ' ') {
|
||||||
$analysisgroupcode = 'NO_GROUPCODE';
|
$analysisgroupcode = 'NO_GROUPCODE';
|
||||||
}
|
}
|
||||||
// check in vocabulary
|
// check in vocabulary
|
||||||
@ -40,26 +48,26 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
$result = $stmt->fetchColumn();
|
$result = $stmt->fetchColumn();
|
||||||
if(!$result){
|
if (!$result) {
|
||||||
// check for result_TestName
|
// check for result_TestName
|
||||||
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE nameanalysisvoc LIKE '$result_TestName'";
|
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE nameanalysisvoc LIKE '$result_TestName'";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
$result = $stmt->fetchColumn();
|
$result = $stmt->fetchColumn();
|
||||||
if(!$result){
|
if (!$result) {
|
||||||
// add 0 to analysis array
|
// add 0 to analysis array
|
||||||
array_push($analysis, 0);
|
array_push($analysisArr, 0);
|
||||||
}else{
|
} else {
|
||||||
// add 1 to analysis array
|
// add 1 to analysis array
|
||||||
array_push($analysis, 1);
|
array_push($analysisArr, 1);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
// add 1 to analysis array
|
// add 1 to analysis array
|
||||||
array_push($analysis, 1);
|
array_push($analysisArr, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for result_AnalytsName
|
// check for result_AnalytsName
|
||||||
foreach ($data['product']['reports'] as $report) {
|
foreach ($data['product']['reports'] as $report) {
|
||||||
@ -70,7 +78,7 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$cas = $result['cas'];
|
$cas = $result['cas'];
|
||||||
|
|
||||||
// cas validation
|
// cas validation
|
||||||
if($cas == '-' || $cas == '' || $cas == ' '){
|
if ($cas == '-' || $cas == '' || $cas == ' ') {
|
||||||
$cas = 'NO_CAS';
|
$cas = 'NO_CAS';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,40 +87,39 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
$result = $stmt->fetchColumn();
|
$result = $stmt->fetchColumn();
|
||||||
if(!$result){
|
if (!$result) {
|
||||||
// check for result_AnalytsName
|
// check for result_AnalytsName
|
||||||
$query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE namecompoundsvocabulary LIKE '$result_AnalytsName'";
|
$query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE namecompoundsvocabulary LIKE '$result_AnalytsName'";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
$result = $stmt->fetchColumn();
|
$result = $stmt->fetchColumn();
|
||||||
if(!$result){
|
if (!$result) {
|
||||||
// add 0 to compounds array
|
// add 0 to compounds array
|
||||||
array_push($compounds, 0);
|
array_push($compoundsArr, 0);
|
||||||
}else{
|
} else {
|
||||||
// add 1 to compounds array
|
// add 1 to compounds array
|
||||||
array_push($compounds, 1);
|
array_push($compoundsArr, 1);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
// add 1 to compounds array
|
// add 1 to compounds array
|
||||||
array_push($compounds, 1);
|
array_push($compoundsArr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate lab reference
|
// Validate lab reference
|
||||||
$labId = getLaboratoryId($data['reflab'], $pdo);
|
$labId = getLaboratoryId($data['reflab'], $pdo);
|
||||||
if (!$labId) {
|
if (!$labId) {
|
||||||
markForIntervention($entry['id'], $pdo);
|
markForIntervention($entry['id'], $pdo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(validateJson($data) && !in_array(0, $analysis) && !in_array(0, $compounds)){
|
if (validateJson($data) && !in_array(0, $analysisArr) && !in_array(0, $compoundsArr)) {
|
||||||
// Validate and insert product
|
// Validate and insert product
|
||||||
$productId = insertProduct($data['product'], $pdo, $uuid);
|
$productId = insertProduct($data['product'], $pdo, $uuid);
|
||||||
|
|
||||||
if ($productId) {
|
if ($productId) {
|
||||||
// Insert reports, parts, analyses, and results
|
// Insert reports, parts, analyses, and results
|
||||||
foreach ($data['product']['reports'] as $report) {
|
foreach ($data['product']['reports'] as $report) {
|
||||||
@ -123,22 +130,22 @@ foreach ($jsonEntries as $entry) {
|
|||||||
|
|
||||||
foreach ($part['analyses'] as $analysis) {
|
foreach ($part['analyses'] as $analysis) {
|
||||||
$result_TestName = $analysis['result_TestName'];
|
$result_TestName = $analysis['result_TestName'];
|
||||||
$groupcode = $analysis['analysisgroupcode'];
|
$analysisgroupcode = $analysis['analysisgroupcode'];
|
||||||
|
|
||||||
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$groupcode'";
|
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$res = $stmt->execute();
|
$res = $stmt->execute();
|
||||||
$res = $stmt->fetchColumn();
|
$res = $stmt->fetchColumn();
|
||||||
if($res){
|
if ($res) {
|
||||||
$analysisCodeId = $res;
|
$analysisCodeId = $res;
|
||||||
}else{
|
} else {
|
||||||
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE nameanalysisvoc LIKE '$result_TestName'";
|
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE nameanalysisvoc LIKE '$result_TestName'";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$res = $stmt->execute();
|
$res = $stmt->execute();
|
||||||
$res = $stmt->fetchColumn();
|
$res = $stmt->fetchColumn();
|
||||||
if($res){
|
if ($res) {
|
||||||
$analysisCodeId = $res;
|
$analysisCodeId = $res;
|
||||||
}else{
|
} else {
|
||||||
$analysisCodeId = 'NO ANALYSIS ID FOUND';
|
$analysisCodeId = 'NO ANALYSIS ID FOUND';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,16 +160,16 @@ foreach ($jsonEntries as $entry) {
|
|||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$res = $stmt->execute();
|
$res = $stmt->execute();
|
||||||
$res = $stmt->fetchColumn();
|
$res = $stmt->fetchColumn();
|
||||||
if($res){
|
if ($res) {
|
||||||
$compoundId = $res;
|
$compoundId = $res;
|
||||||
}else{
|
} else {
|
||||||
$query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE namecompoundsvocabulary LIKE '$result_AnalytsName'";
|
$query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE namecompoundsvocabulary LIKE '$result_AnalytsName'";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$res = $stmt->execute();
|
$res = $stmt->execute();
|
||||||
$res = $stmt->fetchColumn();
|
$res = $stmt->fetchColumn();
|
||||||
if($res){
|
if ($res) {
|
||||||
$compoundId = $res;
|
$compoundId = $res;
|
||||||
}else{
|
} else {
|
||||||
$compoundId = 'NO COMPOUND ID FOUND';
|
$compoundId = 'NO COMPOUND ID FOUND';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,28 +186,47 @@ foreach ($jsonEntries as $entry) {
|
|||||||
} else {
|
} else {
|
||||||
markForIntervention($entry['id'], $pdo);
|
markForIntervention($entry['id'], $pdo);
|
||||||
}
|
}
|
||||||
|
importHistory($pdo, $uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
die(json_encode(['code' => 'success']));
|
||||||
|
|
||||||
// Function definitions
|
// Function definitions
|
||||||
|
|
||||||
function validateJson($json){
|
function importHistory($pdo, $uuid)
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO template_import_his (created_at, importcode, f_status, user_id, importfilename) VALUES (:created_at, :importcode, :f_status, :user_id, :importfilename)";
|
||||||
|
$stmt = $pdo->prepare($query);
|
||||||
|
$stmt->execute([
|
||||||
|
'created_at' => date("Y-m-d H:i:s"),
|
||||||
|
'importcode' => $uuid,
|
||||||
|
'f_status' => 1,
|
||||||
|
'user_id' => 2,
|
||||||
|
'importfilename' => 'JSON API'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateJson($json)
|
||||||
|
{
|
||||||
$checkData = json_encode($json);
|
$checkData = json_encode($json);
|
||||||
if(json_decode($checkData) !== null){
|
if (json_decode($checkData) !== null) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLaboratoryId($reflab, $pdo) {
|
function getLaboratoryId($reflab, $pdo)
|
||||||
|
{
|
||||||
$query = "SELECT idlab FROM laboratories WHERE reflab = :reflab";
|
$query = "SELECT idlab FROM laboratories WHERE reflab = :reflab";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute(['reflab' => $reflab]);
|
$stmt->execute(['reflab' => $reflab]);
|
||||||
return $stmt->fetchColumn();
|
return $stmt->fetchColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertProduct($product, $pdo, $uuid) {
|
function insertProduct($product, $pdo, $uuid)
|
||||||
|
{
|
||||||
$query = "SELECT idproducts FROM products WHERE products_refnumber = :refnumber";
|
$query = "SELECT idproducts FROM products WHERE products_refnumber = :refnumber";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute(['refnumber' => $product['products_refnumber']]);
|
$stmt->execute(['refnumber' => $product['products_refnumber']]);
|
||||||
@ -239,7 +265,8 @@ function insertProduct($product, $pdo, $uuid) {
|
|||||||
return $productId; // Return existing product ID
|
return $productId; // Return existing product ID
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertReport($report, $productId, $labId, $pdo, $uuid) {
|
function insertReport($report, $productId, $labId, $pdo, $uuid)
|
||||||
|
{
|
||||||
// Check if the report already exists
|
// Check if the report already exists
|
||||||
$query = "SELECT idreports FROM reports WHERE reportsNumberLab = :reportsNumberLab AND idLabs = :idlaboratories";
|
$query = "SELECT idreports FROM reports WHERE reportsNumberLab = :reportsNumberLab AND idLabs = :idlaboratories";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
@ -256,7 +283,7 @@ function insertReport($report, $productId, $labId, $pdo, $uuid) {
|
|||||||
// Insert new report
|
// Insert new report
|
||||||
$query = "INSERT INTO reports (reportsNumberLab, reportDateIn, reportsDateOut, reportsDateDue, reportsRating, reportsRating2, pdffilename, reports_LabName, reports_testype, reports_invoicenumber, reports_invoiceamount, reports_invoiceadate, idproducts, idLabs, importcode)
|
$query = "INSERT INTO reports (reportsNumberLab, reportDateIn, reportsDateOut, reportsDateDue, reportsRating, reportsRating2, pdffilename, reports_LabName, reports_testype, reports_invoicenumber, reports_invoiceamount, reports_invoiceadate, idproducts, idLabs, importcode)
|
||||||
VALUES (:reportsNumberLab, :reportDateIn, :reportsDateOut, :reportsDateDue, :reportsRating, :reportsRating2, :pdffilename, :reports_LabName, :reports_testype, :reports_invoicenumber, :reports_invoiceamount, :reports_invoiceadate, :idproducts, :idlaboratories, :importcode)";
|
VALUES (:reportsNumberLab, :reportDateIn, :reportsDateOut, :reportsDateDue, :reportsRating, :reportsRating2, :pdffilename, :reports_LabName, :reports_testype, :reports_invoicenumber, :reports_invoiceamount, :reports_invoiceadate, :idproducts, :idlaboratories, :importcode)";
|
||||||
|
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'reportsNumberLab' => $report['reportsNumberLab'],
|
'reportsNumberLab' => $report['reportsNumberLab'],
|
||||||
@ -279,7 +306,8 @@ function insertReport($report, $productId, $labId, $pdo, $uuid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertPart($part, $reportId,$productId, $pdo, $uuid) {
|
function insertPart($part, $reportId, $productId, $pdo, $uuid)
|
||||||
|
{
|
||||||
// Check if the part already exists
|
// Check if the part already exists
|
||||||
$query = "SELECT idparts FROM parts WHERE partsCode = :partsCode AND idreports = :idreports";
|
$query = "SELECT idparts FROM parts WHERE partsCode = :partsCode AND idreports = :idreports";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
@ -292,11 +320,11 @@ function insertPart($part, $reportId,$productId, $pdo, $uuid) {
|
|||||||
if ($partId) {
|
if ($partId) {
|
||||||
// Part already exists, return the existing ID
|
// Part already exists, return the existing ID
|
||||||
return $partId;
|
return $partId;
|
||||||
} else {
|
} else {
|
||||||
// Insert new part
|
// Insert new part
|
||||||
$query = "INSERT INTO parts (partsCode, partsDescription, partsColor, partsMaterial, idreports, idproducts, importcode)
|
$query = "INSERT INTO parts (partsCode, partsDescription, partsColor, partsMaterial, idreports, idproducts, importcode)
|
||||||
VALUES (:partsCode, :partsDescription, :partsColor, :partsMaterial, :idreports, :idproducts, :importcode)";
|
VALUES (:partsCode, :partsDescription, :partsColor, :partsMaterial, :idreports, :idproducts, :importcode)";
|
||||||
|
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'idproducts' => $productId,
|
'idproducts' => $productId,
|
||||||
@ -312,10 +340,11 @@ function insertPart($part, $reportId,$productId, $pdo, $uuid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function insertAnalysis($analysis, $partId, $productId, $reportId, $pdo, $uuid, $analysisCodeId) {
|
function insertAnalysis($analysis, $partId, $productId, $reportId, $pdo, $uuid, $analysisCodeId)
|
||||||
|
{
|
||||||
$query = "INSERT INTO analysis_project (result_TestName, test_Rating, test_Rating2, requirements, reference, analysisgroupcode, idpart, idproducts, idreports, importcode)
|
$query = "INSERT INTO analysis_project (result_TestName, test_Rating, test_Rating2, requirements, reference, analysisgroupcode, idpart, idproducts, idreports, importcode)
|
||||||
VALUES (:result_TestName, :test_Rating, :test_Rating2, :requirements, :reference, :analysisgroupcode, :idpart , :idproducts, :idreports, :importcode)";
|
VALUES (:result_TestName, :test_Rating, :test_Rating2, :requirements, :reference, :analysisgroupcode, :idpart , :idproducts, :idreports, :importcode)";
|
||||||
|
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'idproducts' => $productId,
|
'idproducts' => $productId,
|
||||||
@ -332,10 +361,11 @@ function insertAnalysis($analysis, $partId, $productId, $reportId, $pdo, $uuid,
|
|||||||
return $pdo->lastInsertId();
|
return $pdo->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertResult($result, $analysisId, $partId, $productId, $reportId, $pdo, $uuid, $compoundId) {
|
function insertResult($result, $analysisId, $partId, $productId, $reportId, $pdo, $uuid, $compoundId)
|
||||||
|
{
|
||||||
$query = "INSERT INTO result_project (result_AnalytsName, result_AnalytsRating, result_Value, result_Comment, test_Rating, test_Rating2, result_UnitofMeasure, cas, requirements, reference, idanalysis_project, idpart, idproducts, idreports, importcode)
|
$query = "INSERT INTO result_project (result_AnalytsName, result_AnalytsRating, result_Value, result_Comment, test_Rating, test_Rating2, result_UnitofMeasure, cas, requirements, reference, idanalysis_project, idpart, idproducts, idreports, importcode)
|
||||||
VALUES (:result_AnalytsName, :result_AnalytsRating, :result_Value, :result_Comment, :test_Rating, :test_Rating2, :result_UnitofMeasure, :cas, :requirements, :reference, :idanalysis_project, :idpart, :idproducts, :idreports, :importcode)";
|
VALUES (:result_AnalytsName, :result_AnalytsRating, :result_Value, :result_Comment, :test_Rating, :test_Rating2, :result_UnitofMeasure, :cas, :requirements, :reference, :idanalysis_project, :idpart, :idproducts, :idreports, :importcode)";
|
||||||
|
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'result_AnalytsName' => $compoundId,
|
'result_AnalytsName' => $compoundId,
|
||||||
@ -356,15 +386,16 @@ function insertResult($result, $analysisId, $partId, $productId, $reportId, $pdo
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function markAsProcessed($id, $pdo) {
|
function markAsProcessed($id, $pdo)
|
||||||
|
{
|
||||||
$query = "UPDATE temp_json_queue SET processed = 1 WHERE id = :id";
|
$query = "UPDATE temp_json_queue SET processed = 1 WHERE id = :id";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute(['id' => $id]);
|
$stmt->execute(['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function markForIntervention($id, $pdo) {
|
function markForIntervention($id, $pdo)
|
||||||
|
{
|
||||||
$query = "UPDATE temp_json_queue SET processed = 2 WHERE id = :id";
|
$query = "UPDATE temp_json_queue SET processed = 2 WHERE id = :id";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute(['id' => $id]);
|
$stmt->execute(['id' => $id]);
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
166
public/userarea/importify/importjson.php
Normal file
166
public/userarea/importify/importjson.php
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
include('../../Connections/repnew.php');
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
// Database connection
|
||||||
|
$host = $servername;
|
||||||
|
$db = $database;
|
||||||
|
$user = $username;
|
||||||
|
$pass = $password;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = new PDO("mysql:host=$host;dbname=$db", $user, $pass);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp_json_queue_id = $_POST['id'];
|
||||||
|
|
||||||
|
// Get the JSON data from the temp_json_queue table
|
||||||
|
$json_data = getInterventionedJson($temp_json_queue_id, $pdo);
|
||||||
|
|
||||||
|
// Decode the JSON data
|
||||||
|
$decoded_json_data = json_decode($json_data, true);
|
||||||
|
|
||||||
|
// Check for unattached analysis
|
||||||
|
$unattached_analysis = checkForUnAttachedAnalysis($decoded_json_data,$pdo);
|
||||||
|
|
||||||
|
// Check for unattached compounds
|
||||||
|
$unattached_compounds = checkForUnAttachedCompounds($decoded_json_data, $pdo);
|
||||||
|
|
||||||
|
// Get all analysis and compounds
|
||||||
|
$analysisArr = getAllAnalysis($pdo);
|
||||||
|
$compoundsArr = getAllCompounds($pdo);
|
||||||
|
|
||||||
|
die(json_encode(array(
|
||||||
|
'code' => "success",
|
||||||
|
'arr_analysis_data' => $unattached_analysis,
|
||||||
|
'arr_compunds_data' => $unattached_compounds
|
||||||
|
)));
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
function getInterventionedJson($id, $pdo){
|
||||||
|
$sql = "SELECT json_data FROM temp_json_queue WHERE id = :id";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute(['id' => $id]);
|
||||||
|
$json_data = $stmt->fetchColumn();
|
||||||
|
return $json_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllAnalysis($pdo){
|
||||||
|
$sql = "SELECT * FROM analysisvocabulary";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$analysisArr = $stmt->fetchAll();
|
||||||
|
return $analysisArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllCompounds($pdo){
|
||||||
|
$sql = "SELECT * FROM compundsvocabulary";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$compoundsArr = $stmt->fetchAll();
|
||||||
|
return $compoundsArr;
|
||||||
|
}
|
||||||
|
function checkForUnAttachedAnalysis($decoded_json_data,$pdo){
|
||||||
|
$unattached_analysis = [];
|
||||||
|
$data = $decoded_json_data;
|
||||||
|
foreach($data['product']['reports'] as $report){
|
||||||
|
foreach($report['parts'] as $part){
|
||||||
|
foreach($part['analyses'] as $analysis){
|
||||||
|
$result_TestName = $analysis['result_TestName'];
|
||||||
|
$analysisgroupcode = $analysis['analysisgroupcode'];
|
||||||
|
$analysis_id = checkForAnalysisId($analysisgroupcode, $result_TestName, $pdo);
|
||||||
|
if(!$analysis_id){
|
||||||
|
|
||||||
|
$arr_analysiskind_refdata = ("SELECT * FROM analysisvocabulary where preferred like 'Y'");
|
||||||
|
$arr_analysiskind_refdata = $pdo->prepare($arr_analysiskind_refdata);
|
||||||
|
$arr_analysiskind_refdata->execute();
|
||||||
|
$arr_analysiskind_ref = $arr_analysiskind_refdata->fetchAll();
|
||||||
|
|
||||||
|
array_push($unattached_analysis, [
|
||||||
|
'word' => $result_TestName,
|
||||||
|
'anaysisword' => $result_TestName,
|
||||||
|
'arr_similary' => $arr_analysiskind_ref,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $unattached_analysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkForUnAttachedCompounds($decoded_json_data, $pdo){
|
||||||
|
$unattached_compounds = [];
|
||||||
|
$data = $decoded_json_data;
|
||||||
|
foreach($data['product']['reports'] as $report){
|
||||||
|
foreach($report['parts'] as $part){
|
||||||
|
foreach($part['analyses'] as $analysis){
|
||||||
|
foreach($analysis['results'] as $result){
|
||||||
|
$cas = $result['cas'];
|
||||||
|
$result_AnalytsName = $result['result_AnalytsName'];
|
||||||
|
$compound_id = checkForCompoundId($cas, $result_AnalytsName, $pdo);
|
||||||
|
if(!$compound_id){
|
||||||
|
$arr_compoundkind_refdata = ("SELECT * FROM compundsvocabulary where preferred like 'Y'");
|
||||||
|
$arr_compoundkind_refdata = $pdo->prepare($arr_compoundkind_refdata);
|
||||||
|
$arr_compoundkind_refdata->execute();
|
||||||
|
$arr_compoundkind_ref = $arr_compoundkind_refdata->fetchAll();
|
||||||
|
|
||||||
|
array_push($unattached_compounds, [
|
||||||
|
'word' => $result_AnalytsName,
|
||||||
|
'anaysisword' => $analysis['result_TestName'],
|
||||||
|
'arr_similary' => $arr_compoundkind_ref,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $unattached_compounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkForAnalysisId($analysisgroupcode, $result_TestName, $pdo){
|
||||||
|
$sql = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$analysis_id = $stmt->fetchColumn();
|
||||||
|
if(!$analysis_id){
|
||||||
|
$sql = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE nameanalysisvoc LIKE '$result_TestName'";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$analysis_id = $stmt->fetchColumn();
|
||||||
|
if(!$analysis_id){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return $analysis_id;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $analysis_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkForCompoundId($cas, $result_AnalytsName, $pdo){
|
||||||
|
// cas check
|
||||||
|
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();
|
||||||
|
$compound_id = $stmt->fetchColumn();
|
||||||
|
if(!$compound_id){
|
||||||
|
$sql = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE namecompoundsvocabulary LIKE '$result_AnalytsName'";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$compound_id = $stmt->fetchColumn();
|
||||||
|
if(!$compound_id){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return $compound_id;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $compound_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -18,6 +18,8 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css">
|
||||||
<script src="../assets/js/jquery.min.js"></script>
|
<script src="../assets/js/jquery.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
|
||||||
|
<script src="../assets/plugins/select2/select2.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
/* Custom styles here */
|
/* Custom styles here */
|
||||||
</style>
|
</style>
|
||||||
@ -25,6 +27,28 @@
|
|||||||
|
|
||||||
<body class="fixed-left">
|
<body class="fixed-left">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#ajax_preloader {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: transparent;
|
||||||
|
z-index: 9999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-container--open {
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div id="ajax_preloader">
|
||||||
|
<div id="status">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<?php include('../include/navigationbar.php'); ?>
|
<?php include('../include/navigationbar.php'); ?>
|
||||||
|
|
||||||
@ -79,7 +103,7 @@
|
|||||||
echo "<td>" . $row['lab_id'] . "</td>";
|
echo "<td>" . $row['lab_id'] . "</td>";
|
||||||
echo "<td>" . $row['received_at'] . "</td>";
|
echo "<td>" . $row['received_at'] . "</td>";
|
||||||
echo "<td>
|
echo "<td>
|
||||||
<a href='importjson.php?id=" . $row['id'] . "' class='btn btn-success btn-sm'>Import</a>
|
<button class='btn btn-success btn-sm' onclick='handleImport(" . $row['id'] . ")'>Import</button>
|
||||||
<button class='btn btn-danger btn-sm' onclick='deleteRow(" . $row['id'] . ")'><i class='bx bx-trash'></i></button>
|
<button class='btn btn-danger btn-sm' onclick='deleteRow(" . $row['id'] . ")'><i class='bx bx-trash'></i></button>
|
||||||
</td>";
|
</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
@ -107,6 +131,286 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function handleImport(id) {
|
||||||
|
formdata = new FormData();
|
||||||
|
formdata.append('id', id);
|
||||||
|
$.ajax({
|
||||||
|
url: 'importjson.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.code == "success") {
|
||||||
|
let arr_data = data;
|
||||||
|
let arr_analysisvoc = arr_data['arr_analysis_data'];
|
||||||
|
let arr_compundsvoc = arr_data['arr_compunds_data'];
|
||||||
|
|
||||||
|
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 eeee.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function process_import() {
|
||||||
|
formData = new FormData();
|
||||||
|
formData.append('method', 'intervention');
|
||||||
|
$.ajax({
|
||||||
|
url: '../apilogic/process_import.php',
|
||||||
|
type: 'POST',
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
beforeSend: function() {
|
||||||
|
$('#ajax_preloader').fadeIn();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#ajax_preloader').fadeOut();
|
||||||
|
showWarningAlert("Server Error");
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('#ajax_preloader').fadeOut();
|
||||||
|
if (data.code == "success") {
|
||||||
|
showSuccessAlert("Successfully imported!");
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
showWarningAlert("Server Error.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
showSuccessAlert("Successfully added!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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]['idanalysisvocabulary'] + '">' + 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">
|
||||||
|
<option value="0">Add new</option>`;
|
||||||
|
swal_html += str_arr_option;
|
||||||
|
|
||||||
|
swal_html += `
|
||||||
|
</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').select2();
|
||||||
|
$('.swal2-popup .ipt_type').bind("change", 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();
|
||||||
|
showWarningAlert("Server Error");
|
||||||
|
},
|
||||||
|
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!");
|
||||||
|
process_import();
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showWarningAlert("Server Error.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function show_compunds_add_popup(voc_info, callback) {
|
||||||
|
let str_word = voc_info['word'];
|
||||||
|
let str_analysis_word = voc_info['anaysisword'];
|
||||||
|
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">
|
||||||
|
<option value="0">Add new</option>`;
|
||||||
|
swal_html += str_arr_option;
|
||||||
|
|
||||||
|
swal_html += `
|
||||||
|
</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').select2();
|
||||||
|
$('.swal2-popup .ipt_type').bind("change", 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();
|
||||||
|
showWarningAlert("Server Error");
|
||||||
|
},
|
||||||
|
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!");
|
||||||
|
process_import();
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showWarningAlert("Server Error.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function deleteRow(id) {
|
function deleteRow(id) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Are you sure?',
|
title: 'Are you sure?',
|
||||||
@ -124,7 +428,6 @@
|
|||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response); // Controlla cosa viene restituito
|
|
||||||
if (response.trim() == "success") {
|
if (response.trim() == "success") {
|
||||||
Swal.fire('Deleted!', 'The record has been deleted.', 'success').then(() => {
|
Swal.fire('Deleted!', 'The record has been deleted.', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@ -141,8 +444,15 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#ajax_preloader').fadeOut();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script src="../assets/js/common_helper.js"></script>
|
||||||
|
<script src="../assets/plugins/alertify/js/alertify.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -83,6 +83,7 @@
|
|||||||
<li><a href="<?php echo USERAREA_PATH; ?>importify/history_importify.php">Import History</a></li>
|
<li><a href="<?php echo USERAREA_PATH; ?>importify/history_importify.php">Import History</a></li>
|
||||||
<li><a href="<?php echo USERAREA_PATH; ?>importify/analysis-vocabulary.php">Analysis Synonims</a></li>
|
<li><a href="<?php echo USERAREA_PATH; ?>importify/analysis-vocabulary.php">Analysis Synonims</a></li>
|
||||||
<li><a href="<?php echo USERAREA_PATH; ?>importify/compounds-vocabulary.php">Compounds Synonims</a></li>
|
<li><a href="<?php echo USERAREA_PATH; ?>importify/compounds-vocabulary.php">Compounds Synonims</a></li>
|
||||||
|
<li><a href="<?php echo USERAREA_PATH; ?>importify/interventionlist.php">Intervention List</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user