From 20020655c07822b91d89fb681ca07cb81b61382a Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Fri, 17 Jun 2011 10:54:09 +1000 Subject: [PATCH] Jobs deleting implented --- controllers/jobs_controller.php | 38 +++++++++++++++++++++++++++++++ views/jobs/get_viewable_row.ctp | 36 ++++++++++++++++++++++------- views/jobs/index.ctp | 28 ++++++++++++++++++----- views/jobs/mark_deleted.ctp | 0 views/jobs/mark_undeleted.ctp | 0 webroot/css/quotenik.css | 4 ++++ webroot/js/job_index.js | 40 +++++++++++++++++++++++++++++++++ 7 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 views/jobs/mark_deleted.ctp create mode 100644 views/jobs/mark_undeleted.ctp diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index 73bce3b1..c0171db7 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -615,6 +615,44 @@ class JobsController extends AppController { } + function markDeleted($id) { + $this->layout = 'ajax'; + + if(!$id) { + echo "FAILURE"; + } + else { + $this->Job->read(null, $id); + $this->Job->set('deleted', true); + if($this->Job->save()) { + echo "SUCCESS"; + } + else { + echo "FAILURE"; + } + } + } + + + function markUndeleted($id) { + $this->layout = 'ajax'; + + if(!$id) { + echo "FAILURE"; + } + else { + $this->Job->read(null, $id); + $this->Job->set('deleted', false); + if($this->Job->save()) { + echo "SUCCESS"; + } + else { + echo "FAILURE"; + } + } + } + + /** * Need to fix the customer_id which hasn't been set for these 500odd records. * diff --git a/views/jobs/get_viewable_row.ctp b/views/jobs/get_viewable_row.ctp index 96db8210..edb992e5 100644 --- a/views/jobs/get_viewable_row.ctp +++ b/views/jobs/get_viewable_row.ctp @@ -1,5 +1,22 @@ - - + +Undelete'; +} +else { +$rowClass = ''; +$button = ''; +} + +?> + + + + + + element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?> @@ -23,15 +40,15 @@ link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id'])); + $poString .= ' '.$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id'])); } echo $poString; ?> element('isEmptyDate', array('date'=>$po['issue_date'])); - echo "
"; + echo $this->element('isEmptyDate', array('date'=>$po['issue_date'])); + echo "
"; } ?> @@ -42,8 +59,8 @@ "; + echo $po['principle_reference']; + echo "
"; } ?> @@ -100,5 +117,8 @@ - + + + + \ No newline at end of file diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index 7dcd1a9b..492a5817 100644 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -12,6 +12,8 @@ echo $javascript->link('job_index');
  • link('Show only Unpaid', array('action'=>'index/1'));?>
  • link('Show only Unsent', array('action'=>'index/0/1'));?>
  • link('Show only Unpaid & Unsent', array('action'=>'index/1/1'));?>
  • +
  • +
  • @@ -75,13 +77,26 @@ echo $paginator->counter(array( create('Job', array('action'=>'ajax_edit', 'class'=>'job_table_form', 'default'=>false)); ?> - + Undelete'; + } + else { + $rowClass = ''; + $button = ''; + } + ?> - - + - element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?> + + + + + element('isEmptyDate', array('date'=>$job['Job']['date_order_received']));?> + element('booleanTick', array('bool'=>$job['Job']['all_paid'])); ?> @@ -176,7 +191,10 @@ echo $paginator->counter(array( - + + + + diff --git a/views/jobs/mark_deleted.ctp b/views/jobs/mark_deleted.ctp new file mode 100644 index 00000000..e69de29b diff --git a/views/jobs/mark_undeleted.ctp b/views/jobs/mark_undeleted.ctp new file mode 100644 index 00000000..e69de29b diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index ce0652c9..4c4d46fb 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1420,6 +1420,10 @@ tr.cancelled td { text-decoration: line-through; } +tr.deleted td { + text-decoration: line-through; +} + #reports h3 { padding-top:0.5em; } diff --git a/webroot/js/job_index.js b/webroot/js/job_index.js index 81ba8b47..fac68bef 100644 --- a/webroot/js/job_index.js +++ b/webroot/js/job_index.js @@ -4,6 +4,8 @@ $(function() { // $(".editButton").show(); + $(".deleted").hide(); + $("#hideDeleted").hide(); $(".editButton").live('click',function() { @@ -24,6 +26,19 @@ $(function() { }); + $("#showDeleted").click(function() { + $(".deleted").show(); + $(this).hide(); + $("#hideDeleted").show(); + }); + + + $("#hideDeleted").click(function() { + $(".deleted").hide(); + $(this).hide(); + $("#showDeleted").show(); + }); + $(".saveButton").live('click',function() { var id = $(this).parents('tr').attr('id'); var thisJobInputs = $('#'+id).find('input,select'); @@ -57,6 +72,18 @@ $(function() { }); + + $(".deleteButton").live('click', function() { + var id = $(this).parents('tr').attr('id'); + markDeleted(id); + + }); + + $(".undeleteButton").live('click', function() { + var id = $(this).parents('tr').attr('id'); + markUndeleted(id); + }) + //console.profileEnd(); }); @@ -91,6 +118,19 @@ function cancelEditable(id) { } +function markDeleted(id) { + $.get('/jobs/markDeleted/'+id,false, function(data) { + getViewable(id); + }); +} + +function markUndeleted(id) { + $.get('/jobs/markUndeleted/'+id,false, function(data) { + getViewable(id); + }); +} + + function getParent() { }