public function createJob($data, $jobgroup = null) { $data['queue'] = $this->_queue; $data['jail'] = $this->_jail; $job = new Job(); if ($job->setJobData($data) !== true) { return false; } if ($job->save() !== true) { return false; } if ($jobgroup == null) { return true; } return $jobgroup->addJob($job->getJobId()); }
private static function outputJob($jobId) { $job = Job::getJob($jobId); $output = ""; $output .= "Job with ID: " . Job::getJobId($job) . "<br>\n"; /* Display a short table with information */ $output .= "<table border=\"1\">\n"; /* header */ $output .= "<tr>\n"; $output .= "<th>Region</th>\n"; $output .= "<th>District</th>\n"; $output .= "<th>WorkType</th>\n"; $output .= "<th>Category</th>\n"; $output .= "<th>SubCategory</th>\n"; $output .= "<th>Job Title</th>\n"; $output .= "<th>Job Description</th>\n"; $output .= "<th>Salary Range</th>\n"; $output .= "<th>Start Date</th>\n"; $output .= "<th>End Date</th>\n"; $output .= "</tr>\n"; $output .= "<tr>\n"; $output .= "<td>" . Job::getRegion($job) . "</td>\n"; $output .= "<td>" . Job::getDistrict($job) . "</td>\n"; $output .= "<td>" . Job::getWorkType($job) . "</td>\n"; $output .= "<td>" . Job::getJobCategory($job) . "</td>\n"; $output .= "<td>" . Job::getJobSubCategory($job) . "</td>\n"; $output .= "<td>" . Job::getJobTitle($job) . "</td>\n"; $output .= "<td>" . Job::getJobDescription($job) . "</td>\n"; /* These last fields need formatting */ $formattedSalaryLow = sprintf("%-6d", Job::getSalaryLow($job)); $formattedSalaryHigh = sprintf("%-6d", Job::getSalaryHigh($job)); $startDate = new DateTime(Job::getDateOfAdvertisement($job)); $formattedStartDate = $startDate->format("j M Y"); $endDate = new DateTime(Job::getEndDateOfAdvertisement($job)); $formattedEndDate = $endDate->format("D, j M Y"); $output .= "<td>\${$formattedSalaryLow} - \${$formattedSalaryHigh}</td>\n"; $output .= "<td>{$formattedStartDate}</td>\n"; $output .= "<td>{$formattedEndDate}</td>\n"; $output .= "</tr>"; $output .= "</table>\n"; return $output; }
protected function outputJobResults() { if (!$this->isSearchedSortOrderKeywords) { $jobList = Job::selectRows($this->searchCondition()); } else { $jobList = Job::selectRowsByKeywords($this->searchCondition(), $this->jobSearchForm->getSearchedKeywords()); } $output = ""; if (!empty($jobList)) { $jobsNumber = $jobList->num_rows; } else { $jobsNumber = 0; } $output .= "Found {$jobsNumber} jobs<br>\n"; if ($jobsNumber != 0) { /* Display a short table with information */ $output .= "<table border=\"1\">\n"; /* header */ $output .= "<tr>\n"; $output .= "<th>Crt. no.</th>\n"; $output .= "<th>Shortlist</th>\n"; $output .= "<th>Region</th>\n"; $output .= "<th>District</th>\n"; $output .= "<th>WorkType</th>\n"; $output .= "<th>Category</th>\n"; $output .= "<th>SubCategory</th>\n"; $output .= "<th>Job Title</th>\n"; $output .= "<th>Job Description</th>\n"; $output .= "<th>Salary Range</th>\n"; $output .= "<th>Start Date</th>\n"; $output .= "<th>End Date</th>\n"; $output .= "</tr>\n"; $count = 0; while (($job = $jobList->fetch_row()) != NULL) { $count++; $output .= "<tr>\n"; $output .= "<td><a href=\"jobDisplay.php?jobId=" . Job::getJobId($job) . "\">{$count}</td>\n"; $output .= "<td><a href=\"../developerPlayGround/jobShortList.php?jobId=" . Job::getJobId($job) . "\">add to shortlist</td>\n"; $output .= static::outputJob($job); $output .= "</tr>"; } $output .= "</table>\n"; } return $output; }
/** * Helper function: convert Job, Job Response and start/ finish times to string * format for emailing & stashing in job history db table. * * @param Job $job * @param String $start * @param String $finish */ private function jobInfoToString(Job $job, JobResponse $response, $start, $finish) { $string = "Job url: " . $job->getUrl() . "\n" . "Job name: " . $job->getJobName() . "\n" . "Job id: " . $job->getJobId() . "\n" . "Timeout: " . $job->getTimeout() . "\n" . "Delay: " . $job->getDelay() . "\n" . "Job started: " . $start . "\n" . "Job finished: " . $finish . "\n" . "JOB SERVER RESPONSE:\n" . "Http response status: " . $response->http_code() . "\n" . "Message: " . $response->message() . "\n"; return $string; }
fclose($fi); $job->set('logfile', $filename); $job->save(); textResponse(200); })->conditions(array('jobid' => '[0-9]')); /* Jobs - Finish a job (with buildstatus and buildreason) */ $app->post('/jobs/:jobid/finish', 'isAllowed', function ($jobid) use($app) { if (!isset($_POST['buildstatus']) || !isset($_POST['buildreason'])) { textResponse(400, 'Post data missing'); } $job = new Job($jobid); if ($job === false) { textResponse(204); } $machine = new Machine(Session::getMachineId()); if (!$machine->hasJob($job->getJobId())) { textResponse(403, 'Job not assigned to you'); } $job->unset('machine'); $job->set('buildstatus', $_POST['buildstatus']); $job->set('buildreason', $_POST['buildreason']); $job->moveToQueue('archivequeue'); jsonResponse(200, $job->getJobData()); })->conditions(array('jobid' => '[0-9]')); /* Jobgroup - List details of jobgroup */ $app->get('/group/:groupid/', 'isAllowed', function ($groupid) use($app) { $jobgroup = new Jobgroup($groupid); if (!$jobgroup->exists()) { textResponse(404, 'Jobgroup not found'); } jsonResponse(200, $jobgroup->getGroupInfo());