예제 #1
0
 /**
  * Creates a new Schedule model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Schedule();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 function save_data($job_id, $employee_id)
 {
     try {
         $sh = new Schedule();
         $user_id = PostJob::findOne($job_id)->user_id;
         $sh->job_id = $job_id;
         $sh->employee_id = $employee_id;
         $sh->create_time = date('Y-m-d H:i:s');
         $sh->update_time = date('Y-m-d H:i:s');
         $sh->agency_id = Yii::$app->user->identity->id;
         $sh->user_id = $user_id;
         $res = $sh->save();
         return $res;
     } catch (Exception $e) {
         return false;
     }
 }
예제 #3
0
 public function jsonadd(Request $request)
 {
     $data = json_decode($request->getContent(), true);
     foreach ($data as $d) {
         $apt = new AirportsAPI();
         $depicao = Airport::where('icao', $d['depicao'])->get();
         $arricao = Airport::where('icao', $d['arricao'])->get();
         if ($depicao->isEmpty()) {
             $apt->addFromDB($d['depicao']);
         }
         if ($arricao->isEmpty()) {
             $apt->addFromDB($d['arricao']);
         }
         $entry = new Schedule();
         $entry->code = $d['code'];
         $entry->flightnum = $d['flightnum'];
         $entry->depicao = $d['depicao'];
         $entry->arricao = $d['arricao'];
         $entry->route = $d['route'];
         $entry->aircraft = $d['aircraft'];
         $entry->type = $d['type'];
         $entry->daysofweek = $d['daysofweek'];
         $entry->enabled = $d['enabled'];
         $entry->save();
     }
 }