public function post_id_principal_term_rate_loandate_handler() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $model = new GumLoanAccountsModel($dbc); $existing_accounts = array(); $next_account = 1; $model->card_no($this->id); foreach ($model->find() as $obj) { $existing_accounts[] = $obj->accountNumber(); $next_account++; } $new = sprintf("%09d-%03d", $this->id, $next_account); while (in_array($new, $existing_accounts)) { $next_account++; $new = sprintf("%09d-%03d", $this->id, $next_account); } $model->accountNumber($new); $model->loanDate($this->loandate); $model->principal($this->principal); $model->termInMonths($this->term); $model->interestRate($this->rate / 100.0); $newid = $model->save(); $model->gumLoanAccountID($newid); $model->accountNumber($new); $model->load(); $emp = GumLib::getSetting('emp_no', 1001); $reg = GumLib::getSetting('register_no', 30); $dept = GumLib::getSetting('loanPosDept', 993); $desc = GumLib::getSetting('loanDescription', 'Member Loan'); $offset = GumLib::getSetting('offsetPosDept', 800); $bridge = GumLib::getSetting('posLayer', 'GumCoreLayer'); if (class_exists($bridge)) { $line1 = array('department' => $dept, 'description' => $desc, 'amount' => $model->principal(), 'card_no' => $model->card_no()); $line2 = array('department' => $offset, 'description' => 'OFFSET ' . $desc, 'amount' => -1 * $model->principal(), 'card_no' => $model->card_no()); $trans_identifier = $bridge::writeTransaction($emp, $reg, array($line1, $line2)); if ($trans_identifier !== true && $trans_identifier !== false) { $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $ledger = new GumLoanLedgerModel($dbc); $ledger->accountNumber($model->accountNumber()); $ledger->amount($model->principal()); $ledger->tdate(date('Y-m-d H:i:s')); $ledger->trans_num($trans_identifier); $ledger->save(); } } header('Location: GumMainPage.php?id=' . $this->id); return false; }
public function get_id_handler() { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $bridge = GumLib::getSetting('posLayer'); $this->custdata = $bridge::getCustdata($this->id); $this->meminfo = $bridge::getMeminfo($this->id); // bridge may change selected database $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']); $this->maillog = new GumEmailLogModel($dbc); $this->maillog->card_no($this->id); $this->loans = array(); $model = new GumLoanAccountsModel($dbc); $model->card_no($this->id); foreach ($model->find('loanDate') as $obj) { $this->loans[] = $obj; } $this->equity = array(); $model = new GumEquitySharesModel($dbc); $model->card_no($this->id); foreach ($model->find('tdate') as $obj) { $this->equity[] = $obj; } $this->dividends = array(); $model = new GumDividendsModel($dbc); $model->card_no($this->id); foreach ($model->find('yearEndDate') as $obj) { $this->dividends[] = $obj; } $this->settings = new GumSettingsModel($dbc); return true; }