public function checkVisitCode($attribute) { $visit = Visits::model()->find(array('condition' => 'visit_code = ' . $this->{$attribute} . ' ')); if (empty($visit)) { $this->addError($attribute, 'Sorry, this visit code does not exist'); } }
public function actionStep3($id) { if (isFrontUserLoggedIn()) { $visit_list = Visits::model()->findAll(array("condition" => " solicitor_id= '" . $id . "' AND end_date > '" . date('Y-m-d') . "' AND status = 1 ")); $this->render('step3', array('visit_list' => $visit_list)); } else { $this->redirect(array("/user")); } }
public function actionStep3() { if (isFrontUserLoggedIn()) { $visit_code = Yii::app()->session['visit_code']; $visit_model = Visits::model()->find(array('condition' => 'visit_code = "' . $visit_code . '" ')); $step3_model = new Step3(); if (isset($_POST['Step3'])) { $step3_model->attributes = $_POST['Step3']; if ($step3_model->validate()) { $donation_model = new Donation(); $donation_model->user_id = Yii::app()->session['user_id']; $donation_model->visit_id = $visit_model->id; $donation_model->mobile = '123456789'; $donation_model->solicitor_id = $visit_model->solicitor->id; $donation_model->amount = $step3_model->amount; $donation_model->mode = 'web'; $donation_model->short_note = $step3_model->message; $donation_model->payment_status = 'pending'; $donation_model->reference_number = getToken(8); $donation_model->validate(); $donation_model->save(); // calculating the debit amount to be inserted in the user_trans table $user_id = Yii::app()->session['user_id']; $user_balance = Users::model()->getUserBalance($user_id); $user_model = Users::model()->findByPk($user_id); $credit_limits = $user_model->credit_limits; $actual_don_amt = $step3_model->amount; // if ($actual_don_amt > $user_balance) { // // deducting the user credit // if ($user_balance > 0) { // $from_user_credit = $actual_don_amt - $user_balance; // } else { // $from_user_credit = $actual_don_amt; // } // $final_user_credit = $credit_limits - $from_user_credit; // $user_model->credit_limits = $final_user_credit; // $user_model->validate(); // $user_model->save(); // } // for storing in the user_trans table $trans_model = new UserTrans(); $trans_model->tran_type = 'DONATION'; $trans_model->user_id = $donation_model->user_id; $trans_model->debit = $actual_don_amt; $trans_model->donation_id = $donation_model->id; $trans_model->save(); unset(Yii::app()->session['visit_code']); $this->redirect(array("/user/default/accountSummary")); } } $this->render('step3', array('visit_model' => $visit_model, 'step3_model' => $step3_model)); } else { $this->redirect(array("/user")); } }
/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function authenticate($attribute, $params) { if (!$this->hasErrors()) { $visits = Visits::model()->find(array("condition" => "visit_code = '" . $this->visit_code . "'")); if ($visits === null) { $this->addError("visit_code", "Visit Code is not correct."); } else { return true; } } }
public function checkVisitCode($attribute) { $visit = Visits::model()->find(array('condition' => "visit_code = '" . $this->{$attribute} . "'")); if (empty($visit)) { $this->addError($attribute, 'Sorry, this visit code does not exist'); } else { $visit_end_date = $visit->end_date; if ($visit_end_date < date("Y-m-d")) { $this->addError($attribute, 'Sorry, you can not donate now as the timeframe for this visit has passed.'); } else { if ($visit->status != 1 || $visit->deleted == 1) { $this->addError($attribute, 'Sorry, you can not donate now as this visit code has been closed.'); } } } }
public function gridVisit($data, $row) { $code = Visits::model()->findByPk($data->visit_id); return $code->visit_code; }
public function actionProcessPending($id) { $visit_model = Visits::model()->findByPk($id); $attributes = array('payment_status' => 'transferred'); //Donation::model()->updateAll($attributes, 'payment_status=:payment_status', array(':payment_status' => 'pending')); Donation::model()->updateAll($attributes, array('condition' => "payment_status = 'pending' AND visit_id = '{$id}' ")); $this->redirect(array('donations', 'id' => $visit_model->solicitor_id)); }
'data'=>$model, 'attributes'=>array( array( 'label'=>'User', 'type'=>'raw', 'value'=>Users::model()->findByPk($model->user_id)->username, ), array( 'label'=>'Solictor', 'type'=>'raw', 'value'=>Solicitor::model()->findByPk($model->solicitor_id)->solicitor_code, ), array( 'label'=>'Visit', 'type'=>'raw', 'value'=>Visits::model()->findByPk($model->visit_id)->visit_code, ), 'mobile', 'amount', 'mode', 'payment_status', 'reference_number', ), )); ?> </div> </div> <div class="box-footer"> <?php echo CHtml::link('Back',array('/admin/donation'),array("class" => 'btn btn-info pull-right',"style"=>"margin-left:10px;")); ?> </div> </div> </div>
public function visitName($visit_id){ return Visits::model()->findByPk($visit_id)->visit_code; }
/** * 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 Visits the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Visits::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
</section> <section class="content"> <div class="row"> <div class="col-xs-12"> <div class="box box-info"> <div class="box-header with-border"> <h3 class="box-title"><?php echo $solicitor->first_name . ' ' . $solicitor->last_name; ?> <small><a href="<?php echo base_url() . '/admin/donation/update?id=' . $model->id; ?> ">EDIT</a></small></h3> </div> <div class="box-body"> <div class="col-xs-12 table-responsive"> <?php $this->widget('zii.widgets.CDetailView', array('htmlOptions' => array("class" => "table table-bordered table-hover dataTable"), 'data' => $model, 'attributes' => array(array('label' => 'User', 'type' => 'raw', 'value' => Users::model()->findByPk($model->user_id)->username), array('label' => 'Solictor', 'type' => 'raw', 'value' => Solicitor::model()->findByPk($model->solicitor_id)->solicitor_code), array('label' => 'Visit', 'type' => 'raw', 'value' => Visits::model()->findByPk($model->visit_id)->visit_code), 'mobile', 'amount', 'mode', 'payment_status', 'reference_number'))); ?> </div> </div> <div class="box-footer"> <?php echo CHtml::link('Back', array('/admin/donation'), array("class" => 'btn btn-info pull-right', "style" => "margin-left:10px;")); ?> </div> </div> </div> </div> </section>