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 @@ -counter(array('format' => '%page% %pages% %current% %count%')); +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; + + + ?> 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 @@ link('job_grid'); ?> +counter(array( +'format' => __('Page %page% of %pages%, showing %current% Jobs out of %count% total, starting on record %start%, ending on %end%', true) +)); +?> + +
+ +prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> +next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?> +
+ +*/ ?>
\ No newline at end of file diff --git a/webroot/js/autocomplete-customer.js b/webroot/js/autocomplete-customer.js index bc24fdae..861ede15 100755 --- a/webroot/js/autocomplete-customer.js +++ b/webroot/js/autocomplete-customer.js @@ -37,7 +37,6 @@ $(function() { source: "/countries/completeCountry", minLength: 3, select: function(event, ui) { - alert("You selected " + ui.item.value + " ID:"+ ui.item.id); $("#CustomerCountryId").val(ui.item.id); if(ui.item.value == 'Australia') { diff --git a/webroot/js/job_grid.js b/webroot/js/job_grid.js index e54f6bd3..3a81b432 100644 --- a/webroot/js/job_grid.js +++ b/webroot/js/job_grid.js @@ -56,7 +56,8 @@ jQuery(document).ready(function(){ name:'customer', index:'customer', width:400, - editable:false + editable:false, + sortable: false }, { @@ -281,9 +282,8 @@ jQuery(document).ready(function(){ ], // viewrecords: true, - sortname: 'id', - sortorder: "asc", - rowNum: 50, + + rowNum: 500, height: '100%', caption:"Jobs", editurl:"/jobs/ajax_edit",