示例#1
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         Session::set("FamilyMemberID", $this->ID);
     }
     if (Session::get("FamilyID")) {
         $this->FamilyID = Session::get("FamilyID");
         $fields->replaceField('FamilyID', new HiddenField('FamilyID'));
     }
     $dateOfBirth = new DateField('DateOfBirth', 'Date Of Birth');
     $dateOfBirth->setConfig('dateformat', 'dd-MM-yyyy');
     $dateOfBirth->setDescription('e.g. ' . date('d-m-Y'));
     $dateOfBirth->setAttribute('placeholder', 'dd-MM-yyyy');
     $fields->addFieldsToTab('Root.Main', $dateOfBirth);
     $genders = Config::inst()->get('FamilyMember', 'Gender');
     $gender = new OptionsetField("Gender", 'Gender', $genders);
     $fields->addFieldsToTab('Root.Main', $gender);
     $status = Config::inst()->get('FamilyMember', 'MartialStatus');
     $martialStatus = new OptionsetField("MartialStatus", 'Martial Status', $status);
     $fields->addFieldsToTab('Root.Main', $martialStatus);
     $fields->insertBefore(new Tab('Job', 'Job'), 'CommunityGroups');
     //Job GridField
     $jobGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $jobList = Job::get()->filter(array('FamilyMemberID' => $this->ID))->sort('ID ASC');
     if ($jobList->count()) {
         $jobGridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $jobGridField = new GridField('Job', 'Job', $jobList, $jobGridFieldConfig);
     $fields->addFieldsToTab('Root.Job', array($jobGridField));
     $fields->insertBefore(new Tab('Health', 'Health'), 'CommunityGroups');
     //Health GridField
     $healthGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $healthList = Health::get()->filter(array('FamilyMemberID' => $this->ID))->sort('ID ASC');
     if ($healthList->count()) {
         $healthGridFieldConfig->removeComponentsByType('GridFieldAddNewButton');
     }
     $healthGridField = new GridField('Health', 'Health', $healthList, $healthGridFieldConfig);
     $fields->addFieldsToTab('Root.Health', array($healthGridField));
     //Job GridField
     /*
     $communityGroupsCongfig = GridFieldConfig_RelationEditor::create();
     //$jobGridFieldConfig = GridFieldConfig_RecordEditor::create();
     $communityGroupsList = $this->CommunityGroups();
     $communityGroupsGridField = new GridField('CommunityGroups', 'Community Groups',
     	$communityGroupsList,
     	$communityGroupsCongfig);
     $fields->addFieldsToTab('Root.CommunityGroups', array(
     	$communityGroupsGridField
     ));
     */
     //CommunityGroups ListboxField
     $communityGroupsList = CommunityGroup::get()->map('ID', 'Title')->toArray();
     $communityGroupsField = new ListboxField($name = "CommunityGroups", $title = "Communtiy Groups", $communityGroupsList);
     $communityGroupsField->setMultiple(true);
     $fields->addFieldsToTab('Root.CommunityGroups', $communityGroupsField);
     //exit('dd');
     return $fields;
 }
 /**
  * Delete a given job
  *
  * @param array $data
  * @param Form $form
  */
 public function doDeleteJobForm($data, $form)
 {
     if (isset($data['JobID'])) {
         $job = Job::get()->byId($data['JobID']);
         // check user has permission
         if (!$job || $job->MemberID != Member::currentUserID() && !Permission::check('ADMIN')) {
             return Security::permissionFailure($this);
         }
         $job->isActive = false;
         $job->write();
     }
     return $this->redirect($this->Link('removed'));
 }
示例#3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Job();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
示例#4
0
文件: main.php 项目: eric116/BotQueue
 /**
  * @param Bot $bot
  * @param Job $job
  * @return array
  */
 private function _getBotData($bot, $job)
 {
     $botData = array();
     $botData['id'] = $bot->id;
     $botData['name'] = $bot->getName();
     $botData['status'] = $bot->getStatus();
     $botData['status_class'] = BotStatus::getStatusHTMLClass($bot);
     $botData['url'] = $bot->getUrl();
     $botData['last_seen'] = BotLastSeen::getHTML($bot);
     $webcam = $bot->getWebCamImage();
     if ($webcam->isHydrated()) {
         $botData['webcam_url'] = $webcam->getDownloadURL();
     } else {
         $botData['webcam_url'] = "/img/colorbars.gif";
     }
     $buttons = $this->_getStatusButtons($bot);
     $menu = array();
     $status = $bot->getStatus();
     if ($status == BotState::Working) {
         $menu[] = $buttons['pause'];
         $menu[] = $buttons['dropjob'];
         $menu[] = $buttons['edit'];
         $menu[] = $buttons['delete'];
     } else {
         if ($status == BotState::Paused) {
             $menu[] = $buttons['play'];
             $menu[] = $buttons['dropjob'];
             $menu[] = $buttons['edit'];
             $menu[] = $buttons['delete'];
         } else {
             if ($status == BotState::Slicing) {
                 $menu[] = $buttons['dropjob'];
                 $menu[] = $buttons['edit'];
                 $menu[] = $buttons['delete'];
             } else {
                 if ($status == BotState::Waiting) {
                     $menu[] = $buttons['qa'];
                     $menu[] = $buttons['edit'];
                     $menu[] = $buttons['delete'];
                 } else {
                     if ($status == BotState::Idle) {
                         $menu[] = $buttons['offline'];
                         $menu[] = $buttons['edit'];
                         $menu[] = $buttons['error'];
                         $menu[] = $buttons['delete'];
                     } else {
                         if ($status == BotState::Offline) {
                             $menu[] = $buttons['online'];
                             $menu[] = $buttons['edit'];
                             $menu[] = $buttons['error'];
                             $menu[] = $buttons['delete'];
                             $menu[] = $buttons['retire'];
                         } else {
                             if ($status == BotState::Maintenance) {
                                 $menu[] = $buttons['online'];
                                 $menu[] = $buttons['offline'];
                                 $menu[] = $buttons['edit'];
                                 $menu[] = $buttons['delete'];
                             } else {
                                 if ($status == BotState::Error) {
                                     $menu[] = $buttons['online'];
                                     $menu[] = $buttons['offline'];
                                     $menu[] = $buttons['edit'];
                                     $menu[] = $buttons['delete'];
                                 } else {
                                     if ($status == BotState::Retired) {
                                         $menu[] = $buttons['delete'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $botData['menu'] = $menu;
     if ($job->isHydrated()) {
         $jobData = array();
         $jobData['id'] = $job->id;
         $jobData['name'] = $job->getName();
         $jobData['url'] = $job->getUrl();
         $jobData['status'] = $job->get('status');
         $jobData['status_class'] = JobStatus::getStatusHTMLClass($job->get('status'));
         $jobData['elapsed'] = $job->getElapsedText();
         $jobData['estimated'] = $job->getEstimatedText();
         if ($job->get('status') == 'taken' || $job->get('status') == 'slicing') {
             $jobData['progress'] = round($job->get('progress'), 2);
             $jobData['bar_class'] = "";
         }
         $temps = JSON::decode($bot->get('temperature_data'));
         if ($bot->get('status') == BotState::Working && $temps !== NULL) {
             if (isset($temps->extruder)) {
                 $botData['temp_extruder'] = $temps->extruder;
             }
             if (isset($temps->bed)) {
                 $botData['temp_bed'] = $temps->bed;
             }
         }
         if ($job->get('status') == 'qa') {
             $jobData['qa_url'] = $job->getUrl() . "/qa";
         }
         $sliceJob = $job->getSliceJob();
         if ($job->get('status') == 'slicing' && $sliceJob->get('status') == 'pending') {
             $jobData['qa_url'] = $sliceJob->getUrl();
             $jobData['bar_class'] = "bar-warning";
             // Set it to 100% so it actually displays
             $jobData['progress'] = 100.0;
         }
         $botData['job'] = $jobData;
     }
     if ($bot->get('status') == 'error') {
         $botData['error_text'] = $bot->get('error_text');
         return $botData;
     }
     return $botData;
 }
function start_retrieval_job(Job $job, DateTime $start_time)
{
    $oResult = client()->initiateJob(array('accountId' => '-', 'vaultName' => VAULT, 'ArchiveId' => $job->get('archive_id'), 'RetrievalByteRange' => $job->get('start') . "-" . $job->get('end'), 'Type' => 'archive-retrieval'));
    $job->set('start_time', $start_time);
    $job->set('running', 1);
    $job->set('jobId', $oResult->get('jobId'));
}
示例#6
0
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;
}
示例#7
0
 /**
  * @param $job Job
  * @param $can_slice bool
  * @return Job
  * @throws Exception
  */
 public function grabJob($job, $can_slice = true)
 {
     $grabAttemptSQL = "\n            UPDATE jobs\n            SET bot_id =\n              CASE\n                WHEN bot_id=0\n                THEN\n                  ?\n                ELSE\n                  bot_id\n              END\n            WHERE id = ?\n        ";
     // Attempt to grab the job unless another bot already has
     db()->execute($grabAttemptSQL, array($this->id, $job->id));
     $job = new Job($job->id);
     // Reload the job
     if ($job->get('bot_id') != $this->id) {
         // We didn't grab it in time.
         throw new Exception("Unable to lock job #{$job->id}");
     }
     $job->setStatus('taken');
     $job->set('taken_time', date('Y-m-d H:i:s'));
     $job->save();
     //do we need to slice this job?
     if (!$job->getFile()->isHydrated() && $can_slice) {
         //pull in our config and make sure it's legit.
         $config = $this->getSliceConfig();
         if (!$config->isHydrated()) {
             $job->setStatus('available');
             $job->set('bot_id', 0);
             $job->set('taken_time', 0);
             $job->save();
             throw new Exception("This bot does not have a slice engine + configuration set.");
         }
         //is there an existing slice job w/ this exact file and config?
         $sj = SliceJob::byConfigAndSource($config->id, $job->get('source_file_id'));
         if ($sj->isHydrated()) {
             //update our job status.
             $job->set('slice_job_id', $sj->id);
             $job->set('slice_complete_time', $job->get('taken_time'));
             $job->set('file_id', $sj->get('output_id'));
             $job->save();
         } else {
             //nope, create our slice job for processing.
             $sj->set('user_id', User::$me->id);
             $sj->set('job_id', $job->id);
             $sj->set('input_id', $job->get('source_file_id'));
             $sj->set('slice_config_id', $config->id);
             $sj->set('slice_config_snapshot', $config->getSnapshot());
             $sj->set('add_date', date("Y-m-d H:i:s"));
             $sj->setStatus('available');
             $sj->save();
             //update our job status.
             $job->setStatus('slicing');
             $job->set('slice_job_id', $sj->id);
             $job->save();
         }
     }
     $log = new JobClockEntry();
     $log->set('job_id', $job->id);
     $log->set('user_id', User::$me->id);
     $log->set('bot_id', $this->id);
     $log->set('queue_id', $job->get('queue_id'));
     $log->set('start_date', date("Y-m-d H:i:s"));
     $log->setStatus('working');
     $log->save();
     $this->set('job_id', $job->id);
     $this->setStatus(BotState::Working);
     $this->set('last_seen', date("Y-m-d H:i:s"));
     $this->save();
     return $job;
 }
示例#8
0
 function JobDetailsPage()
 {
     $job_id = intval($this->request->param('JOB_ID'));
     $job = Job::get()->byID($job_id);
     if ($job) {
         if (!empty($job->MoreInfoLink)) {
             $job->FormattedMoreInfoLink = $this->getViewInfoLink($job->MoreInfoLink);
         }
         return $this->renderWith(array('JobDetail', 'Page'), ['Job' => $job]);
     }
     return $this->httpError(404, 'Sorry that Job could not be found!.');
 }
 public function getUpdatedictionaries()
 {
     $jobs = Job::get();
     foreach ($jobs as $job) {
         foreach ($job->workerunits as $ann) {
             //$ann->type = $job->type;
             $ann->annotationVector = $ann->createWorkerunitVector();
             $ann->save();
         }
         Queue::push('Queues\\UpdateJob', array('job' => serialize($job)));
     }
 }
示例#10
0
<?php

include "../../extensions/global.php";
include "../patches.php";
$patchNumber = 12;
start_patch();
if (!patch_exists($patchNumber)) {
    // Fix the temperature fields:
    $rs = db()->query("SELECT * from jobs");
    while ($row = $rs->fetch(PDO::FETCH_ASSOC)) {
        $job = new Job($row['id']);
        $fixed_data = fix_temp_data($job->get('temperature_data'));
        $job->set('temperature_data', $fixed_data);
        $job->save();
    }
    $rs = db()->query("SELECT * from bots");
    while ($row = $rs->fetch(PDO::FETCH_ASSOC)) {
        $bot = new Bot($row['id']);
        $fixed_data = fix_temp_data($bot->get('temperature_data'));
        $bot->set('temperature_data', $fixed_data);
        $bot->save();
    }
    $expandTemperatureData = "\n\t\tALTER TABLE jobs\n  \t\tMODIFY COLUMN temperature_data longtext NOT NULL";
    db()->execute($expandTemperatureData);
    $expandTemperatureData = "\n\t\tALTER TABLE bots\n  \t\tMODIFY COLUMN temperature_data longtext NOT NULL";
    finish_patch($patchNumber, "Expanded temperature data fields");
}
function fix_temp_data($data)
{
    if (strlen($data) == 0) {
        return "";
示例#11
0
 public function api_webcamupdate()
 {
     if ((int) $this->args('job_id')) {
         $job = new Job($this->args('job_id'));
         if (!$job->isHydrated()) {
             throw new Exception("Job does not exist.");
         }
         $bot = $job->getBot();
         if (!$bot->isHydrated()) {
             throw new Exception("Bot does not exist.");
         }
         if (!$job->getQueue()->isMine()) {
             throw new Exception("This job is not in your queue.");
         }
     } else {
         if ((int) $this->args('bot_id')) {
             $bot = new Bot($this->args('bot_id'));
             if (!$bot->isHydrated()) {
                 throw new Exception("Bot does not exist.");
             }
             $job = new Job();
         } else {
             throw new Exception("You must pass in either a bot or job id.");
         }
     }
     if (!$bot->isMine()) {
         throw new Exception("This is not your bot.");
     }
     if (!empty($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
         //upload our file
         $file = $_FILES['file'];
         $this->ensureGoodFile($file);
         //does it match?
         if (!preg_match("/\\.jpg\$/i", $file['name'])) {
             throw new Exception("The file must end in .jpg");
         }
         //is it a real image?
         $size = getimagesize($file['tmp_name']);
         if (!$size[0] || !$size[1]) {
             throw new Exception("The file is not a valid image.");
         }
         //okay, we're good.. do it.
         if ($job->isHydrated()) {
             $data_file = Storage::newFile();
         } else {
             $data_file = $bot->getWebcamImage();
         }
         $data_file->set('user_id', User::$me->id);
         $data_file->upload($file['tmp_name'], StorageInterface::getNiceDir($file['name']));
         //if we have a job, save our new image.
         if ($job->isHydrated()) {
             $job->set('webcam_image_id', $data_file->id);
             $ids = json::decode($job->get('webcam_images'));
             if ($ids == NULL) {
                 $ids = array();
                 $ids[time()] = $data_file->id;
             } else {
                 $index = time();
                 $ids->{$index} = $data_file->id;
             }
             $job->set('webcam_images', json::encode($ids));
         }
         //always pull the latest image in for the bot.
         $bot->set('webcam_image_id', $data_file->id);
     } else {
         throw new Exception("No file uploaded.");
     }
     //did we get temperatures?
     $this->_updateTemperatures($this->args('temperatures'), $bot, $job);
     //update our job info.
     if ($this->args('progress') && $job->isHydrated()) {
         $job->set('progress', (double) $this->args('progress'));
     }
     //only save the job if its real.
     if ($job->isHydrated()) {
         $job->save();
     }
     //update our bot info
     $bot = $this->_markBotAsSeen($bot);
     //what kind of data to send back.
     if ($job->isHydrated()) {
         return $job->getAPIData();
     } else {
         return $bot->getAPIData();
     }
 }
示例#12
0
 public function getLoop()
 {
     foreach (Job::get() as $job) {
         //if(!isset($job->projectedCost)){
         try {
             $batch = $job->batch;
             $reward = $job->jobConfiguration->content['reward'];
             $workerunitsPerUnit = intval($job->jobConfiguration->content['workerunitsPerUnit']);
             $unitsPerTask = intval($job->jobConfiguration->content['unitsPerTask']);
             $unitsCount = count($batch->wasDerivedFrom);
             if (!$unitsPerTask) {
                 $unitsPerTask = 1;
             }
             $projectedCost = round($reward / $unitsPerTask * ($unitsCount * $workerunitsPerUnit), 2);
             $count = 0;
             foreach ($job->workerunits as $ann) {
                 $count++;
             }
             $job->realCost = $count * $reward;
             $job->unitsCount = $unitsCount;
             $job->projectedCost = $projectedCost;
             $job->save;
         } catch (LogicException $e) {
             echo $e->getMessage();
         }
         //}
     }
 }
 /**
  * 获取属性
  *
  * @param string $key
  * @return mixed
  */
 public function get($key)
 {
     return parent::get($key);
 }
示例#14
0
 public function update_sort()
 {
     $this->assertLoggedIn();
     if (!$this->args('jobs')) {
         die("Error: You didn't pass any jobs in.");
     }
     $jobs = explode(",", $this->args('jobs'));
     if (count($jobs) < 1) {
         die("Error: You need to pass in at least 2 jobs.");
     }
     //load up our ids.
     $jobIds = preg_filter('/^job_(\\d+)$/', '$1', $jobs);
     $jobs = array();
     // Only grab jobs that exist and are ours
     foreach ($jobIds as $id) {
         /** @var Job $job */
         $job = new Job($id);
         if ($job->isHydrated() && $job->isMine()) {
             $jobs[$id] = $job->get('user_sort');
         }
     }
     // Sort the values, but not the keys
     $values = array_values($jobs);
     sort($values);
     $jobs = array_combine(array_keys($jobs), $values);
     // Now actually update
     foreach ($jobs as $id => $sort) {
         /** @var Job $job */
         $job = new Job($id);
         $job->set('user_sort', $sort);
         $job->save();
     }
     die(print_r($jobs, true));
 }
示例#15
0
文件: job.php 项目: pamalite/yel
$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";
    exit;
}
?>
</p>
示例#16
0
 public function AvailableJobs()
 {
     return Job::get()->filter(array('Status' => 'Published'))->exclude(array('ClosingDate:LessThan' => date('Y-m-d')))->sort('ClosingDate ASC');
 }
示例#17
0
文件: bot.php 项目: ricberw/BotQueue
 public function grabJob($job)
 {
     $job->set('status', 'taken');
     $job->set('bot_id', $this->id);
     $job->set('taken_time', date('Y-m-d H:i:s'));
     $job->save();
     usleep(1000 + mt_rand(100, 500));
     $job = new Job($job->id);
     if ($job->get('bot_id') != $this->id) {
         throw new Exception("Unable to lock job #{$job->id}");
     }
     $this->set('job_id', $job->id);
     $this->set('status', 'working');
     $this->set('last_seen', date("Y-m-d H:i:s"));
     $this->save();
 }
示例#18
0
文件: job.php 项目: ricberw/BotQueue
 public function create()
 {
     $this->assertLoggedIn();
     if ($this->args('step2')) {
         $this->setTitle('Step 2 of 2: Create Job');
     } else {
         $this->setTitle('Create new Job');
     }
     try {
         if ($this->args('job_id')) {
             $job = new Job($this->args('job_id'));
             if (!$job->isHydrated()) {
                 throw new Exception("That job does not exist.");
             }
             if ($job->get('user_id') != User::$me->id) {
                 throw new Exception("You do not own this job.");
             }
             $file = $job->getFile();
             $queue_id = $job->get('queue_id');
         } else {
             $file = new S3File($this->args('file_id'));
         }
         if (!$file->isHydrated()) {
             throw new Exception("That file does not exist.");
         }
         if ($file->get('user_id') != User::$me->id) {
             throw new Exception("You do not have access to this file.");
         }
         $this->set('file', $file);
         //load up our form.
         $form = $this->_createJobForm($file, $queue_id);
         if (isset($job)) {
             $form->action = "/job/create/job:{$job->id}";
         } else {
             $form->action = "/job/create/file:{$file->id}";
         }
         //handle our form
         if ($form->checkSubmitAndValidate($this->args())) {
             //pull in our quantity
             $quantity = (int) $form->data('quantity');
             $quantity = max(1, $quantity);
             $quantity = min(1000, $quantity);
             //queue error checking.
             $queue = new Queue($form->data('queue_id'));
             if (!$queue->isHydrated()) {
                 throw new Exception("That queue does not exist.");
             }
             if (!$queue->canAdd()) {
                 throw new Exception("You do not have permission to add to that queue.");
             }
             //okay, we good?
             $queue->addGCodeFile($file, $quantity);
             Activity::log("added {$quantity} new " . Utility::pluralizeWord('job', $quantity));
             $this->forwardToUrl($queue->getUrl());
         }
         $this->set('form', $form);
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
     }
 }
示例#19
0
 public function update_sort()
 {
     $this->assertLoggedIn();
     if (!$this->args('jobs')) {
         die("Error: You didn't pass any jobs in.");
     }
     $jobs = explode(",", $this->args('jobs'));
     if (count($jobs) < 1) {
         die("Error: You need to pass in at least 2 jobs.");
     }
     //load up our ids.
     $jids = array();
     foreach ($jobs as $job) {
         $jarray = explode("_", $job);
         $jid = (int) $jarray[1];
         if (!$jid) {
             die("Error: format must be a csv of job_### where ### is the job id.");
         }
         $jids[] = $jid;
     }
     //find our our current max
     $sql = "SELECT min(user_sort) FROM jobs WHERE id IN (" . implode($jids, ",") . ")";
     $min = (int) db()->getValue($sql);
     //now actually update.
     foreach ($jids as $jid) {
         $job = new Job($jid);
         if ($job->get('user_id') == User::$me->id) {
             $job->set('user_sort', $min);
             $job->save();
             $min++;
         } else {
             die("Error: Job {$jid} is not your job.");
         }
     }
     die("OK");
 }
示例#20
0
        $school = School::get_by_id($batch->schoolid);
        if ($batch->pending == 0 && $batch->enabled == 1 && $school->pending == 0 && $school->enabled == 1) {
            echo "<tr><td><a href='batch.php?id=" . $batch->id . "'>" . $school->name . " " . $batch->get_batchyear() . "</a></td></tr>";
        }
    }
}
?>
            </table>
          </div>

          <div class="span4 boxcontent">
            <span class="myheader2">Other</span>
            <table data-provides="rowlink">
              <tr><td class="myheader">Jobs</td></tr>
              <?php 
$jobs = Job::get($user->id);
if (count($jobs) > 0) {
    foreach ($jobs as $job) {
        echo "<tr><td>" . $job->role . " at " . $job->company . " from " . $job->fromdate . " to " . ($job->present == 1 ? 'Present' : $job->todate) . "</a></td></tr>";
    }
}
?>
            </table>
          </div>

        </div>

      </div>

      <div class="span9 box">
        <ul class="nav nav-tabs">
示例#21
0
 public function getJob($id)
 {
     if (($ret = Job::get($id, $this)) === false) {
         return false;
     }
     if ($ret->hasExpired()) {
         $ret->delete();
         return false;
     }
     if (!$ret->exists()) {
         return false;
     }
     return $ret;
 }
 /**
  * @return Job
  */
 public function getJobFromParams()
 {
     $params = $this->owner->getURLParams();
     if (!$params['ID']) {
         return false;
     }
     $job = Job::get()->filter(array('Slug' => $params['ID']))->first();
     return $job;
 }