diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index 0e91edea..ed8b53b6 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -15,28 +15,19 @@ class JobsController extends AppController { ); function index() { - $this->Job->recursive = 1; +/* $this->Job->recursive = 1; $this->set('jobs', $this->paginate()); $this->set('customers', $this->Job->Enquiry->Customer->find('list')); - $this->set('currencies', $this->Job->Currency->find('list')); + $this->set('currencies', $this->Job->Currency->find('list'));*/ + } - - - function index_grid() { - + $jobs = $this->paginate(); $this->layout = 'jqgrid'; - //$jobs = $this->paginate(); - /*$jobs = $this->Job->find('all', array('recursive'=>0)); - - $this->set('jobs', $jobs); - - $customers = $this->Job->Enquiry->Customer->find('list'); - $this->set('customers', $customers); - $this->set('currencies', $this->Job->Currency->find('list'));*/ + //print_r($this->params); } @@ -44,8 +35,33 @@ class JobsController extends AppController { function build_jobs_json() { $this->layout = 'ajax'; - $jobs = $this->paginate(); + //print_r($this->params); + + + $sortCol = 'id'; //Default we Order by ID + $sortDir = 'desc'; //Descending. + + + + if(isset($this->params['url']['sidx'])) { + $sortCol = $this->params['url']['sidx']; + } + else { + $sortCol = 'Job.id'; + } + + if(isset($this->params['url']['sord'])) { + $sortDir = $this->params['url']['sord']; + } + else { + $sortDir = 'desc'; + } + + $jobPaginated = $this->paginate(); //Not used currently. + + $jobs = $this->Job->find('all', array('recursive'=>1, 'order'=>array('Job.id'=>'desc'))); + //print_r($jobs); $this->set('jobs', $jobs); $customers = $this->Job->Enquiry->Customer->find('list'); diff --git a/views/jobs/build_jobs_json.ctp b/views/jobs/build_jobs_json.ctp index ed734079..c9611163 100644 --- a/views/jobs/build_jobs_json.ctp +++ b/views/jobs/build_jobs_json.ctp @@ -1,10 +1,13 @@ - $countString = $paginator->counter(array('format' => '%page% %pages% %current% %count%')); + + +$countString = $paginator->counter(array('format' => '%page% %pages% %current% %count%')); $numbers = explode(" ",$countString); $page = $numbers[0]; $totalPages = $numbers[1]; $currentNoRecord = $numbers[2]; + $totalNoRecords = $numbers[3]; @@ -12,6 +15,9 @@ $recordObj->total = $totalPages; $recordObj->page = $page; $recordObj->records = $totalNoRecords; + + + ?> @@ -59,7 +65,7 @@ foreach($jobs as $job) { // $job['Job']['id'], $job['Job']['created'], - $job['Job']['title'], + $html->link($job['Job']['title'], array('controller'=>'jobs','action'=>'view', $job['Job']['id'])), $html->link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers','action'=>'view', $job['Enquiry']['customer_id'])), $job['Job']['customer_order_number'], $job['Job']['supplier_reference'], diff --git a/views/jobs/index_grid.ctp b/views/jobs/index_grid.ctp index 3ccbbfdb..c85a01ec 100644 --- a/views/jobs/index_grid.ctp +++ b/views/jobs/index_grid.ctp @@ -1,5 +1,19 @@ echo $javascript->link('job_grid'); ?> + /* +echo $paginator->counter(array( +'format' => __('Page %page% of %pages%, showing %current% Jobs out of %count% total, starting on record %start%, ending on %end%', true) +)); +?> + +