56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/functions.php');
|
||
|
$indent_id = $_POST['indent_id'];
|
||
|
$status = $_POST['status'];
|
||
|
$remarks = $_POST['app_remarks'];
|
||
|
$vendor_id = $_POST['vendor'];
|
||
|
$app_date = $_POST['approval_date'];
|
||
|
$rolecode = $_SESSION['RoleCode'];
|
||
|
$item_list = $_POST['item_list'];
|
||
|
$items=explode(",", $item_list);
|
||
|
error_log('itemlist'.count($items));
|
||
|
begin();
|
||
|
for($i=0;$i<count($items);$i++){
|
||
|
|
||
|
$indent_item_id=$items[$i];
|
||
|
$sql_item="update indent_items set vendor_id='".$vendor_id."' where item_id='".$indent_item_id."' and indent_id='".$indent_id."' ";
|
||
|
error_log($sql_item);
|
||
|
if (!$result_item = @mysqli_query($conn, $sql_item)) {
|
||
|
error_log ("Exception saving save_app_indent_level2:".mysqli_error($conn)." failing query:".$sql_item);
|
||
|
rollback();
|
||
|
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
$approved=0;
|
||
|
$sql_approved="select count(*) as items from indent_items where indent_id='".$indent_id."' and vendor_id=0 ";
|
||
|
error_log('approved'.$sql_approved);
|
||
|
if (!$result_approved = @mysqli_query($conn, $sql_approved)) {
|
||
|
error_log ("Exception saving save_app_indent_level2:".mysqli_error($conn)." failing query:".$sql_approved);
|
||
|
rollback();
|
||
|
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
$row_approved = mysqli_fetch_array($result_approved);
|
||
|
$unapproved=$row_approved['items'];
|
||
|
if($unapproved==0){
|
||
|
|
||
|
$sql = "update indent_master set status='" . $status . "',approval_date=STR_TO_DATE('" . $app_date . "','%d/%m/%Y'),approving_doc_id='" . $_SESSION['user_id'] . "',approval_remarks='" . $remarks . "' where indent_id='" . $indent_id . "'";
|
||
|
|
||
|
error_log("sql " . $sql);
|
||
|
if (!$result = @mysqli_query($conn, $sql)) {
|
||
|
error_log ("Exception saving save_app_indent_level2:".mysqli_error($conn)." failing query:".$sql);
|
||
|
rollback();
|
||
|
|
||
|
exit(mysqli_error($conn));
|
||
|
} else {
|
||
|
|
||
|
$data = "success";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
commit();
|
||
|
echo json_encode($data);
|