D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
ajax
/
Filename :
check-item-stock-availability.php
back
Copy
<?php include_once("../config.php"); $totalitem_qty=0; $total_invoice_item_qty=0; $remainStock=0; if( isset($_POST['item_name_row_id']) ){ $item_name_row_id = mysqli_real_escape_string( $conn, $_POST['item_name_row_id'] ); $sqlGetItem = "SELECT * FROM `inventory` where `id` = '$item_name_row_id'"; } if( isset($_POST['txtitemcode']) ){ $item_codes = mysqli_real_escape_string( $conn, $_POST['txtitemcode'] ); $sqlGetItem = "SELECT * FROM `inventory` where `item_code` = '$item_codes'"; } $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 ( $count) { $msg['status'] = "true"; $msg['instock_itemz'] = (int)$remainStock; $msg['msg'] = "Correct" ; echo json_encode( $msg ); } else { $msg['status'] = "false"; $msg['instock_itemz'] = "0"; $msg['msg'] = "wrong" ; echo json_encode( $msg ); } ?>