jQuery email view working OK

This commit is contained in:
Karl Cordes 2010-03-23 13:27:53 +11:00
parent d1792506d2
commit b2ab892253
7 changed files with 112 additions and 42 deletions

View file

@ -25,7 +25,7 @@ class VaultShell extends Shell {
if($testing == 1) {
$email_dir = '/Users/karlcordes/Sites/quotenik/app/emails';
$ripmime_path = '/opt/local/bin/ripmime';
}
@ -39,7 +39,7 @@ class VaultShell extends Shell {
if($number_of_messages == 0) {
exit(0);
}
/* Loop through the messages and sort them into ones to be processed or discarded */
for ($i=30000; $i <= $number_of_messages; $i++) {
@ -162,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
@ -327,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;
@ -387,8 +387,8 @@ class VaultShell extends Shell {
function getUniqId($email_dir) {
$uniqid = uniqid(null,TRUE);
//while(is_dir($email_dir."/".$uniqid) == TRUE) {
//
// }
//
// }
return $uniqid;
}

View file

@ -1,17 +1,19 @@
<?php echo $javascript->link('email_table'); ?>
<?php // if (!empty($emails)):?>
<?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>
<div id="emailDiv">
<th class="actions"><?php __('Actions');?></th>
</tr>
<table cellpadding = "0" cellspacing = "0" class="emailtable">
<tr>
<th><?php __('Email Date'); ?></th>
<th><?php echo $html->image('attach.png'); ?></th>
<th><?php __('From'); ?></th>
<th><?php __('Subject'); ?></th>
<th><?php __('To'); ?></th>
</tr>
<?php
$i = 0;
foreach ($emails as $email):
@ -26,28 +28,32 @@
?>
<tr<?php echo $class;?>>
<tr<?php echo $class;?>>
<td><?php echo $email['Email']['date'];?></td>
<td><?php if($email['email_attachment_count'] > 0) {
<td><?php echo $email['Email']['date'];?></td>
<td><?php if($email['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>
<td><?php echo $email['Email']['from']; ?></td>
<td><?php //echo $text->highlight($html->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'frame/', $email['Email']['id'])), 'Quotation');
echo $text->highlight($html->link($email['Email']['subject'], '#', array('class'=>'viewLink', 'id'=>$email['Email']['id'])), 'Quotation');
?></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>
<td><?php echo $email['Email']['to']; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</table>
</div>
<?php //endif; ?>
<div id="ViewDialog">
</div>

View file

@ -1,7 +1,6 @@
<div id="emailframe">
<h3>Email</h3>
<iframe src ="<?php echo $html->url("show/$id"); ?>" width="100%" height="500px">
<p>This function only works with a Modern Browser that uses Iframes. Sorry.</p>
</iframe>

View file

@ -1,3 +1,5 @@
<? Configure::write('debug', 0); ?>
<div id="viewemail">
<dl class="mailheaders"><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry'); ?></dt>

View file

@ -67,7 +67,7 @@
<li><?php echo $html->link('Contacts', '/contacts/index'); ?>
<ul>
<li><?php echo $html->link('Contact Index', '/contacts/index'); ?></li>
<li class="last"><?php echo $html->link('Contact Index', '/contacts/index'); ?></li>
</ul>
</li>

View file

@ -286,9 +286,14 @@ a#mailheaders {
color: #003d4c;
}
#viewemail {
text-align: left;
font-size: 80%;
clear: both;
display: block;
}
@ -309,13 +314,14 @@ a#mailheaders {
}
#emailframe {
float: left;
width: 50%;
clear: both;
display: block;
}
#emailattachments {
padding-right: 2em;
float: right;
}
dl#showemail {
@ -1038,9 +1044,8 @@ div.tipbox {
li.selected { background-color: #ffb; }
span {
font-weight: bold;
font-size: 100%;
}
span.note {

58
webroot/js/email_table.js Normal file
View file

@ -0,0 +1,58 @@
/**
* file: email_table.js
* date: Tue 23 March 2010
* author: Karl Cordes
*
* purpose: uses jQuery to create a mail client-like interface for viewing the emails associated with an enquiry (or contact)
*
*/
$(function () {
$("#ViewDialog").dialog({
autoOpen: false,
width: 900,
modal: false,
buttons: {
Close: function() {
$(this).dialog('close');
}
},
close: function() {
//What happens on close goes here.
}
});
$('.viewLink').click(function() {
var currentID = $(this).attr('id');
var subject = $(this).text();
$("#ViewDialog").dialog("option", "title", subject);
$.get('/emails/frame/'+currentID, function (data) {
$("#ViewDialog").html(data);
});
$("#ViewDialog").dialog('open');
return false;
})
}
);