private function get_employers() { $branch = $this->employee->getBranch(); $criteria = array('columns' => "DISTINCT employers.name AS employer, employers.id", 'joins' => "employers ON employers.id = jobs.employer, \n employees ON employees.id = employers.registered_by", 'match' => "employees.branch = " . $branch[0]['id'], 'order' => "employers.name"); $job = new Job(); return $job->find($criteria); }
public function displayjobsItems($jobId) { if (Auth::check()) { $data['job'] = Job::find($jobId); $data['jobs'] = ApplyJobs::where('jobs_id', '=', $jobId)->get(); $data = DB::table('users')->join('jobs_applied', 'users.id', '=', 'jobs_applied.userid')->leftJoin('user_rating', 'users.id', '=', 'user_rating.rated_id')->leftJoin('shortlist', function ($join) { $join->on('users.id', '=', 'shortlist.shorlisted_userid')->on('jobs_applied.jobs_id', '=', 'shortlist.shortlist_jobs_id'); })->select('*', DB::raw('ROUND(avg(user_rating.rating), 2) AS average'))->where('jobs_applied.jobs_id', $jobId)->where('jobs_applied.status', '!=', 'invited')->groupBy('users.id')->get(); // foreach ($data as $value) { // // $data['avg'] = DB::table('user_rating') // ->select(DB::raw('avg(user_rating.rating) AS average')) // ->where('user_rating.user_id', $value->id) // ->get(); // // } // $data = DB::table('users') // ->join('jobs_applied', 'users.id', '=', 'jobs_applied.userid') // ->join('user_rating', 'users.id', '=', 'user_rating.user_id') // ->select('*' , DB::raw('avg(user_rating.rating) AS average')) // ->where('jobs_applied.jobs_id', $jobId) // ->get(); return $data; //return View::make('login/job-itms' , $data); } }
/** * Revive crashed crons */ private function refreshCronJobs() { $jobs = Job::find(['conditions' => ['nextRun' => ['$lte' => time() - 5 * 60], 'status' => 1]]); foreach ($jobs as $job) { $job->save(); } }
private function get_countries() { $criteria = array('columns' => "countries.country_code, countries.country, COUNT(jobs.id) AS job_count", 'joins' => "countries ON countries.country_code = jobs.country", 'match' => "jobs.deleted = FALSE AND jobs.expire_on >= CURDATE() AND jobs.closed = 'N'", 'group' => "countries.country_code", 'order' => "countries.country ASC"); $job = new Job(); $countries = $job->find($criteria); return $countries === false ? array() : $countries; }
/** * Get first queued job from database. * * * @return \Armxy\Queue\Models\Job */ function getFirstQueue() { $firstQueue = Queue::where('status', '=', Job::STATUS_OPEN)->orderBy('created_at')->first(); if (!is_null($firstQueue)) { $job = Job::find($firstQueue->id); return $job; } }
public function get() { $uid = (int) $_REQUEST['uid']; if ($uid == 0) { $uid = $this->user->id; } $where = array(array('uid', '=', $uid)); $userClass = new Job(); $results = $userClass->find($where); if (sizeof($results) == 0) { return false; } $data = $this->parse($results[0]); return $data; }
} } header('Content-type: text/xml'); $response = array('found_employers' => array('found_employer' => $found_employers), 'pagination' => array('total_pages' => $total_pages, 'current_page' => $_POST['page']), 'application' => $result); echo $xml_dom->get_xml_from_array(array('applications' => $response)); exit; } if ($_POST['action'] == 'get_testimony') { $criteria = array('columns' => "testimony", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $referral = new Referral(); $result = $referral->find($criteria); $testimony = htmlspecialchars_decode(str_replace("\n", '<br/>', $result[0]['testimony'])); echo $testimony; exit; } if ($_POST['action'] == 'get_job_desc') { $criteria = array('columns' => "description", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $job = new Job(); $result = $job->find($criteria); $job_desc = htmlspecialchars_decode(str_replace("\n", '<br/>', $result[0]['description'])); echo $job_desc; exit; } if ($_POST['action'] == 'get_employer_remarks') { $criteria = array('columns' => "employer_remarks", 'match' => "id = " . $_POST['id'], 'limit' => "1"); $referral = new Referral(); $result = $referral->find($criteria); $remarks = str_replace("\n", '<br/>', stripslashes($result[0]['employer_remarks'])); echo $remarks; exit; }
protected function top_search($_page_title) { // get the employers $criteria = array('columns' => 'employers.id, employers.name, COUNT(jobs.id) AS job_count', 'joins' => 'employers ON employers.id = jobs.employer', 'group' => 'employers.id', 'order' => 'employers.name ASC'); $job = new Job(); $employers = $job->find($criteria); if ($employers === false) { $employers = array(); } // get the industries $industries = Industry::getIndustriesFromJobs(true); // get the countries $criteria = array('columns' => "countries.country_code, countries.country, COUNT(jobs.id) AS job_count", 'joins' => "countries ON countries.country_code = jobs.country", 'group' => "countries.country_code", 'order' => "countries.country ASC"); $job = new Job(); $countries = $job->find($criteria); $top = file_get_contents(dirname(__FILE__) . '/../../html/top_search.html'); $top = str_replace('%root%', $this->url_root, $top); $employers_options = ''; foreach ($employers as $emp) { $employers_options .= '<option value="' . $emp['id'] . '">' . desanitize($emp['name']); if ($emp['job_count'] > 0) { $employers_options .= ' (' . $emp['job_count'] . ')'; } $employers_options .= '</option>' . "\n"; } $top = str_replace('<!-- %employers_options% -->', $employers_options, $top); $industries_options = ''; foreach ($industries as $industry) { $industries_options .= '<option value="' . $industry['id'] . '">' . $industry['industry']; if ($industry['job_count'] > 0) { $industries_options .= ' (' . $industry['job_count'] . ')'; } $industries_options .= '</option>' . "\n"; } $top = str_replace('<!-- %industries_options% -->', $industries_options, $top); $countries_options = ''; foreach ($countries as $a_country) { $countries_options .= '<option value="' . $a_country['country_code'] . '">' . $a_country['country']; if ($a_country['job_count'] > 0) { $countries_options .= ' (' . $a_country['job_count'] . ')'; } $countries_options .= '</option>' . "\n"; } $top = str_replace('<!-- %countries_options% -->', $countries_options, $top); echo $top; }
<?php require_once dirname(__FILE__) . "/../../private/lib/utilities.php"; header('Content-type: text/xml'); $xml_dom = new XMLDOM(); $response = array(); $result = array(); $result = Job::find(array('columns' => 'employers.id, employers.name', 'joins' => 'employers ON employers.id = jobs.employer', 'match' => 'employers.active = \'Y\' AND jobs.closed = \'N\' AND jobs.expire_on >= NOW()', 'group' => 'employers.id', 'order' => 'employers.name')); $i = 0; foreach ($result as $row) { $response[$i]['id'] = $row['id']; $response[$i]['name'] = $row['name']; $i++; } $xml_array = array('employers' => array('employer' => $response)); echo $xml_dom->get_xml_from_array($xml_array);
//Get all aprameters $r = Feedback::update_feedback($params); $app->response->body(json_encode($r)); }); //Delete Feedback - OK $app->delete("/feedback/delete/:id", function ($id) use($app) { $f = Feedback::find($id); $f->delete(); $app->response->body(); }); //Insert Feedback $app->post("/feedback/set", function () use($app) { $params = $app->request()->params(); //Get all aprameters $set_feedback = JobOffers::set_bid(); $app->response->body(json_encode($set_feedback)); }); //OFFERS $app->post("/job/offer", function () use($app) { $params = $app->request()->params(); $new_bid = JobOffers::set_bid($params); $app->response->body(json_encode($new_bid)); }); $app->post("/job/get_offers", function () use($app) { $params = $app->request()->params(); $j = Job::find($params['id']); $j->jobOffers; $app->response->body($j->toJson()); }); //Run application $app->run();
$data['salary'] = '3200'; $data['salary_negotiable'] = 'N'; $data['created_on'] = $date; $data['expire_on'] = $expiry_date; $data['title'] = "Some lame job"; $data['description'] = "blahlelelll blah... some job descriptions goes here"; if ($job->create($data)) { echo "This job gets the ID of <b>" . $job->getId() . "</b><br><br>"; print_array($job->get()); } else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Get all jobs... </p><p><?php $jobs = $job->find(array('columns' => 'id')); echo "There are " . count($jobs) . " jobs in the database.<br><br>"; ?> </p><p style="font-weight: bold;">Update 1st job... </p><p><?php echo $first_job_id . '<br/>'; $job = new Job($first_job_id); $data = array(); $data['country'] = 'HK'; $data['currency'] = 'HKD'; $data['salary'] = '5562'; $data['salary_negotiable'] = 'Y'; $data['description'] = "wllwh kwhhwf wpejf[w wopj blahlelelll blah... some job descriptions goes here"; if ($job->update($data)) { print_array($job->get()); } else { echo "failed";
if ($_POST['action'] == 'get_jobs') { $employer = new Employer($_POST['id']); $result = $employer->getJobs($_POST['order']); if (is_null($result) || empty($result)) { echo '0'; exit; } if ($result === false) { echo 'ko'; exit; } foreach ($result as $i => $row) { $result[$i]['title'] = htmlspecialchars_decode(stripslashes($row['title'])); } header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array(array('jobs' => array('job' => $result))); exit; } if ($_POST['action'] == 'get_job') { $job = new Job($_POST['id']); $result = $job->get(); $result[0]['title'] = htmlspecialchars_decode(stripslashes($result[0]['title'])); $result[0]['description'] = htmlspecialchars_decode(stripslashes($result[0]['description'])); $result[0]['description'] = str_replace('<br/>', "\n", $result[0]['description']); $criteria = array('columns' => "job_index.state", 'joins' => "job_index ON job_index.job = jobs.id", 'match' => "jobs.id = " . $_POST['id'], 'limit' => "1"); $tmp = $job->find($criteria); $result[0]['state'] = $tmp[0]['state']; header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array(array('job' => $result)); exit; }
<?php require_once dirname(__FILE__) . "/../../private/lib/utilities.php"; header('Content-type: text/xml'); $xml_dom = new XMLDOM(); $result = Job::find(array('columns' => 'SUM(potential_reward) AS sumReward, branches.country AS country_code, branches.currency', 'joins' => 'employers on employers.id = jobs.employer, branches on branches.id = employers.branch', 'match' => 'jobs.closed = \'N\' AND jobs.expire_on >= NOW()', 'group' => 'branches.country', 'order' => 'sumReward')); $response = array(); $i = 0; foreach ($result as $row) { if ($row['sumReward'] != '0') { $response[$i] = $row; $i++; } } /*$response = Job::find(array( 'columns' => 'SUM(potential_reward) AS sumReward, jobs.currency, currencies.country_code', 'joins' => 'currencies ON currencies.symbol = jobs.currency', 'match' => 'jobs.closed = \'N\'', 'group' => 'jobs.currency', 'order' => 'sumReward' ) );*/ // format the rewards foreach ($response as $i => $row) { $response[$i]['sumReward'] = number_format($row['sumReward'], 0, '.', ', '); } $xml_array = array('rewards' => array('potential' => $response)); echo $xml_dom->get_xml_from_array($xml_array);
private function get_job_info() { $criteria = array('columns' => 'jobs.*, industries.industry AS full_industry, countries.country AS country_name, employers.name AS employer_name, employers.website_url AS employer_website_url, branches.currency, DATE_FORMAT(jobs.expire_on, \'%e %b, %Y\') AS formatted_expire_on, DATEDIFF(NOW(), jobs.expire_on) AS expired', 'joins' => 'industries ON industries.id = jobs.industry, countries ON countries.country_code = jobs.country, employers ON employers.id = jobs.employer, employees ON employees.id = employers.registered_by, branches ON branches.id = employees.branch', 'match' => "jobs.id = " . $this->job_id . " AND jobs.deleted = FALSE"); $job = new Job(); $result = $job->find($criteria); $job = array(); if (count($result) <= 0 || is_null($result)) { return NULL; } $job = $result[0]; $total_potential_reward = $job['potential_reward']; $potential_token_reward = $total_potential_reward * 0.05; $potential_reward = $total_potential_reward - $potential_token_reward; $job['description'] = htmlspecialchars_decode($job['description']); if (!is_null($job['alternate_employer']) && !empty($job['alternate_employer'])) { $job['employer_name'] = $job['alternate_employer']; } $job['potential_reward'] = number_format($potential_reward, 0, '.', ', '); $job['potential_token_reward'] = number_format($potential_token_reward, 0, '. ', ', '); $job['salary'] = number_format($job['salary'], 0, '. ', ', '); $job['salary_end'] = number_format($job['salary_end'], 0, '. ', ', '); $job['state'] = ucwords($job['state']); return $job; }
public static function job_offer($params) { $job = Job::find($params['id']); $job->update($params); if ($job->save()) { return 1; } else { return 0; } }
<?php require_once dirname(__FILE__) . "/../../private/lib/utilities.php"; header('Content-type: text/xml'); $xml_dom = new XMLDOM(); $response = Job::find(array('columns' => 'COUNT(*) AS jobcount', 'match' => 'jobs.closed = \'N\' AND jobs.expire_on >= NOW()')); $response[0]['jobcount'] = number_format($response[0]['jobcount'], 0, ".", ","); $xml_array = array('jobs' => $response); echo $xml_dom->get_xml_from_array($xml_array);
/** * Show the form for creating a new job * * @return Response */ public function anyCreate($id = 0) { $user = Sentry::getUser(); $jobCategories = JobCategory::where('active', '=', 1)->orderBy('name')->lists("name", "id"); $jobSubCats = JobSubCategory::all(); $jobSubCategories = array(); foreach ($jobSubCats as $sub) { if (!isset($jobSubCategories[$sub->category_id])) { $jobSubCategories[$sub->category_id] = array(); } $jobSubCategories[$sub->category_id][$sub->id] = $sub->name; } $certifications = Certification::lists("display_value_employer", 'id'); $states = Address::ListStates(); $addresses = Address::Where("user_id", "=", $user->id)->WhereIn("address_type_id", array(AddressType::$HOME, AddressType::$BUSINESS))->orderBy('created_at', 'desc')->get(); $homeAddressId = 0; $businessAddressId = 0; $homeAddress = null; $businessAddress = null; foreach ($addresses as $address) { switch ($address->address_type_id) { case AddressType::$HOME: if ($homeAddressId <= 0) { $homeAddress = $address; $homeAddressId = $address->id; } break; case AddressType::$BUSINESS: if ($businessAddressId <= 0) { $businessAddress = $address; $businessAddressId = $address->id; } break; } } $repost = false; $pastJobs = JobApplicant::where('jobs.user_id', '=', $user->id)->join('jobs', 'jobs.id', '=', 'job_applicants.job_id')->where('job_applicants.job_applicant_status_id', '=', JobApplicantStatus::$AWARDED)->select('job_applicants.*')->distinct()->get(); $pastJobs->load('User'); $favorites = array(); foreach ($pastJobs as $u) { if ($u->user != null) { $favorites[$u->user_id] = $u->user->first_name . " " . $u->user->last_name; } } if (intval($id) > 0) { $job = Job::find($id); if ($job != null) { $job->start_date = ""; $repost = true; if ($job->address_id == $businessAddressId || $job->address_id == $homeAddressId) { $job->address1 = ""; $job->address2 = ""; $job->city = ""; $job->state = ""; $job->zipcode = ""; } } } else { $job = new Job(); } return View::make('jobs.create', compact("homeAddress", "businessAddress", 'favorites', 'repost', 'job', "jobCategories", 'jobSubCategories', 'states', 'certifications', 'homeAddressId', 'businessAddressId')); }
/** * postAppend * * @param null $job_id * * @return mixed */ public function postAppend($job_id = NULL) { if (is_null($job = Job::where('member_id', '=', Auth::user()->id)->find($job_id))) { return Redirect::to('ticket')->with('error', '工单不存在'); } $rules = array('content' => 'required|min:10'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $project = new Project(); $project->member_id = Auth::user()->id; $project->job_id = e(Input::get('job_id')); $project->content = e(Input::get('content')); $project->type = '0'; $project->append = '1'; $project->reply_time = new DateTime(); if ($project->save()) { $job = Job::find($project->job_id); $job->status = '0'; if ($job->save()) { return Redirect::to("ticket/view/" . $project->job_id)->with('success', '工单追加成功'); } } return Redirect::to('ticket/view/' . $project->job_id)->with('error', '工单追加失败'); }
public function get_countries() { $criteria = array('columns' => "DISTINCT countries.country_code, countries.country", 'joins' => "countries ON countries.country_code = jobs.country", 'order' => "countries.country ASC"); $job = new Job(); return $job->find($criteria); }
public function deleteJob($job_id) { $job = Job::find($job_id); $job->delete(); return Redirect::to('/')->with('message', 'Your job has been deleted.'); }
/** * Delete a job * * @param string $uri The unique identifier URI of the job * * @return mixed */ private function deleteJob($uri) { // Get the id $id = str_replace('jobs/delete/', '', $uri); if (is_numeric($id)) { $job = \Job::find($id); if (!empty($job)) { $job->delete(); } return \Redirect::to('api/admin/jobs'); } else { return false; } }
public function search_using($_criterias) { if (!empty($_criterias['employer']) && $_criterias['employer'] != '0') { $this->employer = $_criterias['employer']; } if ($_criterias['industry'] > 0) { $this->industry = $_criterias['industry']; } $keywords = sanitize(trim($_criterias['keywords'])); if (!empty($keywords)) { $this->keywords = $this->remove_punctuations_from($keywords); } // if (array_key_exists('country_code', $_criterias)) { // $this->country_code = $_criterias['country_code']; // } else { // if ($_criterias['is_local'] <= 0) { // $this->country_code = NULL; // } // } if (array_key_exists('country', $_criterias)) { $this->country_code = $_criterias['country']; } else { $this->country_code = NULL; } if ($_criterias['salary'] > 0) { $this->salary = $_criterias['salary']; } if (array_key_exists('salary_end', $_criterias)) { $this->salary_end = $_criterias['salary_end']; } if (array_key_exists('order_by', $_criterias)) { $this->order_by = $_criterias['order_by']; } if (array_key_exists('limit', $_criterias)) { $this->limit = $_criterias['limit']; } if (array_key_exists('offset', $_criterias)) { $this->offset = $_criterias['offset']; } if (array_key_exists('special', $_criterias)) { $this->special = $_criterias['special']; } $criteria = $this->make_query(); $job = new Job(); $result = $job->find($criteria); if (!is_null($result) && !empty($result)) { $this->total = count($result); } $total_pages = ceil($this->total / $this->limit); if ($total_pages <= 0) { return 0; } $start = microtime(); $result = $job->find($this->make_query(true)); $end = microtime(); list($ustart, $istart) = explode(" ", $start); list($uend, $iend) = explode(" ", $end); $this->time_elapsed = (double) $uend + (double) $iend - ((double) $ustart + (double) $istart); if ($result === false) { return false; } // find the unique employers $i = 0; foreach ($result as $row) { $is_in_array = false; if (count($this->result_employers) > 0) { foreach ($this->result_employers as $employer) { if ($row['employer_id'] == $employer['id']) { $is_in_array = true; break; } } } if (!$is_in_array) { $name = $row['employer']; if (!is_null($row['alternate_employer']) && !empty($row['alternate_employer'])) { $name = $row['employer']; } $this->result_employers[$i]['id'] = $row['employer_id']; $this->result_employers[$i]['name'] = $name; $i++; } } // find the unique industries $i = 0; foreach ($result as $row) { $is_in_array = false; if (count($this->result_industries) > 0) { foreach ($this->result_industries as $industry) { if ($row['industry_id'] == $industry['id']) { $is_in_array = true; break; } } } if (!$is_in_array) { $this->result_industries[$i]['id'] = $row['industry_id']; $this->result_industries[$i]['name'] = $row['industry']; $i++; } } // find the unique countries $i = 0; foreach ($result as $row) { $is_in_array = false; if (count($this->result_countries) > 0) { foreach ($this->result_countries as $country) { if ($row['country_code'] == $country['id']) { $is_in_array = true; break; } } } if (!$is_in_array) { $this->result_countries[$i]['id'] = $row['country_code']; $this->result_countries[$i]['name'] = $row['country']; $i++; } } // find the unique salary beginning foreach ($result as $row) { $is_in_array = in_array($row['salary'], $this->result_salaries); if (!$is_in_array) { $this->result_salaries[] = $row['salary']; } } sort($this->result_salaries); return $result; }
public function destroy($id) { $job = Job::find($id); $result = $job->delete(); return Response::json(['data' => $result], 200); }
private function get_hr_contacts() { $criteria = array('columns' => "DISTINCT employers.hr_contacts", 'joins' => "employers ON employers.id = jobs.employer", 'match' => "jobs.id IN (" . implode(',', $this->selected_jobs) . ")"); $job = new Job(); $result = $job->find($criteria); if ($result === false || is_null($result) || empty($result)) { return ''; } $contacts_str = ''; foreach ($result as $i => $row) { $contacts_str .= $row['hr_contacts']; if ($i < count($result) - 1) { $contacts_str .= ','; } } return $contacts_str; }
} $response = array('results' => array('total' => $job_search->total_results(), 'elapsed' => number_format($job_search->time_elapsed(), 6), 'result' => $result)); header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array($response); exit; } if ($_POST['action'] == 'get_job_info') { $criteria = array('columns' => 'jobs.*, currencies.symbol AS currency_symbol, industries.industry AS full_industry, countries.country AS country_name, employers.name AS employer_name, DATE_FORMAT(jobs.created_on, \'%e %b, %Y %k:%i:%s\') AS formatted_created_on, DATE_FORMAT(jobs.expire_on, \'%e %b, %Y %k:%i:%s\') AS formatted_expire_on, DATEDIFF(NOW(), jobs.expire_on) AS expired', 'joins' => 'industries ON industries.id = jobs.industry, countries ON countries.country_code = jobs.country, employers ON employers.id = jobs.employer, currencies ON currencies.country_code = employers.country', 'match' => 'jobs.id = \'' . $_POST['id'] . '\''); $jobs = Job::find($criteria); $job = array(); foreach ($jobs[0] as $key => $value) { $job[$key] = $value; } $job['description'] = htmlspecialchars_decode($job['description']); $job['potential_reward'] = number_format($job['potential_reward'], 2, '. ', ', '); $job['salary'] = number_format($job['salary'], 2, '. ', ', '); $job['salary_end'] = number_format($job['salary_end'], 2, '. ', ', '); $job['state'] = ucwords($job['state']); $response = array('job' => $job); header('Content-type: text/xml'); echo $xml_dom->get_xml_from_array($response); exit; } if ($_POST['action'] == 'save_job_to_bin') {
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $job = Job::find($id); return View::make('temp_jobs.create-edit')->with('job', $job); }