Esempio n. 1
0
 public function anyEmployerOpen()
 {
     $user = Sentry::getUser();
     $jobs = Job::where("user_id", '=', $user->id)->where("job_status_id", '=', JobStatus::$OPEN)->where('start_date', '>=', date('Y-m-d'))->orderBy('start_date', 'asc')->get();
     $jobs->load('jobApplicants', 'address');
     return View::make('jobs.employer_open', compact('jobs'));
 }
Esempio n. 2
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($workerunit) {
         //    dd($workerunit);
         // Inherit type, domain and format
         if (empty($workerunit->type) or empty($workerunit->domain) or empty($workerunit->format)) {
             $j = Job::where('_id', $workerunit->job_id)->first();
             $workerunit->type = $j->type;
             $workerunit->domain = $j->domain;
             $workerunit->format = $j->format;
         }
         $workerunit->annotationVector = $workerunit->createAnnotationVector();
         // Activity if not exists
         if (empty($workerunit->activity_id)) {
             try {
                 $activity = new Activity();
                 $activity->label = "Workerunit is saved.";
                 $activity->softwareAgent_id = $workerunit->softwareAgent_id;
                 $activity->save();
                 $workerunit->activity_id = $activity->_id;
                 Log::debug("Saving workerunit {$workerunit->_id} with activity {$workerunit->activity_id}.");
             } catch (Exception $e) {
                 if ($activity) {
                     $activity->forceDelete();
                 }
                 //if($workerunit) $workerunit->forceDelete();
                 throw new Exception('Error saving activity for workerunit.');
             }
         }
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $jobs = Job::with('creator')->orderBy('required_date')->paginate(4);
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(50);
     }
     $data = array('jobs' => $jobs);
     return View::make('temp_jobs.index')->with($data);
 }
Esempio n. 4
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->line('Welcome to the job cron.');
     $auto_close = Configuration::where('key', 'auto_close')->first();
     if ($auto_close['value']) {
         $auto_close_time = Configuration::where('key', 'auto_close_time')->first();
         $diff_time = date("Y-m-d H:i:s", time() - $auto_close_time['value'] * 60 * 60);
         $jobs = Job::where('status', '=', '1')->where('invalid', '=', '0')->where('start_time', '<', $diff_time)->get();
         foreach ($jobs as $job) {
             Job::where('id', $job->id)->update(array('status' => 2));
         }
     }
     $this->line('Done !');
 }
Esempio n. 5
0
 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     $job_name = $this->argument('jobname');
     list($collection_uri, $name) = InputController::getParts($job_name);
     // Check if the job exists
     $job = \Job::where('name', '=', $name)->where('collection_uri', '=', $collection_uri)->first();
     if (empty($job)) {
         $this->error("The job with identified by: {$job_name} could not be found.\n");
         exit;
     }
     $this->line('The job has been found.');
     $job_exec = new JobExecuter($job, $this);
     $job_exec->execute();
 }
Esempio n. 6
0
 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     // Check for a list option
     $list = $this->option('list');
     $job_name = $this->argument('jobname');
     if (empty($list) && !empty($job_name)) {
         $inputController = new InputController();
         list($collection_uri, $name) = $inputController->getParts($job_name);
         // Check if the job exists
         $job = \Job::where('name', '=', $name)->where('collection_uri', '=', $collection_uri)->first();
         if (empty($job)) {
             $this->error("The job with identified by: {$job_name} could not be found.\n");
             exit;
         }
         $this->info('The job has been found.');
         // Configure a log handler if configured
         $this->addLogHandler();
         $startDate = new Carbon();
         $iso8601 = $startDate->toISo8601String();
         \Log::info("Executing job {$name} at {$iso8601}");
         try {
             $job_exec = new JobExecuter($job, $this);
             $job_exec->execute();
         } catch (\Exception $ex) {
             $endDate = new Carbon();
             $iso8601 = $endDate->toISO8601String();
             \Log::error("The job {$job_name} has failed at {$iso8601}");
             \Log::error($ex->getMessage());
             \Log::error($ex->getTraceAsString());
         }
         $endDate = new Carbon();
         $iso8601 = $endDate->toISO8601String();
         $job->date_executed = time();
         $job->added_to_queue = false;
         $job->save();
         \Log::info("The job has ended at {$iso8601}");
     } else {
         $jobs = \Job::all(['name', 'collection_uri'])->toArray();
         if (!empty($jobs)) {
             $this->info("=== Job names ===");
             foreach ($jobs as $job) {
                 $this->info($job['collection_uri'] . '/' . $job['name']);
             }
         } else {
             $this->info("No jobs found.");
         }
     }
 }
Esempio n. 7
0
 public function loadJob($id)
 {
     $squeeb = Job::where('id', '=', $id)->first();
     View::share('squeeb', $squeeb);
     view::share('model', 'Job');
     //detect device
     $detect = new Mobile_Detect();
     $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
     View::share('deviceType', $deviceType);
     //update the squeeb table
     $this->sqFactor($squeeb);
     if (Auth::user()) {
         return View::make('member.squeeb');
     }
     return View::make('guest.squeeb');
 }
 public function search()
 {
     if (Auth::check()) {
         //do not show jobs that have already been applied to
         //to show active jobs that helper has been selected for
         $activeJobIds = DB::table('jobs')->join('helpers_jobs_mapping', function ($join) {
             $join->on('jobs.id', '=', 'helpers_jobs_mapping.job_id')->where('helpers_jobs_mapping.is_accepted', '=', 1);
         })->lists('id');
         $activeJobs = [];
         if (!empty($activeJobIds)) {
             $activeJobs = Job::whereIn('id', $activeJobIds)->get();
         }
         $appliedQuery = Auth::user()->appliedJobs();
         if (!empty($activeJobIds)) {
             $appliedQuery->whereNotIn('id', $activeJobIds);
         }
         $appliedJobs = $appliedQuery->get();
         //$jobsIds will hold all the ids in the jobs table
         $appliedJobIds = array();
         //search all jobs for current job id
         foreach (Auth::user()->appliedJobs as $job) {
             $appliedJobIds[] = $job->id;
         }
         $jobQuery = Job::with('creator');
         if (count($activeJobIds) > 0) {
             $jobQuery->whereNotIn('id', $activeJobIds);
         }
         if (count($appliedJobIds) > 0) {
             $jobQuery->whereNotIn('id', $appliedJobIds);
         }
         //show all jobs if user has not applied to any
         $jobs = $jobQuery->orderBy('required_date')->paginate(5);
         $data = array('jobs' => $jobs, 'activeJobs' => $activeJobs, 'appliedJobs' => $appliedJobs);
     } else {
         $jobs = Job::with('creator')->orderBy('required_date')->paginate(5);
     }
     if (Input::has('filter')) {
         $filter = Input::get('filter');
         $jobs = Job::where('category', $filter)->paginate(50);
     }
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(5);
     }
     $data = array('jobs' => $jobs);
     return View::make('pages.search')->with($data);
 }
Esempio n. 9
0
 public function index()
 {
     $query = Job::where('status', '=', Job::APPROVED)->where('closing_date', '>=', \Carbon\Carbon::now())->where('published_date', '<=', \Carbon\Carbon::now());
     if (\Input::get('type') && in_array(\Input::get('type'), array(Job::PERMANENT, Job::TEMPORARY))) {
         $query->where('type', '=', \Input::get('type'));
     }
     if (\Input::get('time') && in_array(\Input::get('time'), array(Job::FULL_TIME, Job::PART_TIME))) {
         $query->where('time', '=', \Input::get('time'));
     }
     if (\Input::get('keywords')) {
         $keywords = \Input::get('keywords');
         if (!empty($keywords)) {
             $query->whereRaw("MATCH(title,description,reference,location,search_extra,meta_description,meta_keywords) AGAINST(? IN BOOLEAN MODE)", array($keywords));
         }
     }
     $query->orderby('published_date', \Config::get('laravel-jobs::index_order'));
     $jobs = $query->paginate(\Config::get('laravel-jobs::results_per_page'));
     return \View::make(\Config::get('laravel-jobs::index_view'))->with(compact('jobs'));
 }
Esempio n. 10
0
    if ($payload['exp'] < time()) {
        Response::json(array('message' => 'Token has expired'));
    }
});
Route::filter('auth.job', function ($route) {
    if (!Request::header('Authorization')) {
        return Response::json(array('message' => Request::header()), 401);
    }
    $token = explode(' ', Request::header('Authorization'))[1];
    $payloadObject = JWT::decode($token, Config::get('secrets.TOKEN_SECRET'));
    $payload = json_decode(json_encode($payloadObject), true);
    if ($payload['exp'] < time()) {
        Response::json(array('message' => 'Token has expired'));
    }
    $id = $route->getParameter('id');
    $exist = Job::where('id', $id)->where('user_id', userId())->get()->toArray();
    if (empty($exist)) {
        return Response::json(array('message' => 'You are not allowed access to this record. You have been logged out.'), 401);
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
Esempio n. 11
0
 public function getProcesscrowdgames()
 {
     $gameJobs = Job::where('softwareAgent_id', 'DrDetectiveGamingPlatform')->get();
     $activity = new Activity();
     $activity->softwareAgent_id = 'DrDetectiveGamingPlatform';
     $activity->save();
     foreach ($gameJobs as $job) {
         // $annotations = Entity::where('jobParents', $job['_id'])->get();
         // Create one annotation vector for each image on the game
         $images = Entity::where('jobParents', $job['_id'])->distinct('content.task_data')->get();
         $annotationsSummary = [];
         foreach ($images as $image) {
             $imageName = $image[0];
             // unpack data
             $annotations = Entity::where('jobParents', $job['_id'])->where('content.task_data', $imageName)->get();
             $annotations = $annotations->toArray();
             // Create an array with all coordinates given for target image.
             $coordinates = array_column(array_column(array_column($annotations, 'content'), 'response'), 'Coordinates');
             $allCoordinates = [];
             foreach ($coordinates as $coords) {
                 // Flatten to array of coords.
                 foreach ($coords as $c) {
                     $allCoordinates[] = $c;
                 }
             }
             $aggCoords = static::aggregateCoordinates($allCoordinates);
             $annotationsSummary[] = ['image' => $imageName, 'aggregateCoordinates' => $aggCoords];
         }
         // process annotations for this job into an annotation vector...
         $e = new Entity();
         $e->jobParents = [$job['_id']];
         $e->annotationVector = $annotationsSummary;
         $e->documentType = 'annotationVector';
         $e->activity_id = $activity->_id;
         $e->softwareAgent_id = $job->softwareAgent_id;
         $e->project = $job->project;
         $e->user_id = $job->user_id;
         $e->save();
     }
     return 'OK -- may need adjustments...';
 }
} else {
    ?>

    <p class="flash-message static error"><?php 
    echo e($this->fatalError);
    ?>
</p>
    <p><a href="<?php 
    echo Backend::url('gatto/jobs/qualifications');
    ?>
" class="btn btn-default">Return to Qualifications list</a></p>

<?php 
}
?>





This is a query for the front-end, using Laravel query builder:
it retrieves all the appointments for the logged in customer.

<?php 
$this['appointments'] = Appointments::where('customer_id', '=', Auth::getUser()->id)->where('gatto_jobs_appointments.id', '=', $app_id)->join('gatto_jobs_jobs', 'gatto_jobs_appointments.job_id', '=', 'gatto_jobs_jobs.id')->join('users', 'gatto_jobs_appointments.customer_id', '=', 'users.id')->join('gatto_jobs_timeslots', 'gatto_jobs_timeslots.id', '=', 'time_slot')->get(['gatto_jobs_appointments.*', 'gatto_jobs_jobs.name as name', 'gatto_jobs_timeslots.name as timeslot', 'users.name as username'])->toArray();
?>

This is a simple Eloquent query to find a Job from an ID:
<?php 
$this['selected_job'] = Job::where('id', '=', $this['job_id'])->first()->toArray();
 public function index()
 {
     $jobs = Job::where('user_id', userId())->get()->toArray();
     return Response::json(['data' => $jobs], 200);
 }
Esempio n. 14
0
 /**
  * getReinvalid
  *
  * @param null $job_id
  *
  * @return mixed
  */
 public function getReinvalid($job_id = NULL)
 {
     if (is_null($job = Job::where('member_id', '=', Auth::user()->id)->find($job_id))) {
         return Redirect::to('ticket')->with('error', '工单不存在');
     }
     $job->where('id', $job_id)->update(array('invalid' => 0));
     return Redirect::to('ticket')->with('success', '工单恢复成功');
 }
Esempio n. 15
0
 public static function JobsInterestedIn(StudentInfo $student, $studentAddress = null)
 {
     if ($studentAddress == null) {
         $studentAddress = $student->primaryAddress;
     }
     $preferredCategories = $student->studentJobPreferences->lists('job_category_id');
     return Job::where('job_status_id', '=', JobStatus::$OPEN)->whereIn("jobs.job_category_id", $preferredCategories)->where("jobs.start_date", ">=", date("Y-m-d"))->orderBy('jobs.start_date', 'asc')->select("jobs.*", Address::distanceSelectStatement($studentAddress->latitude, $studentAddress->longitude, 'distance', 'jobs'))->having("distance", "<=", $student->studentProfile->preferred_job_radius)->get();
 }
 public function getJobsByCategory($id)
 {
     $jobs = Job::where('category_id', '=', $id)->get();
     return json_encode($jobs);
 }
Esempio n. 17
0
 /**
  * Edit a job
  *
  * @param string $uri The uri of the job
  *
  * @return \View
  */
 private function editJob($uri)
 {
     $pieces = explode('/', $uri);
     $id = array_pop($pieces);
     if (is_numeric($id)) {
         $job = \Job::where('id', $id)->with('extractor', 'loader')->first();
         if (empty($job)) {
             return \Redirect::to('api/admin/jobs');
         }
     }
     $discovery = \App::make('Tdt\\Core\\Definitions\\DiscoveryController');
     $discovery = json_decode($discovery->get()->getcontent());
     // Get the configuration for the selected ETL
     $input_extract_spec = $discovery->resources->input->methods->put->body->extract->parameters->type;
     $input_load_spec = $discovery->resources->input->methods->put->body->load->parameters->type;
     $extract_type = strtolower($job->extractor->type);
     $load_type = strtolower($job->loader->type);
     $extract_parameters = $input_extract_spec->{$extract_type}->parameters;
     $load_parameters = $input_load_spec->{$load_type}->parameters;
     // Fill in list parameters in the provided configurations
     foreach ($extract_parameters as $parameter) {
         if ($parameter->type == 'list') {
             if (strpos($parameter->list, '|')) {
                 $parameter->list = explode('|', $parameter->list);
             } else {
                 $list = json_decode($this->getDocument($parameter->list));
                 if (!empty($parameter->list_option)) {
                     $filtered_list = [];
                     foreach ($list as $object) {
                         $object = (array) $object;
                         $filtered_list[] = $object[$parameter->list_option];
                     }
                     $parameter->list = $filtered_list;
                 } else {
                     $parameter->list = $list;
                 }
             }
         }
     }
     // Fill in list parameters in the provided configurations
     foreach ($load_parameters as $parameter) {
         if ($parameter->type == 'list') {
             if (strpos($parameter->list, '|')) {
                 $parameter->list = explode('|', $parameter->list);
             } else {
                 $list = json_decode($this->getDocument($parameter->list));
                 if (!empty($parameter->list_option)) {
                     $filtered_list = [];
                     foreach ($list as $object) {
                         $object = (array) $object;
                         $filtered_list[] = $object[$parameter->list_option];
                     }
                     $parameter->list = $filtered_list;
                 } else {
                     $parameter->list = $list;
                 }
             }
         }
     }
     $job_config = [];
     // Job specific settings
     $job_config['schedule'] = explode('|', $discovery->resources->input->methods->put->body->schedule->list);
     return \View::make('input::ui.jobs.edit')->with('title', 'Edit a job | The Datatank')->with('extract_parameters', $extract_parameters)->with('load_parameters', $load_parameters)->with('job', $job)->with('job_config', $job_config);
 }
Esempio n. 18
0
 public function viewArchive($year, $month)
 {
     $archive_links = array();
     $archive_increment = strtotime('2014/08/01');
     $archive_end = strtotime('now');
     do {
         $archive_links[] = array('label' => date('m') . '-' . date('Y'), 'link' => '/job/archive/view/' . date('Y', $archive_increment) . '/' . date('m', $archive_increment));
         $archive_increment = strtotime(date('Y/m/d', $archive_increment) . ' + 1 month');
     } while ($archive_increment <= $archive_end);
     $archive_start_filter = $year . '/' . $month . '/01 00:00:01';
     $archive_end_filter = date('Y/m/d H:i:s', strtotime($archive_start_filter . ' + 1 month'));
     return View::make('job_archive', array('for' => $year . '-' . $month, 'jobs' => Job::where('status', '=', '0')->where('created_at', '>=', $archive_start_filter)->where('created_at', '<=', $archive_end_filter)->get(), 'archive_links' => $archive_links));
 }
 public function getUpdatecfdictionaries()
 {
     foreach (Job::where('softwareAgent_id', 'cf')->get() as $job) {
         foreach ($job->workerunits as $ann) {
             if (!empty($ann->annotationVector)) {
                 continue;
             }
             $ann->type = $job->type;
             $ann->annotationVector = $ann->createWorkerunitVector();
             $ann->save();
             if (is_null($ann->annotationVector)) {
                 echo ">>>>>{$ann->unit_id}";
             } else {
                 echo "_____{$ann->unit_id}";
             }
         }
         //Queue::push('Queues\UpdateJob', array('job' => serialize($job)));
     }
 }
Esempio n. 20
0
 public function getEntity($format, $domain, $docType, $incr, $action)
 {
     try {
         $return = array('status' => 'ok');
         $id = "entity/{$format}/{$domain}/{$docType}/{$incr}";
         switch ($docType) {
             case 'job':
                 $job = Job::where('_id', $id)->first();
                 if (!$job) {
                     throw new Exception('Job not found.');
                 }
                 if ($job->user_id != Auth::user()->_id) {
                     throw new Exception('You can only do this with your own job!');
                 }
                 //$this->authenticateUser();
                 switch ($action) {
                     case 'pause':
                         $job->pause();
                         $return['message'] = 'Job paused successfully.';
                         break;
                     case 'resume':
                         $job->resume();
                         $return['message'] = 'Job resumed successfully.';
                         break;
                     case 'cancel':
                         $job->cancel();
                         $return['message'] = 'Job canceled successfully.';
                         break;
                     case 'order':
                         $job->order();
                         $return['message'] = 'Job ordered successfully.';
                         break;
                     case 'delete':
                         $job->cancel();
                         // TODO SOFT DELETE
                         $return['message'] = 'Job canceled, soft delete not yet implemented.';
                     default:
                         throw new Exception('Action unknown.');
                         break;
                 }
                 break;
             default:
                 throw new Exception("Unknown documenttype '{$docType}'.");
                 break;
         }
     } catch (Exception $e) {
         //throw $e; // for debugging.
         $return['message'] = $e->getMessage();
         $return['status'] = 'bad';
     }
     return $this->returnJson($return);
 }
Esempio n. 21
0
                </div>
                <p>
                    暂无站内简讯
                </p>
                @endif
            </div>
            {{-- /Text Widget --}}

            {{-- Recent Posts Widget --}}
            <div class="widget">

                <div class="widget-title">
                    <h4>热门职位</h4>
                </div>
                <?php 
$posts = Job::where('post_status', 'open')->orderBy('comments_count', 'desc')->paginate(4);
?>
                @foreach($posts as $post)
                <div class="post-box">
                    <a href="{{ route('timeline.getTimeline', $post->user->id) }}"> <img class="img-rounded" src="{{ $post->user->portrait_large }}" width="50" height="50" alt=""> </a>
                    <div>
                        <h5><a href="{{ route('job.show', $post->slug) }}">{{ $post->title }}</a></h5>
                        <small>{{ date("M d, Y",strtotime($post->created_at)) }}</small>
                    </div>
                </div>
                @endforeach
            </div>
            {{-- /Recent Posts Widget --}}

            {{-- Tags Widget --}}
            <div class="widget">
Esempio n. 22
0
 public static function edit_job($params)
 {
     $job = Job::where('id', $params['id'])->update($params);
     //find($params['id']);
     if ($job) {
         return ['status' => 1];
     } else {
         return ['status' => 0];
     }
 }