Current File : /home/giriqfky/public_html/Barga/application/modules/dashboard/controllers//Dashboard.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends Basecontroller {
public function __construct(){
parent::__construct();
$this->load->model('Dashboard_model', 'Dashboard');
$this->load->model('Jobs/Jobs_model', 'Jobs');
$this->load->model('services/Services_model', 'Services');
$this->controller_name = "dashboard";
$this->folder = "dashboard";
$this->per_page = APP_PER_PAGE;
$this->load->library('session');
if(!$this->session->userdata('is_login')) { redirect('sessions','refresh'); } //Checked is logined in or not
}
public function index()
{
$data = array();
$conditions = array();
//calc offset number
$page = $this->input->post('page');
if(!$page) $offset = 0;
else $offset = $page;
$service_id = $this->input->post('service_id');
if(!empty($service_id)){
$conditions['search']['service_id'] = $service_id;
}
$total_record = count($this->Dashboard->getJobList($conditions));
//pagination configuration
$config['target'] = '#data_list';
$config['base_url'] = base_url().$this->controller_name.'/ajaxJobList';
$config['total_rows'] = $total_record;
$config['per_page'] = $this->per_page;
$config['link_func'] = 'searchFilter';
$this->ajax_pagination->initialize($config);
//get the Qualification data
$data['limit'] = $this->per_page;
$data['modal_job_application'] = $this->load->view('jobs/job_view/modal_job_application', array(), true);
$data['job'] = $this->Dashboard->getJobList($conditions,$data);
$data['title'] = "Jobs";
$data['total_record'] = $total_record;
$data['sl_no'] = $page;
$data['jobs_html'] = $this->load->view('jobs/job_list/ajax_job_lists', $data, true);
$data['title'] = "Dashboard";
$data['total_active_jobs'] = $this->Dashboard->getTotalActiveJobs();
$data['total_guardian'] = $this->Dashboard->getTotalCustomer();
$data['total_service_provider'] = $this->Dashboard->getTotalServiceProvider();
$data['total_active_packages'] = $this->Dashboard->getTotalActivePackages();
$data['total_registered_devices'] = $this->Dashboard->getTotalRegisteredDevices();
$this->template->admin('dashboard/index', $data);
}
function addSCript()
{
$js = '<script src="'.base_url("assets/js/graphchart.js").'"></script>';
return $js;
}
public function ajaxJobList()
{
$conditions = array();
//calc offset number
$page = $this->input->post('page');
if(!$page) $offset = 0;
else $offset = $page;
//set conditions for search
$customer = $this->input->post('customer');
$service_provider = $this->input->post('service_provider');
$service_id = $this->input->post('service_id');
$job_post_date_from = $this->input->post('job_post_date_from');
$job_post_date_to = $this->input->post('job_post_date_to');
$job_expiring_date_from = $this->input->post('job_expiring_date_from');
$job_expiring_date_to = $this->input->post('job_expiring_date_to');
$area_locality = $this->input->post('area_locality');
$job_post_code = $this->input->post('job_post_code');
if(!empty($customer)){
$conditions['search']['customer'] = $customer;
}
if(!empty($service_provider)){
$conditions['search']['service_provider'] = $service_provider;
}
if(!empty($service_id)){
$conditions['search']['service_id'] = $service_id;
}
if(!empty($job_post_date_from)){
$conditions['search']['job_post_date_from'] = $job_post_date_from;
}
if(!empty($job_post_date_to)){
$conditions['search']['job_post_date_to'] = $job_post_date_to;
}
if(!empty($job_expiring_date_from)){
$conditions['search']['job_expiring_date_from'] = $job_expiring_date_from;
}
if(!empty($job_expiring_date_to)){
$conditions['search']['job_expiring_date_to'] = $job_expiring_date_to;
}
if(!empty($area_locality)){
$conditions['search']['area_locality'] = $area_locality;
}
if(!empty($job_post_code)){
$conditions['search']['job_post_code'] = $job_post_code;
}
//total rows count
$total_record = count($this->Dashboard->getJobList($conditions));
//pagination configuration
$config['target'] = '#data_list';
$config['base_url'] = base_url().$this->controller_name.'/ajaxJobList';
$config['total_rows'] = $total_record;
$config['per_page'] = $this->per_page;
$config['link_func'] = 'searchFilter';
$this->ajax_pagination->initialize($config);
//set start and limit
$conditions['start'] = $offset;
$conditions['limit'] = $this->per_page;
//get posts data
$data['job'] = $this->Dashboard->getJobList($conditions);
$data['title'] = "Jobs";
$data['total_record'] = $total_record;
$data['sl_no'] = $page;
//load the view
$jobs_html = $this->load->view('jobs/job_list/ajax_job_lists', $data, true);
echo $jobs_html;exit;
}
public function graphActivity()
{
$res = $this->Dashboard->getActivityGraph();
return $res;
}
}