Пример #1
0
 public function actionPurchase()
 {
     if (isset($_POST['Policy'])) {
         $model = new Policy();
         $model->attributes = $_POST['Policy'];
         $model->proposal_no = uniqid();
         $model->is_purchased = 'q';
         if ($model->save()) {
             $parent = Plans::model()->findByPk($_POST['Policy']['parent_plan']);
             $region = PlanRegion::model()->findByPk($_POST['Policy']['region']);
             $amount = $_POST['Policy']['policy_amount'];
             $premium = $_POST['Policy']['policy_premium'];
             $tenure = $_POST['Policy']['tenure'];
             $first_name = $_POST['Policy']['first_name'];
             $age = $_POST['Policy']['age'];
             $plan = Plans::model()->findByPk($model->plan);
             $this->render("purchase", array("model" => $model, "parent" => $parent, "plan" => $plan, "region" => $region, "premium" => $premium, "amount" => $amount, "first_name" => $first_name, "age" => $age, "tenure" => $tenure));
         } else {
             pre($model->getErrors(), true);
         }
     } else {
         $this->redirect(array('quotation'));
     }
 }