/** * Updates an existing Job model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $admin_id = Yii::$app->user->identity->id; $model = $this->findModel($id); $companies = Company::find(); if (Yii::$app->user->identity->type == 'normal') { $companies = $companies->innerJoin('wolf_admin_to_company wc', 'wc.company_id=wolf_company.company_id'); $companies = $companies->where('admin_id=' . $admin_id); } $companies = $companies->orderBy('company_name'); $companies = $companies->asArray(); $companies = $companies->all(); $jobScheduleSearch = new JobScheduleSearch(['job_id' => $id]); $scheduleData = $jobScheduleSearch->search(Yii::$app->request->getQueryParams()); $scheduleData->pagination->pageSize = -1; //infinite value if ($model->load(Yii::$app->request->post())) { $time_in_hour = $_POST['Job']['time_in_hour']; $time_in_minute = $_POST['Job']['time_in_minute']; $time_out_hour = $_POST['Job']['time_out_hour']; $time_out_minute = $_POST['Job']['time_out_minute']; $model->time_in = $time_in_hour . ':' . $time_in_minute . ':00'; $model->time_out = $time_out_hour . ':' . $time_out_minute . ':00'; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['update', 'id' => $model->job_id]); } else { return $this->render('update', ['model' => $model, 'companies' => $companies, 'jobScheduleSearch' => $jobScheduleSearch, 'scheduleData' => $scheduleData]); } }
public function actionJob($id) { $jobScheduleSearch = new JobScheduleSearch(['employee_id' => $id]); $jobScheduleData = $jobScheduleSearch->searchByEmployee(Yii::$app->request->queryParams); $jobScheduleData->pagination->pageSize = 20; return $this->render('job', ['model' => $this->findModel($id), 'jobScheduleData' => $jobScheduleData, 'jobScheduleSearch' => $jobScheduleSearch]); }