/** * * @param \CashWithdrawals $model Model */ public function posts($model) { if (isset($_POST['CashWithdrawals'])) { $model->attributes = $_POST['CashWithdrawals']; CashWithdrawals::model()->dateThis($model); $this->approvals($model); if ($model->save()) { if ($model->effected_by_treasurer == CashWithdrawals::YES && !empty($model->treasurer_date) && $model->approved_by_chairman == CashWithdrawals::YES && !empty($model->chairman_date) && $model->received_by_secretary == CashWithdrawals::YES && !empty($model->secretary_date)) { Expenditures::model()->cashWithdrawalIsExpense($model); Savings::model()->cashWithdrawaltoSavings($model); } Yii::app()->user->setFlash('saved', 'The alteration has been succcessfully saved'); } } }
</tr> <?php $netIncomes = $netIncomes + $income; ?> <?php } } ?> </table> </td> <td size="9"> <table style="margin: 0; padding: 0"> <?php foreach ($dates as $date => $null) { foreach (Expenditures::model()->dailyBatchTransactions($expenditures, $date) as $description => $expenditure) { ?> <tr> <td style="width: 200px"><font size="9"><?php echo $description; ?> </font></td> <td style="width: 50px; text-align: right"><font size="9"><?php echo $expenditure; ?> </font></td> </tr> <?php $netExpenditures = $netExpenditures + $expenditure; ?> <?php
/** * @return Person models */ public function membersForTrialBalance() { $incm = Incomes::model()->tableName(); $exps = Expenditures::model()->tableName(); $user = Users::model()->tableName(); $cri = new CDbCriteria(); $cri->select = 't.id, t.first_name, t.middle_name, t.last_name'; $cri->distinct = true; $cri->condition = "(EXISTS (SELECT member FROM {$incm} WHERE member=t.id LIMIT 1) || " . "EXISTS (SELECT member FROM {$exps} WHERE member=t.id LIMIT 1)) && " . "EXISTS (SELECT id FROM {$user} WHERE id=t.id && status=:stts)"; $cri->params = array(':stts' => Users::STATUS_ACTIVE); $cri->order = 't.first_name ASC, t.middle_name ASC, t.last_name ASC'; return $this->findAll($cri); }
<?php if (!empty($months)) { ?> <?php $netBankIncomes = $netBankExpenditures = Expenditures::model()->netCashOrBankIncomeAfterYesterday($since, ContributionsByMembers::PAYMENT_BY_BANK); if ($netBankIncomes < 0) { $netBankExpenditures = abs($netBankExpenditures); $netBankIncomes = 0; } else { $netBankExpenditures = 0; } $netCashIncomes = $netCashExpenditures = Expenditures::model()->netCashOrBankIncomeAfterYesterday($since, ContributionsByMembers::PAYMENT_BY_CASH); if ($netCashIncomes < 0) { $netCashExpenditures = abs($netCashExpenditures); $netCashIncomes = 0; } else { $netCashExpenditures = 0; } ?> <table style="margin: 0; padding: 0"> <tr> <td style="text-align: center; border-bottom: 2px solid #000000">Debit</td> <td style="text-align: center; border-bottom: 2px solid #000000">Credit</td> </tr> <tr> <td style="border-right: 2px solid #000000" size="8"> <table style="margin: 0; padding: 0"> <tr> <td style="width: 45px"><font size="8"></font></td>
<?php if (!empty($months)) { ?> <?php $netIncomes = $netExpenditures = $member == ContributionsByMembers::PAYMENT_BY_CASH || $member == ContributionsByMembers::PAYMENT_BY_BANK ? Expenditures::model()->netCashOrBankIncomeAfterYesterday($since, $member) : Expenditures::model()->netMembersIncomeAfterYesterday($member, $since, $till); if (is_array($netIncomes)) { $pendingLoans = $netIncomes['expenditure']['pendingTotal']; $pendingSavings = $netIncomes['income']['pendingSaving']; $netIncomes = $netExpenditures = $netIncomes['income']['total'] - $netIncomes['expenditure']['total']; } if ($netIncomes < 0) { $netExpenditures = abs($netExpenditures); $netIncomes = 0; } else { $netExpenditures = 0; } $member = $member == ContributionsByMembers::PAYMENT_BY_CASH || $member == ContributionsByMembers::PAYMENT_BY_BANK ? $member : Person::model()->findByPk($member); $taito = (is_object($member) ? "{$member->first_name} {$member->middle_name} {$member->last_name}'s" : $member) . ' Account'; ?> <table style="margin: 0; padding: 0"> <tr> <td colspan="2" style="text-align: center"><?php echo strtoupper($taito); ?> </td> </tr> <tr> <td style="text-align: center; border-bottom: 2px solid #000000"><?php echo $member == ContributionsByMembers::PAYMENT_BY_CASH || $member == ContributionsByMembers::PAYMENT_BY_BANK ? 'Debit' : 'Credit';
/** * * @param array $balanceRows rows for trial balance * @param Person $members models * @param date $since yyyy-mm-dd * @param date $till yyyy-mm-dd * @return array rows for trial balance */ public function balancesForMembers($balanceRows, $members, $since, $till) { foreach ($members as $member) { $balance = Expenditures::model()->netMembersIncomeAfterYesterday($member->id, $since, LoanApplications::model()->dayAfter($till)); $netIncomes = $netExpenditures = $balance['income']['total'] - $balance['expenditure']['total']; if ($netIncomes > 0) { $netExpenditures = null; } else { $netExpenditures = abs($netExpenditures); $netIncomes = null; } if ($netExpenditures + $netIncomes > 0) { $balanceRows[$member->id]['name'] = "{$member->first_name} {$member->middle_name} {$member->last_name}"; $balanceRows[$member->id]['credit'] = empty($netIncomes) ? null : $netIncomes; $balanceRows[$member->id]['debit'] = empty($netExpenditures) ? null : $netExpenditures; } } return $balanceRows; }
/** * 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 $id the ID of the model to be loaded * @return Expenditures the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Expenditures::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Close a loan application so it won't be further edited * * @param type $model */ public function closeApplication($model) { if ($model->closed != $_POST['LoanApplications']['closed']) { $model->closed = $_POST['LoanApplications']['closed']; if ($model->closed != 'Yes') { $model->close_date = null; } else { $model->close_date = date('Y') . '-' . date('m') . '-' . date('d'); } if ($model->save()) { Expenditures::model()->loanApplicationIsExpense($model); $this->sendMailToApplicant($model->member, 'chairman', 'closed'); } else { $model->closed = 'No'; $model->close_date = null; } } }