Esempio n. 1
0
 public function actionCustum()
 {
     $debug = '';
     $model = new Mod\Custum();
     $prompt = Yii::t('app', 'Select stock');
     $arrError = [];
     if ($model->load(Yii::$app->request->post())) {
         if (!$model->validate()) {
             $debug = print_r($model->geterrors(), true);
             return $this->render('finish', ['debug' => $debug]);
         }
         $arrvin = explode("\n", $model->vins);
         foreach ($arrvin as $vin) {
             if ($car = Mod\Car::findOne(['vin' => trim($vin)])) {
                 $status = Mod\CarStatus::findOne(['car_id' => $car->id]);
                 $status->custum_date = $model->custum_date;
                 $status->custum_num = $model->custum_num;
                 $status->save();
             } else {
                 $arrError[] = $vin . ' не найден VIN';
             }
         }
         $debug = implode('<br>', $arrError);
         return $this->render('finish', ['debug' => $debug]);
     }
     $arrVars = ['model' => $model, 'prompt' => $prompt, 'selLabel' => 'Склад', 'title' => 'Пакетное ведение деклараций'];
     return $this->render('custum', $arrVars);
 }