</font></td> <td style="width: 50px; text-align: right"><font size="8"><?php echo $income->amount; $netIncomes = $netIncomes + $income->amount; ?> </font></td> </tr> <?php if ($member != ContributionsByMembers::PAYMENT_BY_CASH && $member != ContributionsByMembers::PAYMENT_BY_BANK) { ?> <?php if ($income->trans_channes == Incomes::INCOME_BY_CONTRIBUTION || $income->trans_channes == Incomes::INCOME_BY_CASH_SAVING) { ?> <?php $savingValues = Savings::model()->profitEarnedOrToBeEarnedOnSavingBetweenAndIncludingTheseDates($income->trans_channes == Incomes::INCOME_BY_CONTRIBUTION ? ContributionsByMembers::model()->savingIdForContribution($income->associated_id) : $income->associated_id, '0000-00-00', $till); ?> <?php if (!empty($savingValues[Savings::INTEREST])) { ?> <tr> <td style="width: 50px"><font size="8"><?php if ($income->date != $prvsDate) { echo $income->date; } ?> </font></td> <td style="width: 150px"><font size="8">Interest</font></td> <td style="width: 50px; text-align: right"><font size="8"><?php echo $savingValues[Savings::INTEREST]; $netIncomes = $netIncomes + $savingValues[Savings::INTEREST];
<?php $id = Yii::app()->user->id; ?> <?php $true = false; foreach (ContributionTypes::model()->findAll('id>1') as $type) { if ($type->primaryKey == 4) { $true = $true || LoanApplications::model()->memberHasALoan($id); } else { $true = $true || ContributionsByMembers::model()->memberHasAContribution($id, $type->primaryKey); } } ?> <?php if ($true) { ?> <li class="<?php echo isset($_REQUEST['active']) && $_REQUEST['active'] == 'papulo' ? 'active' : ''; ?> "> <a <?php if (isset($_REQUEST['active']) && $_REQUEST['active'] == 'papulo') { ?> <?php } else { ?>
<tr><td style="display:table-cell; text-align:center; width:500px; height: 10px"> </td></tr> <tr> <td style="display:table-cell; text-align:justify; width:500px; height: 12px"> <font style="font-family: sans-serif; font-weight: normal" size="11"> Signature: .......................................................................... Date: ................................................. </font> </td> </tr> <tr><td style="display:table-cell; text-align:center; width:500px; height: 10px"> </td></tr> <?php $totalContributions = ContributionsByMembers::model()->netTotalMemberContribution($loan->member, $loan->witness_date); ?> <tr> <td style="display:table-cell; text-align:justify; width:120px; height: 12px"> <font style="font-family: sans-serif; font-weight: bold" size="11">Total Contributions:</font> </td> <td style="display:table-cell; text-align:justify; width:100px; height: 12px"> <font style="font-family: sans-serif; font-weight: normal" size="11"> <?php echo "KShs. {$totalContributions}"; ?> </font> </td> <td style="display:table-cell; text-align:right; width:180px; height: 12px">
/** * * @param int $member person id * @param \Loanapplications $pendingLoanApplications models * @param int $excempt loan application id * @return double available loan amount */ public function veryNetTotalMemberContribution($member, $pendingLoanApplications, $excempt) { $availableContributions = ContributionsByMembers::model()->netTotalMemberContribution($member, $endDate = date('Y') . '-' . date('m') . '-' . date('d')); if ($availableContributions > 0) { foreach ($pendingLoanApplications as $pendingLoanApplication) { if ($pendingLoanApplication->primaryKey != $excempt) { $availableContributions = $availableContributions - $pendingLoanApplication->amout_borrowed; } } } if ($availableContributions < 0) { $availableContributions = 0; } return $availableContributions; }
} ?> </td> </tr> <tr><td> </td></tr> <?php } ?> <?php } ?> <?php $receipt = ContributionsByMembers::model()->find("member=:mbr && receiptno!='' && receiptno IS NOT NULL", array(':mbr' => $user->id)); ?> <?php if (!empty($receipt)) { ?> <tr> <td> <a class="btn btn-sm btn-primary"><i class="icon-ok bigger-110"></i> <?php echo CHtml::ajaxSubmitButton('Receipt Acknowledgements', array('contributionsByMembers/myReceipts', 'id' => $user->id), array('update' => '#loansList', 'type' => 'submit'), array('id' => 'receipts', 'name' => 'receipts', 'style' => 'background-color: inherit; border: none')); ?> </a> </td> </tr> <?php }
/** * * @param type $member * @param date $since yyyy-mm-dd * @param date $till yyyy-mm-dd * @return array total incomes */ public function totalIncomeFromMemberFromStartToIncludingThisDate($member, $since, $till) { $total = 0; $pendingSavings = 0; foreach ($this->incomesFromMemberBetweenAndIncludingThisDates($member, '0000-00-00', $since) as $income) { $total = $total + $income->amount; if ($income->trans_channes == self::INCOME_BY_CONTRIBUTION || $income->trans_channes == self::INCOME_BY_CASH_SAVING) { $savingValues = Savings::model()->profitEarnedOrToBeEarnedOnSavingBetweenAndIncludingTheseDates($savingId = $income->trans_channes == self::INCOME_BY_CONTRIBUTION ? ContributionsByMembers::model()->savingIdForContribution($income->associated_id) : $income->associated_id, '0000-00-00', $since); if (!empty($savingValues[Savings::INTEREST])) { $total = $total + $savingValues[Savings::INTEREST]; if ($savingValues[Savings::REDUCING_BALANCE] > 0) { $newSavingValues = Savings::model()->profitEarnedOrToBeEarnedOnSavingBetweenAndIncludingTheseDates($savingId, '0000-00-00', $till); $latestSavingHistory = Savings::model()->latestSavingHistoryBetweenAndIncludingTheseDates($savingId, LoanApplications::model()->dayAfter($since), $till); $pendingSavings = $pendingSavings + $newSavingValues[Savings::INTEREST] - (empty($latestSavingHistory) ? $savingValues[Savings::INTEREST] : 0); } } } } return array('total' => $total, 'pendingSaving' => $pendingSavings); }
</tr> </table> </div> <div style="width: 99%; height: 265px; overflow-y: scroll; border-left: 2px solid #000000"> <table style="width: 100%; padding: 0; margin: 0"> <?php $i = 0; ?> <?php foreach ($receipts as $receipt) { ?> <?php $total = 0; foreach ($contributions = ContributionsByMembers::model()->findAll('receiptno=:rcpt', array(':rcpt' => $receipt->receiptno)) as $contribution) { $total = $total + $contribution->amount; } ?> <?php $endDate = substr($endDate = $receipt->date, 8, 2) . ' ' . Defaults::monthName(substr($endDate, 5, 2)) . ' ' . substr($endDate, 0, 4); ?> <tr> <td style="width: <?php echo $no; ?> %; text-align: center"><?php echo ++$i; ?> .</td>
<?php $id = Yii::app()->user->id; ?> <?php $totalContributions = ContributionsByMembers::model()->netTotalMemberContribution($id, date('Y') . '-' . date('m') . '-' . date('d')); if ($totalContributions > 0) { ?> <li class="<?php echo isset($_REQUEST['active']) && $_REQUEST['active'] == 'sava' ? 'active' : ''; ?> "> <a <?php if (isset($_REQUEST['active']) && $_REQUEST['active'] == 'sava') { ?> <?php } else { ?> href="<?php echo Yii::app()->createUrl('/loanApplications/myPendingLoanApplications', array('active' => 'sava')); ?> " <?php } ?> > <i class="icon-suitcase"></i> <span class="menu-text"> <?php
<?php $member = Person::model()->findByPk($model->member); $witness = Person::model()->findByPk($model->witness); if ($model->loan_type == 4) { $guarantor1 = Person::model()->findByPk($model->guarantor1); $guarantor2 = Person::model()->findByPk($model->guarantor2); } $address = PersonAddress::model()->find('person_id=:id', array(':id' => $model->member)); $loan = Loans::model()->findByPk($model->loan_type); $contributions = ContributionsByMembers::model()->netTotalMemberContribution($model->member, date('Y') . '-' . date('m') . '-' . date('d')); ?> <div style="height: 400px; border-right: 3px solid #4f99c6"> <?php if ($model->closed != 'Yes' && empty($model->close_date)) { ?> <div style="height: 20px; text-align: center"> <b><?php echo "{$member->last_name} {$member->first_name} {$member->middle_name}"; ?> </b> </div> <div style="height: 360px; overflow-y: scroll"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'loan-applications-form', 'enableAjaxValidation' => false)); ?>
/** * Return a required contribution * * @param type $pk * @return \ContributionsByMembers */ public function returnAContribution($pk) { return ContributionsByMembers::model()->findByPk($pk); }
/** * Compute loan recovery values. * * @param \LoanRepayments $repayment */ public function computeRecoveries($repayment) { $loanApplicationDue = LoanApplications::model()->returnALoanApplication($repayment->loan_application); $effectiveRepaymentDate = LoanApplications::model()->dayBefore(LoanApplications::model()->repaymentDate($loanApplicationDue->borrowingDate($loanApplicationDue), LoanApplications::model()->recoverLoanAfterLoanRepaymentPeriod() == true ? $loanApplicationDue->repayment_period : $loanApplicationDue->max_repayment_period)); $effectiveRepaymentDate = $repayment->recoverydate > $effectiveRepaymentDate ? $repayment->recoverydate : $effectiveRepaymentDate; $amountDue = $this->computeAmountDue($repayment, $loanApplicationDue, LoanApplications::model()->repaymentDate($loanApplicationDue->borrowingDate($loanApplicationDue), LoanApplications::model()->recoverLoanAfterLoanRepaymentPeriod() == true ? $loanApplicationDue->repayment_period : $loanApplicationDue->max_repayment_period)); $totalContributions = ContributionsByMembers::model()->totalMemberContribution($loanApplicationDue->member, 2, $effectiveRepaymentDate); $totalLoanRecoveries = $this->totalLoanRecoveries($loanApplicationDue->member, $effectiveRepaymentDate); $amountRecovered = $amountDue <= $totalContributions - $totalLoanRecoveries ? $amountDue : $totalContributions - $totalLoanRecoveries; $this->updateRecovery($repayment, $amountDue, $amountRecovered, $effectiveRepaymentDate); }
/** * dropDownList for contribution */ public function actionContributionType() { $data = ContributionsByMembers::model()->contributionType($_POST['ContributionsByMembers']['member']); $data = CHtml::listData($data, 'id', 'contribution_type'); $prompt = ContributionTypes::model()->getAttributeLabel('contribution_type'); echo "<option value=''>-- {$prompt} --</option>"; foreach ($data as $value => $type) { echo CHtml::tag('option', array('value' => $value), CHtml::encode($type), true); } }
public function actionRegiterAmember() { $this->pageTitle = Lang::t('New Member Sign Up'); $user_model = new Users(Users::SCENARIO_SIGNUP); $person_model = new Person(); $person_address = new PersonAddress(); $contribution = new ContributionsByMembers(); $contribution->receiptno = empty($contribution->receiptno) ? NextReceiptNo::model()->receiptNo() : $contribution->receiptno; $user_model->activation_code = Common::generateHash(microtime()); $user_model->user_level = UserLevels::LEVEL_MEMBER; $user_model->timezone = SettingsTimezone::DEFAULT_TIME_ZONE; if (Yii::app()->request->isPostRequest) { $verifyPhoneCode = isset($_POST['verifyPhoneCode']) ? $_POST['verifyPhoneCode'] : null; $verifyMailCode = isset($_POST['verifyMailCode']) ? $_POST['verifyMailCode'] : null; if (isset($_POST['Person'])) { $person_model = Person::model()->find('idno=:idno', array(':idno' => $_POST['Person']['idno'])); $person_model = empty($person_model) ? new Person() : $person_model; $person_model->attributes = $_POST['Person']; $person_model->married = 'n'; $person_model->havechildren = 'n'; $person_model->validate(); } if (isset($_POST['Users'])) { if (!$person_model->isNewRecord) { $user_model = Users::model()->findByPk($person_model->id); if (empty($user_model)) { $user_model = new Users(Users::SCENARIO_SIGNUP); $user_model->id = $person_model->id; } } $user_model->attributes = $_POST['Users']; $user_model->status = 'Active'; $user_model->answer = strtoupper($user_model->answer); $user_model->validate(); } if (isset($_POST['PersonAddress'])) { if (!empty($person_model->id)) { $person_address = PersonAddress::model()->find('person_id=:id', array(':id' => $person_model->id)); } $person_address = empty($person_address) ? new PersonAddress() : $person_address; $person_address->attributes = $_POST['PersonAddress']; $person_address->validate(array('phone1')); } if (isset($_POST['ContributionsByMembers'])) { $contribution->attributes = $_POST['ContributionsByMembers']; $contribution->contribution_type = 1; $contribution->date = date('Y') . '-' . date('m') . '-' . date('d'); $contribution->validate(array('amount', 'receiptno', 'date', 'payment_mode', 'transaction_no')); } if (!$user_model->hasErrors() && !$person_model->hasErrors() && !$person_address->hasErrors() && !$contribution->hasErrors()) { if ($user_model->save(false)) { if (true == ($personNewModel = $person_model->isNewRecord)) { $person_model->id = $user_model->id; } $person_model->save(false); $person_address->person_id = $person_model->id; $person_address->save(false); $contribution->member = $person_model->id; $contribution->rowsToCreate($contribution, $contribution->member, $contribution->contribution_type, $contribution->amount, $contribution->date, $contribution->receiptno, array()); if (!$personNewModel) { $withdrawal = MemberWithdrawal::model()->find('member=:id', array(':id' => $person_model->id)); $withdrawal->status = 'Yes'; $withdrawal->update(array('status')); } Yii::app()->user->setFlash('success', Lang::t('Account created. Click login at bottom of the page to proceed.')); $this->refresh(); } } } $this->render('application.modules.users.views.default.default', array('model' => null, 'others' => array('user_model' => $user_model, 'person_model' => $person_model, 'person_address' => $person_address, 'verifyPhoneCode' => isset($verifyPhoneCode) ? $verifyPhoneCode : null, 'verifyMailCode' => isset($verifyMailCode) ? $verifyMailCode : null, 'contribution' => $contribution, 'render' => 'application.modules.auth.views.register.index'), 'user_model' => Users::model()->loadModel(Yii::app()->user->id), 'person_model' => Person::model()->loadModel(Yii::app()->user->id), 'title' => 'New Account SignUp', 'render' => 'application.modules.users.views.default._createAnotherUser')); }