function savePartQuantity() { $db = Database::getInstance(); $cxn = $db->getConnection(); if ($this->supplierid == '' && $this->moutwardid != '') { $q = "INSERT INTO MO_Drg_Qty (Material_Outward_ID,MI_Drg_Qty_ID,Drawing_ID,Outward_Qty)\n\t\t\tVALUES({$this->moutwardid},{$this->midrgqtyid},{$this->partid},{$this->qty})"; //print("<br>$q"); if (!($res = $cxn->query($q))) { echo "error :", $cxn->error; } else { $pm = new PartMaterial(); $pm->setMIDQID($this->midrgqtyid); $pm->setPartMaterialDetails(); $materialreceived = $pm->getQuantity(); $query = "SELECT sum(Outward_Qty) as oq from MO_Drg_Qty where Drawing_ID={$this->partid} and MI_Drg_Qty_ID={$this->midrgqtyid}"; // print("<br>$query"); if (!($resq = $cxn->query($query))) { echo "error :", $cxn->error; } else { $r = mysqli_fetch_assoc($resq); $oq = $r['oq']; $tq = $materialreceived - $oq; // print("<br>Material received=$materialreceived"); if ($tq == 0) { $q3 = "UPDATE MI_Drg_Qty SET Qty_Open='0' WHERE MI_Drg_Qty_ID={$this->midrgqtyid}"; // print("<br>$q3"); if (!($resq = $cxn->query($q3))) { echo "error :", $cxn->error; } } } // print("Part Quantity of $this->qty Updated in Challan"); } $inwardid = $pm->getInwardID(); $q4 = "SELECT Drawing_ID FROM MI_Drg_Qty WHERE Qty_Open=1 AND Material_Inward_ID={$inwardid};"; //print("<br>$q4"); $res4 = $cxn->query($q4); $opendqty = $res4->num_rows; if ($opendqty == 0) { $q5 = "UPDATE Material_Inward SET Open=0 WHERE Material_Inward_Id={$inwardid};"; //print("<br>$q5"); $res5 = $cxn->query($q5); } } else { $q = "INSERT INTO Misc_Material (Material_Outward_ID,Supplier_ID,Material_Desc,Misc_Qty,Misc_Remarks)\n\t\t\tVALUES({$this->moutwardid},{$this->supplierid},'{$this->miscdec}',{$this->qty},'{$this->remark}')"; //print("<br>$q"); if (!($res = $cxn->query($q))) { echo "error :", $cxn->error; } } }
$eqty = $_POST['eqty']; } //updated material qtys if (isset($_POST['racknoe'])) { $racknoe = $_POST['racknoe']; } //updated material qtys if (isset($_POST['emidqid'])) { $emidqid = $_POST['emidqid']; } else { $emidqid = ''; } //material inward ids for updation $mi->setCustID($_POST['Customer_ID']); $mi->saveMaterialInward(); $partid = $mi->getInwardID(); $partlist = json_decode($partlist); if ($partlist != '') { $l = count($partlist); $i = 0; while ($i < $l) { $mi->setPartID($partlist[$i][0]); $mi->setQuantity($partlist[$i][1]); $mi->setMaterialCode($partlist[$i][2]); $mi->setRackno($partlist[$i][3]); $mi->savePartMaterial(); $i += 1; } } if ($emidqid != '') { $l = count($emidqid);