From 4715c39b0f0eb3593a15295117813859450635ca Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 15 Jul 2013 20:27:28 +1000 Subject: [PATCH] Added delete and undelete functions for enquiries. --- app/config/core.php | 2 +- app/controllers/costings_controller.php | 1 - app/controllers/documents_controller.php | 2 +- app/controllers/enquiries_controller.php | 44 +++++++++++++++-- app/views/costings/add.ctp | 8 +-- app/views/elements/enquiry_table.ctp | 31 ++++-------- app/views/products/view.ctp | 63 ------------------------ app/webroot/js/enquiry_table.js | 14 +++++- 8 files changed, 69 insertions(+), 96 deletions(-) diff --git a/app/config/core.php b/app/config/core.php index 4036635f..15ab51e7 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -56,7 +56,7 @@ if($host == 'cmc.lan' || $host == '192.168.0.7') { Configure::write('smtp_settings', array( 'port' => '25', 'timeout' => '30', - 'host' => '192.168.0.8', + 'host' => '192.168.0.14', 'username' => 'sales', 'password' => '2seng33+02')); diff --git a/app/controllers/costings_controller.php b/app/controllers/costings_controller.php index 531e8932..d3e02b31 100755 --- a/app/controllers/costings_controller.php +++ b/app/controllers/costings_controller.php @@ -39,7 +39,6 @@ class CostingsController extends AppController { $this->set('type', 'line_item'); $this->set('line_item', $line_item); - //die(print_r($line_item)); } diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index e6117c62..ea42b9c9 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -872,7 +872,7 @@ ENDINSTRUCTIONS; return; } - $this->Email->to = $primary_contact['User']['email']; + $this->Email->to = $primary_contact['User']['email']; $this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id'])))); break; case 'orderAck': diff --git a/app/controllers/enquiries_controller.php b/app/controllers/enquiries_controller.php index 270bde7d..30a3c70d 100755 --- a/app/controllers/enquiries_controller.php +++ b/app/controllers/enquiries_controller.php @@ -9,8 +9,7 @@ class EnquiriesController extends AppController { 'contain' => false, 'limit' => 150, - 'order'=>array('Enquiry.id' => 'desc') - + 'order'=>array('Enquiry.id' => 'desc'), ); var $components = array('RequestHandler', 'Email'); @@ -22,7 +21,6 @@ class EnquiriesController extends AppController { function index() { $this->Enquiry->recursive = 0; $this->set('enquiries', $this->paginate()); - $status_list = $this->Enquiry->Status->getJSON(); $this->set('status_list', $status_list); $classNames = $this->Enquiry->Status->getClassNamesJSON(); @@ -530,5 +528,45 @@ class EnquiriesController extends AppController { } + function delete($id = null) { + if($id == null) { + $this->Session->setFlash('Invalid Enquiry ID'); + $this->redirect(array('action'=>'index')); + } + else { + $enquiry = $this->Enquiry->findById($id); + + $enquiry['Enquiry']['archived'] = 1; + + $this->Enquiry->save($enquiry); + + $undo = 'Undo'; + + $this->Session->setFlash('Enquiry '.$enquiry['Enquiry']['title'].' has been deleted. '.$undo); + $this->redirect(array('action'=>'index')); + } + } + + /** Could do it in a single method, but fuck it. */ + function undelete($id = null) { + + if($id == null) { + $this->Session->setFlash('Invalid Enquiry ID'); + $this->redirect(array('action'=>'index')); + } + else { + $enquiry = $this->Enquiry->findById($id); + + $enquiry['Enquiry']['archived'] = 0; + + $this->Enquiry->save($enquiry); + + $undo = 'Undo this'; + + $this->Session->setFlash('Enquiry '.$enquiry['Enquiry']['title'].' has been undeleted. '.$undo); + $this->redirect(array('action'=>'index')); + } + } + } ?> diff --git a/app/views/costings/add.ctp b/app/views/costings/add.ctp index 96e76ec4..5218252e 100755 --- a/app/views/costings/add.ctp +++ b/app/views/costings/add.ctp @@ -5,17 +5,19 @@ input('product_id', array('type'=>'hidden', 'value'=>$product['Product']['id'])); + $title = $product['Product']['title']; } elseif(isset($line_item)) { $form->input('line_item_id', array('type'=>'hidden', 'value'=>$line_item['LineItem']['id'])); + $title = $line_tem['LineItem']['title']; print_r($line_item); + } ?> - - -
+

Add Costing to:

+
Quantity, Unit price, Packing costs options(array('url' => $this->passedArgs)); ?> +

Deleted Enquiries

+
+ + +
counter(array( 'format' => __('Page %page% of %pages%, showing %current% Enquiries out of %count% total, starting on record %start%, ending on %end%', true) @@ -11,7 +16,6 @@ echo $paginator->counter(array( ?>
- prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')); ?> | numbers(); ?> next(__('next', true) . ' >>', array(), null, array('class' => 'disabled')); ?> @@ -69,7 +73,7 @@ echo $paginator->counter(array( $class = ' class="requestforquote"'; } ?> - id="row"> + id="row" data-archived=""> counter(array( - - - Change the date from MySQL DATETIME to a D M Y format - if($enquiry['Enquiry']['submitted']) { - echo date('j M Y',$time->toUnix($enquiry['Enquiry']['submitted'])); - } - else { - /* Maybe should make this so only the assigned user can mark it as submitted. - - echo $html->link('Not Submitted', array('controller'=>'enquiries', 'action'=>'mark_submitted', $enquiry['Enquiry']['id'])); - } - - - */ - ?> - - - counter(array( echo $enquiry['Enquiry']['comments']; } ; - ?> +?> link(__('View', true), array('controller' => 'enquiries', 'action' => 'view', $enquiry['Enquiry']['id'])); ?> link(__('Edit', true), array('controller' => 'enquiries', 'action' => 'edit', $enquiry['Enquiry']['id'])); ?> + + link(__('Delete', true), array('controller' => 'enquiries', 'action' => 'delete', $enquiry['Enquiry']['id'])); ?> diff --git a/app/views/products/view.ctp b/app/views/products/view.ctp index 28a17e74..ecb8fb4d 100755 --- a/app/views/products/view.ctp +++ b/app/views/products/view.ctp @@ -46,73 +46,10 @@
-link('product-model-number-builder'); ?> - - - - -
-

Model Number configuration

-
    - -
  • -
  • -
  • - -
- -
- - -
- - - diff --git a/app/webroot/js/enquiry_table.js b/app/webroot/js/enquiry_table.js index 8a341687..7699bc5e 100755 --- a/app/webroot/js/enquiry_table.js +++ b/app/webroot/js/enquiry_table.js @@ -1,9 +1,7 @@ $(function() { - console.log("WOOT"); var statusNamesJSON = $("#statusJSONlist").html(); - console.log(statusNamesJSON); var statusNames = $.parseJSON(statusNamesJSON); @@ -36,4 +34,16 @@ $(function() { } }); + + //Hide archived Enquiries + $('*[data-archived="1"]').hide(); + + $("#show").click(function() { + $('*[data-archived="1"]').show(); + }); + + $("#hide").click(function() { + $('*[data-archived="1"]').hide(); //No DRY anywhere! + }); + });