Пример #1
0
 /**
  * Creates a new JobModel model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new JobModel();
     $now = new \DateTime();
     $now = $now->getTimestamp();
     //         var_dump($now);
     //         var_dump(Yii::$app->user->identity);
     //         die;
     $model->modify_time = $model->create_time = $now;
     $model->modify_user = $model->create_user = $model->owner = Yii::$app->user->identity->username;
     $model->cron_str = "1 * * * *";
     #$date = date_create(); # php, hehe
     $date = date('Y-m-d');
     $date = new \Datetime($date);
     // $date = $date->getTimestamp();
     $model->start_date = $date->getTimestamp();
     $model->end_date = $date->add(new \DateInterval('P99Y'));
     $model->host_strategy = 0;
     $model->restore_strategy = 0;
     $model->retry_strategy = 0;
     $model->error_strategy = 0;
     $model->exist_strategy = 0;
     $model->mails = Yii::$app->user->identity->mail;
     $model->next_run_time = 0;
     $model->status = 0;
     $model->running_timeout_s = 99999;
     $model->oupput_match_reg = 'error';
     $model->team = 'backend';
     $model->phones = '10086';
     $model->desc = ' ';
     // $model->phone = Yii::$app->user->identity->phone;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }