} } catch (fExpectedException $e) { echo $e->printMessage(); $error = true; } } } } } catch (fExpectedException $e) { echo $e->printMessage(); $error = true; } } else { if ($_POST['type'] == "count") { //$records = Good_receipt_note::findAll(); $records = Good_receipt_note::findCurrentMonth($_POST['branch']); echo sprintf("%03d", $records->count() + 1); } else { if ($_POST['type'] == "deleteDetail") { Good_receipt_note_detail::deleteDetail($_POST['key']); } else { if ($_POST['type'] == "json") { $grn_details = Good_receipt_note_detail::findDetail($_POST['key']); echo $grn_details->toJSON(); } else { if ($_POST['type'] == "save") { try { $grn = new Good_receipt_note($_POST['doc_number']); $grn->populate(); if (!$error) { $grn->store();