60 lines
2.3 KiB
PHP
60 lines
2.3 KiB
PHP
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
include ('log_entry.php');
|
|
error_log("Start Printing Request Attributes");
|
|
$requestStr = "";
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
error_log("End Printing Request Attributes");
|
|
|
|
$noOfRows = $_POST['count_items'];
|
|
error_log($_SESSION['current_ohcttype']);
|
|
|
|
|
|
$india_timezone = new DateTimeZone('Asia/Kolkata');
|
|
$current_date_time = new DateTime('now', $india_timezone);
|
|
$formatted_date = $current_date_time->format('Y-m-d');
|
|
$formatted_date_time = $current_date_time->format('Y-m-d H:i:s');
|
|
|
|
|
|
$sql = "select a.*,date(a.start_date_time) as date from shift_status_details a where current_status='R' and ohc_location_id='" . $_SESSION['current_ohcttype'] . "'";
|
|
$result = @mysqli_query($conn, $sql);
|
|
error_log(mysqli_num_rows($result));
|
|
if (!$row = @mysqli_fetch_assoc($result)) {
|
|
error_log($sql);
|
|
}
|
|
$data = '';
|
|
$shift_id = $_REQUEST['shift_id'];
|
|
|
|
$shift_id_new = $row['shift_id'];
|
|
$date = $row['record_date'];
|
|
|
|
error_log("form shift id " . $shift_id);
|
|
error_log("shift id new " . $shift_id_new);
|
|
error_log("datesafasf" . $date);
|
|
|
|
// echo $procurement_refno;
|
|
begin();
|
|
if (mysqli_num_rows($result) != 0) {
|
|
$query = "update shift_status_details set end_date_time='" . $formatted_date_time . "',current_status='C',modified_by = '" . $_SESSION['user_id'] . "' where current_status='R' and ohc_location_id='" . $_SESSION['current_ohcttype'] . "' ";
|
|
$data = $shift_id_new;
|
|
// updateItemStockDispensaryShiftBalance($_SESSION['current_ohcttype'], $shift_id_new, $date);
|
|
updateItemStockStoreShiftBalance($_SESSION['current_ohcttype'], $shift_id_new, $date);
|
|
} else {
|
|
|
|
$query = "insert into shift_status_details set record_date='" . $formatted_date_time . "',shift_id='" . $shift_id . "',start_date_time='" . $formatted_date_time . "',current_status='R',ohc_location_id='" . $_SESSION['current_ohcttype'] . "',modified_by = '" . $_SESSION['user_id'] . "' ";
|
|
$data = 1;
|
|
error_log("query:" . $query);
|
|
}
|
|
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
error_log("Failed to save Shift Status:" . mysqli_error($conn) . ". Failed query:" . $query);
|
|
rollback();
|
|
die(error_log(mysqli_error($conn)));
|
|
}
|
|
echo json_encode($data);
|
|
commit();
|