From a0efe150e579afe3d9d78b3d748aec0afe3b0ac4 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Thu, 31 Mar 2011 16:15:52 +1100 Subject: [PATCH] Jobs list row color being updated based on Job Status --- views/jobs/build_jobs_json.ctp | 2 + webroot/css/quotenik.css | 4 +- webroot/css/ui.jqgrid.css | 42 +++++++++++++++-- webroot/js/job_grid.js | 85 ++++++++++++++++++++++++++++++---- 4 files changed, 120 insertions(+), 13 deletions(-) diff --git a/views/jobs/build_jobs_json.ctp b/views/jobs/build_jobs_json.ctp index aabb8214..40f53fe0 100644 --- a/views/jobs/build_jobs_json.ctp +++ b/views/jobs/build_jobs_json.ctp @@ -28,6 +28,8 @@ foreach($jobs as $job) { $cellArray = array( // $job['Job']['id'], + + $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'])), diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index fed01706..c4504705 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -377,7 +377,7 @@ div.quoteproducts { /* Tables */ table { - background: #fff; + background: #fff; border:1px solid #ccc; border-right:0; clear: both; @@ -404,7 +404,7 @@ th a:hover { text-decoration: none; } table tr td { - background: #fff; + /* background: #fff; */ border-right: 1px solid #ccc; text-align: center; vertical-align: top; diff --git a/webroot/css/ui.jqgrid.css b/webroot/css/ui.jqgrid.css index 36d88c1e..bbe82714 100755 --- a/webroot/css/ui.jqgrid.css +++ b/webroot/css/ui.jqgrid.css @@ -139,6 +139,42 @@ tr.ui-search-toolbar select {margin: 1px 0px 0px 0px} .ui-searchFilter .divider hr {margin: 1px; } - .ui-jqgrid tr.jqgrow td { - white-space: normal !important; - } \ No newline at end of file +.ui-jqgrid tr.jqgrow td { /* Word wrapping */ + white-space: normal !important; +} + + +/* Job Status Colours */ + + +tr { + border: 1px solid #A6C9E2; +} + +tr.white { + background-color: #FFFFFF; + +} + +tr.yellow { + background-color: #F3FF35; + +} + +tr.light-blue { + background-color: #5CA4FF; +; +} + +tr.magenta { + background-color: #FF2AF8; + +} + +tr.red { + background-color: #FF303E; +} + +tr.brown { + background-color: #9E3F32; +} diff --git a/webroot/js/job_grid.js b/webroot/js/job_grid.js index 9447973d..b0582615 100644 --- a/webroot/js/job_grid.js +++ b/webroot/js/job_grid.js @@ -13,9 +13,6 @@ jQuery(document).ready(function(){ var currenciesList = []; - /* $.getJSON('/currencies/jsonlist', function(data) { - currencies = data; - });*/ $.ajax({ url: '/currencies/jsonlist', @@ -26,7 +23,7 @@ jQuery(document).ready(function(){ } }); - console.log(currencies); + // console.log(currencies); $.each(currencies, function(key, obj) { currenciesList[key] = obj.name; @@ -39,7 +36,7 @@ jQuery(document).ready(function(){ mtype: 'GET', colNames:[ //'id', - 'Sale Cat.','Shipment Cat.','Job Number','Customer','Description','Customer O/N','Order Received','Supplier Ref', + 'Status', 'Sale Cat.','Shipment Cat.','Job Number','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', @@ -61,6 +58,24 @@ jQuery(document).ready(function(){ colModel:[ + { + name:'job_status', + index:'job_status', + width:130, + editable:true, + edittype:"select", + editoptions:{ + + + value: "ORDER RECEIVED FROM CUSTOMER:ORDER RECEIVED FROM CUSTOMER; ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY:ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY;"+ + "GOODS SHIPPED TO CUSTOMER - CMC WAITING ON PAYMENT:GOODS SHIPPED TO CUSTOMER - CMC WAITING ON PAYMENT; WAITING ON PAYMENT AND ANOTHER DELIVERY:WAITING ON PAYMENT AND ANOTHER DELIVERY;"+ + "GOODS DELIVERED TO CUSTOMER & PAID IN FULL:GOODS DELIVERED TO CUSTOMER & PAID IN FULL; PAID IN FULL WAITING ON DELIVERY:PAID IN FULL WAITING ON DELIVERY; JOB CANCELLED:JOB CANCELLED;"+ + "JOB ON HOLD:JOB ON HOLD; CUSTOMER TO PAY 100% WITH ORDER:CUSTOMER TO PAY 100% WITH ORDER" + + } + }, + + { name:'sale_category', index:'sale_category', @@ -321,7 +336,7 @@ jQuery(document).ready(function(){ ], // viewrecords: true, - + gridview: true, rowNum: 500, height: '700px', caption:"Jobs", @@ -333,13 +348,16 @@ jQuery(document).ready(function(){ if(typeof(lastsel) != undefined) { if(rowid && rowid!==lastsel){ - $(this).jqGrid('saveRow',lastsel); + $(this).jqGrid('saveRow',lastsel, false, false,false, setJobStatus); $(this).jqGrid('editRow', rowid, true, pickdates); } - } lastsel = rowid; + }, + + gridComplete: function() { + setJobStatus(); } }); @@ -353,8 +371,59 @@ jQuery(document).ready(function(){ }); + function setJobStatus() { + var jobStatusList = $("#grid").jqGrid('getCol', 'job_status', true); + + $.each(jobStatusList, function() { + if(this.value) { //The Job Status has been set. + addJobStatus(this.id, this.value); + console.log(this.id +":"+ this.value); + } + }); + return true; + } + function addJobStatus(id, status) { + var color; //American spelling for Var Names. + + switch(status) { + case "ORDER RECEIVED FROM CUSTOMER": + color = "white"; + break; + + case "ORDER PLACED ON PRINCIPLE - WAITING ON DELIVERY": + color = "white"; + break; + case "GOODS SHIPPED TO CUSTOMER - CMC WAITING ON PAYMENT": + color = "yellow"; + break; + case "WAITING ON PAYMENT AND ANOTHER DELIVERY": + color = "yellow"; + break; + case "GOODS DELIVERED TO CUSTOMER & PAID IN FULL": + color = "light-blue"; + break; + case "PAID IN FULL WAITING ON DELIVERY": + color = "magenta"; + break; + case "JOB CANCELLED": + color = "red"; + break; + case "JOB ON HOLD": + color = "red"; + break; + case "CUSTOMER TO PAY 100% WITH ORDER": + color = "brown"; + break; + default: + color = "white"; + break; + } + $("#"+id).removeClass('ui-widget-content').addClass(color); + console.log(id+":"+color); + + } function pickdates(id){ jQuery("#"+id+"_date_order_received","#grid").datepicker({