D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
ajax
/
Filename :
check-item-stock-availability-alert.php
back
Copy
<?php include_once("../config.php"); $totalitem_qty=0; $total_invoice_item_qty=0; $remainStock=0; if( isset($_POST['txtitemcode']) && isset($_POST['txtitemcode_row_id']) && isset($_POST['noquantity'])){ $txtitemcode = mysqli_real_escape_string( $conn, $_POST['txtitemcode'] ); $txtitemcode_row_id = mysqli_real_escape_string( $conn, $_POST['txtitemcode_row_id'] ); $noquantity = mysqli_real_escape_string( $conn, $_POST['noquantity'] ); $sqlGetItem = "SELECT * FROM `inventory` WHERE `id` = '$txtitemcode_row_id' AND `item_code` = '$txtitemcode'"; $resultGetItem = mysqli_query($conn,$sqlGetItem); $count = mysqli_num_rows( $resultGetItem ); if($count){ $rowGetItem = mysqli_fetch_array($resultGetItem); $item_code = $rowGetItem['item_code']; $item_qty = $rowGetItem['item_qty']; $totalitem_qty=$totalitem_qty+$item_qty; $sqld1 = "SELECT sum(`qty`) as `total_invoice_item_qty` FROM `invoice_item` where `item_code` = '$item_code' AND `marge_status` != 'yes' GROUP by `item_code`"; $resultd1 = mysqli_query($conn,$sqld1); $count1 = mysqli_num_rows( $resultd1 ); if($count1){ $result_row = mysqli_fetch_array($resultd1); $total_invoice_item_qty = $result_row['total_invoice_item_qty']; }else{ $total_invoice_item_qty=0; } }else{ $totalitem_qty=0; $total_invoice_item_qty=0; } $remainStock=$totalitem_qty-$total_invoice_item_qty; if ( $remainStock>=$noquantity) { $msg['status'] = "true"; $msg['msg'] = "ok" ; echo json_encode( $msg ); exit(); } else { $msg['status'] = "false"; $msg['msg'] = "Please add quantity in stock for $txtitemcode. For increase stock quantity! Click on Plus sign(+) Or Click Add Item Quantity button. You have entered $noquantity items but there are $remainStock items in the stock. " ; echo json_encode( $msg ); exit(); } } ?>