ohctech_p8/save_communication.php
Dushant Mali 899fb3e65a Upgrade 7 to 8
Upgrade 7 to 8
2024-11-02 18:03:13 +05:30

68 lines
2.6 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");
save_log($requestStr, 'Communication List', 'SAVE', 'save_communication.php');
$noOfRows = $_POST['count_items'];
error_log("rows: " . $noOfRows);
begin();
$modified_by = $_SESSION['user_id'];
$shift_details_id = $_REQUEST['shift_details_id0'];
$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');
// $dis_agncy = $_POST['dis_agncy'];
//echo "hello".$noOfRows;
$sql_ifexists = " select * from communication_details where modified_by = '" . $modified_by . "' and date_format(comm_date,'%d-%m-%Y') ='" . ${"comm_date"} . "' and ohc_location_id = '" . $_SESSION['current_ohcttype'] . "' and shift_details_id='" . $shift_details_id . "' ";
//echo $sql_ifexists;
$result_ifexists = mysqli_query($conn, $sql_ifexists);
$exists = @mysqli_num_rows($result_ifexists);
error_log("existing rows:" . $exists);
if ($exists > 0) {
$del_qry = "delete from communication_details where modified_by = '" . $modified_by . "' and date_format(comm_date,'%d-%m-%Y') ='" . ${"comm_date"} . "' and ohc_location_id = '" . $_SESSION['current_ohcttype'] . "' and shift_details_id='" . $shift_details_id . "' ";
error_log("com del query" . $del_qry);
mysqli_query($conn, $del_qry);
}
$communication_id = $_POST['communication_id'];
for ($i = 0; $i < $noOfRows; $i++) {
$communication_id_str = "communication_id" . $i;
$communication_id = $_REQUEST[$communication_id_str];
// echo $communication_id;
error_log("communication_id" . $communication_id);
//echo $procurement_refno;
$query_initial = "insert into ";
$endquery = "";
$query = $query_initial . " communication_details set communication_id ='" . ${"communication_id$i"} . "',shift_details_id = '" . ${"shift_details_id$i"} . "',details ='" . ${"details$i"} . "',remarks ='" . ${"remarks$i"} . "',comm_date = '" . $formatted_date_time . "' , ohc_location_id = '" . $_SESSION['current_ohcttype'] . "',modified_by = '" . $_SESSION['user_id'] . "' " . $endquery;
error_log("save comm query:" . $query);
if (!$result = @mysqli_query($conn, $query)) {
rollback();
die(error_log(mysqli_error($conn)));
}
}
commit();