Vault More of Less Finished. Installing on Saturn Now

This commit is contained in:
Karl Cordes 2009-02-10 16:39:26 +11:00
parent 05c16e9f65
commit 8f7d1a1022
22 changed files with 355 additions and 103 deletions

View file

@ -60,19 +60,24 @@ class AddressesController extends AppController {
}
if (!empty($this->data)) {
if ($this->Address->save($this->data)) {
$id = $this->Address->id;
$address = $this->Address->findById($id);
$this->Session->setFlash(__('The Address has been saved', true));
$this->redirect(array('action'=>'index'));
$this->redirect(array('controller' => 'customers', 'action'=>'view/'.$address['Address']['customer_id']));
} else {
$this->Session->setFlash(__('The Address could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Address->read(null, $id);
}
$customers = $this->Address->Customer->find('list');
$address = $this->Address->read(null, $id);
$customer = $this->Address->Customer->findById($address['Address']['customer_id']);
$states = $this->Address->State->find('list');
$countries = $this->Address->Country->find('list');
$this->set(compact('customers','states','countries'));
$this->set(compact('customer','states','countries', 'address'));
if (empty($this->data)) {
$this->data = $address;
}
}

View file

@ -2,8 +2,8 @@
class EmailsController extends AppController {
var $name = 'Emails';
var $helpers = array('Html', 'Form');
var $helpers = array('Html', 'Form', 'Number', 'Ajax', 'Text', 'Link');
var $components = array('RequestHandler');
function index() {
$this->Email->recursive = 0;
$this->set('emails', $this->paginate());
@ -31,36 +31,23 @@ class EmailsController extends AppController {
$this->set(compact('enquiries'));
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Email', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Email->save($this->data)) {
$this->Session->setFlash(__('The Email has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Email could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Email->read(null, $id);
}
$enquiries = $this->Email->Enquiry->find('list');
$this->set(compact('enquiries'));
function frame($id = null) {
$this->set('id', $id);
}
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Email', true));
$this->redirect(array('action'=>'index'));
function show($id = null) {
$this->layout = 'minimal';
$this->set('email', $this->Email->read(null, $id));
}
if ($this->Email->del($id)) {
$this->Session->setFlash(__('Email deleted', true));
$this->redirect(array('action'=>'index'));
/* Violates DRY. Should probably clean this up at some point */
function printview($id = null) {
$this->layout = 'minimal';
$this->set('email', $this->Email->read(null, $id));
}
}
}
?>
?>

View file

@ -4,7 +4,7 @@ App::import('Core', 'Sanitize');
class EnquiriesController extends AppController {
var $name = 'Enquiries';
var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax', 'Number');
var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax', 'Number', 'Text');
var $paginate = array(
'limit' => 250,
@ -30,6 +30,7 @@ class EnquiriesController extends AppController {
$this->set('number_of_emails', $this->Enquiry->Email->find('count', 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))));
if($enquiry['Enquiry']['billing_address_id'] != 0) {
$this->set('billingaddress', $this->Enquiry->BillingAddress->findById($enquiry['Enquiry']['billing_address_id']));
}

View file

@ -4,12 +4,12 @@
<legend><?php __('Edit Address for Customer: '.$customer['Customer']['name']);?></legend>
<?php
echo $form->input('id');
echo $form->input('name');
echo $form->input('address');
echo $form->input('city');
echo $form->input('postcode');
echo $form->input('state_id');
echo $form->input('country_id');
echo $form->input('customer_id');
echo $form->input('customer_id', array('type' => 'hidden', 'value' => $customer['Customer']['id']));
echo $form->input('type', array('label' => 'Address Type (Billing,Shipping or Both)', 'options' => array('Billing','Shipping', 'Both Shipping and Billing')));
?>
</fieldset>

View file

@ -14,7 +14,7 @@ Please see below for the contact details we have for this enquiry and advise if
<b>Mobile:</b> <?php echo $enquiry['Contact']['mobile']; ?><br>
<b>Fax:</b> <?php echo $enquiry['Contact']['fax']; ?><br>
<br>
Depending on the nature of your request, we may need input from our manufacturers overseas. This will usually take 24 to 48 hours, but if your application is more complex, it may take longer. <br /><br />
Depending on the nature of your request, we may need input from our manufacturers overseas. This will usually take 24 to 48 hours, but if your enquiry is non-standard, it may take a little longer. <br /><br />
Sincerely, <br /><br />

View file

@ -18,7 +18,7 @@ Mobile: <?php echo $enquiry['Contact']['mobile']; ?>
Fax: <?php echo $enquiry['Contact']['fax']; ?>
Depending on the nature of your request, we may need input from our manufacturers overseas. This will usually take 24 to 48 hours, but if your application is more complex, it may take longer.
Depending on the nature of your request, we may need input from our manufacturers overseas. This will usually take 24 to 48 hours, but if your enquiry is non-standard, it may take a little longer.
Sincerely,

View file

@ -1,11 +1,12 @@
<?php if (!empty($emails)):?>
<table cellpadding = "0" cellspacing = "0" class="filetable">
<table cellpadding = "0" cellspacing = "0" class="emailtable">
<tr>
<th><?php __('Email Date'); ?></th>
<th><?php __('Subject'); ?></th>
<th><?php __('To'); ?></th>
<th><?php __('CC'); ?></th>
<th><?php __('From'); ?></th>
<th><?php __('Subject'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -22,10 +23,11 @@
<tr<?php echo $class;?>>
<td><?php echo $email['Email']['date'];?></td>
<td><?php echo $html->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'view/', $email['Email']['id'])); ?></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 $html->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'view/', $email['Email']['id'])); ?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'emails', 'action'=>'view/', $email['Email']['id'])); ?>
</td>

View file

@ -0,0 +1,51 @@
<?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>
<?php endif; ?>

View file

@ -1,28 +0,0 @@
<div class="emails form">
<?php echo $form->create('Email');?>
<fieldset>
<legend><?php __('Edit Email');?></legend>
<?php
echo $form->input('enquiry_id');
echo $form->input('id');
echo $form->input('to');
echo $form->input('from');
echo $form->input('cc');
echo $form->input('body');
echo $form->input('date');
echo $form->input('subject');
echo $form->input('content-type');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value('Email.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Email.id'))); ?></li>
<li><?php echo $html->link(__('List Emails', 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>
<li><?php echo $html->link(__('List Email Attachments', true), array('controller'=> 'email_attachments', 'action'=>'index')); ?> </li>
<li><?php echo $html->link(__('New Email Attachment', true), array('controller'=> 'email_attachments', 'action'=>'add')); ?> </li>
</ul>
</div>

3
views/emails/frame.ctp Normal file
View file

@ -0,0 +1,3 @@
<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

@ -0,0 +1,47 @@
<div id="viewemail">
Enquiry Number: <?php echo $email['Enquiry']['title']; ?> <br>
Date: <?php echo $email['Email']['date']; ?> <br>
Subject: <?php echo $email['Email']['subject']; ?> <br>
To: <?php echo $email['Email']['to']; ?> <br>
From: <?php echo $email['Email']['from']; ?> <br>
CC: <?php echo $email['Email']['cc']; ?> <br>
<hr>
<div id="printemailbody">
<?php
/* strip out thinks messing up my link styles! */
$cleanbody = strip_tags($email['Email']['body'], '<p><a><br><hr><span><table><tr><td>'); ?>
<?php echo $cleanbody; ?>
</div>
<div class="related">
<h3><?php __('Attachments');?></h3>
<?php if (!empty($email['EmailAttachment'])):?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php __('Name'); ?></th>
<th><?php __('Type'); ?></th>
<th><?php __('Size'); ?></th>
</tr>
<?php
$i = 0;
foreach ($email['EmailAttachment'] as $emailAttachment):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php echo $emailAttachment['name'];?></td>
<td><?php echo $emailAttachment['type'];?></td>
<td><?php echo $number->toReadableSize($emailAttachment['size']);?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</div>

80
views/emails/show.ctp Normal file
View file

@ -0,0 +1,80 @@
<div id="viewemail">
<dl class="mailheaders"><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($email['Enquiry']['title'], array('controller'=> 'enquiries', 'action'=>'view', $email['Enquiry']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Date'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['date']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Subject'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['subject']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('To'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $link->autoLinkEmailsSubject($email['Email']['to'], $email['Email']['subject']); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('From'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $text->autoLinkEmails($email['Email']['from']); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Cc'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $text->autoLinkEmails($email['Email']['cc']); ?>
&nbsp;
</dd>
</dl>
<div id="emailbody">
<?php
/* strip out thinks messing up my link styles! */
$cleanbody = str_replace(array('a:link', 'a:visited'), '', $email['Email']['body']);
?>
<?php echo $cleanbody; ?>
</div>
<div class="related">
<h3><?php __('Attachments');?></h3>
<?php if (!empty($email['EmailAttachment'])):?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php __('Name'); ?></th>
<th><?php __('Type'); ?></th>
<th><?php __('Size'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($email['EmailAttachment'] as $emailAttachment):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td><?php echo $emailAttachment['name'];?></td>
<td><?php echo $emailAttachment['type'];?></td>
<td><?php echo $number->toReadableSize($emailAttachment['size']);?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'email_attachments', 'action'=>'download', $emailAttachment['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</div>

View file

@ -1,14 +1,21 @@
<div class="emails view">
<h2><?php __('Email');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Enquiry'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($email['Enquiry']['title'], array('controller'=> 'enquiries', 'action'=>'view', $email['Enquiry']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Date'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['id']; ?>
<?php echo $email['Email']['date']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Subject'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['subject']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('To'); ?></dt>
@ -27,30 +34,12 @@
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Body'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<dd class = "emailbody">
<?php echo $email['Email']['body']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['created']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Date'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['date']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Subject'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['subject']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Content-type'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $email['Email']['content-type']; ?>
&nbsp;
</dd>
</dl>
</div>
@ -63,7 +52,6 @@
<th><?php __('Name'); ?></th>
<th><?php __('Type'); ?></th>
<th><?php __('Size'); ?></th>
<th><?php __('Description'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -78,14 +66,11 @@
<td><?php echo $emailAttachment['name'];?></td>
<td><?php echo $emailAttachment['type'];?></td>
<td><?php echo $emailAttachment['size'];?></td>
<td><?php echo $number->toReadableSize($emailAttachment['size']);?></td>
<td><?php echo $emailAttachment['description'];?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'email_attachments', 'action'=>'view', $emailAttachment['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=> 'email_attachments', 'action'=>'edit', $emailAttachment['id'])); ?>
<?php echo $html->link(__('Delete', true), array('controller'=> 'email_attachments', 'action'=>'delete', $emailAttachment['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $emailAttachment['id'])); ?>
<?php echo $html->link(__('View', true), array('controller'=> 'email_attachments', 'action'=>'download', $emailAttachment['id'])); ?>
</td>
</tr>
<?php endforeach; ?>

View file

@ -99,10 +99,12 @@
</div>
<div class="related">
<h3><?php __($number_of_emails.' Emails for this Enquiry');?></h3>
<?php echo $this->element('email_table', $emails); ?>
<h3><?php __($number_of_emails.' Emails for this Enquiry');?><?php echo $html->image('internet-mail.png'); ?></h3>
<?php echo $this->element('email_table_ajax', $emails); ?>
</div>
<div id="showemail">
</div>
<div class="related">
<h3><?php __($number_of_quotes.' Quotes in this Enquiry');?></h3>
<?php echo $this->element('quote_table', $quotes); ?>

47
views/helpers/link.php Normal file
View file

@ -0,0 +1,47 @@
<?php
if (!class_exists('HtmlHelper')) {
App::import('Helper', 'Html');
}
class LinkHelper extends AppHelper {
/**
* Adds email links with subject (<a href="mailto:someone@somewhere.com?subject=What a Cool Subject) to a given text.
*
* @param string $text Text
* @param string $subject Subject
* @return string The text with links, seperated by spaces.
* @access public
*/
function autoLinkEmailsSubject($text, $subject) {
$matches = array();
$links = "";
$number_of_matches = preg_match_all('#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#', $text, $matches, PREG_PATTERN_ORDER);
if($number_of_matches > 0) {
$Html = new HtmlHelper();
$Html->tags = $Html->loadConfig();
foreach($matches[0] as $match) {
$links .= $Html->link($match, "mailto:" . $match . "?subject=" .$subject).' ';
}
return $links;
}
else {
return;
}
}
}

View file

@ -127,7 +127,13 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
<li><?php echo $html->link('Add User', '/users/add'); ?></li>
</ul>
</li>
<li><h3><?php echo $html->link('Help', '/pages/help'); ?></h3>
<ul>
<li><?php echo $html->link('About', '/pages/about'); ?></li>
</ul>
</li>
</ul>
</div>

View file

@ -0,0 +1,8 @@
<?
echo $html->css('quotenik');
?>
<body>
<div id="content">
<? echo $content_for_layout; ?>
</div>
</body>

View file

@ -0,0 +1,2 @@
<h1>About this Software</h1>

0
views/pages/help.ctp Normal file
View file

View file

@ -200,6 +200,42 @@ ul, li {
padding: 6px 10px;
text-align: right;
}
#mailheaders {
width: 80%;
}
a#mailheaders {
color: #003d4c;
}
#viewemail {
text-align: left;
font-size: 80%;
}
#emailbody {
text-align: left;
font-size: 100%;
background-color: #FFFFFF;
color: #000000;
}
#printemailbody {
text-align: left;
font-size: 90%;
background-color: #FFFFFF;
color: #000000;
}
#showemail {
padding-top:1em;
width: 70%;
}
dl#showemail {
line-height: 2em;
margin: 0em 0em;
}
.addressradio label {
display: block;
@ -342,6 +378,10 @@ table.quotetable tr.mostrecent td {
table.quotetable tr.altrow td {
background: #f4f4f4;
}
table.emailtable {
font-size: small;
}
/* Paging */
div.paging {
@ -367,6 +407,14 @@ dl {
margin: 0em 0em;
width: 60%;
}
dl.mailheaders {
line-height: 2em;
margin: 0em 0em;
width: 100%;
color: #000000;
}
dl.altrow {
background: #f4f4f4;
}
@ -387,6 +435,7 @@ dd {
dd.altrow {
background: #E6F0F0;
}
/* Forms */
form {
@ -695,6 +744,11 @@ span.warning {
color: #FF0000;
}
span.highlight {
background-color: #74DD63;
}
span.tip {
color: #000000;
}

BIN
webroot/img/attach.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB