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() {
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,6 +46,21 @@ 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) {

View file

@ -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' => ''
)
);

View file

@ -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";
*/

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;
@ -181,6 +181,8 @@ class VaultShell extends Shell {
}
}

View file

@ -89,12 +89,24 @@
<th>Name</th>
<th class="actions"></th>
</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 $html->link(__('View', true), array('controller'=>'customers', 'action'=>'view', $custRes['Customer']['id'])); ?></td>
</tr>
<?php endforeach;?>
<?php
$i++;
endforeach;?>
</table>
<?php endif;?>
@ -112,14 +124,24 @@
<th>Customer</th>
<th class="actions"></th>
</tr>
<?php foreach($contactResults as $contact): ?>
<tr>
<?php
$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']['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(__('View', true), array('controller'=>'contacts', 'action'=>'view', $contact['Contact']['id'])); ?></td>
</tr>
<?php endforeach;?>
<?php
$i++;
endforeach;?>
</table>
<?php endif;?>

View file

@ -1,22 +1,50 @@
<div class="jobs form">
<?php echo $javascript->link('addjob'); ?>
<?php echo $form->create('Job');?>
<fieldset>
<legend><?php __('Add Job');?></legend>
<?php
/*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');
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']));
?>
<div class="input text">
<label for="JobDateOrderReceivedDisplay">Date Order Received by CMC</label>
<input id="JobDateOrderReceivedDisplay" type="text" value="" class="datePicker">
</div>
<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('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');
?>
</fieldset>
<?php echo $form->end('Submit');?>
@ -24,5 +52,13 @@
<div class="actions">
<ul>
<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>
</div>

View file

@ -5,10 +5,7 @@
<?php
echo $form->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 @@
<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(__('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>
</div>

View file

@ -11,10 +11,7 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('created');?></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('contact_id');?></th>
<th><?php echo $paginator->sort('comments');?></th>
<th><?php echo $paginator->sort('date_order_received');?></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']; ?>
</td>
<td>
<?php echo $job['Job']['state_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']; ?>
<?php echo $html->link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>
</td>
<td>
<?php echo $job['Job']['comments']; ?>
@ -100,5 +88,7 @@ foreach ($jobs as $job):
<div class="actions">
<ul>
<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>
</div>

View file

@ -16,24 +16,9 @@
<?php echo $job['Job']['title']; ?>
&nbsp;
</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;?>>
<?php echo $job['Job']['state_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']; ?>
<?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 __('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(__('List Jobs', true), array('action' => 'index')); ?> </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>
</div>

View file

@ -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 {