From 6ba966a94dbda1ec98a1efbd4c2a0634de2add85 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 4 Apr 2011 18:48:58 +1000 Subject: [PATCH] Removing jqGrid. Implementing this fucking thing myself. Ugh --- controllers/jobs_controller.php | 111 ++++++++++++-------------------- views/jobs/build_jobs_json.ctp | 89 ++++++++++++------------- views/jobs/index.ctp | 104 +++++++++++++++++++++++++++++- webroot/css/quotenik.css | 16 ++++- webroot/js/job_grid.js | 22 +++++-- 5 files changed, 217 insertions(+), 125 deletions(-) diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index 6f343dce..bcb6b85f 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -15,10 +15,10 @@ 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')); } @@ -63,6 +63,7 @@ class JobsController extends AppController { $jobs = $this->Job->find('all', array('recursive'=>1, 'order'=>array('Job.id'=>'desc'))); //print_r($jobs); $this->set('jobs', $jobs); + $this->set('sale_category_options', $this->sale_category_options_array()); $customers = $this->Job->Enquiry->Customer->find('list'); $this->set('customers', $customers); @@ -70,6 +71,43 @@ class JobsController extends AppController { } + + /** + * Build the HTML select for sale_category1. + * + * + * + * + */ + function sale_category_options() { + $this->layout = 'none'; + $options = $this->sale_category_options_array(); + $this->set('options', $options); + + } + + + function sale_category_options_array() { + + $options['Australian Sale'] = array( + 0 => "Australian Customer & Australian Destination (GST Applies)", + 1 => "Overseas Customer & Australian Destination (GST Applies)", + 2 => "Commission from Australian Company or Supplier (GST Applies)", + + ); + + $options['Exports'] = array( + 3 => "Overseas Customer & Overseas Destination (no GST)", + 4 => "Australian Customer & Overseas Destination (no GST)", + 5 => "Commission from Overseas Company (no GST)" + ); + + + return $options; + } + + + function ajax_edit() { if(isset($this->params['form'])) { @@ -103,74 +141,7 @@ class JobsController extends AppController { } - function index_oldgrid() { - - $this->layout = 'grid'; - $jobs = $this->paginate(); - - $this->set('jobs', $jobs); - - $jsonObj = array(); - - $customers = $this->Job->Enquiry->Customer->find('list'); - $this->set('customers', $customers); - - - foreach($jobs as $job) { - $jsonObj[] = array( - 'id' => $job['Job']['id'], - 'created' => $job['Job']['created'], - 'title' => $job['Job']['title'], - 'customer' => $customers[$job['Enquiry']['customer_id']], - 'customer_order_number' => $job['Job']['customer_order_number'], - 'supplier_reference' =>$job['Job']['supplier_reference'], - 'date_order_received' => $job['Job']['date_order_received'], - 'date_order_placed_on_principle' => $job['Job']['date_order_placed_on_principle'], - 'date_scheduled_ex_works' => $job['Job']['date_scheduled_ex_works'], - 'date_order_sent_to_customer' => $job['Job']['date_order_sent_to_customer'], - 'domestic_freight_paid_by' => $job['Job']['domestic_freight_paid_by'], - 'sale_category' => $job['Job']['sale_category'], - 'shipment_category' => $job['Job']['shipment_category'], - 'comments' => $job['Job']['comments'], - 'company_gross_sales_aud' => $job['Job']['company_gross_sales_aud'], - 'net_sales_aud' => $job['Job']['net_sales_aud'], - 'gross_profit_aud' => $job['Job']['gross_profit_aud'], - 'ato_exchange_rate' => $job['Job']['ato_exchange_rate'], - 'gst'=> $job['Job']['gst'], - 'currency_id' => $job['Job']['currency_id'], - 'gst_amount' => $job['Job']['gst_amount'], - 'gross_commisions' => $job['Job']['gross_commisions'], - 'invoiced_amount_inc_gst' => $job['Job']['invoiced_amount_inc_gst'], - 'net_export_sales_aud' =>$job['Job']['net_export_sales_aud'], - 'gross_profit_exports_aud' => $job['Job']['gross_profit_exports_aud'], - 'gp_percent' => $job['Job']['gp_percent'], - 'gross_australian_sales_foreign_currency' => $job['Job']['gross_australian_sales_foreign_currency'], - 'net_australian_sales_foreign_currency' => $job['Job']['net_australian_sales_foreign_currency'], - 'gross_profit_value_australian_sales_foreign_currency' => $job['Job']['gross_profit_value_australian_sales_foreign_currency'], - 'gross_export_sales_foreign_currency' => $job['Job']['gross_export_sales_foreign_currency'], - 'net_export_sales_foreign_currency' => $job['Job']['net_export_sales_foreign_currency'], - 'gross_profit_value_after_discount_exports_foreign_currency' => $job['Job']['gross_profit_value_after_discount_exports_foreign_currency'], - 'gross_commissions' => $job['Job']['gross_commissions'], - 'net_commissions' => $job['Job']['net_commissions'] - - - ); - - - - - }; - - - $jsonObj = json_encode($jsonObj); - - $this->set('jsonObj', $jsonObj); - - $this->set('jobs', $jobs); - - $this->set('currencies', $this->Job->Currency->find('list')); - - } + function view($id = null) { if (!$id) { diff --git a/views/jobs/build_jobs_json.ctp b/views/jobs/build_jobs_json.ctp index 9146f3fa..4bb1ab21 100644 --- a/views/jobs/build_jobs_json.ctp +++ b/views/jobs/build_jobs_json.ctp @@ -31,62 +31,63 @@ foreach($jobs as $job) { } - $cellArray = array( + $cellArray = array( - $job['Job']['job_status'], - $job['Job']['sale_category'], - $job['Job']['shipment_category'], - $html->link($job['Job']['title'], array('controller'=>'jobs','action'=>'view', $job['Job']['id'])), - $poString, + $job['Job']['job_status'], + $job['Job']['sale_category1'], + $job['Job']['sale_category'], + $job['Job']['shipment_category'], + $html->link($job['Job']['title'], array('controller'=>'jobs','action'=>'view', $job['Job']['id'])), + $poString, - $html->link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers','action'=>'view', $job['Enquiry']['customer_id'])), - $job['Job']['comments'], - $job['Job']['customer_order_number'], - $job['Job']['date_order_received'], + $html->link($customers[$job['Enquiry']['customer_id']], array('controller'=>'customers','action'=>'view', $job['Enquiry']['customer_id'])), + $job['Job']['comments'], + $job['Job']['customer_order_number'], + $job['Job']['date_order_received'], - $job['Job']['supplier_reference'], - $job['Job']['date_order_placed_on_principle'], + $job['Job']['supplier_reference'], + $job['Job']['date_order_placed_on_principle'], - $job['Job']['date_scheduled_ex_works'], - $job['Job']['date_order_sent_to_customer'], - $job['Job']['domestic_freight_paid_by'], + $job['Job']['date_scheduled_ex_works'], + $job['Job']['date_order_sent_to_customer'], + $job['Job']['domestic_freight_paid_by'], - $job['Job']['company_gross_sales_aud'], - $job['Job']['net_sales_aud'], - $job['Job']['gross_profit_aud'], - $job['Job']['ato_exchange_rate'], - $job['Job']['gst'], - $job['Job']['currency_id'], - $job['Job']['gst_amount'], - $job['Job']['gross_commisions'], - $job['Job']['invoiced_amount_inc_gst'], - $job['Job']['net_export_sales_aud'], - $job['Job']['gross_profit_exports_aud'], - $job['Job']['gp_percent'], - $job['Job']['gross_australian_sales_foreign_currency'], - $job['Job']['net_australian_sales_foreign_currency'], - $job['Job']['gross_profit_value_australian_sales_foreign_currency'], - $job['Job']['gross_export_sales_foreign_currency'], - $job['Job']['net_export_sales_foreign_currency'], - $job['Job']['gross_profit_value_after_discount_exports_foreign_currency'], - $job['Job']['gross_commissions'], - $job['Job']['net_commissions'] - ); + $job['Job']['company_gross_sales_aud'], + $job['Job']['net_sales_aud'], + $job['Job']['gross_profit_aud'], + $job['Job']['ato_exchange_rate'], + $job['Job']['gst'], + $job['Job']['currency_id'], + $job['Job']['gst_amount'], + $job['Job']['gross_commisions'], + $job['Job']['invoiced_amount_inc_gst'], + $job['Job']['net_export_sales_aud'], + $job['Job']['gross_profit_exports_aud'], + $job['Job']['gp_percent'], + $job['Job']['gross_australian_sales_foreign_currency'], + $job['Job']['net_australian_sales_foreign_currency'], + $job['Job']['gross_profit_value_australian_sales_foreign_currency'], + $job['Job']['gross_export_sales_foreign_currency'], + $job['Job']['net_export_sales_foreign_currency'], + $job['Job']['gross_profit_value_after_discount_exports_foreign_currency'], + $job['Job']['gross_commissions'], + $job['Job']['net_commissions'] + ); - $recordObj->rows[$i]['id'] = $job['Job']['id']; - //$rows[$i] = $job; - $recordObj->rows[$i]['cell'] = $cellArray; - //$recordObj->rows[$i]['cell'] = $job['Job']; - $i++; - }; + $recordObj->rows[$i]['id'] = $job['Job']['id']; + //$rows[$i] = $job; + $recordObj->rows[$i]['cell'] = $cellArray; + //$recordObj->rows[$i]['cell'] = $job['Job']; + $i++; +}; - $jsonObj = json_encode($recordObj); - echo $jsonObj; +$jsonObj = json_encode($recordObj); +echo $jsonObj; ?> diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index 6a38ebfc..fdd746b6 100644 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -3,7 +3,7 @@ //echo $javascript->link('jquery.jeditable.mini'); //echo $javascript->link('jobindex_editinplace'); //echo $javascript->link('addjob'); -echo $javascript->link('job_index'); +//echo $javascript->link('job_index'); ?> @@ -15,12 +15,110 @@ echo $javascript->link('job_index'); ?> + + + +
+ + prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?> +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sort('Status');?>sort('Sale Category 1');?>sort('Sale Category 2');?>sort('Shipment Category');?>sort('Job Number');?>CMC POssort('Customer');?>DescriptionCustomer Order Nosort('Order Received');?>sort('Supplier Ref');?>sort('Scheduled Ex-Works');?>sort('Date Sent to Customer');?>sort('Freight Paid By CMC');?>sort('Sale Currency');?>sort('Gross Sales AUD');?>sort('Net Sales AUD');?>sort('Gross Profit AUD');?>sort('Net Export Sales Converted to Or Charged in AUD');?>sort('Gross Profit Value Export in AUD');?>sort('GP% Excl Commissions');?>sort('Company Gross Sales AUD');?>sort('ATO Exchange Rate');?>sort('Gross Australian Sales Foreign Currency');?>sort('Net Australian Sales Foreign Currency');?>sort('Gross Profit value Australian Sales Foreign Currency');?>sort('Gross Export Sales Foreign Currency');?>sort('Net Export Sales Foreign Currency');?>sort('Gross Profit Value After Discount Exports Foreign Currency');?>sort('Gross Commissions');?>sort('Net Commisions');?>
SALE CATEGORY 1 DROPDOWNSale Cat 2 DropdownShipment Cat.link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id'])); + } + echo $poString; + ?> + Net Export Sales Conv to AUD?%? Double column?Actions
+
+
- +
- \ No newline at end of file diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 838ebbae..939811eb 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -672,7 +672,7 @@ dt.altrow { } #emailHeaders dt { - + } dd { @@ -1283,4 +1283,18 @@ span.addLineItem { button.actionButtons { margin-right: 3em; margin-bottom: 1em; +} + +#jobTable { + height: 900px; + width: 100%; + overflow: scroll; +} + +table.jobsTable tr th { + border: 1px solid; +} + +table.jobsTable tr td { + border: 1px solid; } \ No newline at end of file diff --git a/webroot/js/job_grid.js b/webroot/js/job_grid.js index 0419bf0f..aac1cacb 100644 --- a/webroot/js/job_grid.js +++ b/webroot/js/job_grid.js @@ -36,7 +36,7 @@ jQuery(document).ready(function(){ mtype: 'GET', colNames:[ //'id', - 'Status', 'Sale Cat.','Shipment Cat.','Job Number','CMC POs', 'Customer','Description','Customer O/N','Order Received','Supplier Ref', + 'Status','Sale Cat. 1','Sale Cat. 2','Shipment Cat.','Job Number','CMC POs', 'Customer','Description','Customer O/N','Order Received','Supplier Ref', 'Order Placed Principle','date_scheduled_ex_works','date_order_sent_to_customer','Freight Paid By', 'company_gross_sales_aud','net_sales_aud','gross_profit_aud','ato_exchange_rate', 'gst','Sale Currency','gst_amount','gross_commisions','invoiced_amount_inc_gst','net_export_sales_aud', @@ -75,6 +75,18 @@ jQuery(document).ready(function(){ }, + { + name:'sale_category1', + index:'sale_category1', + width:200, + editable:true, + edittype:"select", + editoptions: { + dataUrl: '/jobs/sale_category_options' + + } + }, + { name:'sale_category', index:'sale_category', @@ -359,8 +371,6 @@ jQuery(document).ready(function(){ $("#editButton").click(function(){ var s; s = jQuery("#grid").jqGrid('getGridParam','selarrrow'); - //alert(s); - $.each(s, function(index, value) { jQuery("#grid").jqGrid('editRow', value, false, pickdates, false, '/jobs/ajax_edit'); }); @@ -372,7 +382,6 @@ jQuery(document).ready(function(){ $("#cancelButton").click(function() { var s; s = jQuery("#grid").jqGrid('getGridParam','selarrrow'); - //alert(s); $.each(s, function(index, value) { jQuery("#grid").jqGrid('restoreRow', value, true, pickdates); @@ -384,14 +393,13 @@ jQuery(document).ready(function(){ $("#saveButton").click(function() { var s; s = jQuery("#grid").jqGrid('getGridParam','selarrrow'); - //alert(s); $.each(s, function(index, value) { - jQuery("#grid").jqGrid('saveRow', value, setJobStatus, '/jobs/ajax_edit'); + jQuery("#grid").jqGrid('saveRow', value, false, '/jobs/ajax_edit'); }); disableSaveEdit(); - //setJobStatus(); + setJobStatus(); });