/** * save income or expenditure * * @param int $member person id * @param string $type income or expense * @param string $heading depending on $type */ public function actionIncomeOrExpense($member, $type, $heading) { $form = $this->beginWidget('CActiveForm', array('id' => 'expenditures-form', 'enableAjaxValidation' => true)); $model = $type == Voteheads::INCOME ? new Incomes() : new Expenditures(); if (isset($_POST[$className = get_class($model)])) { $model->attributes = $_POST[get_class($model)]; $model->receipt_no = NextReceiptNo::model()->receiptNo(); $model->cask_or_bank = $className == 'Incomes' && $model->votehead == Incomes::WITHDRAWAL_FROM_BANK || $className == 'Expenditures' && $model->votehead == Expenditures::DEPOSIT_TO_BANK ? ContributionsByMembers::PAYMENT_BY_CASH : $model->cask_or_bank; $model->logged_in = Yii::app()->user->id; if ($model->save()) { NextReceiptNo::model()->updateNextReceiptNo($model->receipt_no); if ($className == 'Incomes' && $model->votehead == Incomes::WITHDRAWAL_FROM_BANK) { Expenditures::model()->depositIntoBankIsExpense($model); } else { if ($className == 'Expenditures' && $model->votehead == Expenditures::DEPOSIT_TO_BANK) { Incomes::model()->withdrawalFromBankIsIncome($model); } } $this->refresh(); } } $this->renderPartial('fieldsTable', array('form' => $form, 'model' => $model, 'heading' => $heading, 'user' => Users::model()->loadModel($member), 'field' => $type, 'fieldType' => Voteheads::SELECT)); }
/** * * @param Expenditures $expense model */ public function withdrawalFromBankIsIncome($expense) { $income = $this->find('trans_channes=:chnl && associated_id=:id', array(':chnl' => $className = get_class($expense), ':id' => $expense->primaryKey)); $nextReceiptNo = false; if (empty($income)) { $income = new Incomes(); $income->votehead = $expense->votehead; $income->trans_channes = $className; $income->associated_id = $expense->id; $income->receipt_no = NextReceiptNo::model()->receiptNo(); $income->member = $expense->member; $income->description = $expense->description; $income->cask_or_bank = ContributionsByMembers::PAYMENT_BY_BANK; $income->logged_in = Yii::app()->user->id; $income->date = $expense->date; $nextReceiptNo = true; } $income->amount = $expense->amount; if ($income->save(false) && $nextReceiptNo) { NextReceiptNo::model()->updateNextReceiptNo($income->receipt_no); } }
/** * * @param int $bala receipt no */ public function actionPrintReceipts($bala) { $this->pageTitle = 'Receipt Acknowledgement'; NextReceiptNo::model()->printReceipts(array($bala)); }
/** * save bank payment as contribution and copy transaction */ public function bankPayments() { foreach (BankPayments::model()->pendingBankPayments() as $bankPayment) { $person = Person::model()->memberByIdno($bankPayment->idno); if (!empty($person)) { if ($this->rowsToCreate(new ContributionsByMembers(), $person->primaryKey, $bankPayment->contribution_type, $bankPayment->amount, $bankPayment->date, NextReceiptNo::model()->receiptNo())) { $bankPayment->copyBankPayment($bankPayment); } } } }
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')); }