From 8c822a23e6d4c7c3f6e3801ee57a0a859f505645 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Thu, 13 May 2010 17:10:10 +1000 Subject: [PATCH] Changed firstpass to delete individual emails --- controllers/jobs_controller.php | 28 +++++++++++++-- models/job.php | 27 ++------------ vendors/shells/firstpass.php | 14 ++++---- vendors/shells/vault.php | 4 ++- views/enquiries/do_search.ctp | 34 ++++++++++++++---- views/jobs/add.ctp | 62 ++++++++++++++++++++++++++------- views/jobs/edit.ctp | 5 ++- views/jobs/index.ctp | 16 ++------- views/jobs/view.ctp | 21 +++-------- webroot/css/quotenik.css | 4 ++- 10 files changed, 128 insertions(+), 87 deletions(-) diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index d792bde6..667477cb 100644 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -17,11 +17,20 @@ class JobsController extends AppController { } function add() { + + + if (!empty($this->data)) { $this->Job->create(); if ($this->Job->save($this->data)) { - $this->flash(__('Job saved.', true), array('action'=>'index')); + $jobid = $this->Job->id; + + $this->Session->setFlash(__('Job Saved', true)); + $this->redirect(array('action'=>'view', $jobid)); } else { + $this->Session->setFlash(__('Please Fix the Errors Below', true)); + $enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']); + $this->set(compact('enquiry')); } } else { @@ -37,7 +46,22 @@ class JobsController extends AppController { } } - } + $freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer"); + $this->set('freight_paid_options', $freight_paid_options); + + $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); + + } function edit($id = null) { if (!$id && empty($this->data)) { diff --git a/models/job.php b/models/job.php index adf0c7d1..cf4e349c 100644 --- a/models/job.php +++ b/models/job.php @@ -4,10 +4,9 @@ class Job extends AppModel { var $name = 'Job'; var $validate = array( 'title' => array('notempty'), - 'state_id' => array('numeric'), - 'customer_id' => array('numeric'), + 'enquiry_id' => array('numeric'), - 'contact_id' => array('numeric'), + 'date_order_received' => array('date'), 'customer_order_number' => array('notempty'), 'domestic_freight_paid_by' => array('notempty'), @@ -17,20 +16,7 @@ class Job extends AppModel { //The Associations below have been created with all possible keys, those that are not needed can be removed var $belongsTo = array( - 'State' => array( - 'className' => 'State', - 'foreignKey' => 'state_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ), - 'Customer' => array( - 'className' => 'Customer', - 'foreignKey' => 'customer_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' - ), + 'Enquiry' => array( 'className' => 'Enquiry', 'foreignKey' => 'enquiry_id', @@ -38,13 +24,6 @@ class Job extends AppModel { 'fields' => '', 'order' => '', 'counterCache' => true - ), - 'Contact' => array( - 'className' => 'Contact', - 'foreignKey' => 'contact_id', - 'conditions' => '', - 'fields' => '', - 'order' => '' ) ); diff --git a/vendors/shells/firstpass.php b/vendors/shells/firstpass.php index 0829e0ae..8599db01 100644 --- a/vendors/shells/firstpass.php +++ b/vendors/shells/firstpass.php @@ -66,14 +66,14 @@ class FirstpassShell extends Shell { $message = $this->getMessage($mbox, $i, $this_header); //echo "Checking msg number: $i\tSubject: ".$message['subject']."\n"; - echo "Checking msg number: $i\n"; + //echo "Checking msg number: $i\n"; $enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList); if($enqID == false) { echo "Deleting msg number: $i\tSubject: ".$message['subject']."\n"; - //imap_delete($mbox, $i); - $discardArray[] = $i; + imap_delete($mbox, $i); + //$discardArray[] = $i; } @@ -84,7 +84,7 @@ class FirstpassShell extends Shell { reset($discardArray); - +/* $numberToDiscard= count($discardArray); @@ -107,19 +107,19 @@ class FirstpassShell extends Shell { } } - + */ imap_expunge($mbox); - echo "Messages before delete: ".$number_of_messages."\n"; + /* echo "Messages before delete: ".$number_of_messages."\n"; $check = imap_check($mbox); echo "Messages after delete: ".$check->Nmsgs."\n"; - +*/ diff --git a/vendors/shells/vault.php b/vendors/shells/vault.php index c7affd63..be38547f 100755 --- a/vendors/shells/vault.php +++ b/vendors/shells/vault.php @@ -158,7 +158,7 @@ class VaultShell extends Shell { } } } - echo "Email stored in the DB under enquiry ID".$enqID." Will be moved to the stored folder\n"; + echo "Email stored in the DB under enquiry ID".$enqID." Message will now be deleted\n"; //$storedArray[] = $i; @@ -181,6 +181,8 @@ class VaultShell extends Shell { } + + } diff --git a/views/enquiries/do_search.ctp b/views/enquiries/do_search.ctp index 02dd941e..0d18892a 100644 --- a/views/enquiries/do_search.ctp +++ b/views/enquiries/do_search.ctp @@ -89,12 +89,24 @@ Name - - + + + + "; + } + else { + echo ''; + } + ?> link(__('View', true), array('controller'=>'customers', 'action'=>'view', $custRes['Customer']['id'])); ?> - + @@ -112,14 +124,24 @@ Customer - - + + "; + } + else { + echo ''; + } + ?> link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?> link(__('View', true), array('controller'=>'contacts', 'action'=>'view', $contact['Contact']['id'])); ?> - + diff --git a/views/jobs/add.ctp b/views/jobs/add.ctp index c75cb46b..bdd064ac 100644 --- a/views/jobs/add.ctp +++ b/views/jobs/add.ctp @@ -1,22 +1,50 @@
+link('addjob'); ?> + create('Job');?>
input('title'); - echo $form->input('state_id'); - echo $form->input('customer_id'); - echo $form->input('enquiry_id'); - echo $form->input('contact_id'); */ - echo $form->input('comments'); - echo $form->input('date_order_received'); - echo $form->input('date_order_placed_on_principle'); - echo $form->input('date_scheduled_ex_works'); - echo $form->input('date_order_sent_to_customer'); + //echo $form->input('title'); + echo $form->input('enquiry_id', array('type'=>'hidden', 'value'=>$enquiry['Enquiry']['id'])); + + ?> +
+ + +
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ input('date_order_received', array('type'=>'hidden')); + echo $form->input('date_order_placed_on_principle', array('type'=>'hidden')); + echo $form->input('date_scheduled_ex_works', array('type'=>'hidden')); + echo $form->input('date_order_sent_to_customer', array('type'=>'hidden')); echo $form->input('customer_order_number'); - echo $form->input('domestic_freight_paid_by'); - echo $form->input('sale_category'); - echo $form->input('shipment_category'); + echo $form->input('domestic_freight_paid_by', array('type'=>'select', 'options'=>$freight_paid_options)); + echo $form->input('sale_category', array('type'=>'select', 'options'=>$sale_category_options)); + echo $form->input('shipment_category', array('type'=>'select', 'options'=>$shipment_category_options)); + + echo $form->input('comments'); ?>
end('Submit');?> @@ -24,5 +52,13 @@
  • link(__('List Jobs', true), array('action' => 'index'));?>
  • +
  • link(__('List States', true), array('controller' => 'states', 'action' => 'index')); ?>
  • +
  • link(__('New State', true), array('controller' => 'states', 'action' => 'add')); ?>
  • +
  • link(__('List Customers', true), array('controller' => 'customers', 'action' => 'index')); ?>
  • +
  • link(__('New Customer', true), array('controller' => 'customers', 'action' => 'add')); ?>
  • +
  • link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?>
  • +
  • link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?>
  • +
  • link(__('List Contacts', true), array('controller' => 'contacts', 'action' => 'index')); ?>
  • +
  • link(__('New Contact', true), array('controller' => 'contacts', 'action' => 'add')); ?>
diff --git a/views/jobs/edit.ctp b/views/jobs/edit.ctp index f7a5422d..40c4cb39 100644 --- a/views/jobs/edit.ctp +++ b/views/jobs/edit.ctp @@ -5,10 +5,7 @@ input('id'); echo $form->input('title'); - echo $form->input('state_id'); - echo $form->input('customer_id'); echo $form->input('enquiry_id'); - echo $form->input('contact_id'); echo $form->input('comments'); echo $form->input('date_order_received'); echo $form->input('date_order_placed_on_principle'); @@ -26,5 +23,7 @@
diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index 93d6fbbe..144bc0aa 100644 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -11,10 +11,7 @@ echo $paginator->counter(array( sort('id');?> sort('created');?> sort('title');?> - sort('state_id');?> - sort('customer_id');?> sort('enquiry_id');?> - sort('contact_id');?> sort('comments');?> sort('date_order_received');?> sort('date_order_placed_on_principle');?> @@ -45,16 +42,7 @@ foreach ($jobs as $job): - - - - - - - - - - + link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?> @@ -100,5 +88,7 @@ foreach ($jobs as $job):
diff --git a/views/jobs/view.ctp b/views/jobs/view.ctp index 785ea9f8..2b587b27 100644 --- a/views/jobs/view.ctp +++ b/views/jobs/view.ctp @@ -16,24 +16,9 @@   - > + > > - -   - - > - > - -   - - > - > - -   - - > - > - + link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>   > @@ -89,5 +74,7 @@
  • link(__('Delete Job', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['id'])); ?>
  • link(__('List Jobs', true), array('action' => 'index')); ?>
  • link(__('New Job', true), array('action' => 'add')); ?>
  • +
  • link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?>
  • +
  • link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?>
  • diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index a2b822f0..1611d10f 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -403,7 +403,9 @@ table tr td { padding: 1px; } table tr.altrow td { - background: #f4f4f4; + /* background: #f4f4f4; + background-color: #98cbfe;*/ + background: #d1f0ff; } table tr.customer-suspect td {