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

@ -1,16 +1,18 @@
<?php echo $javascript->link('email_table'); ?>
<?php // if (!empty($emails)):?>
<?php if (!empty($emails)):?> <div id="emailDiv">
<table cellpadding = "0" cellspacing = "0" class="emailtable">
<table cellpadding = "0" cellspacing = "0" class="emailtable">
<tr> <tr>
<th><?php __('Email Date'); ?></th> <th><?php __('Email Date'); ?></th>
<th><?php echo $html->image('attach.png'); ?></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><?php __('From'); ?></th>
<th><?php __('Subject'); ?></th>
<th><?php __('To'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr> </tr>
<?php <?php
$i = 0; $i = 0;
@ -29,25 +31,29 @@
<tr<?php echo $class;?>> <tr<?php echo $class;?>>
<td><?php echo $email['Email']['date'];?></td> <td><?php echo $email['Email']['date'];?></td>
<td><?php if($email['email_attachment_count'] > 0) { <td><?php if($email['Email']['email_attachment_count'] > 0) {
echo $html->image('attach.png'); echo $html->image('attach.png');
} }
?> ?>
</td> </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><?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><?php echo $email['Email']['to']; ?></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> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
<?php endif; ?> </div>
<?php //endif; ?>
<div id="ViewDialog">
</div>

View file

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

View file

@ -1,3 +1,5 @@
<? Configure::write('debug', 0); ?>
<div id="viewemail"> <div id="viewemail">
<dl class="mailheaders"><?php $i = 0; $class = ' class="altrow"';?> <dl class="mailheaders"><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry'); ?></dt> <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'); ?> <li><?php echo $html->link('Contacts', '/contacts/index'); ?>
<ul> <ul>
<li><?php echo $html->link('Contact Index', '/contacts/index'); ?></li> <li class="last"><?php echo $html->link('Contact Index', '/contacts/index'); ?></li>
</ul> </ul>
</li> </li>

View file

@ -286,9 +286,14 @@ a#mailheaders {
color: #003d4c; color: #003d4c;
} }
#viewemail { #viewemail {
text-align: left; text-align: left;
font-size: 80%; font-size: 80%;
clear: both;
display: block;
} }
@ -309,13 +314,14 @@ a#mailheaders {
} }
#emailframe { #emailframe {
float: left;
width: 50%; clear: both;
display: block;
} }
#emailattachments { #emailattachments {
padding-right: 2em;
float: right;
} }
dl#showemail { dl#showemail {
@ -1039,8 +1045,7 @@ li.selected { background-color: #ffb; }
span { span {
font-weight: bold;
font-size: 100%;
} }
span.note { 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;
})
}
);