$_SESSION['account-transaction'] = null; $_SESSION['account-transaction-list'] = array(); // Delete // if ($req->getPost('c') == 'Delete') { // $aje = new AccountJournalEntry($id); // $aje->delete(); // $this->_s->info = 'Journal Entry #' . $id . ' deleted'; // $this->redirect('/account/ledger'); // } // $this->_d->beginTransaction(); $aje = new AccountJournalEntry($id); $aje['auth_user_id'] = $_SESSION['uid']; $aje['date'] = $_POST['date']; $aje['note'] = $_POST['note']; $aje['kind'] = $_POST['kind']; $aje->save(); $_SESSION['account-transaction'] = $aje; // $this->_s->AccountJournalEntry->date = $this->_request->getPost('date'); // Was throwing and __PHP_INcomplete_Class error ? // $_SESSION['account']['date'] = $_POST['date']; // And Make the Wizard // $awj = AccountWizardJournal::makeFromAccountJournal($aje); if ($id) { Session::flash('info', 'Account Journal Entry #' . $id . ' updated'); } else { Session::flash('info', 'Account Journal Entry #' . $aje['id'] . ' created'); } // Save Ledger Entries foreach ($_POST as $k => $v) { // Trigger process only when matchin this if (!preg_match('/^(\\d+)_id$/', $k, $m)) {
} // Skip Entries Missing Date (or the last of the count) if (empty($_POST['date'])) { header('HTTP/1.1 400 Bad Request', true, 400); die(json_encode(array('status' => 'failure', 'detail' => 'Invalid Date'))); } // Journal Entry $je = new AccountJournalEntry(); $je['auth_user_id'] = $_SESSION['uid']; $je['date'] = $_POST['date']; // $req->getPost('date'); $je['note'] = $_POST['note']; // $req->getPost('note'); $je['kind'] = 'N'; // $req->getPost('kind'); $je->save(); // Debit Side $dr = new AccountLedgerEntry(); $dr['auth_user_id'] = $_SESSION['uid']; $dr['account_journal_id'] = $je['id']; // Credit Side $cr = new AccountLedgerEntry(); $cr['auth_user_id'] = $_SESSION['uid']; $cr['account_journal_id'] = $je['id']; if (!empty($_POST['cr'])) { // Credit to the Upload Target Account $cr['account_id'] = $_ENV['upload_account_id']; $cr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['cr'])); $dr['account_id'] = $_POST['offset_account_id']; $dr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['cr'])) * -1; } elseif (!empty($_POST['dr'])) {