<?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 { ?>
/** * * @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; }
</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];
/** * * @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><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">
<?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
} ?> </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 }
</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 $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); } }