public function actionEmi() { $emi = ''; $loan = new Loan(); $emiData = array('amount' => '', 'interest' => '', 'year' => '', 'month' => '', 'type' => ''); if (isset($_POST['emi'])) { $year = ''; $months = ''; $amount = $_POST['amt']; $interest = $_POST['interest']; $year = $_POST['years']; $month = $year * 12; $interest_div = $interest / 1200; $top = $amount * $interest_div * pow(1 + $interest_div, $month); $bottom = pow(1 + $interest_div, $month) - 1; $emi = $top / $bottom; $emi = round($emi, 2); if ($_POST['type'] == 'years') { $emi = 12 * $emi; } $emiData = array('amount' => $amount, 'interest' => $interest, 'year' => $year, 'type' => $_POST['type']); } if (isset($_POST['loan'])) { $loan->attributes = $_POST['Loan']; if ($loan->validate()) { if ($loan->save()) { Yii::app()->user->setFlash('success', 'Your Request For Loan has been submitted'); $this->redirect('/emi'); } else { Yii::app()->user->setFlash('error', 'Your Request For Loan not submitted.Please <a href="/emi">retry</a>'); } } } $this->render('emi', array('emi' => $emi, 'loan' => $loan, 'emiData' => $emiData)); }
/** * GPS安装 */ public function gpsAction() { if ($this->isAjax()) { $data = $this->request->getPost(); $uid = $data['uid']; !$uid and $this->error('参数错误'); $data['gps'] = 1; $model = new LoanForm('gps'); if ($result = $model->validate($data)) { if ($model->sign()) { Log::add($uid, $this->getOperatorId(), \App\Config\Log::loanOperate('gps')); $this->success('操作成功'); } else { $this->error('操作失败'); } } else { $this->error('验证失败'); } exit; } $uid = $this->urlParam(); empty($uid) and $this->pageError('param'); $loan = Loan::findByUid($uid); $user = User::findFirst($uid)->toArray(); $this->view->setVars(['loan' => $loan, 'user' => $user]); $this->view->pick('afterrc/detail'); }
public function detailAction() { $uid = $this->urlParam(); empty($uid) and $this->pageError('param'); $loan = Loan::findByUid($uid); $user = User::findFirst($uid)->toArray(); $this->view->setVars(['loan' => $loan, 'user' => $user]); }
public static function findByUid($uid) { $uid = intval($uid); $info = LoanSketch::findFirst("uid={$uid}"); if (!$info) { return false; } return Loan::format([$info->toArray()])[0]; }
/** * 合同签署 */ public function signAction() { if ($this->isAjax()) { $data = $this->request->getPost(); $uid = $data['uid']; !$uid and $this->error('参数错误'); $data['begintime'] = strtotime(date('Y-m-d 23:59:59', time())); //还款开始时间,签署合同当天23:59:59秒计时 //$data['status'] = \App\LoanStatus::getStatusRepay(); $data['return_num'] = 0; $data['return_amount'] = 0; $data['last_repay_time'] = $data['begintime']; $data['next_repay_time'] = strtotime('+1 month', $data['begintime']); $data['endtime'] = 0; $model = new LoanForm('contractSign'); if ($result = $model->validate($data)) { if ($model->sign()) { Log::add($data['uid'], $this->getOperatorId(), \App\Config\Log::loanOperate('sign')); $this->success('操作成功'); } else { $this->error('操作失败'); } } else { $this->error('验证失败'); } exit; } $uid = $this->urlParam(); empty($uid) and $this->pageError('param'); $loan = Loan::findByUid($uid); $user = User::findFirst($uid)->toArray(); $this->view->setVars(['loan' => $loan, 'user' => $user]); $this->view->pick('afterrc/detail'); }
require_once DOL_DOCUMENT_ROOT . '/core/lib/loan.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $langs->load("compta"); $langs->load("bills"); $langs->load("loan"); $id = GETPOST('id', 'int'); $action = GETPOST('action'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'alpha'); // Security check $socid = GETPOST('socid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'loan', $id, '', ''); $object = new Loan($db); /* * Actions */ // Classify paid if ($action == 'confirm_paid' && $confirm == 'yes') { $object->fetch($id); $result = $object->set_paid($user); if ($result > 0) { setEventMessage($langs->trans('LoanPaid')); } else { setEventMessage($loan->error, 'errors'); } } // Delete loan if ($action == 'confirm_delete' && $confirm == 'yes') {
public function getCMSFields() { $fields = parent::getCMSFields(); if ($this->ID) { Session::set("FamilyID", $this->ID); } $nameField = TextField::create('Name', 'Family Name'); $fields->replaceField('Name', $nameField); $houseNoField = TextField::create('HouseNo', 'House No (govt)'); $fields->replaceField('HouseNo', $houseNoField); $parishes = Parish::get()->map('ID', 'NameWithLocation')->toArray(); $parishField = DropdownField::create('ParishID', 'Parish')->setSource($parishes); $parishField->setEmptyString('select...'); $fields->replaceField('ParishID', $parishField); //remove FamilyMembers tab $fields->removeByName('FamilyMembers'); $memberGridFieldConfig = GridFieldConfig_RecordEditor::create(); $familyMemberList = FamilyMember::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); $familyMemberGridField = new GridField('Members', 'Family members', $familyMemberList, $memberGridFieldConfig); $fields->addFieldsToTab('Root.Members', array($familyMemberGridField)); //house gridfield $houseGridFeildConfig = GridFieldConfig_RecordEditor::create(); $houseList = House::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($houseList->count()) { $houseGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $houseGridField = new GridField('House', 'House', $houseList, $houseGridFeildConfig); $fields->addFieldsToTab('Root.Housing', array($houseGridField)); //land gridfield $landGridFeildConfig = GridFieldConfig_RecordEditor::create(); $landList = Land::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($landList->count()) { $landGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $landGridField = new GridField('Land', 'Land', $landList, $landGridFeildConfig); $fields->addFieldsToTab('Root.Housing', array($landGridField)); //ShiftedFrom gridfield $shiftedFromGridFeildConfig = GridFieldConfig_RecordEditor::create(); $shiftedFromList = ShiftedFrom::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($shiftedFromList->count()) { $shiftedFromGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $shiftedFromGridField = new GridField('Shifted', 'Shifted', $shiftedFromList, $shiftedFromGridFeildConfig); $fields->addFieldsToTab('Root.Housing', array($shiftedFromGridField)); //Agriculture gridfield $agricultureGridFeildConfig = GridFieldConfig_RecordEditor::create(); $agricultureList = Agriculture::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($agricultureList->count()) { $agricultureGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $agricultureGridField = new GridField('Agriculture', 'Agriculture', $agricultureList, $agricultureGridFeildConfig); $fields->addFieldsToTab('Root.Occupation', array($agricultureGridField)); //Business gridfield $businessGridFeildConfig = GridFieldConfig_RecordEditor::create(); $businessList = Business::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($businessList->count()) { $businessGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $businessGridField = new GridField('Business', 'Business', $businessList, $businessGridFeildConfig); $fields->addFieldsToTab('Root.Occupation', array($businessGridField)); //MonthlyIncome gridfield $monthlyIncomeGridFeildConfig = GridFieldConfig_RecordEditor::create(); $monthlyIncomeList = MonthlyIncome::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($monthlyIncomeList->count()) { $monthlyIncomeGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $monthlyIncomeGridField = new GridField('MonthlyIncome', 'MonthlyIncome', $monthlyIncomeList, $monthlyIncomeGridFeildConfig); $fields->addFieldsToTab('Root.Monthly', array($monthlyIncomeGridField)); //MonthlyExpense gridfield $monthlyExpenseGridFeildConfig = GridFieldConfig_RecordEditor::create(); $monthlyExpenseList = MonthlyExpense::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($monthlyExpenseList->count()) { $monthlyExpenseGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $monthlyExpenseGridField = new GridField('MonthlyExpense', 'MonthlyExpense', $monthlyExpenseList, $monthlyExpenseGridFeildConfig); $fields->addFieldsToTab('Root.Monthly', array($monthlyExpenseGridField)); //Vehicle gridfield $vehicleGridFeildConfig = GridFieldConfig_RecordEditor::create(); $vehicleList = Vehicle::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($vehicleList->count()) { $vehicleGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $vehicleGridField = new GridField('Vehicle', 'Vehicle', $vehicleList, $vehicleGridFeildConfig); $fields->addFieldsToTab('Root.OtherDetails', array($vehicleGridField)); //Appliance gridfield $applianceGridFeildConfig = GridFieldConfig_RecordEditor::create(); $applianceList = Appliance::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($applianceList->count()) { $applianceGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $applianceGridField = new GridField('Appliance', 'Appliance', $applianceList, $applianceGridFeildConfig); $fields->addFieldsToTab('Root.OtherDetails', array($applianceGridField)); //OtherFacility gridfield $otherFacilityGridFeildConfig = GridFieldConfig_RecordEditor::create(); $otherFacilityList = OtherFacility::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($otherFacilityList->count()) { $otherFacilityGridFeildConfig->removeComponentsByType('GridFieldAddNewButton'); } $otherFacilityGridField = new GridField('OtherFacility', 'Other Facility', $otherFacilityList, $otherFacilityGridFeildConfig); $fields->addFieldsToTab('Root.OtherDetails', array($otherFacilityGridField)); //Media gridfield $mediaGridFieldConfig = GridFieldConfig_RecordEditor::create(); $mediaList = Media::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($mediaList->count()) { $mediaGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $mediaGridField = new GridField('Media', 'Media', $mediaList, $mediaGridFieldConfig); $fields->addFieldsToTab('Root.OtherDetails', array($mediaGridField)); //CatholicMagazine gridfield $catholicMagazineGridFieldConfig = GridFieldConfig_RecordEditor::create(); $catholicMagazineList = CatholicMagazine::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($catholicMagazineList->count()) { $catholicMagazineGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $catholicMagazineGridField = new GridField('CatholicMagazine', 'Catholic Magazine', $catholicMagazineList, $catholicMagazineGridFieldConfig); $fields->addFieldsToTab('Root.OtherDetails', array($catholicMagazineGridField)); //Loan gridfield $loanGridFieldConfig = GridFieldConfig_RecordEditor::create(); $loanList = Loan::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($loanList->count()) { $loanGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $loanGridField = new GridField('Loan', 'Loan', $loanList, $loanGridFieldConfig); $fields->addFieldsToTab('Root.Financial', array($loanGridField)); //Saving gridfield $savingGridFieldConfig = GridFieldConfig_RecordEditor::create(); $savingList = Saving::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($savingList->count()) { $savingGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $savingGridField = new GridField('Saving', 'Saving', $savingList, $savingGridFieldConfig); $fields->addFieldsToTab('Root.Financial', array($savingGridField)); //Talent gridfield $talentGridFieldConfig = GridFieldConfig_RecordEditor::create(); $talentList = Talent::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($talentList->count()) { $talentGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $talentGridField = new GridField('Talent', 'Talent', $talentList, $talentGridFieldConfig); $fields->addFieldsToTab('Root.Members', array($talentGridField)); //Contact gridfield $contactGridFieldConfig = GridFieldConfig_RecordEditor::create(); $contactList = Contact::get()->filter(array('FamilyID' => $this->ID))->sort('ID ASC'); // remove add button if record already exists if ($contactList->count()) { $contactGridFieldConfig->removeComponentsByType('GridFieldAddNewButton'); } $contactGridField = new GridField('Contact', 'Contact', $contactList, $contactGridFieldConfig); $fields->addFieldsToTab('Root.Contact', array($contactGridField)); return $fields; }
/** * 逾期还款操作 */ public function repayAction() { $data = $this->request->getPost(); empty($data['uid']) || empty($data['id']) || empty($data['date']) || empty($data['amount']) and $this->error('参数错误'); $data['status'] = 1; $data['date'] = strtotime($data['date']); $model = new RepayForm('repay'); if ($result = $model->validate($data)) { if ($model->repay()) { Loan::updateRepay($data['uid'], $data['amount'], $data['no'], $data['date']); $this->success('操作成功'); } else { $this->error('操作失败'); } } else { $this->error('验证失败'); } }
private function getUnactionedLoanCount() { $newLoans = Loan::where('status_id', 1)->get()->toArray(); foreach ($newLoans as $index => $loan) { $transactions = Transaction::where('loan_id', $loan['id'])->where('user_id', '!=', $loan['user_id'])->get()->toArray(); if (isset($transactions[0])) { // Remove this loan unset($newLoans[$index]); } } return array('unactionedLoanCount' => count($newLoans)); }
public function remit() { $uid = $this->data['uid']; return Loan::updateByUid($uid, $this->data); }
$langs->load("compta"); $langs->load("bills"); $langs->load("loan"); $id = GETPOST('id', 'int'); $action = GETPOST("action"); // Security check $socid = GETPOST('socid', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'loan', $id, '', ''); /* * View */ $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $langs->trans("Loan"), $help_url); if ($id > 0) { $loan = new Loan($db); $loan->fetch($id); $loan->info($id); $head = loan_prepare_head($loan); dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); print '<table width="100%"><tr><td>'; dol_print_object_info($loan); print '</td></tr></table>'; print '</div>'; } else { // $id ? } llxFooter(); $db->close();
} if (isset($_POST['return_transfer'])) { $transfer = Transfer::find_by_sql("SELECT * FROM transfers WHERE player = {$_GET['id']} AND returned = 0 ORDER BY start DESC"); if (isset($transfer[0])) { $transfer[0]->returned = time(); $transfer[0]->save(); } } if (isset($_POST['contFrom']) && isset($_POST['contTo'])) { $newCont = new Contract(); $newCont->set($_GET['id'], $_POST['team'], strtotime($_POST['contFrom']), strtotime($_POST['contTo'])); $newCont->save(); } if (isset($_POST['loanFrom']) && isset($_POST['loanTo'])) { $contractTeam = $player->find_contract_team(); $newLoan = new Loan(); $newLoan->set($_GET['id'], $contractTeam->id, $_POST['toteam'], strtotime($_POST['loanFrom']), strtotime($_POST['loanTo'])); $newLoan->save(); } if (isset($_POST['insTo'])) { $newIns = new Insurance(); $newIns->set($_GET['id'], strtotime($_POST['insTo'])); $newIns->save(); } if (isset($_POST['visaTo'])) { $newVisa = new Visa(); $newVisa->set($_GET['id'], strtotime($_POST['visaTo'])); $newVisa->save(); } if (isset($_POST['transFrom'])) { $newTrans = new Transfer();
public function getInfo($id) { return Loan::find($id); }
$sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } $object = new Loan($db); if ($id > 0) { $object->fetch($id); } $upload_dir = $conf->loan->dir_output . '/' . dol_sanitizeFileName($object->ref); $modulepart = 'loan'; /* * Actions */ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; /* * View */ $form = new Form($db); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("", $langs->trans("Loan"), $help_url);
/** * 获取贷款所有信息、全国风控提交之前的数据 */ public static function infos($uid, $level = '*') { $uid = intval($uid); $infos = []; $infos['user'] = self::findFirst("uid={$uid}")->toArray(); $isArray = is_array($level); $all = $level == '*'; if ($all || ($isArray and in_array('loansketch', $level))) { $infos['loansketch'] = LoanSketch::findByUid($uid); $infos['loansketch_advises'] = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'loansketch'); } //面审 if ($all || ($isArray and in_array('face', $level))) { $infos['face'] = Face::findByUid($uid); $infos['face_advises'] = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'face'); } //外访 if ($all || ($isArray and in_array('visit', $level))) { $infos['visit'] = Visit::findByUid($uid); $infos['visit_advises'] = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'visit'); } //车评 if ($all || ($isArray and in_array('car', $level))) { $infos['car'] = Car::findByUid($uid); $infos['car_advises'] = Advise::getAdvisesByUid($uid, Advise::STATUS_UNDO, 'car'); } if ($all || ($isArray and in_array('car_files', $level))) { $infos['car_files'] = Files::getFilesByUid($uid, \App\Config\Loan::uploadTypes('car')); } //贷款 if ($all || ($isArray and in_array('loan', $level))) { $infos['loan'] = Loan::findByUid($uid); } return $infos; }
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * \file htdocs/loan/note.php * \brief Tab for notes on loan * \ingroup loan */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/loan.lib.php'; $action = GETPOST('action'); $langs->load('loan'); // Security check $id = GETPOST('id', 'int'); $result = restrictedArea($user, 'loan', $id, '&loan'); $object = new Loan($db); if ($id > 0) { $object->fetch($id); } $permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php /* * Actions */ include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once /* * View */ $form = new Form($db); llxHeader('', $langs->trans("LoanArea") . ' - ' . $langs->trans("Notes"), '');
$action = 'addline'; } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline = new AccountLine($db); $result = $accline->fetch(GETPOST("rowid")); $result = $accline->delete(); } /* * View */ llxHeader('', $langs->trans("FinancialAccount") . '-' . $langs->trans("Transactions")); $societestatic = new Societe($db); $userstatic = new User($db); $chargestatic = new ChargeSociales($db); $loanstatic = new Loan($db); $memberstatic = new Adherent($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); $donstatic = new Don($db); $expensereportstatic = new ExpenseReport($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($vline) { $viewline = $vline; } else { $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT) ? 20 : $conf->global->MAIN_SIZE_LISTE_LIMIT;
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $fac->generateDocument($fac->modelpdf, $outputlangs); } } header('Location: card.php?id=' . $payment->id); exit; } else { setEventMessage($payment->error); $db->rollback(); } } /* * View */ llxHeader(); $loan = new Loan($db); $form = new Form($db); $h = 0; $head[$h][0] = DOL_URL_ROOT . '/loan/payment/card.php?id=' . $_GET["id"]; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment'); /* * Confirm deletion of the payment */ if ($action == 'delete') { print $form->formconfirm('card.php?id=' . $payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } /* * Confirm validation of the payment
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $filtre = GETPOST("filtre"); $optioncss = GETPOST('optioncss', 'alpha'); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_ref = ""; $search_label = ""; $search_amount = ""; } /* * View */ $loan_static = new Loan($db); llxHeader(); $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend,"; $sql .= " SUM(pl.amount_capital) as alreadypayed"; $sql .= " FROM " . MAIN_DB_PREFIX . "loan as l LEFT JOIN " . MAIN_DB_PREFIX . "payment_loan AS pl"; $sql .= " ON l.rowid = pl.fk_loan"; $sql .= " WHERE l.entity = " . $conf->entity; if ($search_amount) { $sql .= " AND l.capital='" . $db->escape(price2num(trim($search_amount))) . "'"; } if ($search_ref) { $sql .= " AND l.rowid = " . $db->escape($search_ref); } if ($search_label) { $sql .= " AND l.label LIKE '%" . $db->escape($search_label) . "%'"; }
public function isAuthorizedPersonForLoan(){ $id = $_GET['id']; $rtn = $this->isSUorAdmin(); if(!$rtn){ $model=Loan::model()->findByPk($id); if($model!==null){ $rtn = (!Yii::app()->user->isGuest && Yii::app()->user->person->id === $model->person_id); }else{ $rtn = false; } } return $rtn; }
*/ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT . '/loan/class/paymentloan.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $langs->load("bills"); $langs->load("loan"); $chid = GETPOST('id', 'int'); $action = GETPOST('action'); $cancel = GETPOST('cancel', 'alpha'); // Security check $socid = 0; if ($user->societe_id > 0) { $socid = $user->societe_id; } $loan = new Loan($db); $loan->fetch($chid); /* * Actions */ if ($action == 'add_payment') { $error = 0; if ($cancel) { $loc = DOL_URL_ROOT . '/loan/card.php?id=' . $chid; header("Location: " . $loc); exit; } $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (!GETPOST('paymenttype', 'int') > 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), 'errors'); $error++;
<?php /** * Created by PhpStorm. * User: pliski * Date: 25/11/2015 * Time: 17:42 */ namespace Lendinvest\Model; require_once 'app/Config/start.php'; //Instancing Loan and tranches $dateStart = new \DateTime("2015-10-01"); $dateEnd = new \DateTime("2015-11-15"); $loan = new Loan($dateStart, $dateEnd); $aParams = array('interest' => 3, 'maxAmount' => 1000); $loan->addTranche("TrancheA", $aParams); $aParams = array('interest' => 6, 'maxAmount' => 1000); $loan->addTranche("TrancheB", $aParams); //Investors $aInvestors = array(); for ($i = 1; $i <= 4; $i++) { $aInvestors[$i] = new Investor(1000, $i); } //Stream option $aInvestors[1]->addStream('Sms'); $aInvestors[2]->addStream('Sms'); $aInvestors[3]->addStream('eMail'); $aInvestors[4]->addStream('eMail'); //Investment $loan->invest($aInvestors[1], new \DateTime("2015-10-03"), "TrancheA", 1000);
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'library' TTransaction::open('library'); // get the form data into an active record Loan $data = $this->form->getData('Loan'); $msg = ''; $persisted_objects = TSession::getValue('checkin_objects'); if ($persisted_objects) { // iterate the collection of active records foreach ($persisted_objects as $object) { // add the object inside the datagrid $this->datagrid->addItem($object); $item = Item::newFromBarcode($object->barcode); if ($item->status_id == '2') { $loan = Loan::getFromBarcode($item->barcode); $loan->arrive_date = date('Y-m-d'); // store the item $item->status_id = '1'; $item->store(); // stores the loan $loan->store(); $msg .= "{$item->barcode} - " . _t('Success') . "<br>"; } else { $msg .= "{$item->barcode} - " . _t('Not checked out') . "<br>"; } } TSession::setValue('checkin_objects', NULL); // set the data back to the form $this->form->setData($object); // shows the success message new TMessage('info', $msg); } // close the transaction TTransaction::close(); // reload the listing $this->onReload(); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * @param Loan $loan **/ public function setLoan($loan) { $loan->addPayment($this); $this->loan = $loan; }
public static function infos($uid) { $infos = User::infos($uid); $infos['loan'] = Loan::findByUid($uid); return $infos; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Loan::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$total_pay = $total_interest + $loan_amount; echo "total:{$total_pay}, monthly:\n"; $month = 1; foreach ($month_pays as $month_pay) { echo "{$month}: {$month_pay['0']}+{$month_pay['1']} = " . ($month_pay[0] + $month_pay[1]) . "\n"; $month++; } } else { /* 等额本息 */ $month_roll_rate = pow(1 + $month_rate, $months); $month_pay = $loan_amount * $month_rate * $month_roll_rate / ($month_roll_rate - 1); $total_pay = $month_pay * $months; $month_pay = round($month_pay, 2); $total_pay = round($total_pay, 2); /* 每个月的多少利息多少本金显示 */ $returned_capital = 0; for ($i = 1; $i <= $months; $i++) { $month_interest = round(($loan_amount - $returned_capital) * $month_rate, 2); $month_capital = $month_pay - $month_interest; $returned_capital += $month_capital; echo "{$i}: {$month_pay} = {$month_capital} + {$month_interest}\n"; } echo "total:{$total_pay}, monthly:{$month_pay}*{$months}, rate:{$rate} month_rate:{$month_rate}, roll_rate:{$month_roll_rate}\n"; } } } $h1 = new HousePrice(313, true); #$h1->calculateDownPayment(); $loan = new Loan(1850000, 20); $loan->calculationMonthPayment(false); $loan->calculationMonthPayment(true);
public function adviseAction($uid) { $data = $this->request->getPost(); $adviseTypes = \App\Config\Loan::adviseTypes(); $adviseType = $data['advisetype']; $reason = $data['reason']; if (!array_key_exists($adviseType, $adviseTypes) || empty($reason)) { $this->error('参数错误'); } $foid = $this->getOperatorId(); if (Loan::advise($uid, $foid, $adviseType, $reason)) { $this->success('操作成功'); } $this->error('操作失败'); }
/** * 确认放款 */ public function confirmAction($uid) { if ($this->isAjax()) { !$uid and $this->error('参数错误'); if (Loan::updateStatus($uid, \App\LoanStatus::getStatusRunConfirm())) { Log::add($uid, $this->getOperatorId(), \App\Config\Log::loanOperate('runconfirm')); $this->success('操作成功'); } $this->error('操作失败'); } $loan = Loan::findByUid($uid); $user = User::findFirst($uid)->toArray(); $this->view->setVars(['loan' => $loan, 'user' => $user]); $this->view->pick('run/detail'); }