/** * Creates a new Affiliated model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Affiliated(); if ($model->load(Yii::$app->request->post())) { $model->create_date = date("Y-m-d H:i:s"); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { $config = new \app\models\Config_system(); $company_id = $config->autoId("affiliated", "company_id", 10); return $this->render('create', ['model' => $model, 'company_id' => $company_id]); } }
/** * Creates a new Driver model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Driver(); if ($model->load(Yii::$app->request->post())) { $model->create_date = date("Y-m-d"); $model->d_update = date("Y-m-d H:i:s"); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { $config = new \app\models\Config_system(); $driver_id = $config->autoId("driver", "driver_id", 5); return $this->render('create', ['model' => $model, 'driver_id' => $driver_id]); } }
/** * Creates a new Customer model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Customer(); if ($model->load(Yii::$app->request->post())) { $tax_number = $model->tax_number; $check = $model->find()->where(['tax_number' => $tax_number])->one(); if ($check['tax_number'] != '') { $config = new \app\models\Config_system(); $cusId = $config->autoId("customer", "cus_id", 7); return $this->render('create', ['error' => "ลูกค้าบริษัทนี้นี้มีอยู่ในระบบแล้ว ...!", 'model' => $model, 'cus_id' => $cusId]); } else { $model->create_date = date("Y-m-d H:i:s"); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } } else { $config = new \app\models\Config_system(); $cusId = $config->autoId("customer", "cus_id", 7); return $this->render('create', ['error' => '', 'model' => $model, 'cus_id' => $cusId]); } }