Ejemplo n.º 1
0
 /**
  * Creates a new Order model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($build_id)
 {
     $model = new Order();
     $model->build_fk = $build_id;
     $build = $model->getBuildFk()->one();
     //$build2 = $this->findBuild($build_id);
     $parts = new ActiveDataProvider(['query' => $build->getParts(), 'sort' => false]);
     $address = $this->getAddress($build->user_fk);
     //$model->build_fk = $build->build_guide_id;
     $model->customer_fk = $build->user_fk;
     $model->status_fk = Order::STAT_PENDING;
     $model->date_of_order = date("Y-m-d H:i:s");
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->order_id]);
     } else {
         return $this->render('create', ['model' => $model, 'build' => $build, 'parts' => $parts, 'address' => $address]);
     }
 }