$ro4 = new database4(); $user = $ro->selectNow('registeredUser', 'username', 'employeeID', $_SESSION['employeeID']); foreach ($endingNo as $end) { $totalEnding += $ro->selectNow("endingInventory", "endingQTY", "endingNo", $end); $endingNo1 = $end; $ro->editNow("endingInventory", "endingNo", $end, "status", "encoded_" . $user); } if ($ro->selectNow("inventoryStockCard", "inventoryType", "stockCardNo", $ro->selectNow("endingInventory", "stockCardNo", "endingNo", $endingNo1)) == "medicine") { $stockCardNo = $ro->selectNow("endingInventory", "stockCardNo", "endingNo", $endingNo1); $genericName = $ro->selectNow("inventoryStockCard", "genericName", "stockCardNo", $stockCardNo); $brandName = $ro->selectNow("inventoryStockCard", "description", "stockCardNo", $stockCardNo); $preparation = $ro->selectNow("inventory", "preparation", "stockCardNo", $stockCardNo); $qty = $totalEnding; $unitcost = $ro->selectNow("endingInventory", "unitcost", "endingNo", $endingNo1); //selectLast($table,$cols,$identifier,$identifierData,$ordering) $opdPrice = $ro4->selectLast("inventory", "opdPrice", "stockCardNo", $stockCardNo, "inventoryCode"); $ipdPrice = $ro4->selectLast("inventory", "ipdPrice", "stockCardNo", $stockCardNo, "inventoryCode"); $expiration = $ro4->selectLast('inventory', 'expiration', 'stockCardNo', $stockCardNo, 'inventoryCode'); $remarks = "Ending inventory - " . date('Y-m-d'); $locked = "no"; $criticalLevel = "5"; $inventoryType = $ro->selectNow("inventoryStockCard", "inventoryType", "stockCardNo", $stockCardNo); $inventoryLocation = $ro->selectNow("endingInventory", "inventoryLocation", "endingNo", $endingNo1); $supplier = $ro4->selectLast("inventory", "supplier", "stockCardNo", $stockCardNo, "inventoryCode"); $dateAdded = date('Y-m-d'); $timeAdded = date('H:i:s'); $addedBy = $ro->selectNow("registeredUser", "username", "employeeID", $_SESSION['employeeID']); $beginningQTY = $totalEnding; $medicine = array("stockCardNo" => $stockCardNo, "genericName" => $genericName, "description" => $brandName, "preparation" => $preparation, "quantity" => $qty, "unitcost" => $unitcost, "opdPrice" => $opdPrice, "ipdPrice" => $ipdPrice, "expiration" => $expiration, "remarks" => $remarks, "locked" => $locked, "criticalLevel" => $criticalLevel, "inventoryType" => $inventoryType, "inventoryLocation" => $inventoryLocation, "supplier" => $supplier, "dateAdded" => $dateAdded, "timeAdded" => $timeAdded, "addedBy" => $addedBy, "beginningQTY" => $qty); $ro4->insertNow("inventory", $medicine); } else {
echo "<br>"; echo "lock: ".$lock; */ $counterDate = $ro->selectNow("counters", "counterdate", "id", "1"); $counter02 = $ro->selectNow("counters", "counter02", "id", "1"); $purchaseDate = date("Ymd"); if ($counterDate != $purchaseDate) { $ro->editNow("counters", "id", "1", "counter02", "0"); } else { $newCounter02 = $counter02 + 1; $ro->editNow("counters", "id", "1", "counter02", $newCounter02); } if ($counter02 < 10) { $refNo = $purchaseDate . "000" . $counter02; } else { if ($counter02 > 9 && $counter02 < 100) { $refNo = $purchaseDate . "00" . $counter02; } else { if ($counter02 > 99 && $counter02 < 1000) { $refNo = $purchaseDate . "0" . $counter02; } else { $refNo = $purchaseDate . $counter02; } } } $inventory = array("stockCardNo" => $stockCardNo, "description" => $brandName, "genericName" => $genericName, "preparation" => $preparation, "quantity" => $quantity + $freeGoods, "fgQuantity" => $freeGoods, "unitcost" => $unitcost, "opdPrice" => $opdPrice, "ipdPrice" => $ipdPrice, "expiration" => $expiration, "addedBy" => $ro->selectNow("registeredUser", "username", "employeeID", $_SESSION['employeeID']), "timeAdded" => date("H:i:s"), "dateAdded" => $dateAdded, "inventoryType" => "medicine", "inventoryLocation" => $inventoryLocation, "criticalLevel" => $criticalLevel, "supplier" => $supplier, "invoiceNo" => $invoiceNo, "remarks" => $remarks, "locked" => $lock, "autoDispense" => "no", "classification" => "inventory", "beginningQTY" => $quantity + $freeGoods); $ro4->insertNow("inventory", $inventory); //inventorycode nung last inserted $inventoryCode = $ro4->selectLast("inventory", "inventoryCode", "stockCardNo", $stockCardNo, "inventoryCode"); $salesInvoiceItem = array("refNo" => $refNo, "siNo" => $siNo, "inventoryCode" => $inventoryCode, "description" => $brandName, "unit" => $preparation, "unitPrice" => $unitcost, "quantity" => $quantity + $freeGoods, "fgquantity" => $freeGoods, "type" => "medicine", "status" => "Active", "encodedBy" => $ro->selectNow("registeredUser", "username", "employeeID", $_SESSION['employeeID']), "dateEncoded" => date("YmdHi")); $ro4->insertNow("salesInvoiceItems", $salesInvoiceItem);