D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
shubmkcj
/
urbane.createerp.com
/
ajax
/
Filename :
check-product-stock.php
back
Copy
<?php include_once("../config.php"); //$instock_tem=0; $itemNameId = filter_var( $_POST['item'], FILTER_SANITIZE_STRING ); if (!empty( $itemNameId)){ //check in stock po item $sql1 = "SELECT * ,sum(`qty` * 1) as `totalStock` FROM `po_item` WHERE `item_id` ='$itemNameId' GROUP by `item_id`;"; //echo $sql1; // die; $query1 = mysqli_query( $conn, $sql1 ); $count1 = mysqli_num_rows( $query1 ); $result1 = mysqli_fetch_assoc( $query1 ); $totalStock = (int)$result1['totalStock']; $sql = "SELECT * ,sum(`qty` * 1) as `totalSell` FROM `invoice_item` WHERE `marge_status` != 'yes' AND `item_id` ='$itemNameId' GROUP by `item_id`;"; //echo $sql; // die; $query = mysqli_query( $conn, $sql ); $count = mysqli_num_rows( $query ); $result = mysqli_fetch_assoc( $query ); $totalSell = (int)$result['totalSell']; $instock_item=$totalStock-$totalSell; if($totalSell>$totalStock){ $instock_item="0"; }else{ $instock_item=$instock_item; } if ( $count == 1 ) { $msg['status'] = "true"; $msg['instock_itemz'] = $instock_item; $msg['msg'] = "Correct" ; echo json_encode( $msg ); } else { $msg['status'] = "false"; $msg['msg'] = "incorrect"; echo json_encode( $msg ); } } ?>