112 lines
3.2 KiB
PHP
112 lines
3.2 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,'Oxygen Cylinder','SAVE','save_oxygen_cylinder_checklist.php');
|
|
|
|
$id = $_POST['cylinder_id'];
|
|
|
|
error_log("ID:".$id);
|
|
|
|
$query_initial="";
|
|
$endquery="";
|
|
begin();
|
|
if(!empty($id)){
|
|
$query_initial="update ";
|
|
$endquery=" where id = '".$id."' ";
|
|
}else{
|
|
$query_initial="insert into ";
|
|
}
|
|
|
|
|
|
$query=$query_initial." oxygen_cylinder_checklist set oxygen_cylinder_id='".$_POST['oxygen_cylinder_id']."',date_receiving=STR_TO_DATE('".$_POST['date_receive']."', '%d/%m/%Y'),date_validity=STR_TO_DATE('".$_POST['date_validity']."', '%d/%m/%Y'),issue_date=STR_TO_DATE('".$_POST['issue_date']."', '%d/%m/%Y'),location='".$_POST['location']."',check_date=STR_TO_DATE('".$_POST['date_check']."', '%d/%m/%Y'),pressure_reading='".$_POST['pressure_reading']."',any_leakage='".$_POST['any_leakage']."', valve_closed='".$_POST['valve_closed']."',checked_by='".$_POST['checked_by']."',status='".$_POST['status']."',water_humidifier_date=STR_TO_DATE('".$_POST['water_humidifier_date']."', '%d/%m/%Y'),remarks='".$_POST['remarks']."' ".$endquery;
|
|
|
|
error_log("ehwifhew".$query);
|
|
|
|
if (!$result = mysqli_query($conn,$query)) {
|
|
rollback();
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
$noOfRows=$_POST['count_qstn'];
|
|
|
|
|
|
error_log("rows: ".$noOfRows);
|
|
|
|
$check_date = $_REQUEST['date_check'];
|
|
|
|
|
|
$cylinder_id = $_POST['oxygen_cylinder_id'];
|
|
error_log("CYLINDER_ID".$cylinder_id);
|
|
$question_id = $_POST['question_id'];
|
|
error_log("QUESTION".$question_id);
|
|
|
|
$remarks=array();
|
|
$total_yes=array();
|
|
|
|
for($i=0;$i<$noOfRows;$i++){
|
|
|
|
$qr = 'qremarks'.$i;
|
|
array_push($remarks,$_POST[$qr]);
|
|
|
|
$xyz='answer'.$i;
|
|
|
|
if(strcmp($_POST[$xyz],"Y")===0){
|
|
|
|
$abc='question_id'.$i;
|
|
|
|
array_push($total_yes,$_POST[$abc]);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//error_log("REMARKS".$remarks);
|
|
|
|
$yes=implode(",",$total_yes);
|
|
$qremarks = implode(",",$remarks);
|
|
error_log("REMARKS:".$qremarks);
|
|
|
|
$count=getFieldFromTable('count(oxygen_cylinder_id)','oxygen_cylinder_checklist_details','oxygen_cylinder_id',$cylinder_id);
|
|
|
|
if($count != 0){
|
|
error_log('update query');
|
|
$query1="update oxygen_cylinder_checklist_details set check_date=STR_TO_DATE('".$check_date."', '%d/%m/%Y %h:%i %p'),question_id='$yes',remarks='$qremarks' where oxygen_cylinder_id = '$cylinder_id' ";
|
|
}
|
|
else{
|
|
$query1="insert into oxygen_cylinder_checklist_details set check_date=STR_TO_DATE('".$check_date."', '%d/%m/%Y %h:%i %p'),question_id='$yes',remarks='$qremarks' ,oxygen_cylinder_id='$cylinder_id'";
|
|
}
|
|
|
|
|
|
|
|
error_log("CHECKLIST QUERY:".$query1);
|
|
if (!$result = @mysqli_query($conn,$query1)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
|
|
$data=$row;
|
|
}
|
|
}
|
|
|
|
if($data==null)
|
|
{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
echo json_encode($data);
|
|
|
|
|
|
|
|
commit();
|
|
?>
|
|
|