84 lines
2.9 KiB
PHP
84 lines
2.9 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,'Medicine issue point','SAVE','save_issuepoint.php');
|
||
|
// $point_id = $_POST['point_id'];
|
||
|
$type_name = $_POST['type_name'];
|
||
|
$issue_point_name = $_POST['issue_point_name'];
|
||
|
$location = $_POST['location'];
|
||
|
$code = $_POST['code'];
|
||
|
error_log($type_name ." ".$issue_point_name." ". $location. " ". $code );
|
||
|
$query = "";
|
||
|
$data = array();
|
||
|
// begin();
|
||
|
// if (!empty($point_id)) {
|
||
|
// $query = "update medicine_issue_point set type_name='$type_name', issue_point_name='$issue_point_name' ,location='$location',code='$code',modified_by = '" . $_SESSION['user_id'] . "' where point_id =
|
||
|
// '" . $point_id . "'";
|
||
|
// // error_log("update issue point: ".$query);
|
||
|
|
||
|
|
||
|
// } else {
|
||
|
// $check_query = "select * from medicine_issue_point where issue_point_name='$issue_point_name'";
|
||
|
// if (!$results = @mysqli_query($conn,$check_query)) {
|
||
|
// // main insert fails
|
||
|
// // rollback ();
|
||
|
// error_log(" Medicine issue duplicate check Exception:" . mysqli_error($conn));
|
||
|
// error_log("Failing Query " . $check_query);
|
||
|
// // exit ( error_log ( mysqli_error($conn) ) );
|
||
|
// }
|
||
|
|
||
|
// // $results=mysqli_query($conn,$check_query);
|
||
|
// $checkrows = mysqli_num_rows($results);
|
||
|
|
||
|
// if ($checkrows > 0) {
|
||
|
|
||
|
// $data['status'] = 'ERROR';
|
||
|
// error_log($data['status']);
|
||
|
// } else {
|
||
|
// $query = "insert into medicine_issue_point(type_name,issue_point_name,location,code,modified_by)
|
||
|
// values ('$type_name','$issue_point_name','$location','$code','" . $_SESSION['user_id'] . "' )";
|
||
|
// error_log("insert issue point: " . $query);
|
||
|
// }
|
||
|
// }
|
||
|
// //echo $query;
|
||
|
// if (!$result = @mysqli_query($conn,$query)) {
|
||
|
// rollback();
|
||
|
// error_log("Failed to Execute Medicine Issue Point" . mysqli_error($conn));
|
||
|
// error_log("Failing Query" . $query);
|
||
|
// exit(mysqli_error($conn));
|
||
|
// }
|
||
|
|
||
|
// // error_log($data['status']);
|
||
|
// commit();
|
||
|
// echo json_encode($data);
|
||
|
|
||
|
|
||
|
$check_query = "select * from medicine_issue_point where issue_point_name='$issue_point_name' OR code='$code'";
|
||
|
$results=mysqli_query($conn,$check_query);
|
||
|
$checkrows = mysqli_num_rows($results);
|
||
|
error_log("Check Query".$check_query);
|
||
|
if ($checkrows > 0) {
|
||
|
error_log("Checking Rows".$checkrows);
|
||
|
$data['status'] = 'ERROR';
|
||
|
error_log($data['status']);
|
||
|
} else {
|
||
|
$query = "insert into medicine_issue_point(type_name,issue_point_name,location,code,modified_by)
|
||
|
values ('$type_name','$issue_point_name','$location','$code','" . $_SESSION['user_id'] . "' )";
|
||
|
error_log("insert issue point: " . $query);
|
||
|
}
|
||
|
if(isset($query))
|
||
|
{
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
}
|
||
|
echo json_encode($data[0]);
|
||
|
?>
|