Changed firstpass to delete individual emails

This commit is contained in:
Karl Cordes 2010-05-13 17:10:10 +10:00
parent da2cc3c6f2
commit 8c822a23e6
10 changed files with 128 additions and 87 deletions

View file

@ -17,11 +17,20 @@ class JobsController extends AppController {
} }
function add() { function add() {
if (!empty($this->data)) { if (!empty($this->data)) {
$this->Job->create(); $this->Job->create();
if ($this->Job->save($this->data)) { 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 { } 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 { 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) { function edit($id = null) {
if (!$id && empty($this->data)) { if (!$id && empty($this->data)) {

View file

@ -4,10 +4,9 @@ class Job extends AppModel {
var $name = 'Job'; var $name = 'Job';
var $validate = array( var $validate = array(
'title' => array('notempty'), 'title' => array('notempty'),
'state_id' => array('numeric'),
'customer_id' => array('numeric'),
'enquiry_id' => array('numeric'), 'enquiry_id' => array('numeric'),
'contact_id' => array('numeric'),
'date_order_received' => array('date'), 'date_order_received' => array('date'),
'customer_order_number' => array('notempty'), 'customer_order_number' => array('notempty'),
'domestic_freight_paid_by' => 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 //The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array( 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( 'Enquiry' => array(
'className' => 'Enquiry', 'className' => 'Enquiry',
'foreignKey' => 'enquiry_id', 'foreignKey' => 'enquiry_id',
@ -38,13 +24,6 @@ class Job extends AppModel {
'fields' => '', 'fields' => '',
'order' => '', 'order' => '',
'counterCache' => true 'counterCache' => true
),
'Contact' => array(
'className' => 'Contact',
'foreignKey' => 'contact_id',
'conditions' => '',
'fields' => '',
'order' => ''
) )
); );

View file

@ -66,14 +66,14 @@ class FirstpassShell extends Shell {
$message = $this->getMessage($mbox, $i, $this_header); $message = $this->getMessage($mbox, $i, $this_header);
//echo "Checking msg number: $i\tSubject: ".$message['subject']."\n"; //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); $enqID = $this->checkIfValidEnquiry($message['subject'], $enquiryList);
if($enqID == false) { if($enqID == false) {
echo "Deleting msg number: $i\tSubject: ".$message['subject']."\n"; echo "Deleting msg number: $i\tSubject: ".$message['subject']."\n";
//imap_delete($mbox, $i); imap_delete($mbox, $i);
$discardArray[] = $i; //$discardArray[] = $i;
} }
@ -84,7 +84,7 @@ class FirstpassShell extends Shell {
reset($discardArray); reset($discardArray);
/*
$numberToDiscard= count($discardArray); $numberToDiscard= count($discardArray);
@ -107,19 +107,19 @@ class FirstpassShell extends Shell {
} }
} }
*/
imap_expunge($mbox); imap_expunge($mbox);
echo "Messages before delete: ".$number_of_messages."\n"; /* echo "Messages before delete: ".$number_of_messages."\n";
$check = imap_check($mbox); $check = imap_check($mbox);
echo "Messages after delete: ".$check->Nmsgs."\n"; echo "Messages after delete: ".$check->Nmsgs."\n";
*/

View file

@ -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; //$storedArray[] = $i;
@ -181,6 +181,8 @@ class VaultShell extends Shell {
} }
} }

View file

@ -89,12 +89,24 @@
<th>Name</th> <th>Name</th>
<th class="actions"></th> <th class="actions"></th>
</tr> </tr>
<?php foreach($customerResults as $custRes): ?>
<tr>
<?php
$i =0;
foreach($customerResults as $custRes): ?>
<?php if($i % 2 == 0) {
echo "<tr>";
}
else {
echo '<tr class="altrow">';
}
?>
<td><?php echo $custRes['Customer']['name'];?></td> <td><?php echo $custRes['Customer']['name'];?></td>
<td><?php echo $html->link(__('View', true), array('controller'=>'customers', 'action'=>'view', $custRes['Customer']['id'])); ?></td> <td><?php echo $html->link(__('View', true), array('controller'=>'customers', 'action'=>'view', $custRes['Customer']['id'])); ?></td>
</tr> </tr>
<?php endforeach;?> <?php
$i++;
endforeach;?>
</table> </table>
<?php endif;?> <?php endif;?>
@ -112,14 +124,24 @@
<th>Customer</th> <th>Customer</th>
<th class="actions"></th> <th class="actions"></th>
</tr> </tr>
<?php foreach($contactResults as $contact): ?> <?php
<tr> $i = 0;
foreach($contactResults as $contact): ?>
<?php if($i % 2 == 0) {
echo "<tr>";
}
else {
echo '<tr class="altrow">';
}
?>
<td><?php echo $contact['Contact']['first_name'];?></td> <td><?php echo $contact['Contact']['first_name'];?></td>
<td><?php echo $contact['Contact']['last_name'];?></td> <td><?php echo $contact['Contact']['last_name'];?></td>
<td><?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?></td> <td><?php echo $html->link($contact['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $contact['Customer']['id'])); ?></td>
<td><?php echo $html->link(__('View', true), array('controller'=>'contacts', 'action'=>'view', $contact['Contact']['id'])); ?></td> <td><?php echo $html->link(__('View', true), array('controller'=>'contacts', 'action'=>'view', $contact['Contact']['id'])); ?></td>
</tr> </tr>
<?php endforeach;?> <?php
$i++;
endforeach;?>
</table> </table>
<?php endif;?> <?php endif;?>

View file

@ -1,22 +1,50 @@
<div class="jobs form"> <div class="jobs form">
<?php echo $javascript->link('addjob'); ?>
<?php echo $form->create('Job');?> <?php echo $form->create('Job');?>
<fieldset> <fieldset>
<legend><?php __('Add Job');?></legend> <legend><?php __('Add Job');?></legend>
<?php <?php
/*echo $form->input('title'); //echo $form->input('title');
echo $form->input('state_id'); echo $form->input('enquiry_id', array('type'=>'hidden', 'value'=>$enquiry['Enquiry']['id']));
echo $form->input('customer_id');
echo $form->input('enquiry_id'); ?>
echo $form->input('contact_id'); */ <div class="input text">
echo $form->input('comments'); <label for="JobDateOrderReceivedDisplay">Date Order Received by CMC</label>
echo $form->input('date_order_received'); <input id="JobDateOrderReceivedDisplay" type="text" value="" class="datePicker">
echo $form->input('date_order_placed_on_principle'); </div>
echo $form->input('date_scheduled_ex_works');
echo $form->input('date_order_sent_to_customer');
<div class="input text" id="OrderPlacedOnPrincipleDiv">
<label for="JobDateOrderPlacedOnPrincipleDisplay">Date Order Placed on Principle</label>
<input id="JobDateOrderPlacedOnPrincipleDisplay" type="text" value="" class="datePicker">
</div>
<div class="input text">
<label for="JobDateScheduledExWorksDisplay">Date Scheduled Ex Works</label>
<input id="JobDateScheduledExWorksDisplay" type="text" value="" class="datePicker">
</div>
<div class="input text">
<label for="JobDateOrderSentToCustomerDisplay">Date Order Sent to Customer</label>
<input id="JobDateOrderSentToCustomerDisplay" type="text" value="" class="datePicker">
</div>
<?
echo $form->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('customer_order_number');
echo $form->input('domestic_freight_paid_by'); echo $form->input('domestic_freight_paid_by', array('type'=>'select', 'options'=>$freight_paid_options));
echo $form->input('sale_category'); echo $form->input('sale_category', array('type'=>'select', 'options'=>$sale_category_options));
echo $form->input('shipment_category'); echo $form->input('shipment_category', array('type'=>'select', 'options'=>$shipment_category_options));
echo $form->input('comments');
?> ?>
</fieldset> </fieldset>
<?php echo $form->end('Submit');?> <?php echo $form->end('Submit');?>
@ -24,5 +52,13 @@
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $html->link(__('List Jobs', true), array('action' => 'index'));?></li> <li><?php echo $html->link(__('List Jobs', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List States', true), array('controller' => 'states', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New State', true), array('controller' => 'states', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Customers', true), array('controller' => 'customers', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Customer', true), array('controller' => 'customers', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Contacts', true), array('controller' => 'contacts', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Contact', true), array('controller' => 'contacts', 'action' => 'add')); ?> </li>
</ul> </ul>
</div> </div>

View file

@ -5,10 +5,7 @@
<?php <?php
echo $form->input('id'); echo $form->input('id');
echo $form->input('title'); echo $form->input('title');
echo $form->input('state_id');
echo $form->input('customer_id');
echo $form->input('enquiry_id'); echo $form->input('enquiry_id');
echo $form->input('contact_id');
echo $form->input('comments'); echo $form->input('comments');
echo $form->input('date_order_received'); echo $form->input('date_order_received');
echo $form->input('date_order_placed_on_principle'); echo $form->input('date_order_placed_on_principle');
@ -26,5 +23,7 @@
<ul> <ul>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Job.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Job.id'))); ?></li> <li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Job.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Job.id'))); ?></li>
<li><?php echo $html->link(__('List Jobs', true), array('action' => 'index'));?></li> <li><?php echo $html->link(__('List Jobs', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
</ul> </ul>
</div> </div>

View file

@ -11,10 +11,7 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('id');?></th> <th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('created');?></th> <th><?php echo $paginator->sort('created');?></th>
<th><?php echo $paginator->sort('title');?></th> <th><?php echo $paginator->sort('title');?></th>
<th><?php echo $paginator->sort('state_id');?></th>
<th><?php echo $paginator->sort('customer_id');?></th>
<th><?php echo $paginator->sort('enquiry_id');?></th> <th><?php echo $paginator->sort('enquiry_id');?></th>
<th><?php echo $paginator->sort('contact_id');?></th>
<th><?php echo $paginator->sort('comments');?></th> <th><?php echo $paginator->sort('comments');?></th>
<th><?php echo $paginator->sort('date_order_received');?></th> <th><?php echo $paginator->sort('date_order_received');?></th>
<th><?php echo $paginator->sort('date_order_placed_on_principle');?></th> <th><?php echo $paginator->sort('date_order_placed_on_principle');?></th>
@ -45,16 +42,7 @@ foreach ($jobs as $job):
<?php echo $job['Job']['title']; ?> <?php echo $job['Job']['title']; ?>
</td> </td>
<td> <td>
<?php echo $job['Job']['state_id']; ?> <?php echo $html->link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>
</td>
<td>
<?php echo $job['Job']['customer_id']; ?>
</td>
<td>
<?php echo $job['Job']['enquiry_id']; ?>
</td>
<td>
<?php echo $job['Job']['contact_id']; ?>
</td> </td>
<td> <td>
<?php echo $job['Job']['comments']; ?> <?php echo $job['Job']['comments']; ?>
@ -100,5 +88,7 @@ foreach ($jobs as $job):
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $html->link(__('New Job', true), array('action' => 'add')); ?></li> <li><?php echo $html->link(__('New Job', true), array('action' => 'add')); ?></li>
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
</ul> </ul>
</div> </div>

View file

@ -16,24 +16,9 @@
<?php echo $job['Job']['title']; ?> <?php echo $job['Job']['title']; ?>
&nbsp; &nbsp;
</dd> </dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('State Id'); ?></dt> <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>> <dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $job['Job']['state_id']; ?> <?php echo $html->link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Customer Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $job['Job']['customer_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $job['Job']['enquiry_id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Contact Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $job['Job']['contact_id']; ?>
&nbsp; &nbsp;
</dd> </dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Comments'); ?></dt> <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Comments'); ?></dt>
@ -89,5 +74,7 @@
<li><?php echo $html->link(__('Delete Job', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['id'])); ?> </li> <li><?php echo $html->link(__('Delete Job', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['id'])); ?> </li>
<li><?php echo $html->link(__('List Jobs', true), array('action' => 'index')); ?> </li> <li><?php echo $html->link(__('List Jobs', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Job', true), array('action' => 'add')); ?> </li> <li><?php echo $html->link(__('New Job', true), array('action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Enquiries', true), array('controller' => 'enquiries', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Enquiry', true), array('controller' => 'enquiries', 'action' => 'add')); ?> </li>
</ul> </ul>
</div> </div>

View file

@ -403,7 +403,9 @@ table tr td {
padding: 1px; padding: 1px;
} }
table tr.altrow td { table tr.altrow td {
background: #f4f4f4; /* background: #f4f4f4;
background-color: #98cbfe;*/
background: #d1f0ff;
} }
table tr.customer-suspect td { table tr.customer-suspect td {