Merge branch 'Lasha_Kapanadze_process_import_branch' of http://192.168.1.93:8418/solocla/Moncler-Portal
This commit is contained in:
@@ -13,19 +13,22 @@ try {
|
||||
} catch (PDOException $e) {
|
||||
die("Connection failed: " . $e->getMessage());
|
||||
}
|
||||
|
||||
$method = $_POST['method'];
|
||||
if ($method == 'intervention') {
|
||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 2";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute();
|
||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} else {
|
||||
// method validation
|
||||
if (!isset($_POST['method'])) {
|
||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 0";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute();
|
||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
else {
|
||||
$method = $_POST['method'];
|
||||
if($method == 'intervention'){
|
||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 2";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute();
|
||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($jsonEntries as $entry) {
|
||||
$data = json_decode($entry['json_data'], true);
|
||||
@@ -132,6 +135,11 @@ foreach ($jsonEntries as $entry) {
|
||||
$result_TestName = $analysis['result_TestName'];
|
||||
$analysisgroupcode = $analysis['analysisgroupcode'];
|
||||
|
||||
// groupcode validation
|
||||
if ($analysisgroupcode == '-' || $analysisgroupcode == '' || $analysisgroupcode == ' ') {
|
||||
$analysisgroupcode = 'NO_GROUPCODE';
|
||||
}
|
||||
|
||||
$query = "SELECT idanalysisvocabulary FROM analysisvocabulary WHERE analysiscode LIKE '$analysisgroupcode'";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$res = $stmt->execute();
|
||||
@@ -156,6 +164,11 @@ foreach ($jsonEntries as $entry) {
|
||||
$result_AnalytsName = $result['result_AnalytsName'];
|
||||
$cas = $result['cas'];
|
||||
|
||||
// cas validation
|
||||
if ($cas == '-' || $cas == '' || $cas == ' ') {
|
||||
$cas = 'NO_CAS';
|
||||
}
|
||||
|
||||
$query = "SELECT idcompoundsvocabulary FROM compundsvocabulary WHERE cascompoundvocabulary LIKE '%$cas%'";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$res = $stmt->execute();
|
||||
@@ -180,17 +193,21 @@ foreach ($jsonEntries as $entry) {
|
||||
}
|
||||
|
||||
markAsProcessed($entry['id'], $pdo);
|
||||
importHistory($pdo, $uuid);
|
||||
die(json_encode(['code' => 'success']));
|
||||
} else {
|
||||
markForIntervention($entry['id'], $pdo);
|
||||
importHistory($pdo, $uuid);
|
||||
die(json_encode(['code' => 'success', 'message' => 'Intervention']));
|
||||
}
|
||||
} else {
|
||||
markForIntervention($entry['id'], $pdo);
|
||||
importHistory($pdo, $uuid);
|
||||
die(json_encode(['code' => 'success', 'message' => 'Intervention']));
|
||||
}
|
||||
importHistory($pdo, $uuid);
|
||||
}
|
||||
|
||||
|
||||
die(json_encode(['code' => 'success']));
|
||||
|
||||
// Function definitions
|
||||
|
||||
@@ -398,4 +415,6 @@ function markForIntervention($id, $pdo)
|
||||
$query = "UPDATE temp_json_queue SET processed = 2 WHERE id = :id";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->execute(['id' => $id]);
|
||||
|
||||
$query = "INSERT INTO notifications (`title`,`description`) VALUES ('Intervention Required', 'Intervention required for JSON entry with ID $id')";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user