From aa26dd8a199720bfdf84f3f11c7328b3d5190e7e Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Fri, 15 Apr 2011 17:34:51 +1000 Subject: [PATCH] Added JS to edit jobs to enforce the correct columns. Not 100pc finished --- controllers/jobs_controller.php | 50 +++--------- models/currency.php | 2 + views/freight_forwarders/index.ctp | 2 +- views/freight_forwarders/view.ctp | 8 -- views/jobs/get_editable_row.ctp | 122 ++++++++++++++++++++++++----- views/jobs/index.ctp | 30 +++---- views/shipments/add_edit.ctp | 15 ++++ views/shipments/index.ctp | 18 +---- webroot/css/quotenik.css | 31 +++++++- webroot/js/shipment_index.js | 5 +- 10 files changed, 178 insertions(+), 105 deletions(-) create mode 100644 views/shipments/add_edit.ctp diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index a4e2fa53..d46179ba 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -17,7 +17,7 @@ class JobsController extends AppController { function index($showUnpaid = null, $showUnsent = null) { $this->Job->recursive = 1; - + if(!empty($showUnpaid) && !empty($showUnsent)) { @@ -30,7 +30,7 @@ class JobsController extends AppController { else if(!empty($showUnpaid)) { $conditions = array( 'Job.all_paid' => 0, - + ); } @@ -246,7 +246,7 @@ class JobsController extends AppController { } - + /** @@ -260,13 +260,13 @@ class JobsController extends AppController { return $enumOpts; } - function shipment_category_options() { + function shipment_category_options() { $options = array( - 0 => '', - 1 => 'Indent - via CMC', - 2 => 'Direct - Principle to final', - 3 => 'Stock', - 4 => 'No Shipment' + 0 => '', + 1 => 'Indent - via CMC', + 2 => 'Direct - Principle to final', + 3 => 'Stock', + 4 => 'No Shipment' ); return $options; @@ -409,15 +409,7 @@ class JobsController extends AppController { $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); $this->set('sale_category_options', $sale_category_options); - - $shipment_category_options = array( - "AUSTRALIA"=>"AUSTRALIA", - "EXPORT"=>"EXPORT", - "DIRECT-INTL"=>"DIRECT-INTL", - "DIRECT-AUST"=>"DIRECT-AUST", - "NO-SHIP"=>"NO-SHIP" - ); - $this->set('shipment_category_options', $shipment_category_options); + $this->set('shipment_category_options', $this->shipment_category_options()); } @@ -452,30 +444,10 @@ class JobsController extends AppController { $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); $this->set('sale_category_options', $sale_category_options); - - $shipment_category_options = array( - "AUSTRALIA"=>"AUSTRALIA", - "EXPORT"=>"EXPORT", - "DIRECT-INTL"=>"DIRECT-INTL", - "DIRECT-AUST"=>"DIRECT-AUST", - "NO-SHIP"=>"NO-SHIP" - ); - $this->set('shipment_category_options', $shipment_category_options); - - + $this->set('shipment_category_options', $this->shipment_category_options()); } - /* - function delete($id = null) { - if (!$id) { - $this->flash(__('Invalid Job', true), array('action'=>'index')); - } - if ($this->Job->del($id)) { - $this->flash(__('Job deleted', true), array('action'=>'index')); - } - } - */ function __isNotEmptyDate($date) { diff --git a/models/currency.php b/models/currency.php index 48689bc1..5e985103 100755 --- a/models/currency.php +++ b/models/currency.php @@ -32,5 +32,7 @@ class Currency extends AppModel { ); + var $order = "Currency.name ASC"; + } ?> diff --git a/views/freight_forwarders/index.ctp b/views/freight_forwarders/index.ctp index 570d506b..c4892ba1 100644 --- a/views/freight_forwarders/index.ctp +++ b/views/freight_forwarders/index.ctp @@ -30,7 +30,7 @@ foreach ($freightForwarders as $freightForwarder): link(__('View', true), array('action' => 'view', $freightForwarder['FreightForwarder']['id'])); ?> link(__('Edit', true), array('action' => 'edit', $freightForwarder['FreightForwarder']['id'])); ?> - link(__('Delete', true), array('action' => 'delete', $freightForwarder['FreightForwarder']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $freightForwarder['FreightForwarder']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $freightForwarder['FreightForwarder']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $freightForwarder['FreightForwarder']['id'])); ?> diff --git a/views/freight_forwarders/view.ctp b/views/freight_forwarders/view.ctp index ee71194c..4d55137d 100644 --- a/views/freight_forwarders/view.ctp +++ b/views/freight_forwarders/view.ctp @@ -1,11 +1,6 @@

- > - > - -   - > > @@ -16,8 +11,5 @@
  • link(__('Edit FreightForwarder', true), array('action' => 'edit', $freightForwarder['FreightForwarder']['id'])); ?>
  • -
  • link(__('Delete FreightForwarder', true), array('action' => 'delete', $freightForwarder['FreightForwarder']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $freightForwarder['FreightForwarder']['id'])); ?>
  • -
  • link(__('List FreightForwarders', true), array('action' => 'index')); ?>
  • -
  • link(__('New FreightForwarder', true), array('action' => 'add')); ?>
diff --git a/views/jobs/get_editable_row.ctp b/views/jobs/get_editable_row.ctp index f977b0b6..41050985 100644 --- a/views/jobs/get_editable_row.ctp +++ b/views/jobs/get_editable_row.ctp @@ -5,7 +5,8 @@ $(function() { - + /** This could be cleaner. However, this will work with multiple rows being edited */ + getSelectIDs(); $('#_date_order_received_display').datepicker({ showButtonPanel: true, dateFormat: 'd M yy', @@ -32,11 +33,92 @@ }); + $("#_sale_category").change(function() { + getSelectIDs(); + }); + + + + $("#_currency_id").change(function() { + getSelectIDs(); + }); + + + + function getSelectIDs() { + var catID = getSaleCategoryID(); + var currencyID = getCurrencyID(); + whichInputsReadOnly(catID, currencyID); + } + + + + function whichInputsReadOnly(catID, currencyID) { + $(".highlighted").removeClass("highlighted"); + + if(catID < 2) { //Aust Sale. + if(currencyID == 2) { //Aust Sale. AUD + $(".aust_sale_aud").attr("readonly",false); + $(".aust_sale_aud").addClass("highlighted"); + + $(".aust_sale_fc").attr("readonly",true); + $('.export_sale_fc').attr("readonly",true); + $('.export_sale_aud').attr("readonly",true); + } + else { //Aust Sale, Foreign Currency. + $(".aust_sale_fc").attr("readonly",false); + $(".aust_sale_fc").addClass("highlighted"); + + $(".aust_sale_aud").attr("readonly",true); + $('.export_sale_fc').attr("readonly",true); + $('.export_sale_aud').attr("readonly",true); + } + + } + else { //Export Sale + if(currencyID == 2) {//Export Sale. AUD + $('.export_sale_aud').attr("readonly",false); + $(".export_sale_aud").addClass("highlighted"); + + $(".aust_sale_fc").attr("readonly",true); + $(".aust_sale_aud").attr("readonly",true); + $('.export_sale_fc').attr("readonly",true); + + } + else { //Export Sale. Foreign Currency. + $('.export_sale_fc').attr("readonly",false); + $(".export_sale_fc").addClass("highlighted"); + + $(".aust_sale_fc").attr("readonly",true); + $(".aust_sale_aud").attr("readonly",true); + $('.export_sale_aud').attr("readonly",true); + + } + } + + + + } + + function getSaleCategoryID() { + var id; + $("#_sale_category :selected").each(function(i, selected) { + id = this.value; + }); + return id; + } + + function getCurrencyID() { + var id; + $("#_currency_id :selected").each(function(i, selected) { + id = this.value; + }); + return id; + } }); - @@ -69,12 +151,12 @@ else { input('all_sent', array('type'=>'select','options'=>array($yesNo), 'label'=>false, 'selected'=>$job['Job']['all_sent'], 'class'=>'yesNo'));?> input('job_status', array('type'=>'select', 'options'=>$job_status_options, 'value'=>$job['Job']['job_status'], 'label'=>false, 'class'=>''));?> - input('sale_category', array('options'=>$sale_category_options, 'type'=>'select', 'label'=>false, 'value'=>$job['Job']['sale_category'], 'class'=>'sale_category'));?> + input('sale_category', array('id'=>$job['Job']['id'].'_sale_category', 'options'=>$sale_category_options, 'type'=>'select', 'label'=>false, 'value'=>$job['Job']['sale_category'], 'class'=>'sale_category'));?> input('job_type', array('options'=>$job_type_options, 'label' => false, 'selected'=>$job['Job']['job_type']));?> input('shipment_category', array('options'=>$shipment_category_options, - 'type'=>'select','label'=>false,'value'=>$job['Job']['shipment_category']));?> + 'type'=>'select','label'=>false,'value'=>$job['Job']['shipment_category']));?> link($job['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $job['Job']['id']));?> link($job['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view', $job['Enquiry']['id']));?> @@ -117,48 +199,48 @@ else { input('domestic_freight_paid_by', array('type'=>'select','options'=>$freight_paid_by_options, 'value'=>$job['Job']['domestic_freight_paid_by'], 'label'=>false));?> - input('currency_id', array('value'=>$job['Job']['currency_id'], 'type'=>'select', 'options'=>$currencies, 'label'=>false ));?> + input('currency_id', array('id'=>$job['Job']['id']."_currency_id",'value'=>$job['Job']['currency_id'], 'type'=>'select', 'options'=>$currencies, 'label'=>false ));?> - input('company_gross_sales_aud', array('value'=>$job['Job']['company_gross_sales_aud'], 'label'=>false));?> + input('company_gross_sales_aud', array('id'=>$job['Job']['id']."_company_gross_sales_aud", 'value'=>$job['Job']['company_gross_sales_aud'], 'label'=>false,'class'=>'aust_sale_aud'));?> - input('net_sales_aud', array('value'=>$job['Job']['net_sales_aud'], 'label'=>false));?> + input('net_sales_aud', array('id'=>$job['Job']['id']."_net_sales_aud",'value'=>$job['Job']['net_sales_aud'], 'label'=>false,'class'=>'aust_sale_aud'));?> - input('gross_profit_aud', array('value'=>$job['Job']['gross_profit_aud'], 'label'=>false ));?> + input('gross_profit_aud', array('id'=>$job['Job']['id']."_gross_profit_aud",'value'=>$job['Job']['gross_profit_aud'], 'label'=>false,'class'=>'aust_sale_aud' ));?> - input('net_export_sales_aud', array('value'=>$job['Job']['net_export_sales_aud'], 'label'=>false ));?> + input('net_export_sales_aud', array('id'=>$job['Job']['id']."_net_export_sales_aud",'value'=>$job['Job']['net_export_sales_aud'], 'label'=>false,'class'=>'export_sale_aud' ));?> - input('gross_profit_exports_aud', array('value'=>$job['Job']['gross_profit_exports_aud'], 'label'=>false));?> + input('gross_profit_exports_aud', array('id'=>$job['Job']['id']."_gross_profit_exports_aud",'value'=>$job['Job']['gross_profit_exports_aud'], 'label'=>false,'class'=>'export_sale_aud'));?> - input('gp_percent', array('value'=>$job['Job']['gp_percent'], 'label'=>false));?> + input('gp_percent', array('id'=>$job['Job']['id']."_gp_percent",'value'=>$job['Job']['gp_percent'], 'label'=>false));?> - input('ato_exchange_rate', array('value'=>$job['Job']['ato_exchange_rate'], 'label'=>false ));?> + input('ato_exchange_rate', array('id'=>$job['Job']['id']."_ato_exchange_rate",'value'=>$job['Job']['ato_exchange_rate'], 'label'=>false ));?> - input('gross_australian_sales_foreign_currency', array('value'=>$job['Job']['gross_australian_sales_foreign_currency'], 'label'=>false));?> + input('gross_australian_sales_foreign_currency', array('id'=>$job['Job']['id']."_gross_australian_sales_foreign_currency",'value'=>$job['Job']['gross_australian_sales_foreign_currency'], 'label'=>false, 'class'=>'aust_sale_fc'));?> - input('net_australian_sales_foreign_currency', array('value'=>$job['Job']['net_australian_sales_foreign_currency'], 'label'=>false));?> + input('net_australian_sales_foreign_currency', array('id'=>$job['Job']['id']."_net_australian_sales_foreign_currency",'value'=>$job['Job']['net_australian_sales_foreign_currency'], 'label'=>false, 'class'=>'aust_sale_fc'));?> - input('gross_profit_value_australian_sales_foreign_currency', array('value'=>$job['Job']['gross_profit_value_australian_sales_foreign_currency'], 'label'=>false));?> + input('gross_profit_value_australian_sales_foreign_currency', array('id'=>$job['Job']['id']."_gross_profit_value_australian_sales_foreign_currency",'value'=>$job['Job']['gross_profit_value_australian_sales_foreign_currency'], 'label'=>false, 'class'=>'aust_sale_fc'));?> - input('gross_export_sales_foreign_currency', array('value'=>$job['Job']['gross_export_sales_foreign_currency'], 'label'=>false));?> + input('gross_export_sales_foreign_currency', array('id'=>$job['Job']['id']."_gross_export_sales_foreign_currency",'value'=>$job['Job']['gross_export_sales_foreign_currency'], 'label'=>false, 'class'=>'export_sale_fc'));?> - input('net_export_sales_foreign_currency', array('value'=>$job['Job']['net_export_sales_foreign_currency'], 'label'=>false));?> + input('net_export_sales_foreign_currency', array('id'=>$job['Job']['id']."_net_export_sales_foreign_currency",'value'=>$job['Job']['net_export_sales_foreign_currency'], 'label'=>false,'class'=>'export_sale_fc'));?> - input('gross_profit_value_after_discount_exports_foreign_currency', array('value'=>$job['Job']['gross_profit_value_after_discount_exports_foreign_currency'], 'label'=>false));?> + input('gross_profit_value_after_discount_exports_foreign_currency', array('id'=>$job['Job']['id']."_gross_profit_value_after_discount_exports_foreign_currency",'value'=>$job['Job']['gross_profit_value_after_discount_exports_foreign_currency'], 'label'=>false, 'class'=>'export_sale_fc'));?> - input('gross_commissions', array('value'=>$job['Job']['gross_commissions'], 'label'=>false));?> + input('gross_commissions', array('id'=>$job['Job']['id']."_gross_commissions",'value'=>$job['Job']['gross_commissions'], 'label'=>false));?> - input('net_commissions', array('value'=>$job['Job']['net_commissions'], 'label'=>false));?> + input('net_commissions', array('id'=>$job['Job']['id']."_net_commissions",'value'=>$job['Job']['net_commissions'], 'label'=>false));?> diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index c3092d58..d02c0878 100644 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -52,21 +52,21 @@ echo $paginator->counter(array( sort('Date Sent to Customer', '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 Invoiced in AUD');?> - sort('Gross Profit Value Export in AUD');?> - sort('GP% Excl Commissions');?> - 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');?> + sort('Gross Sales AUD');?> + sort('Net Sales AUD');?> + sort('Gross Profit AUD');?> + sort('Net Export Sales Converted to Or Invoiced in AUD');?> + sort('Gross Profit Value Export in AUD');?> + sort('GP% Excl Commissions');?> + 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');?> diff --git a/views/shipments/add_edit.ctp b/views/shipments/add_edit.ctp new file mode 100644 index 00000000..c5f1111e --- /dev/null +++ b/views/shipments/add_edit.ctp @@ -0,0 +1,15 @@ +create('Shipment');?> + + input('box_count'); + echo $form->input('freight_forwarder_id'); + echo $form->input('date_arrived'); + echo $form->input('date_dispatched'); + echo $form->input('airway_bill'); + echo $form->input('comments'); + echo $form->input('Job'); + echo $form->input('Principle'); + echo $form->input('PurchaseOrder'); + ?> +end('Submit');?> \ No newline at end of file diff --git a/views/shipments/index.ctp b/views/shipments/index.ctp index 76fb8d62..94dd19a4 100644 --- a/views/shipments/index.ctp +++ b/views/shipments/index.ctp @@ -104,23 +104,7 @@
-

- - create('Shipment');?> -
- - input('box_count'); - echo $form->input('freight_forwarder_id'); - echo $form->input('date_arrived'); - echo $form->input('date_dispatched'); - echo $form->input('airway_bill'); - echo $form->input('comments'); - echo $form->input('Job'); - echo $form->input('Principle'); - echo $form->input('PurchaseOrder'); - ?> -
+

OH BABY

\ No newline at end of file diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index e34db6ae..777eb2cb 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -392,13 +392,13 @@ th { text-align: center; } th a { - background:#f2f2f2; + display: block; padding: 2px 4px; text-decoration: none; } th a:hover { - background: #ccc; + color: #333; text-decoration: none; } @@ -1283,6 +1283,28 @@ table.jobsTable tr th { } +/** Header Colors for Job table to replaced 'Book1'. */ +th.purple { + background-color: #8D80FC; +} + +th.pink { + background-color: #FFB2ED; +} + +th.lightblue { + background-color: #71DAED; +} + +th.lightgreen { + background-color: #A5FFDC; +} + +th.darkgreen { + background-color: #4DBC6B; +} + + table.jobsTable tr td { border: 1px solid; @@ -1314,6 +1336,11 @@ select.sale_category { } +input.highlighted { + background-color:#77A7FF; + font-size: 80%; +} + select.yesNo { width: 50px; } diff --git a/webroot/js/shipment_index.js b/webroot/js/shipment_index.js index 8a15dfc0..5f2b7cc4 100644 --- a/webroot/js/shipment_index.js +++ b/webroot/js/shipment_index.js @@ -1,7 +1,6 @@ $(function() { - // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore! - $( "#dialog:ui-dialog" ).dialog( "destroy" ); + var name = $( "#name" ), email = $( "#email" ), password = $( "#password" ), @@ -44,7 +43,7 @@ $(function() { width: 350, modal: true, buttons: { - "Create an account": function() { + "New Shipment": function() { var bValid = true; allFields.removeClass( "ui-state-error" );