예제 #1
0
 public function actionCreate()
 {
     $model = new Order();
     $description = new OrderDescription();
     //$order_option_value = new OrderOptionValue;
     $this->performAjaxValidation(array($model, $description), 'order-form');
     if (isset($_POST[$this->modelName])) {
         $model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         $suc = Yii::t('info', 'Order was successfully created');
         $err = Yii::t('info', 'Could not create Order');
         $description->order_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($this->validateOrder($model, $description)) {
             if ($model->save()) {
                 $description->order_id = $model->id;
                 $description->save();
                 $this->orderSave($model);
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'description' => $description, 'customer' => $this->_ordercustomer, 'orderProduct' => $this->_orderproduct), false, true);
                     Yii::app()->end();
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
             }
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form_order', array('model' => $model, 'description' => $description, 'customer' => $this->_ordercustomer, 'orderproduct' => $this->_orderproduct), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'description' => $description, 'customer' => $this->_ordercustomer, 'orderproduct' => $this->_orderproduct));
 }
예제 #2
0
 public function actionRefreshDetails()
 {
     $model = new Order();
     $description = new OrderDescription();
     $sess = Yii::app()->user->getState('order_product');
     $model->setAttributes($_POST[$this->modelName]);
     $description->setAttributes($_POST[$this->modelName . 'Description']);
     $this->renderPartial('_details', array('orderproduct' => $sess, 'model' => $model, 'description' => $description), false, true);
     Yii::app()->end();
 }