Esempio n. 1
0
 /**
  * Lists all Job models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new Job();
     // This is used to search/filter organizations
     $dataProvider = null;
     if (isset($_GET['user_id'])) {
         $user_id = $_GET['user_id'];
         if ($user_id !== null) {
             $query = new Query();
             $query->from(Job::tableName());
             $query->where(['user_id' => $user_id]);
             $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
         }
     } else {
         $dataProvider = new ActiveDataProvider(['query' => Job::find(), 'pagination' => ['pageSize' => 5]]);
     }
     if ($model->load(Yii::$app->request->post())) {
         $query = new Query();
         $query->from(Job::tableName());
         if (!is_null($model->employment_type) && is_array($model->employment_type)) {
             $query->where(['employment_type' => array_map('intval', $model->employment_type)]);
         }
         if (!is_null($model->job_type) && is_array($model->job_type)) {
             $query->where(['job_type' => array_map('intval', $model->job_type)]);
         }
         if (!is_null($model->work_domain) && is_array($model->work_domain)) {
             $query->andWhere(['work_domain' => array_map('intval', $model->work_domain)]);
         }
         if (isset($_GET['user_id'])) {
             $query->andWhere(['user_id' => $_GET['user_id']]);
         }
         $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
     }
     return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]);
 }
Esempio n. 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $payload['success'] = false;
     $user = new User();
     $updateJob = false;
     foreach ($request->all() as $key => $value) {
         if ('jobId' == $key) {
             $updateJob = $value;
         } else {
             $user->{$key} = $value;
         }
     }
     // Update job with user id
     // @todo - add check on success/failure to save
     if (false !== $updateJob) {
         $job = \App\Models\Job::find($updateJob);
         $job->user = $user->id;
         $job->save();
     }
     $output = $user->save();
     if (false !== $output) {
         $payload['success'] = true;
         $payload['contents'] = ['id' => $user->id];
     }
     return response()->json($payload);
 }
 /**
  * Displays a single Organization model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $query = new Query();
     $query->from(OrganizationAddress::tableName());
     $query->where(['org_id' => $id]);
     $addressDataProvider = new ActiveDataProvider(['query' => $query]);
     $jobDataProvider = new ActiveDataProvider(['query' => Job::find()->where(['org_id' => $id]), 'pagination' => ['pageSize' => 5]]);
     return $this->render('extended_view', ['model' => $this->findModel($id), 'workModel' => OrganizationWork::find()->where(['org_id' => $id])->one(), 'addressDataProvider' => $addressDataProvider, 'jobDataProvider' => $jobDataProvider]);
 }
Esempio n. 4
0
 /**
  * RESTful method for retrieving a job
  *
  * @param  string
  * @return json
  * @author Ashley Banks <*****@*****.**>
  */
 public function show($id = "")
 {
     $payload['success'] = false;
     $output = Job::find($id);
     if (false !== $output) {
         $payload['success'] = true;
         $payload['contents'] = $output;
     }
     return response()->json($payload);
 }
Esempio n. 5
0
 /**
  * Preview of a job for company use
  *
  * @param  string $id
  * @return Response
  * @author Ashley Banks <*****@*****.**>
  */
 public function preview($id = "")
 {
     $job = Job::find($id);
     if (false === $job) {
         throw new Exception("Must provide valid job identifier to preview job");
     }
     if (false !== Auth::check()) {
         return view('jobs.preview', ['id' => $id]);
     }
     // Redirect to another stage
     return redirect('jobs/user/' . $job->id);
 }
Esempio n. 6
0
 public function Run()
 {
     while ($this->keepRunning()) {
         $job = Job::find()->where('status IS NULL')->one();
         if ($job === null) {
             sleep(1);
             continue;
         }
         if (!$this->assignJob($job)) {
             continue;
         }
         $this->runJob($job);
     }
 }
Esempio n. 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Job::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 8
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Job::find(), 'pagination' => ['pageSize' => 1]]);
     $model = new DynamicModel(['search_keyword', 'search_location', 'search_type']);
     $model->addRule('search_type', 'integer')->addRule('search_location', 'string', ['max' => 128])->addRule('search_keyword', 'string', ['max' => 128]);
     if ($model->load(Yii::$app->request->post())) {
         switch ($model->search_type) {
             case Lookup::item_code('SearchType', 'Organizations'):
                 return $this->redirect(['organization/index', 'search_keyword' => $model->search_keyword]);
                 break;
             case Lookup::item_code('SearchType', 'Opportunities'):
                 return $this->redirect(['job/index', 'search_keyword' => $model->search_keyword]);
                 break;
             default:
                 throw new NotFoundHttpException('Your search:' . $model->search_keyword);
                 break;
         }
     }
     return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]);
 }
Esempio n. 9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $access = Access::findAll(['user_id' => Yii::$app->user->getId()]);
     $counties = ArrayHelper::getColumn($access, 'county_id');
     $query = Job::find()->where(['county.id' => $counties]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     $dataProvider->sort->attributes['jobField.name'] = ['asc' => ['job_field.name' => SORT_ASC], 'desc' => ['Job_field.name' => SORT_DESC]];
     $dataProvider->sort->attributes['city.name'] = ['asc' => ['city.name' => SORT_ASC], 'desc' => ['city.name' => SORT_DESC]];
     $dataProvider->sort->attributes['state.name'] = ['asc' => ['state.name' => SORT_ASC], 'desc' => ['state.name' => SORT_DESC]];
     $dataProvider->sort->attributes['county.name'] = ['asc' => ['county.name' => SORT_ASC], 'desc' => ['county.name' => SORT_DESC]];
     $query->joinWith(['jobField']);
     $query->joinWith(['city']);
     $query->joinWith(['state']);
     $query->joinWith(['county']);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'job_field_id' => $this->job_field_id, 'state_id' => $this->state_id, 'date_posted' => $this->date_posted, 'job_field.name' => $this->jobField['name'], 'city.name' => $this->city['name'], 'county.name' => $this->county['name'], 'state.name' => $this->state['name']]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'phone_number', $this->phone_number])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'job_field.name', $this->getAttribute('jobField.name')])->andFilterWhere(['like', 'city.name', $this->getAttribute('city.name')])->andFilterWhere(['like', 'county.name', $this->getAttribute('county.name')])->andFilterWhere(['like', 'state.name', $this->getAttribute('state.name')]);
     return $dataProvider;
 }
Esempio n. 10
0
 public function searchByCompany($params)
 {
     $company_id = $params['id'];
     $wherelist1 = '';
     $wherelist2 = '';
     if (isset($params['from_date']) && !empty($params['from_date'])) {
         $from_date = $params['from_date'];
         $wherelist1 = 'job_date >= "' . $from_date . '"';
     }
     if (isset($params['to_date']) && !empty($params['to_date'])) {
         $to_date = $params['to_date'];
         $wherelist2 = 'job_date <= "' . $to_date . '"';
     }
     $query = Job::find();
     $query->where('company_id=' . $company_id);
     if ($wherelist1 != "") {
         $query->andWhere($wherelist1);
     }
     if ($wherelist2 != "") {
         $query->andWhere($wherelist2);
     }
     if ($wherelist1 == "" && $wherelist2 == "") {
         $query->andWhere('job_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY');
     }
     // echo $query->createCommand()->getRawSql();exit;
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['job_date' => SORT_ASC]]]);
     // $this->load($params);
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['job_id' => $this->job_id, 'company_id' => $this->company_id, 'job_date' => $this->job_date, 'quota' => $this->quota, 'time_in' => $this->time_in, 'time_out' => $this->time_out, 'close_hour' => $this->close_hour]);
     $query->andFilterWhere(['like', 'job_order', $this->job_order]);
     return $dataProvider;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return view('jobs.view', ['job' => Job::find($id)]);
 }
Esempio n. 12
0
 public function actionJobs($q = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if (is_null($q)) {
         $q = "";
     }
     $out = ['results' => []];
     $occurrence = false;
     $jobs = Job::find()->where('name LIKE :q')->params([':q' => '%' . $q . '%'])->asArray()->all();
     foreach ($jobs as $job) {
         if ($job['name'] == $q) {
             $occurrence = true;
         }
         $out['results'][] = ['id' => $job['id'], 'text' => $job['name']];
     }
     if (!$occurrence && $q != "") {
         $out['results'][] = ['id' => $q, 'text' => $q];
     }
     return $out;
 }
Esempio n. 13
0
 public function actionStatus()
 {
     echo "Pending   jobs: " . Job::find()->where('status IS NULL')->count() . "\n";
     echo "Running   jobs: " . Job::find()->where('status = "running"')->count() . "\n";
     echo "Completed jobs: " . Job::find()->where('status = "completed"')->count() . "\n";
 }