ESH/save_bio_medical_waste_new.php
2024-10-23 18:28:06 +05:30

61 lines
2.2 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
$noOfRows=$_POST['count_items'];
$dis_agncy = $_POST['dis_agncy'];
//echo "hello".$noOfRows;
$waste_id = $_POST['waste_id'];
for($i=0;$i<$noOfRows;$i++){
$waste_id_str="waste_id".$i;
$waste_id =$_REQUEST[$waste_id_str];
$sql="SELECT waste_id FROM `bio_medical_waste_new` WHERE `ohc_type_id` = '" . $_SESSION['current_ohcttype'] ."' and waste_gen_date=STR_TO_DATE('".${"waste_gen_date$i"}."','%d/%m/%Y')";
error_log('idddd'.$waste_id);
$resultl = mysqli_query($conn,$sql);
$rowl=mysqli_fetch_array($resultl);
$query_initial="";
$endquery="";
begin();
if(!empty($waste_id)){
$query_initial="update bio_medical_waste_new set";
$endquery="where waste_id = '".$waste_id."' and ohc_type_id = '" . $_SESSION['current_ohcttype'] . "' ";
}else{
$query_initial="insert into bio_medical_waste_new set ohc_type_id = '" . $_SESSION['current_ohcttype'] . "', ";
}
$emp_id = getFieldFromTable('emp_id','tbl_users','user_id',$_SESSION['user_id']);
if($_SESSION['RoleCode'] == "DOC"){
$emp_id = getFieldFromTable('emp_id','tbl_users','user_id',$_SESSION['user_id']);
}
else{
$emp_id = '';
}
$query=" dis_agncy='".$dis_agncy."', waste_gen_date=STR_TO_DATE('".${"waste_gen_date$i"}."','%d/%m/%Y %h:%i %p'), plant_yellow_qty ='".${"plant_yellow_qty$i"}."',plant_white_qty='".${"plant_white_qty$i"}."',plant_blue_qty='".${"plant_blue_qty$i"}."', plant_red_qty='".${"plant_red_qty$i"}."',yellow_bags='".${"yellow_bags$i"}."',red_bags='".${"red_bags$i"}."',white_bags='".${"white_bags$i"}."',blue_bags='".${"blue_bags$i"}."',collected_by='".$_POST['collected_by']."',vehicle_no='".$_POST['vehicle_no']."',surveillance_by='".$_POST['surveillance_by']."',challan_no='".$_POST['challan_no']."',approved_by = '$emp_id',approval_status='".$_POST['approval_status']."',modified_by = '".$_SESSION['user_id']."' ";
error_log("query111".$query);
//echo $query;
$query=$query_initial.$query.$endquery;
error_log($query);
if (!$result = mysqli_query($conn,$query)) {
error_log(mysqli_error($conn));
rollback();
exit(mysqli_error($conn));
}
}
commit();
?>