public function backupAction() { header('content-type: text/html; charset=utf8'); $db = new Setting_Model_DbTable_DbLabel(); $data = $db->getAllSystemSetting(); $this->view->data = $data; //Application_Form_FrmMessage::Sucessfull('ទិន្នន័យត្រូវបានរក្សាទុក ដោយជោគជ័យ ','/setting/Database'); }
public function indexAction() { $db = new Setting_Model_DbTable_DbLabel(); $data = $db->getAllSystemSetting(); $this->view->data = $data; if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); try { $db = $db->updateKeyCode($post, $data); Application_Form_FrmMessage::Sucessfull('ការកែប្រែជោគជ័យ', '/setting/setting'); } catch (Exception $e) { $this->view->msg = 'ការបញ្ចូលមិនជោគជ័យ'; } } }
function addAction() { if($this->getRequest()->isPost()){ $_data = $this->getRequest()->getPost(); try { $db = new Loan_Model_DbTable_DbLoanGroup(); $db->addNewLoanGroup($_data); if(!empty($_data['saveclose'])){ Application_Form_FrmMessage::Sucessfull("INSERT_SUCCESS","/loan/GroupDisburse/index"); }else{ Application_Form_FrmMessage::message("INSERT_SUCCESS"); } }catch (Exception $e) { Application_Form_FrmMessage::message("INSERT_FAIL"); $err =$e->getMessage(); Application_Model_DbTable_DbUserLog::writeMessageError($err); } } $frm = new Loan_Form_FrmLoan(); $frm_loan=$frm->FrmAddLoan(); Application_Model_Decorator::removeAllDecorator($frm_loan); $this->view->frm_loan = $frm_loan; $frmpopup = new Application_Form_FrmPopupGlobal(); $this->view->frmpupoploantype = $frmpopup->frmPopupLoanTye(); $this->view->frmPopupZone = $frmpopup->frmPopupZone(); $db_option = new Application_Model_GlobalClass(); $this->view->member_option = $db_option->getAllClientGroupOption(); $this->view->code_option = $db_option->getAllClientCodeOption(); $db = new Setting_Model_DbTable_DbLabel(); $this->view->setting=$db->getAllSystemSetting(); // $this->view->frmPopupCommune = $frmpopup->frmPopupCommune(); // $this->view->frmPopupDistrict = $frmpopup->frmPopupDistrict(); // $this->view->frmPopupVillage = $frmpopup->frmPopupVillage(); // $this->view->frmpupopclient = $frmpopup->frmPopupClient(); // $this->view->frmPopupCO = $frmpopup->frmPopupCO(); }
public function addRepayMentSchedule($data){ $db = $this->getAdapter(); $db->beginTransaction(); try{ $arr_update = array( 'is_reschedule'=>1 ); $where = ' status = 1 AND g_id = '.$data['group_id']; $this->update($arr_update, $where); $session_transfer=new Zend_Session_Namespace(); $session_user=new Zend_Session_Namespace('auth'); $user_id = $session_user->user_id; $this->_name = 'ln_loan_member'; $where = ' is_completed = 0 AND status = 1 AND group_id = '.$data['group_id'].' AND client_id = '.$data["member"]; $this->update($arr_update, $where); $this->_name='ln_loan_group'; $datagroup = array( 'group_id'=>$data['member'], 'co_id'=>$data['co_id'], 'zone_id'=>$data['zone'], 'level'=>$data['level'], 'date_release'=>$data['release_date'], 'date_line'=>$data['date_line'], 'create_date'=>date("Y-m-d"), 'branch_id'=>$data['branch_id'], 'total_duration'=>$data['period'], 'first_payment'=>$data['first_payment'], 'time_collect'=>$data['time'], 'pay_term'=>$data['pay_every'], 'payment_method'=>$data['repayment_method'], 'holiday'=>$data['every_payamount'], 'is_renew'=>1, 'loan_type'=>1, 'collect_typeterm'=>$data['collect_termtype'], 'for_loantype'=>$data['loan_type'], 'is_reschedule'=>2, 'reschedule_opt'=>$data['reschedule_opt'], 'user_id'=>$user_id, ); $g_id = $this->insert($datagroup);//add group loan unset($datagroup); //reschedule_postfix $dbsetting = new Setting_Model_DbTable_DbLabel(); $array = $dbsetting->getAllSystemSetting(); $arr = array( 're_loan_number'=>$data['loan_code'].$array['reschedule_postfix'], 'loan_number'=>$data['loan_code'], 'reschedule_date'=>$data['release_date'], 're_amount'=>$data['total_amount'], 're_interest_rate'=>$data['interest_rate'], 'maturity'=>$data['date_line'], 're_payment_method'=>$data['repayment_method'], 'user_id'=>$user_id, ); $this->_name="ln_reschedule"; $this->insert($arr); $datamember = array( 'group_id'=>$g_id, 'loan_number'=>$data['loan_code'].$array['reschedule_postfix'], 'client_id'=>$data['member'], 'payment_method'=>$data['repayment_method'], 'currency_type'=>$data['currency_type'], 'total_capital'=>$data['total_amount'],//$data[''], 'admin_fee'=>$data['loan_fee'], 'other_fee'=>$data['other_fee'], 'interest_rate'=>$data['interest_rate'], 'status'=>1, 'is_completed'=>0, 'branch_id'=>$data['branch_id'], //'pay_before'=>$data['pay_before'], 'pay_after'=>$data['pay_late'], 'graice_period'=>$data['graice_pariod'], 'amount_collect_principal'=>$data['amount_collect'], 'collect_typeterm'=>$data['collect_termtype'], 'semi'=>$data['amount_collect_pricipal'], 'is_reschedule'=>2, ); $this->_name='ln_loan_member'; $member_id = $this->insert($datamember);//add member loan unset($datamember); // $arr =array( // 'branch_id'=>$data['branch_id'], // 'receipt_number'=>$data['loan_code'], // 'date'=>$data['release_date'], // 'create_date'=>date('Y-m-d'), // 'note'=>'from loan disburse', // 'from_location'=>1, // 'user_id'=>$this->getUserId(), // 'balance'=>$data['total_amount'], // 'loan_fee'=>$data['loan_fee'], // 'client_id'=>$data['member'], // 'currency_type'=>$data['currency_type'] // ); // // $this->insert($arr); // // unset($arr); // $db_j = new Accounting_Model_DbTable_DbJournal(); // $jur_id = $db_j->addTransactionJournal($arr); $remain_principal = $data['total_amount']; $next_payment = $data['first_payment']; $start_date = $data['release_date'];//loan release; // $next_payment = $start_date; $old_remain_principal = 0; $old_pri_permonth = 0; $old_interest_paymonth = 0; $old_amount_day = 0; $amount_collect = 1; $ispay_principal=2;//for payment type = 5; $is_subremain = 2; $curr_type = $data['currency_type']; //for IRR method if($data['repayment_method']==6){ $term_install = $data['period']; $loan_amount = $data['total_amount']; $total_loan_amount = $loan_amount+($loan_amount*$data['interest_rate']/100*$term_install); $irr_interest = $this->calCulateIRR($total_loan_amount,$loan_amount,$term_install,$curr_type); } //end IRR method $this->_name='ln_loanmember_funddetail'; $dbtable = new Application_Model_DbTable_DbGlobal(); $borrow_term = $dbtable->getSubDaysByPaymentTerm($data['pay_every'],null);//return amount day for payterm $amount_borrow_term = $borrow_term*$data['period'];//amount of borrow $fund_term = $dbtable->getSubDaysByPaymentTerm($data['collect_termtype'],null);//return amount day for payterm $amount_fund_term = $fund_term*$data['amount_collect']; $loop_payment = ($amount_borrow_term)/($amount_fund_term); $payment_method = $data['repayment_method']; // for($i=1;$i<=($data['period']/$data['amount_collect']);$i++){ for($i=1;$i<=$loop_payment;$i++){ $amount_collect = $data['amount_collect']; $day_perterm = $dbtable->getSubDaysByPaymentTerm($data['collect_termtype'],$amount_collect);//return amount day for payterm $str_next = $dbtable->getNextDateById($data['collect_termtype'],$data['amount_collect']);//for next,day,week,month; if($payment_method==1){//decline//completed // $pri_permonth = ($data['total_amount']/($data['period']-$data['graice_pariod'])*$amount_collect); $pri_permonth = $data['total_amount']/(($amount_borrow_term-($data['graice_pariod']*$borrow_term))/$amount_fund_term); $pri_permonth = $this->round_up_currency($curr_type, $pri_permonth); if($i*$amount_collect<=$data['graice_pariod']){//check here//for graice period $pri_permonth = 0; } if($i!=1){ if($data['graice_pariod']!=0){//if collect =1 not other check if($i*$amount_collect>$data['graice_pariod']+$amount_collect){//not wright $remain_principal = $remain_principal-$pri_permonth; }else{ } }else{ $remain_principal = $remain_principal-$pri_permonth;//OSប្រាក់ដើមគ្រា} } if($i==$loop_payment){//check condition here//for end of record only // echo $remain_principal; $pri_permonth = $data['total_amount']-$pri_permonth*($i-(($data['graice_pariod']/$amount_collect)+1));//code error here } $start_date = $next_payment; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount'],$data['first_payment']); $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $remain_principal*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = $remain_principal*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm); }else{ $next_payment = $data['first_payment']; $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $remain_principal*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = $data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm); } }elseif($payment_method==2){//baloon $pri_permonth=0; if(($i*$amount_fund_term)==$amount_borrow_term){//check here $pri_permonth = ($curr_type==1)?round($data['total_amount'],-2):$data['total_amount']; $pri_permonth =$this->round_up_currency($curr_type, $pri_permonth); $remain_principal = $pri_permonth;//$remain_principal-$pri_permonth;//OSប្រាក់ដើមគ្រា } if($i!=1){ $start_date = $next_payment; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount'],$data['first_payment']); $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); }else{ $next_payment = $data['first_payment']; $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); } $interest_paymonth = $data['total_amount']*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = $data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm); }elseif($payment_method==3){//fixed rate $pri_permonth = ($data['total_amount']/($amount_borrow_term/$amount_fund_term)); $pri_permonth =$this->round_up_currency($curr_type,$pri_permonth); if($i!=1){ $remain_principal = $remain_principal-$pri_permonth;//OSប្រាក់ដើមគ្រា if($i==$loop_payment){//for end of record only $pri_permonth = $remain_principal; } $start_date = $next_payment; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount'],$data['first_payment']); }else{ $next_payment = $data['first_payment']; } $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $data['total_amount']*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = $data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($day_perterm/$day_perterm); }elseif($payment_method==4){//fixed payment full last period yes if($i!=1){ $remain_principal = $remain_principal-$pri_permonth;//OSប្រាក់ដើមគ្រា $start_date = $next_payment; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount'],$data['first_payment']); // $interest_paymonth = $data['total_amount']*($data['interest_rate']/100)*($amount_day/$day_perterm); }else{ $next_payment = $data['first_payment']; } $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $remain_principal*($data['interest_rate']/100/$borrow_term)*$amount_day; $interest_paymonth = $this->round_up_currency($curr_type, $interest_paymonth); $pri_permonth = $data['amount_collect_pricipal']-$interest_paymonth; if($i==$loop_payment){//for end of record only $pri_permonth = $remain_principal; } }elseif($payment_method==5){//semi baloon//ok if($i!=1){ $ispay_principal++; $is_subremain++; $pri_permonth=0; if(($is_subremain-1)==$data['amount_collect_pricipal']){ $pri_permonth = ($data['total_amount']/$data['period'])*$data['amount_collect_pricipal']; $pri_permonth = $this->round_up_currency($curr_type, $pri_permonth); $is_subremain=1; } if(($ispay_principal-1)==$data['amount_collect_pricipal']+1){ $remain_principal = $remain_principal-($data['total_amount']/$data['period'])*$data['amount_collect_pricipal']; $ispay_principal=2; } if($i==$loop_payment){//check condition here//for end of record only $pri_permonth = $remain_principal; } $start_date = $next_payment; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount'],$data['first_payment']); $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $remain_principal*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($remain_principal*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($day_perterm/$day_perterm)); }else{ $pri_permonth = 0;//check if get pri first too much change; $next_payment = $data['first_payment']; $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $data['total_amount']*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($day_perterm/$day_perterm)); } }else{// fixed payment with fixed rate if($i!=1){ $remain_principal = $remain_principal-$pri_permonth; $next_payment = $dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount']); $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $this->round_up_currency($curr_type,$remain_principal*$irr_interest); $fixed_principal = round($total_loan_amount/$term_install,0, PHP_ROUND_HALF_DOWN); $pri_permonth = $fixed_principal-$interest_paymonth; if($i==$loop_payment){//for end of record only $pri_permonth = $remain_principal; $fixed_principal = round($total_loan_amount/$term_install,0, PHP_ROUND_HALF_DOWN); $fixed_principal= $this->round_up_currency($curr_type,$fixed_principal); $interest_paymonth = $fixed_principal-$remain_principal; } }else{ $fixed_principal = round($total_loan_amount/$term_install,0, PHP_ROUND_HALF_DOWN);//fixed $fixed_principal= $this->round_up_currency($curr_type,$fixed_principal); $post_fiexed = $total_loan_amount/$term_install-$fixed_principal; $total_payment_first = $this->round_up_currency($curr_type,$post_fiexed*$term_install); $pri_permonth = $fixed_principal+$total_payment_first; $amount_day = $dbtable->CountDayByDate($start_date,$next_payment); $interest_paymonth = $this->round_up_currency($curr_type,$loan_amount*($irr_interest)); $pri_permonth = ($fixed_principal+$total_payment_first)-$interest_paymonth; } } $old_remain_principal =$old_remain_principal+$remain_principal; $old_pri_permonth = $old_pri_permonth+$pri_permonth; $old_interest_paymonth = $this->round_up_currency($curr_type,($old_interest_paymonth+$interest_paymonth)); $old_amount_day =$old_amount_day+ $amount_day; if($data['amount_collect']==$amount_collect){ $datapayment = array( 'member_id'=>$member_id, 'total_principal'=>$remain_principal,//good 'principal_permonth'=> $old_pri_permonth,//good 'principle_after'=> $old_pri_permonth,//good 'total_interest'=>$old_interest_paymonth,//good 'total_interest_after'=>$old_interest_paymonth,//good 'total_payment'=>$old_pri_permonth+$old_interest_paymonth,//good 'total_payment_after'=>$old_pri_permonth+$old_interest_paymonth,//good 'date_payment'=>$next_payment,//good 'is_completed'=>0, 'branch_id'=>$data['branch_id'], 'status'=>1, 'amount_day'=>$old_amount_day, 'collect_by'=>$data['co_id'] ); $this->insert($datapayment); $amount_collect=0; $old_remain_principal = 0; $old_pri_permonth = 0; $old_interest_paymonth = 0; $old_amount_day = 0; }else{ //if(){ the old record; //} //if record not cherk min smer 0 } $amount_collect++; } if(($amount_borrow_term)%($amount_fund_term)!=0){///end for record odd number only $start_date = $next_payment;//$dbtable->getNextPayment($str_next, $next_payment, $data['amount_collect'],$data['every_payamount']); $amount_day = $amount_day = $dbtable->CountDayByDate($start_date,$data['date_line']); if($payment_method==1){ $pri_permonth = $remain_principal-$pri_permonth; // $pri_permonth*($amount_day/$amount_fund_term);//check it if khmer currency $interest_paymonth = $pri_permonth*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($pri_permonth*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm)); $interest_paymonth = $this->round_up_currency($curr_type,$interest_paymonth); }elseif($payment_method==2){ $pri_permonth = $this->round_up_currency($curr_type, $pri_permonth); $remain_principal = $pri_permonth;//$remain_principal-$pri_permonth;//OSប្រាក់ដើមគ្រា $interest_paymonth = $pri_permonth*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm)); $interest_paymonth = $this->round_up_currency($curr_type,$interest_paymonth); }elseif($payment_method==3){ $pri_permonth = $remain_principal-$pri_permonth; $interest_paymonth = $data['total_amount']*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($day_perterm/$day_perterm)); $interest_paymonth = $this->round_up_currency($curr_type,$interest_paymonth); // $pri_permonth = $this->round_up_currency($curr_type,$pri_permonth); }elseif($payment_method==4){ $interest_paymonth = $data['total_amount']*($data['interest_rate']/100/$borrow_term)*$amount_day; // $interest_paymonth = ($data['total_amount']*((($amount_fund_term*$data['interest_rate'])/$borrow_term)/100)*($amount_day/$day_perterm)); $interest_paymonth = $this->round_up_currency($curr_type,$interest_paymonth); $pri_permonth = $remain_principal-$pri_permonth; }elseif($payment_method==5){ $pri_permonth = $remain_principal; $interest_paymonth = $remain_principal*($data['interest_rate']/100/$borrow_term)*$amount_day; $interest_paymonth = $this->round_up_currency($curr_type,$interest_paymonth); }elseif($payment_method==6){ $interest_paymonth = $this->round_up_currency($curr_type,$remain_principal*$irr_interest); $fixed_principal = round($total_loan_amount/$term_install,0, PHP_ROUND_HALF_DOWN); $pri_permonth = $remain_principal; } $datapayment = array( 'member_id'=>$member_id, 'total_principal'=>$pri_permonth,//good 'principal_permonth'=> $pri_permonth,//good 'principle_after'=> $old_pri_permonth,//good 'total_interest'=>$interest_paymonth,//good 'total_interest_after'=>$interest_paymonth,//good 'total_payment'=>$interest_paymonth+$pri_permonth,//good 'total_payment_after'=>$interest_paymonth+$pri_permonth,//good 'date_payment'=>$data['date_line'],//good 'is_completed'=>0, 'branch_id'=>$data['branch_id'], 'status'=>1, 'amount_day'=>$amount_day, 'collect_by'=>$data['co_id'] ); $this->insert($datapayment); } $db->commit(); return 1; }catch (Exception $e){ $db->rollBack(); $err =$e->getMessage(); Application_Model_DbTable_DbUserLog::writeMessageError($err); } }
function addAction() { if($this->getRequest()->isPost()){ $_data = $this->getRequest()->getPost(); try { $_dbmodel = new Loan_Model_DbTable_DbRepaymentSchedule(); $_dbmodel->addRepayMentSchedule($_data); if(!empty($_data['saveclose'])){ Application_Form_FrmMessage::Sucessfull("INSERT_SUCCESS","/loan/repaymentschedule"); }else{ Application_Form_FrmMessage::message("INSERT_SUCCESS"); } }catch (Exception $e) { Application_Form_FrmMessage::message("INSERT_FAIL"); $err =$e->getMessage(); Application_Model_DbTable_DbUserLog::writeMessageError($err); } } $frm = new Loan_Form_FrmLoan(); $frm_loan=$frm->FrmAddLoan(); Application_Model_Decorator::removeAllDecorator($frm_loan); $this->view->frm_loan = $frm_loan; $db = new Application_Model_DbTable_DbGlobal(); $this->view->allclient = $db->getAllClient(); $this->view->allclient_number = $db->getAllClientNumber(); $frmpopup = new Application_Form_FrmPopupGlobal(); $this->view->frmpupoploantype = $frmpopup->frmPopupLoanTye(); $this->view->frmPopupZone = $frmpopup->frmPopupZone(); $db_keycode = new Application_Model_DbTable_DbKeycode(); $this->view->keycode = $db_keycode->getKeyCodeMiniInv(); $this->view->graiceperiod = $db_keycode->getSystemSetting(9); $db = new Setting_Model_DbTable_DbLabel(); $this->view->setting=$db->getAllSystemSetting(); }
public function checkHolidayExist($date_next, $holiday_option) { //for check collect payment in holiday or not $db = $this->getAdapter(); $sql = "SELECT start_date FROM `ln_holiday` WHERE start_date='" . $date_next . "'"; $rs = $db->fetchRow($sql); $db = new Setting_Model_DbTable_DbLabel(); $array = $db->getAllSystemSetting(); if ($rs) { $d = new DateTime($rs['start_date']); if ($holiday_option == 1) { $str_option = 'previous day'; } elseif ($holiday_option == 2) { $str_option = 'next day'; } else { return $d->format('Y-m-d'); } $d->modify($str_option); //here check for holiday option //can next day,next week,next month $date_next = $d->format('Y-m-d'); // return $date_next; $d = new DateTime($date_next); $day_work = date("D", strtotime($date_next)); if ($day_work == 'Sat' or $day_work == 'Sun') { if ($day_work == 'Sat' and $array['work_saturday'] == 1 or $day_work == 'Sun' and $array['work_sunday'] == 1) { //sat working return $date_next; } else { if ($day_work == 'Sat' and $array['work_saturday'] == 0) { //sat not working if ($holiday_option == 1) { //after $str_next = '+2 day'; } else { //before $str_next = '-1 day'; //thu } $d->modify($str_next); //here check for holiday option //can next day,next week,next month $date_next = $d->format('Y-m-d'); return $date_next; } else { //sun not working continue to monday // but not check if mon day not working if ($holiday_option == 1) { //after $str_next = '+1 day'; } else { //before $str_next = '-1 day'; //thu } $d->modify($str_next); //here check for holiday option //can next day,next week,next month $date_next = $d->format('Y-m-d'); return $date_next; } } } else { return $date_next; } } else { $d = new DateTime($date_next); $day_work = date("D", strtotime($date_next)); if ($day_work == 'Sat' or $day_work == 'Sun') { if ($day_work == 'Sat' and $array['work_saturday'] == 1 or $day_work == 'Sun' and $array['work_sunday'] == 1) { //sat working return $date_next; } else { if ($day_work == 'Sat' and $array['work_saturday'] == 0) { //sat not working $str_next = '+2 day'; $d->modify($str_next); //here check for holiday option //can next day,next week,next month $date_next = $d->format('Y-m-d'); return $date_next; } else { //sun not working continue to monday // but not check if mon day not working $str_next = '+1 day'; $d->modify($str_next); //here check for holiday option //can next day,next week,next month $date_next = $d->format('Y-m-d'); return $date_next; } } } else { return $date_next; } } }
function editAction() { if($this->getRequest()->isPost()){ $_data = $this->getRequest()->getPost(); try { $db = new Loan_Model_DbTable_DbLoanGroup(); $effect = $db->upDateLoanDisburse($_data); if($effect==true){ Application_Form_FrmMessage::Sucessfull("EDIT_SUCCESS","/loan/GroupDisburse/index"); }else{ Application_Form_FrmMessage::Sucessfull("EDIT_FAIL","/loan/groupdisburse/index"); } }catch (Exception $e) { Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage()); Application_Form_FrmMessage::Sucessfull("EDIT_FAIL","/loan/groupdisburse/index"); } } $id = $this->getRequest()->getParam('id'); $db = new Loan_Model_DbTable_DbLoanIL(); $row = $db->getTranLoanByIdWithBranch($id,2); $db_g = new Application_Model_DbTable_DbGlobal(); $rs = $db_g->getLoanFundExist($id); if($rs==true){ Application_Form_FrmMessage::Sucessfull("LOAN_FUND_EXIST","/loan/groupdisburse/index"); } $frm = new Loan_Form_FrmLoan(); $frm_loan=$frm->FrmAddLoan($row); $this->view->client_id = $row['client_id']; $db = new Loan_Model_DbTable_DbLoanGroup(); $rows = $db->getAllMemberLoanById($id); $this->view->list_members = $rows; if(empty($rows)){ Application_Form_FrmMessage::Sucessfull("RECORD_NOT_EXIST","/loan/groupdisburse/index"); } Application_Model_Decorator::removeAllDecorator($frm_loan); $this->view->frm_loan = $frm_loan; $frmpopup = new Application_Form_FrmPopupGlobal(); $this->view->frmpupopclient = $frmpopup->frmPopupClient(); $this->view->frmPopupCO = $frmpopup->frmPopupCO(); $this->view->frmPopupZone = $frmpopup->frmPopupZone(); $this->view->frmPopupCommune = $frmpopup->frmPopupCommune(); $this->view->frmPopupDistrict = $frmpopup->frmPopupDistrict(); $this->view->frmPopupVillage = $frmpopup->frmPopupVillage(); $db_option = new Application_Model_GlobalClass(); $this->view->member_option = $db_option->getAllClientGroupOption(); $this->view->code_option = $db_option->getAllClientCodeOption(); $db = new Setting_Model_DbTable_DbLabel(); $this->view->setting=$db->getAllSystemSetting(); }
function addAction() { if($this->getRequest()->isPost()){ $_data = $this->getRequest()->getPost(); try { $_dbmodel = new Loan_Model_DbTable_DbLoanIL(); $_dbmodel->addNewLoanIL($_data); if(!empty($_data['saveclose'])){ Application_Form_FrmMessage::Sucessfull("INSERT_SUCCESS","/loan"); }else{ Application_Form_FrmMessage::message("INSERT_SUCCESS"); } }catch (Exception $e) { Application_Form_FrmMessage::message("INSERT_FAIL"); Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage()); } } $frm = new Loan_Form_FrmLoan(); $frm_loan=$frm->FrmAddLoan(); Application_Model_Decorator::removeAllDecorator($frm_loan); $this->view->frm_loan = $frm_loan; // $db = new Application_Model_DbTable_DbGlobal(); // $client=$db->getAllClient(); // // $client_type = $db->getclientdtype(); // array_unshift($client,array( // 'id' => -1, // 'name' => '---Add New ---', // 'branch_id' => -1 // ) ); // $this->view->allclient = $client; // $client_number= $db->getAllClientNumber(); // array_unshift($client_number,array( // 'id' => -1, // 'name' => '---Add New ---', // 'branch_id' => -1 // ) ); // $this->view->allclient_number=$client_number; $frmpopup = new Application_Form_FrmPopupGlobal(); $this->view->frmpupoploantype = $frmpopup->frmPopupLoanTye(); $this->view->frmPopupZone = $frmpopup->frmPopupZone(); $this->view->frmpupopinfoclient = $frmpopup->frmPopupindividualclient(); $this->view->frmPopupCO = $frmpopup->frmPopupCO(); $db = new Setting_Model_DbTable_DbLabel(); $this->view->setting=$db->getAllSystemSetting(); $db = new Application_Model_DbTable_DbGlobal(); $co_name = $db->getAllCoNameOnly(); array_unshift($co_name,array( 'id' => -1, 'name' => '---Add New ---', ) ); $this->view->co_name=$co_name; }