function classfied() { $cat_model = new \modules\classfied\models\Classfied_categories(); $cat_model->_select = "classfied_categories.*, (SELECT COUNT(*) FROM classfied_jobs WHERE classfied_jobs.classfied_category_id = classfied_categories.classfied_category_id) AS total_vacancies "; $cat_model->_order_by['category_order'] = 'ASC'; $country = new \modules\classfied\models\Classfied_countries(); $country->_select = "classfied_countries.*, (SELECT COUNT(*) FROM classfied_jobs WHERE classfied_jobs.classfied_country_id = classfied_countries.classfied_country_id) AS total_vacancies "; return ['categories' => $cat_model->get(), 'countries' => $country->get()]; }
public function indexAction($id, $offset = 0) { $category = new \modules\classfied\models\Classfied_categories(); $jobs = new \modules\classfied\models\Classfied_jobs(); $category->classfied_category_id = $id; $jobs->classfied_category_id = $id; $jobs->is_active = 1; $jobs->_select = 'classfied_jobs.classfied_job_id, classfied_jobs.title, classfied_jobs.created_on, classfied_jobs.company, `classfied_countries`.`image` as country_image, `locations`.`image` as location_image, `locations`.`name` as location_name, `classfied_countries`.`name` as country_name,`classfied_types`.`name` as type, `classfied_types`.`color`, (SELECT COUNT(*) FROM classfied_job_applications WHERE classfied_job_applications.classfied_job_id = classfied_jobs.classfied_job_id) as appicants'; $jobs->_joins = ['classfied_countries' => ['`classfied_countries`.`classfied_country_id`=`classfied_jobs`.`classfied_country_id`', 'left'], 'classfied_countries` `locations' => ['`locations`.`classfied_country_id`=`classfied_jobs`.`classfied_country_id`', 'left'], 'classfied_types' => ['`classfied_types`.`classfied_type_id`=`classfied_jobs`.`classfied_type_id`', 'left']]; $jobs->_order_by['classfied_jobs.classfied_job_id'] = 'DESC'; $this->load->library('pagination'); $jobs->_limit = $this->config->get('limit'); $jobs->_offset = $offset; return $this->render('classfied_category', ['item' => $category->get(), 'jobs' => $jobs->get(), 'pagination' => $this->Pagination->generate(['url' => Uri_helper::url('classfied_category/index/' . $id), 'total' => $jobs->get(true), 'limit' => $jobs->_limit, 'offset' => $jobs->_offset])]); }
public function manageAction($id = false) { $this->permission('manage'); if ($id) { $classfied = new \modules\classfied\models\Classfied_categories('edit'); $classfied->classfied_category_id = $id; } else { $classfied = new \modules\classfied\models\Classfied_categories('add'); } $classfied->set('name', $this->input->post('name')); $classfied->set('var_name', $this->input->post('var_name')); $classfied->set('title', $this->input->post('title')); $classfied->set('description', $this->input->post('description')); $classfied->set('keywords', $this->input->post('keywords')); $classfied->set('category_order', $this->input->post('category_order')); $classfied->language_id = $this->language->getDefaultLanguage(); if ($classfied->save()) { Uri_helper::redirect("management/classfied_categories"); } else { return $this->render('classfied_categories/manage', ['item' => $id ? $classfied->get() : null]); } }