/** * Short description for 'getStats' * * Long description (if any) ... * * @param integer $itemid Job ID * @param string $category Job type * @param integer $admin Admin access? * @return mixed False if errors, Array upon success */ public function getStats($itemid = NULL, $category = 'employer', $admin = 0) { if ($itemid === NULL) { return false; } $stats = array('total_resumes' => 0, 'shortlisted' => 0, 'applied' => 0, 'bookmarked' => 0, 'total_viewed' => 0, 'total_shared' => 0, 'viewed_today' => 0, 'viewed_thisweek' => 0, 'viewed_thismonth' => 0, 'lastviewed' => ''); // get total resumes in the pool $row = new JobSeeker($this->_db); $filters = array('filterby' => 'all', 'sortby' => '', 'search' => '', 'category' => '', 'type' => ''); $stats['total_resumes'] = $row->countSeekers($filters); // get stats for employer if ($category == 'employer') { $filters['filterby'] = 'shortlisted'; $stats['shortlisted'] = $row->countSeekers($filters, $itemid); $filters['filterby'] = 'applied'; $itemid = $admin ? 1 : $itemid; $stats['applied'] = $row->countSeekers($filters, $itemid); } // get stats for seeker if ($category == 'seeker') { $stats['totalviewed'] = $this->getView($itemid, $category); $stats['viewed_today'] = $this->getView($itemid, $category, 'viewed', 'today'); $stats['viewed_thisweek'] = $this->getView($itemid, $category, 'viewed', 'thisweek'); $stats['viewed_thismonth'] = $this->getView($itemid, $category, 'viewed', 'thismonth'); $stats['shortlisted'] = $row->countShortlistedBy($itemid); } return $stats; }
/** * Job posting * * @return void */ public function jobTask() { // Incoming $code = Request::getVar('code', ''); $code = !$code && $this->_jobCode ? $this->_jobCode : $code; $obj = new Job($this->database); $job = $obj->get_opening(0, User::get('id'), $this->_masterAdmin, $code); // Push some styles to the template $this->css(); // Push some scripts to the template $this->js(); if (!$job) { $this->setError(Lang::txt('COM_JOBS_ERROR_JOB_INACTIVE')); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } // Output HTML $view = new View(array('name' => 'error')); $view->title = Lang::txt(strtoupper($this->_name)); if ($this->getError()) { $view->setError($this->getError()); } $view->display(); return; } if (User::get('id') == $job->employerid && !$this->_emp && !$this->_masterAdmin) { // check validity of subscription App::redirect(Route::url('index.php?option=com_jobs&task=dashboard'), Lang::txt('COM_JOBS_WARNING_SUBSCRIPTION_INVALID'), 'warning'); return; } // Set the pathway $this->_jobid = $job->id; $this->_jobtitle = $job->title; $this->_buildPathway(); if (User::isGuest() && $job->status != 1) { // Not authorized $error = Lang::txt('COM_JOBS_ERROR_NOT_AUTHORIZED_JOB_VIEW'); $error .= User::isGuest() ? ' ' . Lang::txt('COM_JOBS_WARNING_LOGIN_REQUIRED') : ''; $this->setError($error); // Output HTML $view = new View(array('name' => 'error')); $view->title = Lang::txt(strtoupper($this->_name)); if ($this->getError()) { $view->setError($this->getError()); } $view->display(); return; } if ($job->status != 1 && !$this->_admin && (!$this->_emp && User::get('id') != $job->employerid)) { // Not authorized App::abort(403, Lang::txt('COM_JOBS_ERROR_NOT_AUTHORIZED_JOB_VIEW')); } // Set page title $this->_subtitle = $job->status == 4 ? Lang::txt('COM_JOBS_ACTION_PREVIEW_AD') . ' ' . $job->code : $job->title; $this->_buildTitle(); // Get category & type names $jt = new JobType($this->database); $jc = new JobCategory($this->database); $job->type = $jt->getType($job->type); $job->cat = $jc->getCat($job->cid); // Get applications $ja = new JobApplication($this->database); $job->applications = ($this->_admin or $this->_emp && User::get('id') == $job->employerid) ? $ja->getApplications($job->id) : array(); // Get profile info of applicants $job->withdrawnlist = array(); if (count($job->applications) > 0) { $js = new JobSeeker($this->database); foreach ($job->applications as $ap) { $seeker = $js->getSeeker($ap->uid, $job->employerid); $ap->seeker = (!$seeker or count($seeker) == 0) ? NULL : $seeker[0]; if ($ap->status == 2) { $job->withdrawnlist[] = $ap; } } } // Output HTML $this->view->title = $this->_title; $this->view->config = $this->config; $this->view->emp = $this->_emp; $this->view->job = $job; $this->view->admin = $this->_admin; $this->view->task = $this->_task; $this->view->option = $this->_option; // Set any errors if ($this->getError()) { \Notify::error($this->getError()); } $this->view->setName('job')->setLayout('default')->display(); }