public function register(Request $request)
 {
     $job = new Job();
     $job->timestamps = false;
     $job->jobTitle = $request->input('title');
     $job->jobAttributes = $request->input('attributes');
     $job->jobDescription = $request->input('description');
     $job->jobPublishDate = $request->input("finishDate");
     $job->jobFinishDate = $request->input('finishDate');
     $job->jobLocation = $request->input('location');
     $job->jobNeedPersonal = $request->input('needPersonal');
     $job->jobSector = $request->input('sector');
     $job->jobPozisyonTip = $request->input('pozisyonTip');
     $job->jobDepartment = $request->input('department');
     $job->jobLevel = $request->input('level');
     $job->jobExperienceLevel = $request->input('experienceLevel');
     $job->jobEducationLevel = $request->input('educationLevel');
     if ($job->save()) {
         //Session::set('employeeId', $query->employeeId);
         $result = array("result" => "success");
     } else {
         $result = array("result" => "failed");
     }
     return \View::make('ajaxResult', $result);
 }
Example #2
0
 function refreshComment($id)
 {
     $job = new Job();
     $job->type = 'refresh_comment';
     $job->arguments = json_encode(['id' => $id]);
     $job->save();
 }
 private function failJob(Job $job, $msg)
 {
     $message = "Job with ID {$job->id} failed: {$msg}";
     echo "{$message}\n";
     Yii::getLogger()->log($message, Logger::LEVEL_ERROR);
     $job->status = 'failed';
     if (!$job->save()) {
         Yii::getLogger()->log("Failed to save failure status in the job {$job->id}", Logger::LEVEL_ERROR);
     }
 }
Example #4
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->call(function () {
         Log::info('attaching new verified skills started');
         $skills = Skill::whereNotNull('verified_skill_id')->get();
         foreach ($skills as $skill) {
             $jobs = Job::whereHas('skills', function ($query) use($skill) {
                 $query->where('skill_id', $skill->id);
             })->whereHas('verifiedSkills', function ($query) use($skill) {
                 $query->where('verified_skill_id', $skill->verified_skill_id);
             }, '<', 1)->get();
             foreach ($jobs as $job) {
                 $job->verifiedSkills()->attach($skill->verified_skill_id);
             }
         }
     })->daily();
     $schedule->call(function () {
         Log::info('HH parsing started');
         $hhGrabber = $this->app['App\\Helpers\\HeadHunterGrabber'];
         $job = $this->app['App\\Models\\Job'];
         $parser = new Parser([$hhGrabber], $job);
         $parser->parse();
     })->daily();
 }
Example #5
0
 /**
  * получает  массив вакансий за пол года, содержащих хотябы один навык из перечисленных
  *
  * @param $skillIds - массив навыков
  * @param $areaId - регион
  */
 public static function getJobWithSkills($skillIds, $areaId)
 {
     $currentDate = new \DateTime();
     $halfYear = new \DateInterval('P3M');
     $date = $currentDate->sub($halfYear)->format('Y-m-d');
     $jobs = Job::with('verifiedSkills')->where('area_id', $areaId)->where('endda', '>=', $date)->whereHas('verifiedSkills', function ($query) use($skillIds) {
         $query->whereIn('verified_skills.id', $skillIds);
     })->get();
     $groups = [];
     foreach ($jobs as $job) {
         $groupElement = $job->toGroupElement($skillIds);
         if ($groupElement['additional_skills_count'] <= 3) {
             $groups[$job->getGroupName($skillIds)][] = $groupElement;
         }
     }
     $result = [];
     foreach ($groups as $groupName => $group) {
         $groupAggregation = Job::getGroupAggregation($groupName, $group);
         if ($groupAggregation['aggregation']['actual_count'] > 0) {
             $result[] = $groupAggregation;
         }
     }
     usort($result, function ($group1, $group2) {
         $a = $group1['aggregation']['additional_skills_count'];
         $b = $group2['aggregation']['additional_skills_count'];
         if ($a === $b) {
             return 0;
         }
         return $a > $b ? 1 : -1;
     });
     return $result;
 }
Example #6
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);
 }
Example #7
0
 public function attributes()
 {
     $allAttr = array_merge(parent::attributes(), ['city.name']);
     $allAttr = array_merge($allAttr, ['state.name']);
     $allAttr = array_merge($allAttr, ['jobField.name']);
     $allAttr = array_merge($allAttr, ['county.name']);
     return $allAttr;
 }
 /**
  * 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]);
 }
Example #9
0
 /**
  * Edit Emails Reports
  * @return Array json Emails
  */
 public function editemails($id)
 {
     // Find the emailreport using the email id
     $email = Emails::find($id);
     $clientspermissions = "";
     $jobspermissions = "";
     $clientspermissions = unserialize($email->clients);
     $jobspermissions = unserialize($email->jobs);
     Former::populate($email);
     return View::make('admin.emailnewedit')->with('when', array('Daily' => 'Daily', "Weekly" => "Weekly", "Monthly" => "Monthly"))->with('whenSelected', $email->when)->with('clients', Client::clientSelectBox())->with('clientsSelected', $clientspermissions)->with('jobsSelected', $jobspermissions)->with('jobs', Job::jobSelectBox())->with('emails', $email->emails)->with('id', $email->id);
 }
Example #10
0
 /**
  * Show job
  *
  * @param  string $urlname [description]
  * @return Response
  * @author Ashley Banks <*****@*****.**>
  */
 public function show($urlname = "")
 {
     $job = Job::where('urlname', '=', $urlname)->first();
     if (false === $job) {
         throw new Exception("Must provide valid job to display");
     }
     if (false !== Auth::check()) {
     }
     // Redirect to another stage
     return redirect('jobs/user/' . $job->id);
 }
Example #11
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;
 }
Example #12
0
 public static function jobSelectBox($jobsall = null)
 {
     // Code to resolve pgsql names
     $f_Name = 'Name';
     $f_JobID = 'JobId';
     if (Config::get('database.default') == 'pgsql') {
         $f_Name = strtolower($f_Name);
         $f_JobID = strtolower($f_JobID);
     }
     if ($jobsall == null) {
         $jobsall = Job::select($f_JobID, $f_Name)->distinct($f_Name)->orderBy($f_Name, 'asc')->get()->toArray();
     }
     $jobsName = array_fetch($jobsall, $f_Name);
     $jobsId = array_fetch($jobsall, $f_JobID);
     $jobsSelectBox = array_unique(array_combine($jobsId, $jobsName));
     natsort($jobsSelectBox);
     return $jobsSelectBox;
 }
Example #13
0
 public static function postJob($data)
 {
     // Charge Stripe
     Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
     $customer = Stripe\Customer::create(['email' => $data['email'], 'card' => $data['stripe_token']]);
     $charge = Stripe\Charge::create(['customer' => $customer->id, 'amount' => $data['total'] * 100, 'currency' => 'aud']);
     if ($charge->status == 'failed') {
         return false;
     }
     // Save Job
     unset($data['stripe_token']);
     unset($data['_token']);
     $data['end_date'] = Carbon::createFromFormat('Y-m-d', $data['start_date'])->addWeeks($data['duration']);
     $job = Job::create($data);
     // Email Confirmation / edit link
     //Mail::queue();
     // Return Job Object
     return $job;
 }
Example #14
0
 /**
  * Edit User
  * @return Array json Users
  */
 public function edituser($id)
 {
     // Find the user using the user id
     $user = Sentry::getUserProvider()->findById($id);
     // Get the user groups
     $groupsOfSelected = $user->getGroups();
     foreach ($groupsOfSelected as $group) {
         $this->groupSelected[$group->id] = $group->id;
     }
     $clientspermissions = "";
     $jobspermissions = "";
     $permissions = Userspermissions::find($id);
     if ($permissions != null) {
         $clientspermissions = unserialize($permissions->clients);
         $jobspermissions = unserialize($permissions->jobs);
     }
     Former::populate($user);
     //LOG::info(User::find($id));
     return View::make('admin.usersnewedit')->with('groups', $this->group_array)->with('groupSelected', $this->groupSelected)->with('clients', Client::clientSelectBox())->with('clientsSelected', $clientspermissions)->with('jobsSelected', $jobspermissions)->with('jobs', Job::jobSelectBox())->with('email', $user->email)->with('id', $user->id);
 }
Example #15
0
 /**
  * Execute the email command.
  *
  * @return mixed
  */
 public function fire()
 {
     $schedule = $this->argument('schedule');
     if ($schedule == "DAY") {
         $schedule = '1 Day';
     } elseif ($schedule == "WEEK") {
         $schedule = '7 Day';
     } else {
         $schedule = '31 Day';
     }
     $emails = Emails::where('when', '=', $schedule)->get();
     foreach ($emails as $email) {
         $tjobs = Job::where('jobstatus', '=', 'T')->where('starttime', '>=', Date::now()->sub($schedule))->where('endtime', '<=', Date::now())->whereIn('clientid', unserialize($email->clients))->get();
         $data['table'] = $tjobs;
         /* sends Email */
         Mail::send('emails.report', $data, function ($message, $schedule) {
             $message->to($email->emails)->subject('Backups Stats ' . $schedule . ' Report');
         });
     }
 }
Example #16
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]);
 }
Example #17
0
 /**
  * Edit Group
  * @return Array json groups
  */
 public function editgroup($id)
 {
     // Find the user using the user id
     $group = Sentry::getGroupProvider()->findById($id);
     $users = Sentry::getUserProvider()->findAllInGroup($group);
     // Get the user groups
     $userSelected = "";
     foreach ($users as $user) {
         $userSelected[$user->id] = $user->id;
     }
     /* Get Groups Permissions */
     $clientspermissions = "";
     $jobspermissions = "";
     $permissions = Groupspermissions::find($id);
     if ($permissions != null) {
         $clientspermissions = unserialize($permissions->clients);
         $jobspermissions = unserialize($permissions->jobs);
     }
     // LOG::info( $group->name);
     Former::populate($group->id);
     return View::make('admin.groupsnewedit')->with('users', $this->user_array)->with('userSelected', $userSelected)->with('clients', Client::clientSelectBox())->with('clientsSelected', $clientspermissions)->with('jobsSelected', $jobspermissions)->with('jobs', Job::jobSelectBox())->with('groupname', $group->name)->with('id', $group->id);
 }
Example #18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getJob()
 {
     return $this->hasOne(Job::className(), ['id' => 'job_id']);
 }
Example #19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getJobs()
 {
     return $this->hasMany(Job::className(), ['idCategory' => 'id']);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return view('jobs.view', ['job' => Job::find($id)]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Job $jobModel, Request $request, StoreJobPostRequest $request)
 {
     $title = $request->input('title');
     $jobModel->create($request->all());
     return redirect('/');
 }
Example #22
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;
 }
Example #23
0
 public function getvolumes()
 {
     $tjobs = Job::select(array($this->tables['job'] . '.jobid', 'name', 'starttime', 'endtime', 'level', 'jobbytes', 'jobfiles', 'jobstatus'))->join($this->tables['jobmedia'], $this->tables['jobmedia'] . '.jobid', '=', $this->tables['job'] . '.jobid')->join($this->tables['media'], $this->tables['media'] . '.mediaid', '=', $this->tables['jobmedia'] . '.mediaid')->where($this->tables['media'] . '.mediaid', '=', Input::get('Volume'))->groupby($this->tables['job'] . '.jobid')->groupby('starttime')->groupby('endtime')->groupby('level')->groupby('jobbytes')->groupby('jobfiles')->groupby('jobstatus')->groupby('name')->groupby('volumename');
     return Datatables::of($tjobs)->edit_column('name', '{{ link_to_route("jobs", $name ,array("Job" => $jobid)) }} ')->edit_column('jobid', '{{ link_to_route("jobs", $jobid ,array("Job" => $jobid)) }} ')->make();
 }
Example #24
0
 /**
  * Finds the Job model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Job the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Job::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #25
0
 public function getclients()
 {
     $start = Input::get('start', Date::now()->format('date'));
     $end = Input::get('end', Date::now()->format('date'));
     $client = Client::where('clientid', '=', Input::get('Client'))->first();
     $tjobs = Job::select(array('jobid', 'name', 'starttime', 'endtime', 'level', 'jobbytes', 'jobfiles', 'jobstatus'))->where('clientid', '=', $client->clientid)->where('starttime', '>=', $start)->where('endtime', '<=', $end);
     switch (Input::get('type')) {
         case "terminated":
             $tjobs->where('jobstatus', '=', 'T');
             break;
         case "running":
             $tjobs->where('jobstatus', '=', 'R');
             break;
         case "watting":
             $tjobs->wherein('jobstatus', array('c', 'F', 'j', 'M', 'm', 'p', 's', 't'));
             break;
         case "error":
             $tjobs->wherein('jobstatus', array('e', 'f', 'E'));
             break;
         case "cancel":
             $tjobs->where('jobstatus', '=', 'A');
             break;
     }
     return Datatables::of($tjobs)->edit_column('name', '{{ link_to_route("jobs", $name ,array("Job" => $jobid)) }} ')->edit_column('jobid', '{{ link_to_route("jobs", $jobid ,array("Job" => $jobid)) }} ')->make();
 }
Example #26
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getJobs()
 {
     return $this->hasMany(Job::className(), ['idCompany' => 'idUser']);
 }
Example #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('payables')->delete();
     DB::table('payable_types')->delete();
     DB::table('job_order_jobs')->delete();
     DB::table('job_orders')->delete();
     DB::table('jobs')->delete();
     DB::table('customer_phones')->delete();
     DB::table('customers')->delete();
     DB::table('users')->delete();
     DB::table('companies')->delete();
     $companies = [];
     foreach (range(0, 2) as $x) {
         $companies[] = \App\Models\Company::create(['name' => "Empresa {$x}", 'email' => "empresa{$x}@teste.com.br", 'cnpj' => '81.748.407/0001-01', 'ie' => '309.639.790.252', 'address' => "Endereço da Empresa {$x}", 'number' => $x, 'district' => "Bairro de Teste {$x}", 'city' => "Cidade de Teste {$x}", 'state' => "Teste", 'zip' => '00000-0' . str_pad($x, 2, '0', STR_PAD_LEFT), 'contact' => "Pessoa de Teste {$x}"]);
     }
     $cid = 0;
     foreach ($companies as $company) {
         $cid += 1;
         User::create(['name' => 'Teste', 'email' => "teste{$cid}@teste.com.br", 'password' => Hash::make('teste')])->company()->associate($company)->save();
         $jobs = [];
         foreach (range(0, 15) as $x) {
             $job = Job::create(['name' => "Serviço de teste {$cid}/{$x}", 'price' => $x * 100, 'description' => "Serviço de teste {$x}"])->company()->associate($company);
             $job->save();
             $jobs[] = $job;
         }
         $customers = [];
         foreach (range(0, 15) as $x) {
             $customer = Customer::create(['name' => "Cliente {$cid}/{$x}", 'email' => "cliente{$x}@teste.com.br", 'cnpj' => '81.748.407/0001-01', 'ie' => '309.639.790.252', 'address' => "Endereço de Teste {$x}", 'number' => $x, 'district' => "Bairro de Teste {$x}", 'city' => "Cidade de Teste {$x}", 'state' => "Teste", 'zip' => '00000-0' . str_pad($x, 2, '0', STR_PAD_LEFT), 'contact' => "Pessoa de Teste {$x}"])->company()->associate($company);
             $customer->save();
             foreach (range(0, rand(1, 5)) as $y) {
                 $customer->phones()->create(['phone' => "1398765432{$y}"]);
             }
             $testJobs = array_pick_index($jobs, array_rand($jobs, 5));
             $customerJobOrder = JobOrder::create(['customer_id' => $customer->id, 'note' => "Nota de teste para o cliente {$cid}/{$x}"])->company()->associate($company);
             $customerJobOrder->save();
             $testJobs = array_map(function ($item) {
                 return ['job_id' => $item->id, 'price' => $item->price];
             }, $testJobs);
             $customerJobOrder->jobs()->sync($testJobs);
             $customerJobOrder->save();
             $customers[] = $customer;
         }
         $payableTypes = [];
         foreach (range(0, 15) as $i) {
             $payableType = PayableType::create(['name' => "Conta de Teste {$cid}/{$i}", 'description' => "Descrição do tipo {$i}"])->company()->associate($company);
             $payableType->save();
             $payableTypes[] = $payableType;
         }
         $payables = [];
         foreach ($customers as $customer) {
             foreach (range(0, rand(1, 5)) as $x) {
                 $type = current(array_pick_index($payableTypes, array_rand($payableTypes, 5)));
                 $payable = \App\Models\Payable::create(['payable_type_id' => $type->id, 'date' => \Carbon\Carbon::now()->addDays(rand(1, 60)), 'status' => rand(1, 2), 'price' => $x * 100, 'description' => "Descrição de uma conta a pagar {$customer->id}/{$x}"])->company()->associate($company);
                 $payable->save();
                 $payables[] = $payable;
             }
         }
     }
     Model::reguard();
 }
Example #28
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getJobs()
 {
     return $this->hasMany(Job::className(), ['org_id' => 'id']);
 }
Example #29
0
 public function index(Request $request)
 {
     return Job::throughCompany()->ngTable($request, null, ['id', 'name'], ['id', 'name']);
 }
Example #30
0
 /**
  * RESTful method for deleting a job
  *
  * @param  string $id
  * @return json
  * @author Ashley Banks <*****@*****.**>
  */
 public function destroy($id = "")
 {
     $payload['success'] = false;
     if (false !== Job::destroy($id)) {
         $payload['success'] = true;
     }
     return response()->json($payload);
 }