Пример #1
0
 public function actionBill()
 {
     $model = new Bills();
     if (Yii::$app->request->isPost) {
         $bills = Yii::$app->request->post('Bills');
         for ($i = 0; $i < sizeof($bills); $i++) {
             $model = new Bills();
             $model->billrecord = $bills['billrecord'];
             $model->pament_mode = $bills['pament_mode'];
             $model->watches_id = $bills['watches_id'][$i];
             $model->quantity = $bills['quantity'][$i];
             if ($bills['watches_id'][$i] == '' || $bills['quantity'][$i] == '') {
                 continue;
             } else {
                 if (!$model->save()) {
                     throw new Exception('Bill not saved' . Json::encode($model->getErrors()));
                 }
                 $bill_id = $model->billrecord;
             }
         }
         return $this->redirect(array('site/report/', 'billId' => $bill_id));
     }
     return $this->render('bill', ['model' => $model, 'count' => 0]);
 }