71 lines
2.5 KiB
PHP
71 lines
2.5 KiB
PHP
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
include ('log_entry.php');
|
|
$noOfRows = $_POST['count_items'];
|
|
error_log("noOfRows".$noOfRows);
|
|
begin();
|
|
// echo $noOfRows;
|
|
// $calibration_id = $_POST['calibration_id'];
|
|
include('log_entry.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
//echo "shu";
|
|
|
|
$data = array();
|
|
|
|
|
|
// if (! empty($calibration_id)) {
|
|
|
|
// $current_stock_level_calibration_item_tbl_query = "select cat_id,qty,cali_on,next_cali from calibration_item_tbl where calibration_id='" . $calibration_id . "' ";
|
|
// $results_calibration_item = mysqli_query($conn,$current_stock_level_calibration_item_tbl_query);
|
|
// // echo $current_stock_level_calibration_item_tbl_query;
|
|
|
|
// }
|
|
// clear existing entries into the child table
|
|
// $query_del = " delete from calibration_item_tbl where calibration_id = '" . $calibration_id . "' ";
|
|
// // echo $query_del;
|
|
// $result_del = @mysqli_query($conn,$query_del);
|
|
|
|
for ($i = 0; $i < $noOfRows; $i ++) {
|
|
if(!empty(${"cat_id$i"})){
|
|
$initquery = "";
|
|
$endquery = "";
|
|
$calibration_id=${"calibration_id$i"};
|
|
if(!empty($calibration_id)){
|
|
$initquery = "Update ";
|
|
$endquery = " where calibration_id='".$calibration_id."'";
|
|
}else{
|
|
$initquery = "insert into ";
|
|
$endquery = " ";
|
|
}
|
|
|
|
$file_q='';
|
|
|
|
$file_path=$_FILES['bill_file'.$i]['tmp_name']; //pdf is the name of the input type where we are uploading files
|
|
$file_type=$_FILES['bill_file'.$i]['type'];
|
|
$file_size=$_FILES['bill_file'.$i]['size'];
|
|
$file_name=$_FILES['bill_file'.$i]['name'];
|
|
|
|
$file_data=mysqli_real_escape_string($conn,file_get_contents($file_path));
|
|
|
|
if(!empty($file_data)){
|
|
|
|
$file_q=",bill_file = '".$file_data."',bill_file_name='".$file_name."',bill_file_type='".$file_type."' ";
|
|
}
|
|
|
|
$query1 = $initquery." calibration_item_tbl set cat_id ='" . ${"cat_id$i"} . "',qty = '" . ${"qty$i"} . "',model_no = '" . ${"model_no$i"} . "',id_no = '" . ${"id_no$i"} . "',location = '" . ${"location$i"} . "',cali_on=STR_TO_DATE('" . ${"cali_on$i"} . "','%d/%m/%Y'),next_cali=STR_TO_DATE('" . ${"next_cali$i"} . "','%d/%m/%Y'),modified_by = '" . $_SESSION['user_id'] . "',ohc_type_id = '" . $_SESSION['current_ohcttype'] . "' ".$file_q.$endquery;
|
|
// echo $query1;
|
|
error_log("query save calibration ".$query1);
|
|
if (! $result1 = @mysqli_query($conn,$query1)) {
|
|
|
|
rollback();
|
|
header('HTTP/1.1 500 Internal Server Error');
|
|
echo json_encode(die('failed!' . mysqli_error($conn)));
|
|
}
|
|
}
|
|
}
|
|
commit();
|
|
|
|
echo json_encode($data);
|
|
|
|
?>
|