55 lines
1.9 KiB
PHP
55 lines
1.9 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'];
|
||
|
error_log($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 waste_gen_date=STR_TO_DATE('".${"waste_gen_date$i"}."','%d/%m/%Y')";
|
||
|
error_log($sql);
|
||
|
$resultl = mysqli_query($conn,$sql);
|
||
|
$rowl=mysqli_fetch_array($resultl);
|
||
|
|
||
|
$query_initial="";
|
||
|
$endquery="";
|
||
|
begin();
|
||
|
|
||
|
|
||
|
|
||
|
if(!empty($rowl['waste_id'])){
|
||
|
$query_initial="update ";
|
||
|
$endquery=" where waste_id = '".$rowl['waste_id']."' ";
|
||
|
}else{
|
||
|
$query_initial="insert into ";
|
||
|
|
||
|
}
|
||
|
|
||
|
$query=" bio_medical_waste_new set dis_agncy='".$dis_agncy."', waste_gen_date=STR_TO_DATE('".${"waste_gen_date$i"}."','%d/%m/%Y'), plant_yellow_qty ='".${"plant_yellow_qty$i"}."',mines_yellow_qty = '".${"mines_yellow_qty$i"}."',yellow_qty_total='".${"plant_yellow_qty$i"}."'+mines_yellow_qty,plant_white_qty='".${"plant_white_qty$i"}."',mines_white_qty='".${"mines_white_qty$i"}."',white_qty_total='".${"plant_white_qty$i"}."'+mines_white_qty,plant_blue_qty='".${"plant_blue_qty$i"}."',mines_blue_qty='".${"mines_blue_qty$i"}."',blue_qty_total='".${"plant_blue_qty$i"}."'+mines_blue_qty, plant_red_qty='".${"plant_red_qty$i"}."', mines_red_qty='".${"mines_red_qty$i"}."',red_qty_total='".${"plant_red_qty$i"}."'+mines_red_qty,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();
|
||
|
?>
|
||
|
|