/**
  * Creates a new Inventory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Inventory();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionProcess()
 {
     $model = new Inventory();
     if ($model->load(Yii::$app->request->post())) {
         $model->bill_no = $model->bill_no;
         $model->inventory = 'i';
         $model->save();
         $cart = new Cart();
         foreach ($cart->contents() as $items) {
             $detail = new \app\models\Inventorydetail();
             $detail->load(Yii::$app->request->post());
             $detail->inventory_id = $model->id;
             $detail->product_id = $items['id'];
             $detail->qty = $items['qty'];
             $detail->price = $items['price'];
             $product = Products::findOne($items['id']);
             echo $product->qty = $items['qty'];
             $product->save();
             $detail->save();
         }
         $cart->destroy();
         return $this->redirect(['inventory/index']);
     }
 }