D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
ajax
/
Filename :
add-item-quantity-instok.php
back
Copy
<?php include_once("../config.php"); $totalitem_qty=0; $total_invoice_item_qty=0; $remainStock=0; $item_rowattRowClass = $_POST['item_rowattRowClass']; // echo $no_item_qty = mysqli_real_escape_string( $conn, $_POST['no_item_qty'] ); if( isset($_POST['no_item_qty']) && isset($_POST['item_qty_code']) && isset($_POST['item_qty_row_id'])){ $no_item_qty = mysqli_real_escape_string( $conn, $_POST['no_item_qty'] ); $item_qty_code = mysqli_real_escape_string( $conn, $_POST['item_qty_code'] ); $item_qty_row_id = mysqli_real_escape_string( $conn, $_POST['item_qty_row_id'] ); $sqlGetItem = "SELECT * FROM `inventory` WHERE `id` = '$item_qty_row_id' AND `item_code`='$item_qty_code'"; $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; } $totalitem_qty=$totalitem_qty+$no_item_qty; $sql = "UPDATE `inventory` SET `item_qty`='$totalitem_qty' WHERE `id` = '$item_qty_row_id' AND `item_code`='$item_qty_code'"; // echo " ".$no_item_qty; if ( mysqli_query( $conn, $sql ) ) { $remainStock=$totalitem_qty-$total_invoice_item_qty; $msg['status'] = "true"; $msg['instock_itemz'] = (int)$remainStock; $msg['item_rowattRowClass'] = $item_rowattRowClass; $msg['msg'] = "Correct" ; echo json_encode( $msg ); exit(); }else{ $msg['status'] = "false"; $msg['instock_itemz'] = "0"; $msg['item_rowattRowClass'] = $item_rowattRowClass; $msg['msg'] = "wrong" ; echo json_encode( $msg ); exit(); } }else { $msg['status'] = "false"; $msg['instock_itemz'] = "0"; $msg['item_rowattRowClass'] = $item_rowattRowClass; $msg['msg'] = "wrong" ; echo json_encode( $msg ); } ?>