Email vault coming along. Implementing jQuery powered view for next commit

This commit is contained in:
Karl Cordes 2010-03-23 10:03:03 +11:00
parent 5622d8b94c
commit d1792506d2
7 changed files with 422 additions and 375 deletions

View file

@ -65,6 +65,8 @@ class EnquiriesController extends AppController {
* Fix up Email Attachment icon on email box. Currently broken -KC 6/8/09
$this->set('number_of_emails', $this->Enquiry->Email->find('count', array('conditions'=>array('Email.enquiry_id'=>$id))));
*/
$this->set('emails', $this->Enquiry->Email->find('all', array('conditions'=>array('Email.enquiry_id' => $id))));
$this->set('number_of_quotes', $this->Enquiry->Quote->find('count', array('conditions'=>array('Quote.enquiry_id'=>$id))));
//$this->set('number_of_files', $this->Enquiry->EnquiryFile->find('count', array('conditions' => array('EnquiryFile.enquiry_id'=>$id))));
$this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id']));

View file

@ -1,17 +1,18 @@
<?php
class Email extends AppModel {
var $name = 'Email';
var $belongsTo = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'enquiry_id'));
var $hasMany = array(
'EmailAttachment' => array('className' => 'EmailAttachment',
'foreignKey' => 'email_id',
'dependent' => false
));
}
var $name = 'Email';
var $belongsTo = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'enquiry_id',
'counterCache' => true));
var $hasMany = array(
'EmailAttachment' => array('className' => 'EmailAttachment',
'foreignKey' => 'email_id',
'dependent' => false
));
}
?>

View file

@ -6,7 +6,8 @@ class EmailAttachment extends AppModel {
var $belongsTo = array(
'Email' => array('className' => 'Email',
'foreignKey' => 'email_id',
'conditions' => '',
'counterCache' => true,
'conditions' => '',
'fields' => '',
'order' => ''
));

View file

@ -1,188 +1,191 @@
<?php
class Enquiry extends AppModel {
var $name = 'Enquiry';
var $name = 'Enquiry';
var $validate = array(
'user_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'User ID must be selected',
'on' => 'create'
),
'customer_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Customer for this Enquiry',
'on' => 'create'
),
'contact_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Contact for this Enquiry',
//'on' => 'create'
),
'customer_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Customer for this Enquiry',
'on' => 'create'
),
var $validate = array(
'user_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'User ID must be selected',
'on' => 'create'
),
'customer_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Customer for this Enquiry',
'on' => 'create'
),
'state_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a State for this Enquiry',
'on' => 'create'
),
'country_id' => array(
'numeric' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Country for this Enquiry',
'on' => 'create'
),
'checkStates' => array(
'rule' => array('checkStates'),
'message' => 'Australian Enquiries must be assigned to Australian States. Overseas Enquiries must be assigned to other Countries',
'on' => 'create')),
'principle_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Principle for this Enquiry',
'on' => 'create'
),
'status_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Status for this Enquiry'
),
'gst' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must select whether GST is applicable for this Enquiry',
'on' => 'create'
)
);
'contact_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Contact for this Enquiry',
//'on' => 'create'
),
/*Custom Validation Rule to Check that Enquiries with Australian States are assigned to Australia.
'customer_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Customer for this Enquiry',
'on' => 'create'
),
'state_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a State for this Enquiry',
'on' => 'create'
),
'country_id' => array(
'numeric' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Country for this Enquiry',
'on' => 'create'
),
'checkStates' => array(
'rule' => array('checkStates'),
'message' => 'Australian Enquiries must be assigned to Australian States. Overseas Enquiries must be assigned to other Countries',
'on' => 'create')),
'principle_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Principle for this Enquiry',
'on' => 'create'
),
'status_id' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must choose a Status for this Enquiry'
),
'gst' => array(
'rule' => 'numeric',
'required' => true,
'message' => 'Must select whether GST is applicable for this Enquiry',
'on' => 'create'
)
);
/*Custom Validation Rule to Check that Enquiries with Australian States are assigned to Australia.
* and that Overseas enquiries are NOT assigned to Australia.
* Not Portable at all. This code is only for CMC usage
* Should probably change this to use RegExes.
*/
function checkStates($data) {
if($this->data['Enquiry']['country_id'] != 1) { //This Enquiry is not for Australia. State must be set to overseas.
if($this->data['Enquiry']['state_id'] != 9) { //The State isn't set to Overseas. Return false
return FALSE;
}
else {
return TRUE;
}
}
if($this->data['Enquiry']['country_id'] == 1) { //This enquiry is for Australia. State must be for an Australian State
if($this->data['Enquiry']['state_id'] == 9) {
return FALSE;
}
else {
return TRUE;
}
}
}
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Customer' => array('className' => 'Customer',
'foreignKey' => 'customer_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Contact' => array('className' => 'Contact',
'foreignKey' => 'contact_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'State' => array('className' => 'State',
'foreignKey' => 'state_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Country' => array('className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Principle' => array('className' => 'Principle',
'foreignKey' => 'principle_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Status' => array('className' => 'Status',
'foreignKey' => 'status_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'BillingAddress' => array('className' => 'Address',
'foreignKey' => 'billing_address_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'ShippingAddress' => array('className' => 'Address',
'foreignKey' => 'shipping_address_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
*/
var $hasMany = array(
'Quote' => array('className' => 'Quote',
'foreignKey' => 'enquiry_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
/* 'EnquiryFile' => array('className' => 'EnquiryFile',
function checkStates($data) {
if($this->data['Enquiry']['country_id'] != 1) { //This Enquiry is not for Australia. State must be set to overseas.
if($this->data['Enquiry']['state_id'] != 9) { //The State isn't set to Overseas. Return false
return FALSE;
}
else {
return TRUE;
}
}
if($this->data['Enquiry']['country_id'] == 1) { //This enquiry is for Australia. State must be for an Australian State
if($this->data['Enquiry']['state_id'] == 9) {
return FALSE;
}
else {
return TRUE;
}
}
}
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'User' => array('className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Customer' => array('className' => 'Customer',
'foreignKey' => 'customer_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Contact' => array('className' => 'Contact',
'foreignKey' => 'contact_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'State' => array('className' => 'State',
'foreignKey' => 'state_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Country' => array('className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Principle' => array('className' => 'Principle',
'foreignKey' => 'principle_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Status' => array('className' => 'Status',
'foreignKey' => 'status_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'BillingAddress' => array('className' => 'Address',
'foreignKey' => 'billing_address_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'ShippingAddress' => array('className' => 'Address',
'foreignKey' => 'shipping_address_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
var $hasMany = array(
'Quote' => array('className' => 'Quote',
'foreignKey' => 'enquiry_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Email' => array('className' => 'Email',
'foreignKey' => 'enquiry_id',
'dependent' => false
),
/* 'EnquiryFile' => array('className' => 'EnquiryFile',
'foreignKey' => 'enquiry_id',
'dependent' => false
),*/
/*'Email' => array('className' => 'Email',
'foreignKey' => 'enquiry_id',
'dependent' => false
),
*/
);
var $hasOne = array('EnquiryEmailQueue');
);
var $hasOne = array('EnquiryEmailQueue');
}
?>

View file

@ -17,11 +17,17 @@ class VaultShell extends Shell {
/* Setup Connection to the IMAP server */
$username = 'vault';
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
$email_dir = '/var/www/cakephp/app/emails/working';
$email_dir = '/var/www/cakephp/app/emails';
$temp_filename = 'temp.eml';
$ripmime_path = '/usr/local/bin/ripmime';
if($testing == 1) {
$email_dir = '/Users/karlcordes/Sites/app/emails/working';
$email_dir = '/Users/karlcordes/Sites/quotenik/app/emails';
$ripmime_path = '/opt/local/bin/ripmime';
}
$mbox = imap_open("{mail.cmctechnologies.com.au:143}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
@ -33,19 +39,24 @@ class VaultShell extends Shell {
if($number_of_messages == 0) {
exit(0);
}
exit(0);
/* Loop through the messages and sort them into ones to be processed or discarded */
for ($i=1; $i <= $number_of_messages; $i++) {
for ($i=30000; $i <= $number_of_messages; $i++) {
$this_header = imap_headerinfo($mbox, $i);
$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";
$enquiry = $this->checkIfValidEnquiry($message['subject'], $testing);
if($enquiry) {
echo "Found Enquiry number: ".$enquiry['Enquiry']['title']." Processing.\n";
//Process it and store the message and its attachments.
//Generate a Uniqid for this email.
$uniqid = $this->getUniqId($email_dir);
$this->Email->create();
$this->data['Email']['enquiry_id'] = $enquiry['Enquiry']['id'];
$this->data['Email']['to'] = $message['to'];
@ -55,27 +66,28 @@ class VaultShell extends Shell {
$this->data['Email']['subject'] = $message['subject'];
$this->data['Email']['body'] = "";
$this->data['Email']['plainbody'] = "";
$this->data['Email']['uniqid'] = $uniqid;
$structure = imap_fetchstructure($mbox, $i);
$attachments = 1;
if (empty($structure->parts)) { /* A single part message. No attachments and is plain text */
$this->data['Email']['body'] = imap_body($mbox, $i);
}
else {
$attachments = $this->fetchBodyAttachments($mbox, $i, $temp_filename, $email_dir);
$attachments = $this->fetchBodyAttachments($mbox, $i, $temp_filename, $email_dir, $uniqid, $ripmime_path);
if($attachments != 1) {
foreach ($attachments as $attachment) {
if($attachment['type'] == 'text/html') { //Assuming All HTML attachments are the body of the email
if(file_exists($email_dir.'/'.$attachment['name'])) {
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
if(file_exists($email_dir.'/'.$uniqid.'/'.$attachment['name'])) {
$filecontents = file_get_contents($email_dir.'/'.$uniqid.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$uniqid.'/'.$attachment['name']);
$this->data['Email']['body'] .= $filecontents;
}
}
if($attachment['type'] == 'text/plain') { //Found plain text
if(file_exists($email_dir.'/'.$attachment['name'])) {
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
$filecontents = file_get_contents($email_dir.'/'.$uniqid.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$uniqid.'/'.$attachment['name']);
$this->data['Email']['plainbody'] .= $filecontents;
}
@ -92,7 +104,7 @@ class VaultShell extends Shell {
$email_id = $this->Email->id;
if($attachments != 1) {
foreach ($attachments as $attachment) {
if(file_exists($email_dir.'/'.$attachment['name']) != FALSE) {
if(file_exists($email_dir.'/'.$uniqid.'/'.$attachment['name']) != FALSE) {
if( ($attachment['type'] != 'text/html') && ($attachment['type'] != 'multipart/mixed') &&
($attachment['type'] != 'multipart/alternative') ) {
@ -101,7 +113,7 @@ class VaultShell extends Shell {
$this->data['EmailAttachment']['name'] = $attachment['name'];
$this->data['EmailAttachment']['type'] = $attachment['type'];
$this->data['EmailAttachment']['size'] = filesize($email_dir.'/'.$attachment['name']);
$this->data['EmailAttachment']['data'] = file_get_contents($email_dir.'/'.$attachment['name']);
$this->data['EmailAttachment']['filename'] = $email_dir.'/'.$uniqid.'/'.$attachment['name'];
if ($this->EmailAttachment->save($this->data)) {
echo "Saved file successfully to database\n";
}
@ -150,7 +162,7 @@ class VaultShell extends Shell {
}
$this->rmdirr($email_dir); //delete all attachments from the working directory. Easiest way to stop random files persisting
// $this->rmdirr($email_dir); //delete all attachments from the working directory. Easiest way to stop random files persisting
@ -191,11 +203,17 @@ class VaultShell extends Shell {
*
*/
function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) {
function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir, $uniqid, $ripmime_path) {
$email_file = $email_dir.'/'.$filename;
$mkdirresult = mkdir ($email_dir.'/'.$uniqid);
if($mkdirresult == FALSE) {
echo "ERROR: Failed to make ".$email_dir.'/'.$uniqid;
return 1;
}
$email_file = $email_dir.'/'.$uniqid.'/'.$filename;
imap_savebody($mailbox, $email_file, $msg_number);
$command = "/usr/local/bin/ripmime -i $email_file -d $email_dir -v --verbose-contenttype --paranoid --prefix $msg_number";
$command = "$ripmime_path -i $email_file -d $email_dir/$uniqid -v --verbose-contenttype --paranoid --prefix $msg_number";
$output = array();
exec($command, $output, $status);
@ -237,7 +255,7 @@ class VaultShell extends Shell {
function getMessage($mbox, $msgnumber, $headers) {
$subject = $headers->subject;
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1");
$subject = iconv_mime_decode($subject, 0, "ISO-8859-1//IGNORE");
$date = $headers->date;
$recipients = $this->getRecipients($headers);
$message['subject'] = $subject;
@ -309,7 +327,7 @@ class VaultShell extends Shell {
if(isset($output[0])) { //Found a valid-looking Enquiry Number
$fetched_enquirynumber = $output[0];
echo $fetched_enquirynumber."\n";
// echo $fetched_enquirynumber."\n";
$enquiry = $this->Enquiry->findByTitle($fetched_enquirynumber);
if($enquiry) {
return $enquiry;
@ -359,5 +377,21 @@ class VaultShell extends Shell {
//rmdir($dirname);
}
/**
* Generate a uniq id.
* @todo Ensure the sub-directory doesn't exist to avoid collisions
*
*/
function getUniqId($email_dir) {
$uniqid = uniqid(null,TRUE);
//while(is_dir($email_dir."/".$uniqid) == TRUE) {
//
// }
return $uniqid;
}
}
?>

View file

@ -1,51 +1,53 @@
<?php if (!empty($emails)):?>
<table cellpadding = "0" cellspacing = "0" class="emailtable">
<tr>
<th><?php __('Email Date'); ?></th>
<th><?php echo $html->image('attach.png'); ?></th>
<th><?php __('Subject'); ?></th>
<th><?php __('To'); ?></th>
<th><?php __('CC'); ?></th>
<th><?php __('From'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($emails as $email):
$class = null;
if ($i % 2 == 0) {
$class = ' class="altrow"';
}
$i++;
?>
<tr<?php echo $class;?>>
<td><?php echo $email['Email']['date'];?></td>
<td><?php if(count($email['EmailAttachment']) > 0) {
echo $html->image('attach.png');
}
?>
</td>
<td><?php echo $text->highlight($ajax->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'frame/', $email['Email']['id']), array('update'=>'showemail')), 'Quotation'); ?></td>
<td><?php echo $email['Email']['to']; ?></td>
<td><?php echo $email['Email']['cc']; ?></td>
<td><?php echo $email['Email']['from']; ?></td>
<td class="actions">
<?php //echo $html->link(__('View', true), array('controller'=> 'emails', 'action'=>'view/', $email['Email']['id']));
echo $ajax->link('View', array('controller'=>'emails', 'action'=>'frame/', $email['Email']['id']), array('update' => 'showemail'));
echo $html->link('Print', array('controller' => 'emails', 'action'=>'printview/', $email['Email']['id']));
?>
</td>
</tr>
<?php endforeach; ?>
</table>
<tr>
<th><?php __('Email Date'); ?></th>
<th><?php echo $html->image('attach.png'); ?></th>
<th><?php __('Subject'); ?></th>
<th><?php __('To'); ?></th>
<th><?php __('CC'); ?></th>
<th><?php __('From'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($emails as $email):
$class = null;
if ($i % 2 == 0) {
$class = ' class="altrow"';
}
$i++;
?>
<tr<?php echo $class;?>>
<td><?php echo $email['Email']['date'];?></td>
<td><?php if($email['email_attachment_count'] > 0) {
echo $html->image('attach.png');
}
?>
</td>
<td><?php echo $text->highlight($ajax->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'frame/', $email['Email']['id']), array('update'=>'showemail')), 'Quotation'); ?></td>
<td><?php echo $email['Email']['to']; ?></td>
<td><?php echo $email['Email']['cc']; ?></td>
<td><?php echo $email['Email']['from']; ?></td>
<td class="actions">
<?php //echo $html->link(__('View', true), array('controller'=> 'emails', 'action'=>'view/', $email['Email']['id']));
echo $ajax->link('View', array('controller'=>'emails', 'action'=>'frame/', $email['Email']['id']), array('update' => 'showemail'));
echo $html->link('Print', array('controller' => 'emails', 'action'=>'printview/', $email['Email']['id']));
?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

View file

@ -1,141 +1,145 @@
<div class="enquiries-view">
<h2><?php __("Enquiry: " . $enquiry['Enquiry']['title']);?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry Number'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $enquiry['Enquiry']['title']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Assigned to User'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['User']['username'], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Customer'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Contact'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('State'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['State']['name'], array('controller'=> 'states', 'action'=>'view', $enquiry['State']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Country'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Country']['name'], array('controller'=> 'countries', 'action'=>'view', $enquiry['Country']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('GST Applicable'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['Enquiry']['gst'] == 0) {
echo "No - GST Not Applicable";
}
else {
echo "Yes - GST Applicable";
}
?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Status'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Status']['name'], array('controller'=> 'statuses', 'action'=>'view', $enquiry['Status']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Comments'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<span class="enquiry-view-comments">
<?php echo $enquiry['Enquiry']['comments']; ?>
</span>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Billing Address'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['BillingAddress']['customer_id'] != NULL) {
echo $enquiry['BillingAddress']['address'].'<br>';
echo $enquiry['BillingAddress']['city'].' '.$billingaddress['State']['name'].' '.$enquiry['BillingAddress']['postcode'].'<br>';
echo '<b>'.$billingaddress['Country']['name'].'</b>';
}
else {
echo 'No Billing Address Assigned for this Enquiry';
}
?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Address'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['ShippingAddress']['customer_id'] != NULL) {
echo $enquiry['ShippingAddress']['address'].'<br>';
echo $enquiry['ShippingAddress']['city'].' '.$shippingaddress['State']['name'].' '.$enquiry['ShippingAddress']['postcode'].'<br>';
echo '<b>'.$shippingaddress['Country']['name'].'</b>';
}
else { echo 'No Shipping Address Assigned for this Enquiry';
}
?>
&nbsp;
</dd>
</dl>
<h2><?php __("Enquiry: " . $enquiry['Enquiry']['title']);?></h2>
<dl><?php $i = 0;
$class = ' class="altrow"';?>
<div class="enquiry-actions">
<ul>
<li><?php echo $html->link(__('Edit Enquiry', true), array('action'=>'edit', $enquiry['Enquiry']['id'])); ?> </li>
</ul>
</div>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry Number'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $enquiry['Enquiry']['title']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Assigned to User'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['User']['username'], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Customer'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Contact'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('State'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['State']['name'], array('controller'=> 'states', 'action'=>'view', $enquiry['State']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Country'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Country']['name'], array('controller'=> 'countries', 'action'=>'view', $enquiry['Country']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('GST Applicable'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['Enquiry']['gst'] == 0) {
echo "No - GST Not Applicable";
}
else {
echo "Yes - GST Applicable";
}
?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Status'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($enquiry['Status']['name'], array('controller'=> 'statuses', 'action'=>'view', $enquiry['Status']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Comments'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<span class="enquiry-view-comments">
<?php echo $enquiry['Enquiry']['comments']; ?>
</span>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Billing Address'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['BillingAddress']['customer_id'] != NULL) {
echo $enquiry['BillingAddress']['address'].'<br>';
echo $enquiry['BillingAddress']['city'].' '.$billingaddress['State']['name'].' '.$enquiry['BillingAddress']['postcode'].'<br>';
echo '<b>'.$billingaddress['Country']['name'].'</b>';
}
else {
echo 'No Billing Address Assigned for this Enquiry';
}
?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Address'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php
if($enquiry['ShippingAddress']['customer_id'] != NULL) {
echo $enquiry['ShippingAddress']['address'].'<br>';
echo $enquiry['ShippingAddress']['city'].' '.$shippingaddress['State']['name'].' '.$enquiry['ShippingAddress']['postcode'].'<br>';
echo '<b>'.$shippingaddress['Country']['name'].'</b>';
}
else {
echo 'No Shipping Address Assigned for this Enquiry';
}
?>
&nbsp;
</dd>
</dl>
<div class="enquiry-actions">
<ul>
<li><?php echo $html->link(__('Edit Enquiry', true), array('action'=>'edit', $enquiry['Enquiry']['id'])); ?> </li>
</ul>
</div>
</div>
<div class="principle-emails">
<?php
$boxdata = array();
$boxdata['enquirynumber'] = $enquiry['Enquiry']['title'];
<?php
$boxdata = array();
$boxdata['enquirynumber'] = $enquiry['Enquiry']['title'];
//$boxdata['principle_emails'] = $principle_emails;
?>
?>
<?php echo $this->element('principle_contacts_email_box', array('enquirynumber' => $enquiry['Enquiry']['title'],
'principle_emails' => $principle_emails )); ?>
'principle_emails' => $principle_emails )); ?>
</div>
<? /*
<div class="related">
<h3><?php __($number_of_files.' Files in this Enquiry');?><?php echo $html->image('document.png'); ?></h3>
<?php echo $this->element('enquiry_file_table', $files); ?>
</div>
*/?>
<div class="related">
<h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3>
<?php echo $this->element('quote_table', $quotes); ?>
</div>
<div id="showemail">
</div>
<? /*
<div class="related">
<h3>
<?php __($number_of_emails.' Emails for this Enquiry');?><?php echo $html->image('internet-mail.png'); ?></h3>
<?php //echo $this->element('email_table_ajax', $enquiry); ?>
<?php echo $this->element('email_table_ajax', $enquiry, array('cache'=>'+1 day')); ?>
</div>
<div class="related">
<h3><?php __($number_of_files.' Files in this Enquiry');?><?php echo $html->image('document.png'); ?></h3>
<?php echo $this->element('enquiry_file_table', $files); ?>
</div>
*
*/
?>
<div class="related">
<h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3>
<?php echo $this->element('quote_table', $quotes); ?>
<h3>
<?php __($enquiry['Enquiry']['email_count'].' Emails for this Enquiry');?><?php echo $html->image('internet-mail.png'); ?></h3>
<?php //echo $this->element('email_table_ajax', $enquiry); ?>
<?php echo $this->element('email_table_ajax', $enquiry, array('cache'=>'+1 day')); ?>
</div>
<?php debug($quotes); ?>
<?php //debug($emails); ?>