/**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new CustomerOrder model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CustomerOrder();
     $event = new Event();
     // $event -> event_no = $model -> order_id;
     $data = Yii::$app->db->createCommand("call getLastID()")->queryScalar();
     if ($data == null) {
         $event->event_no = 1;
     } else {
         $event->event_no = $data + 1;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save() && $event->load(Yii::$app->request->post()) && $event->save()) {
         $ary = Yii::$app->db->createCommand("call getItems('{$model->qtyItem_1}','{$model->item_1}')")->queryAll();
         for ($x = 0; $x < sizeof($ary); $x++) {
             $item_no = ArrayHelper::getValue($ary[$x], 'item_no');
             Yii::$app->db->createCommand("call insertRentedItem('{$item_no}','{$event->event_no}','{$event->start_date_time}','{$event->end_date_time}')")->query();
             Yii::$app->db->createCommand("call updateStatus('{$item_no}')")->query();
         }
         return $this->redirect(['view', 'id' => $model->order_id]);
     } else {
         return $this->render('create', ['model' => $model, 'event' => $event]);
     }
 }