/** * 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 MemberWithdrawal the loaded model * @throws CHttpException */ public function loadModel($id) { $model = MemberWithdrawal::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Return member withdrawal * * @param type $member * @return type */ public function member($member) { return MemberWithdrawal::model()->find('member=:mbr', array(':mbr' => $member)); }
<?php } ?> <?php $currentChairman = Maofficio::model()->returnCurrentPostHolder(1); if (!empty($currentChairman) && $currentChairman->member == $id) { $model = MemberWithdrawal::model()->find("status='Pending' && forwarded_by_secretary!='Pending' && secretary_date IS NOT NULL && forwarded_by_treasurer!='Pending' && treasurer_date IS NOT NULL"); } else { $currentSecretary = Maofficio::model()->returnCurrentPostHolder(2); if (!empty($currentSecretary) && $currentSecretary->member == $id) { $model = MemberWithdrawal::model()->find("status='Pending' && forwarded_by_treasurer='Pending' && treasurer_date IS NULL && approved_by_chairman='Pending' && chairman_date IS NULL"); } else { $currentTreasurer = Maofficio::model()->returnCurrentPostHolder(3); if (!empty($currentTreasurer) && $currentTreasurer->member == $id) { $model = MemberWithdrawal::model()->find("status='Pending' && forwarded_by_secretary!='Pending' && secretary_date IS NOT NULL && approved_by_chairman='Pending' && chairman_date IS NULL"); } } } if (!empty($model)) { ?> <li class="<?php echo isset($_REQUEST['active']) && $_REQUEST['active'] == 'rurwa' ? 'active' : ''; ?> "> <a <?php if (isset($_REQUEST['active']) && $_REQUEST['active'] == 'rurwa') { ?> <?php
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')); }