public function indexAction() { $this->_delete(); $this->_multi(); $page = (int) $this->_request->get("page", 1); if ($page < 1) { $page = 1; } $perPage = $this->_getPerPage(); $qstring = array(); $sq1 = new Daq_Db_Query(); $sq1->select("count(*) AS `c_all`")->from("Wpjb_Model_Job t2")->where("t2.job_category=t1.id"); $query = new Daq_Db_Query(); $query->select("*"); $query->from("Wpjb_Model_Application t"); $query->join("t.job t2"); $query->order("is_rejected ASC, applied_at DESC"); $query->limitPage($page, $perPage); if ($this->_request->get("job") > 0) { $jId = $this->_request->get("job"); $query->where("job_id = ?", $jId); $this->view->job = new Wpjb_Model_Job($jId); $qstring["job"] = $jId; } $result = $query->execute(); $total = (int) $query->select("COUNT(*) as `total`")->limit(1)->fetchColumn(); $this->view->current = $page; $this->view->total = ceil($total / $perPage); $this->view->data = $result; $qs = ""; foreach ($qstring as $k => $v) { $qs .= $k . "/" . esc_html((string) $v); } $this->view->qstring = $qs; }
public function applicationsAction() { $this->_setTitle(__("Applications", WPJB_DOMAIN)); $job = $this->getObject(); $emp = $job->getEmployer(true); if ($this->_isCandidate()) { return false; } if ($emp->user_id < 1 || $emp->user_id != wp_get_current_user()->ID) { $this->view->_flash->addError(__("You are not allowed to access this page.", WPJB_DOMAIN)); return false; } $this->view->job = $job; $query = new Daq_Db_Query(); $query->select("*"); $query->from("Wpjb_Model_Application t"); $query->where("job_id = ?", $job->getId()); $query->order("is_rejected ASC, applied_at DESC"); $result = $query->execute(); $this->view->applicantList = $result; return "job-applications"; }
public function indexAction() { $this->_delete(); $this->_multi(); $this->_employers(); $page = (int) $this->_request->get("page", 1); if ($page < 1) { $page = 1; } $perPage = $this->_getPerPage(); $qstring = array(); $employer = 0; if ($this->_request->get("employer") > 0) { $emp = new Wpjb_Model_Employer($this->_request->get("employer")); if ($emp->getId() > 0) { $employer = $emp->getId(); $this->view->company = $emp; $this->view->repr = $emp->getUsers(true); $qstring['employer'] = $employer; } } $show = $this->_request->get("show", "all"); $days = $this->_request->post("days", null); if ($days === null) { $days = $this->_request->get("days", ""); } $query1 = new Daq_Db_Query(); $query1->select("*")->from("Wpjb_Model_Job t1")->join("t1.category t2")->join("t1.type t3"); $query2 = new Daq_Db_Query(); $query2->select("COUNT(*) AS total")->from("Wpjb_Model_Job t1")->join("t1.category t2")->join("t1.type t3"); if ($show == "active") { $query1->where("t1.is_active = 1"); $query1->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)"); $query1->orWhere("t1.job_visible = 0)"); $query2->where("t1.is_active = 1"); $query2->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)"); $query2->orWhere("t1.job_visible = 0)"); } elseif ($show == "inactive") { $query1->where("t1.is_active = 0"); $query1->orWhere("(t1.job_created_at < DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)"); $query1->Where("t1.job_visible > 0)"); $query2->where("t1.is_active = 0"); $query2->orWhere("(t1.job_created_at < DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)"); $query2->Where("t1.job_visible > 0)"); } elseif ($show == "awaiting") { $query1->where("t1.is_approved = 0"); $query1->where("t1.is_active = 0"); $query2->where("t1.is_approved = 0"); $query2->where("t1.is_active = 0"); } if (is_numeric($days)) { $query1->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days); $query2->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days); } if ($employer > 0) { $query1->where("t1.employer_id = ?", $employer); $query2->where("t1.employer_id = ?", $employer); } $result = $query1->order("t1.job_created_at DESC")->limitPage($page, $perPage)->execute(); $total = $query2->limit(1)->fetchColumn(); $this->view->employer = $employer; $this->view->days = $days; $this->view->show = $show; $this->view->current = $page; $this->view->total = ceil($total / $perPage); $this->view->data = $result; $query = new Daq_Db_Query(); $list = array("COUNT(*) AS c_total", "SUM(t1.is_approved) AS c_awaiting"); $query->select(join(", ", $list)); $query->from("Wpjb_Model_Job t1"); if (is_numeric($days)) { $query->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days); $qstring['days'] = $days; } if ($employer > 0) { $query->where("t1.employer_id = ?", $employer); } $summary1 = $query->fetch(); $query = new Daq_Db_Query(); $query = $query->select("COUNT(*) AS c_active")->from("Wpjb_Model_Job t1")->where("t1.is_active = 1")->where("t1.is_approved = 1")->where("(t1.job_created_at > DATE_SUB(NOW(), INTERVAL t1.job_visible DAY)")->orWhere("t1.job_visible = 0)"); if (is_numeric($days)) { $query->where("t1.job_created_at > DATE_SUB(NOW(), INTERVAL ? DAY)", $days); } if ($employer > 0) { $query->where("t1.employer_id = ?", $employer); } $summary2 = $query->fetch(); $stat = new stdClass(); $stat->total = $summary1->c_total; $stat->active = $summary2->c_active; $stat->inactive = $summary1->c_total - $summary2->c_active; $stat->awaiting = $summary1->c_total - $summary1->c_awaiting; $this->view->stat = $stat; $qs = ""; foreach ($qstring as $k => $v) { $qs .= $k . "/" . esc_html((string) $v); } $this->view->qstring = $qs; }