public function indexAction() { $this->view->title = "View Loan"; $this->view->id = $offerproduct_id = (int) $this->_getParam('id'); $loan = new Loans_Model_Loan(); $result = $loan->viewLoanmy($offerproduct_id); $this->view->loan = $result; $offerproduct_id = $loan->getofferproductid($offerproduct_id); foreach ($offerproduct_id as $offerproduct_id) { $offerproduct_id = $offerproduct_id['id']; } $interest = new Loans_Model_Loan(); $result = $interest->viewLoan3($offerproduct_id); $this->view->interest = $result; }
public function loanseditAction() { $this->view->title = $this->view->translate("Edit loan"); $offerproduct_id = (int) $this->_getParam('id'); $this->view->offerproduct_id = $offerproduct_id; $loan = new Loans_Model_Loan(); $loanForm = new Loans_Form_Loan(); $this->view->form = $loanForm; $membertype_id = $this->view->adm->viewRecord("ourbank_master_membertypes", "id", "DESC"); foreach ($membertype_id as $membertype_id) { $loanForm->applicableto->addMultiOption($membertype_id['id'], $membertype_id['type']); } $product = new Loans_Model_Product(); $product = $product->fetchAllProductNames(); foreach ($product as $product) { $loanForm->product_id->addMultiOption($product['id'], $product['name']); } // // $glsubcode = $loan->fetchAllglsubcode('3');//ledgercode for assets // // foreach($glsubcode as $glsubcode) { // // $loanForm->glsubcode_id->addMultiOption($glsubcode['id'],$glsubcode['header']."[".$glsubcode['glsubcode']."]"); // // } // $glsubcode = $loan->fetchAllglsubcode('2');//ledger id for income 2 // foreach($glsubcode as $glsubcode) { // $loanForm->fee_glsubcode_id->addMultiOption($glsubcode['id'],$glsubcode['header']."[".$glsubcode['glsubcode']."]"); // $loanForm->interest_glsubcode_id->addMultiOption($glsubcode['id'],$glsubcode['header']."[".$glsubcode['glsubcode']."]"); // } $interesttype1 = $this->view->adm->viewRecord("ourbank_master_interesttypes", "id", "ASC"); foreach ($interesttype1 as $interesttypes) { $loanForm->interesttype_id->addMultiOption($interesttypes['id'], $interesttypes['description']); } $loan = new Loans_Model_Loan(); $result = $loan->viewLoanmy($offerproduct_id); $this->view->loan = $result; foreach ($this->view->loan as $loan) { $this->view->form->product_id->setValue($loan['productid']); $this->view->form->offerproductname->setValue($loan['productname']); $this->view->form->offerproductshortname->setValue($loan['productshortname']); $this->view->form->offerproduct_description->setValue($loan['productdescription']); $this->view->form->begindate->setValue($this->view->dateconvert->phpnormalformat($loan['begindate'])); $this->view->form->closedate->setValue($this->view->dateconvert->phpnormalformat($loan['closedate'])); $this->view->form->applicableto->setValue($loan['applicableto']); $this->view->form->minmumloanamount->setValue($loan['minmumloanamount']); $this->view->form->maximunloanamount->setValue($loan['maximunloanamount']); $this->view->form->minimumfrequency->setValue($loan['minimumfrequency']); $this->view->form->maximumfrequency->setValue($loan['maximumfrequency']); $this->view->form->penal_Interest->setValue($loan['penal_Interest']); // // $this->view->form->fee_glsubcode_id->setValue($loan['fee_glsubcode_id']); $this->view->form->graceperiodnumber->setValue($loan['graceperiodnumber']); // // // $this->view->form->glsubcode_id->setValue($loan['glsubcode_id']); $this->view->form->interesttype_id->setValue($loan['interesttype_id']); // // // $this->view->form->interest_glsubcode_id->setValue($loan['Interest_glsubcode_id']); $offerproduct_id = $loan['productsoffer_id']; } $interest = new Loans_Model_Interest(); $interestdeatils = $interest->Getinterestdetail($offerproduct_id); $this->view->interest1 = $interestdeatils; $loanForm->offerproductname->removeValidator('Db_NoRecordExists'); $loanForm->offerproductshortname->removeValidator('Db_NoRecordExists'); if ($this->_request->isPost() && $this->_request->getPost('Update')) { if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($loanForm->isValid($formData)) { $loan = new Loans_Model_Loan(); $product_id = $this->_request->getParam('product_id'); $offerproductname = $this->_request->getParam('offerproductname'); $offerproductshortname = $this->_request->getParam('offerproductshortname'); $offerproduct_description = $this->_request->getParam('offerproduct_description'); $begindate = $this->view->dateconvert->phpmysqlformat($this->_request->getParam('begindate')); $closedate = $this->view->dateconvert->phpmysqlformat($this->_request->getParam('closedate')); $applicableto = $this->_request->getParam('applicableto'); $minmumloanamount = $this->_request->getParam('minmumloanamount'); $maximunloanamount = $this->_request->getParam('maximunloanamount'); $minimumfrequency = $this->_request->getParam('minimumfrequency'); $maximumfrequency = $this->_request->getParam('maximumfrequency'); $penal_Interest = $this->_request->getParam('penal_Interest'); $graceperiodnumber = $this->_request->getParam('graceperiodnumber'); // $glsubcode_id = $this->_request->getParam('glsubcode_id'); // $interesttype_id = $this->_request->getParam('interesttype_id'); $productnamedetails = $this->view->adm->editRecord('ourbank_product', $product_id); foreach ($productnamedetails as $productnamedetails) { $productname = $productnamedetails['name']; } $applicabletodetails = $loan->viewappliesto($applicableto); foreach ($applicabletodetails as $applicabletodetails) { $appliesto = $applicabletodetails['type']; } $result = $loan->viewLoanmy($offerproduct_id); $this->view->loan = $result; foreach ($this->view->loan as $loan) { $productnameold = $loan['productname1']; $offerproductnameold = $loan['productname']; $offerproductshortnameold = $loan['productshortname']; $offerproduct_descriptionold = $loan['productdescription']; $begindateold = $loan['begindate']; $closedateold = $loan['closedate']; $appliestoold = $loan['type']; $minmumloanamountold = $loan['minmumloanamount']; $maximunloanamountold = $loan['maximunloanamount']; $minimumfrequencyold = $loan['minimumfrequency']; $maximumfrequencyold = $loan['maximumfrequency']; $penal_Interestold = $loan['penal_Interest']; $graceperiodnumberold = $loan['graceperiodnumber']; // $glsubcode_idold=$loan['glsubcode_id']; // $interesttype_idold=$loan['interesttype_id']; } $updateOldloan = array('productname' => $productnameold, 'offerproductname' => $offerproductnameold, 'offerproductshortname' => $offerproductshortnameold, 'offerproduct_description' => $offerproduct_descriptionold, 'begindate' => $begindateold, 'closedate' => $closedateold, 'membertype' => $appliestoold, 'minmumloanamount' => $minmumloanamountold, 'maximunloanamount' => $maximunloanamountold, 'minimumfrequency' => $minimumfrequencyold, 'maximumfrequency' => $maximumfrequencyold, 'penal_Interest' => $penal_Interestold, 'graceperiodnumber' => $graceperiodnumberold); $updateNewloan = array('productname' => $productname, 'offerproductname' => $offerproductname, 'offerproductshortname' => $offerproductshortname, 'offerproduct_description' => $offerproduct_description, 'begindate' => $begindate, 'closedate' => $closedate, 'membertype' => $appliesto, 'minmumloanamount' => $minmumloanamount, 'maximunloanamount' => $maximunloanamount, 'minimumfrequency' => $minimumfrequency, 'maximumfrequency' => $maximumfrequency, 'penal_Interest' => $penal_Interest, 'graceperiodnumber' => $graceperiodnumber); $match = array(); foreach ($updateOldloan as $key => $val) { if ($val != $updateNewloan[$key]) { $match[] = $key; } } if (count($match) <= 0) { /** if the values are not changed */ echo "Values are not changed in form"; } else { if ($begindate > $closedate) { $this->view->datesinfo = "Closed date must be grater than beging date" . -$begindate; } elseif ($minmumloanamount > $maximunloanamount) { $this->view->amounts = "Max amount must be grater than min amount" . -$minmumloanamount; } elseif ($minimumfrequency > $maximumfrequency) { $this->view->freequency = "Maximum freequency must be grate than min freequency" . -$minimumfrequency; } else { $adm = new App_Model_Adm(); $glcodes = $adm->getsingleRecord('ourbank_productsoffer', 'glsubcode_id', 'id', $offerproduct_id); //Insert old data to productsofferlog $productoffer = $this->view->adm->editRecord('ourbank_productsoffer', $offerproduct_id); $this->view->adm->addRecord('ourbank_productsoffer_log', $productoffer[0]); //Insert old data to productsloanlog $loan = new Loans_Model_Loan(); $productloan = new Loans_Model_Productsloan(); $productsloan = $loan->fetchProductloan1('ourbank_productsloan', $offerproduct_id); $this->view->adm->addRecord('ourbank_productsloan_log', $productsloan[0]); //edit current table values $loan->editOffer('ourbank_productsoffer', $formData, $offerproduct_id, $glcodes); $productloan->editLoan('ourbank_productsloan', $formData, $offerproduct_id); //fetch interest rates for offerproduct_id $interestdetails = $loan->fetchProductloan('ourbank_interest_periods', $offerproduct_id); foreach ($interestdetails as $interestdetails1) { $interestdetails1['record_id'] = ''; $loan->insertRow5('ourbank_interest_periods_log', $interestdetails1); } } $loan->deleteRecord('ourbank_interest_periods', 'offerproduct_id', $offerproduct_id); echo $count1 = $this->_request->getParam('count1'); for ($i = 1; $i <= $count1; $i++) { if ($this->_request->getParam('period_ofrange_monthfrom' . $i)) { $period_ofrange_monthfrom = $this->_request->getParam('period_ofrange_monthfrom' . $i); $period_ofrange_monthto = $this->_request->getParam('period_ofrange_monthto' . $i); $Interest = $this->_request->getParam('Interest' . $i); $period_ofrange_description = $period_ofrange_monthfrom . -$period_ofrange_monthto; $loan->insertRow5('ourbank_interest_periods', array('period_ofrange_monthfrom' => $period_ofrange_monthfrom, 'period_ofrange_monthto' => $period_ofrange_monthto, 'period_ofrange_description' => $period_ofrange_description, 'offerproduct_id' => $offerproduct_id, 'Interest' => $Interest, 'intereststatus_id' => 3)); } } echo $memberCount = $this->_request->getParam('id'); for ($i = $count1 + 1; $i <= $memberCount; $i++) { $From = $this->_request->getParam('from' . $i); $To = $this->_request->getParam('to' . $i); $Rate = $this->_request->getParam('rate' . $i); $period_ofrange_description = $From . -$To; if ($From) { $loan->insertRow5('ourbank_interest_periods', array('period_ofrange_monthfrom' => $From, 'period_ofrange_monthto' => $To, 'period_ofrange_description' => $period_ofrange_description, 'offerproduct_id' => $offerproduct_id, 'Interest' => $Rate, 'intereststatus_id' => 3)); } } $this->_redirect('loans/index'); } } } } }