Esempio n. 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($app_id)
 {
     if (Yii::app()->user->checkAccess($this->id . '.' . $this->action->id)) {
         $model = new PaymentDetail();
         $applicant = Applicant::model()->findByPk($app_id);
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         $allotments = $applicant->getAllotments();
         if ($applicant !== null && !empty($allotments)) {
             $model->allotment_id = $allotments->data[0]->id;
             $model->applicant_id = $app_id;
         } else {
             throw new CHttpException('Please make allotment first. ' . CHtml::link('Click here to go Back', Yii::app()->user->returnUrl));
             exit;
         }
         $paymentTypeOptions = PaymentType::getPaymentTypes($allotments->data[0]->category_id);
         if (isset($_POST['PaymentDetail'])) {
             $model->attributes = $_POST['PaymentDetail'];
             if ($model->save()) {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         }
         $this->render('create', array('model' => $model, 'applicant' => $applicant, 'paymentTypeOptions' => $paymentTypeOptions));
     } else {
         $this->accessDenied();
     }
 }