fixed bugs
This commit is contained in:
parent
1325bf8b24
commit
994884d3c9
@ -13,19 +13,22 @@ try {
|
|||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
die("Connection failed: " . $e->getMessage());
|
die("Connection failed: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
// method validation
|
||||||
$method = $_POST['method'];
|
if (!isset($_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 {
|
|
||||||
$query = "SELECT * FROM temp_json_queue WHERE processed = 0";
|
$query = "SELECT * FROM temp_json_queue WHERE processed = 0";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$jsonEntries = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$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) {
|
foreach ($jsonEntries as $entry) {
|
||||||
$data = json_decode($entry['json_data'], true);
|
$data = json_decode($entry['json_data'], true);
|
||||||
@ -180,17 +183,21 @@ foreach ($jsonEntries as $entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
markAsProcessed($entry['id'], $pdo);
|
markAsProcessed($entry['id'], $pdo);
|
||||||
|
importHistory($pdo, $uuid);
|
||||||
|
die(json_encode(['code' => 'success']));
|
||||||
} else {
|
} else {
|
||||||
markForIntervention($entry['id'], $pdo);
|
markForIntervention($entry['id'], $pdo);
|
||||||
|
importHistory($pdo, $uuid);
|
||||||
|
die(json_encode(['code' => 'success', 'message' => 'Intervention']));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
markForIntervention($entry['id'], $pdo);
|
markForIntervention($entry['id'], $pdo);
|
||||||
|
importHistory($pdo, $uuid);
|
||||||
|
die(json_encode(['code' => 'success', 'message' => 'Intervention']));
|
||||||
}
|
}
|
||||||
importHistory($pdo, $uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
die(json_encode(['code' => 'success']));
|
|
||||||
|
|
||||||
// Function definitions
|
// Function definitions
|
||||||
|
|
||||||
|
|||||||
@ -131,6 +131,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function refresh_table(){
|
||||||
|
// location reload in 2 seconds
|
||||||
|
setTimeout(function(){
|
||||||
|
location.reload();
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function handleImport(id) {
|
function handleImport(id) {
|
||||||
formdata = new FormData();
|
formdata = new FormData();
|
||||||
formdata.append('id', id);
|
formdata.append('id', id);
|
||||||
@ -171,7 +179,7 @@
|
|||||||
showWarningPopup("Excel data format is not valid!")
|
showWarningPopup("Excel data format is not valid!")
|
||||||
} else {
|
} else {
|
||||||
$('#f_csv').val("");
|
$('#f_csv').val("");
|
||||||
showWarningAlert("Server eeee.")
|
showWarningAlert("Server Error.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -197,7 +205,7 @@
|
|||||||
$('#ajax_preloader').fadeOut();
|
$('#ajax_preloader').fadeOut();
|
||||||
if (data.code == "success") {
|
if (data.code == "success") {
|
||||||
showSuccessAlert("Successfully imported!");
|
showSuccessAlert("Successfully imported!");
|
||||||
window.location.reload();
|
refresh_table();
|
||||||
} else {
|
} else {
|
||||||
showWarningAlert("Server Error.")
|
showWarningAlert("Server Error.")
|
||||||
}
|
}
|
||||||
@ -326,7 +334,7 @@
|
|||||||
|
|
||||||
let str_arr_option = '';
|
let str_arr_option = '';
|
||||||
for (let i = 0; i < arr_similary.length; i++) {
|
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 += '<option value="' + arr_similary[i]['idcompoundsvocabulary'] + '">' + arr_similary[i]['namecompoundsvocabulary'] + '</option>';
|
||||||
}
|
}
|
||||||
str_arr_option += tmp_str_arr_compunds_kind_option;
|
str_arr_option += tmp_str_arr_compunds_kind_option;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user