} catch (fExpectedException $e) { echo $e->printMessage(); } } else { if ($_POST['type'] == "count") { $records = Material_transfer::findCurrentMonth($_POST['branch']); echo sprintf("%03d", $records->count() + 1); } else { if ($_POST['type'] == "transit") { try { $mattrans_detail = new Material_transfer_detail($_POST['key']); $mattrans = new Material_transfer($mattrans_detail->getDocNumber()); if ($mattrans_detail->getStatus() != "pending") { throw new fProgrammerException('Status Overidden: ' . $mattrans_detail->getStatus()); } Inv_stock::transitStock($mattrans_detail->getItemId(), $mattrans->getBranchFrom(), $mattrans_detail->getQuantity()); $mattrans_detail->setStatus("transit"); $mattrans_detail->setApprover($_POST['user']); $mattrans_detail->store(); $mat_details = Material_transfer_detail::findDetail($mattrans->getDocNumber()); foreach ($mat_details as $mat_detail) { if ($mat_detail->getStatus() == "completed") { $mattrans->setStatus("completed"); } else { $mattrans->setStatus("pending"); } } $mattrans->store(); } catch (fExpectedException $e) { echo $e->printMessage(); }