Adding Invoices and Jobs to Customer view

This commit is contained in:
Karl Cordes 2011-03-14 11:21:56 +11:00
parent 45ac2e734b
commit 740de15efc
17 changed files with 404 additions and 319 deletions

View file

@ -34,6 +34,8 @@ class CustomersController extends AppController {
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.customer_id' => $id)));
$this->set('contacts', $this->Customer->Contact->find('all', array('conditions' => array('customer_id' => $id), 'order' => 'Contact.last_name ASC')));
$this->set('invoices', $this->Customer->Invoice->find('all', array('conditions'=>array('Invoice.customer_id'=>$id), 'order'=> 'Invoice.id DESC')));
$this->set('jobs', $this->Customer->Job->find('all', array('conditions'=>array('Job.customer_id'=>$id), 'order'=> 'Job.id DESC')));
$statuses = $this->Customer->Enquiry->Status->find('all', array('recursive'=>0));

View file

@ -55,6 +55,12 @@ class EmailAttachmentsController extends AppController {
$contents = file_get_contents($file_path."/".$file['EmailAttachment']['name']);
if($file['EmailAttachment']['type'] == 'text/plain') {
$contents = nl2br($contents, true);
}
$this->set('contents', $contents);
}

View file

@ -481,16 +481,21 @@ class EnquiriesController extends AppController {
if(count($words) == 2) {
$contactConditions = array('AND'=>array('Contact.first_name LIKE' => "%$words[0]%",
'Contact.last_name LIKE' => "%$words[1]%"));
'Contact.last_name LIKE' => "%$words[1]%"));
}
else {
$contactConditions = array('OR'=>array('Contact.first_name LIKE' => "%$searchQuery%",
'Contact.last_name LIKE' => "%$searchQuery%"));
}
$customerResults = $this->Enquiry->Customer->find('all', array('conditions' => $custConditions, 'recursive'=>0));
$enquiryResults = $this->Enquiry->find('all', array('conditions'=>$enqConditions, 'recursive'=>0));
$contactResults = $this->Enquiry->Contact->find('all', array('conditions'=>$contactConditions, 'recursive'=>0));
$customerFields = array('Customer.id', 'Customer.name');
$enquiryFields = array('Enquiry.id', 'Enquiry.title', 'Customer.name', 'Customer.id');
$contactFields = array('Contact.id', 'Contact.type','Contact.customer_id', 'Contact.first_name','Contact.last_name', 'Customer.name');
$customerResults = $this->Enquiry->Customer->find('all', array('conditions' => $custConditions, 'recursive'=>0, 'fields'=>$customerFields));
$enquiryResults = $this->Enquiry->find('all', array('conditions'=>$enqConditions, 'recursive'=>0, 'fields'=>$enquiryFields));
$contactResults = $this->Enquiry->Contact->find('all', array('conditions'=>$contactConditions, 'recursive'=>0, 'fields'=>$contactFields));
$searchDone = true;

View file

@ -2,7 +2,7 @@
class InvoicesController extends AppController {
var $name = 'Invoices';
var $helpers = array('Html', 'Form', 'Time');
var $helpers = array('Html', 'Form', 'Time', 'Text','Javascript');
var $paginate = array(
@ -21,7 +21,17 @@ class InvoicesController extends AppController {
$this->Session->setFlash(__('Invalid Invoice.', true));
$this->redirect(array('action'=>'index'));
}
$this->set('invoice', $this->Invoice->read(null, $id));
$invoice = $this->Invoice->read(null, $id);
$this->set('invoice', $invoice);
$emailIDs = array();
foreach($invoice['Email'] as $email) {
$emailIDs[] = $email['id'];
}
$emails = $this->Invoice->Email->find('all', array('conditions'=>array('Email.id'=>$emailIDs)));
$this->set('emails', $emails);
}

View file

@ -2,35 +2,46 @@
class JobsController extends AppController {
var $name = 'Jobs';
var $helpers = array('Html', 'Form');
var $helpers = array('Html', 'Form', 'Text', 'Javascript');
var $components = array('RequestHandler');
var $paginate = array(
var $paginate = array(
'contain' => false,
'limit' => 100,
'order'=>array('Job.id' => 'desc')
'contain' => false,
'limit' => 100,
'order'=>array('Job.id' => 'desc')
);
function index() {
//$this->Job->recursive = 1;
$this->set('jobs', $this->paginate());
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
$this->set('currencies', $this->Job->Currency->find('list'));
//$this->Job->recursive = 1;
$this->set('jobs', $this->paginate());
$this->set('customers', $this->Job->Enquiry->Customer->find('list'));
$this->set('currencies', $this->Job->Currency->find('list'));
}
function view($id = null) {
if (!$id) {
$this->flash(__('Invalid Job', true), array('action'=>'index'));
}
if (!$id) {
$this->flash(__('Invalid Job', true), array('action'=>'index'));
}
$job = $this->Job->read(null, $id);
$this->set('job', $job);
$this->set('customer', $this->Job->Enquiry->Customer->findById($job['Enquiry']['customer_id']));
$job = $this->Job->read(null, $id);
$emailIDs = array();
foreach($job['Email'] as $email) {
$emailIDs[] = $email['id'];
}
$emails = $this->Job->Email->find('all', array('conditions'=>array('Email.id'=>$emailIDs)));
$this->set('emails', $emails);
$this->set('job', $job);
$this->set('customer', $this->Job->Enquiry->Customer->findById($job['Enquiry']['customer_id']));
$this->set('principles', $this->Job->PurchaseOrder->Principle->find('list'));
$this->pageTitle = $job['Job']['title'];
$this->pageTitle = $job['Job']['title'];
}
@ -38,120 +49,120 @@ class JobsController extends AppController {
if (!empty($this->data)) {
$this->Job->create();
if (!empty($this->data)) {
$this->Job->create();
$job_offset = 6141;
$job_offset = 6141;
$number_of_jobs = $this->Job->findCount();
$new_job_number = $job_offset + $number_of_jobs;
$number_of_jobs = $this->Job->findCount();
$new_job_number = $job_offset + $number_of_jobs;
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']);
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']);
$monthYearShort = strtoupper(date("My"));
$monthYearShort = strtoupper(date("My"));
$jobLetter = $enquiry['State']['enqform'];
$jobLetter = $enquiry['State']['enqform'];
$this->data['Job']['title'] = $monthYearShort.$jobLetter."J".$new_job_number;
$this->data['Job']['title'] = $monthYearShort.$jobLetter."J".$new_job_number;
if ($this->Job->save($this->data)) {
$jobid = $this->Job->id;
if ($this->Job->save($this->data)) {
$jobid = $this->Job->id;
//$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won';
$enquiry['Enquiry']['status_id'] = 3;
//$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won';
$enquiry['Enquiry']['status_id'] = 3;
$this->Job->Enquiry->save($enquiry);
$this->Job->Enquiry->save($enquiry);
$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 {
if(isset($this->params['named']['enquiryid'])) {
$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 {
if(isset($this->params['named']['enquiryid'])) {
$enquiry = $this->Job->Enquiry->findById($this->params['named']['enquiryid']);
$enquiry = $this->Job->Enquiry->findById($this->params['named']['enquiryid']);
$this->set(compact('enquiry'));
}
else {
$this->Session->setFlash(__('Invalid Enquiry ID', true));
$this->redirect(array('action'=>'index'));
}
}
$this->set(compact('enquiry'));
}
else {
$this->Session->setFlash(__('Invalid Enquiry ID', true));
$this->redirect(array('action'=>'index'));
}
}
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
$this->set('freight_paid_options', $freight_paid_options);
$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);
$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);
$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) {
if (!$id && empty($this->data)) {
$this->flash(__('Invalid Job', true), array('action'=>'index'));
}
if (!empty($this->data)) {
$jobid = $this->data['Job']['id'];
if ($this->Job->save($this->data)) {
// $this->flash(__('The Job has been saved.', true), array('action'=>'view', $jobid));
if (!$id && empty($this->data)) {
$this->flash(__('Invalid Job', true), array('action'=>'index'));
}
if (!empty($this->data)) {
$jobid = $this->data['Job']['id'];
if ($this->Job->save($this->data)) {
// $this->flash(__('The Job has been saved.', true), array('action'=>'view', $jobid));
$this->Session->setFlash(__('The Job has been saved', true));
$this->Session->setFlash(__('The Job has been saved', true));
$this->redirect(array('action' =>'view/'.$jobid), null, false);
$this->redirect(array('action' =>'view/'.$jobid), null, false);
} else {
}
}
if (empty($this->data)) {
$job = $this->Job->read(null, $id);
$this->data = $job;
$this->set('currencies', $this->Job->Currency->find('list'));
} else {
}
}
if (empty($this->data)) {
$job = $this->Job->read(null, $id);
$this->data = $job;
$this->set('currencies', $this->Job->Currency->find('list'));
}
}
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
$this->set('freight_paid_options', $freight_paid_options);
$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);
$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);
$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 delete($id = null) {
if (!$id) {
$this->flash(__('Invalid Job', true), array('action'=>'index'));
@ -160,16 +171,25 @@ class JobsController extends AppController {
$this->flash(__('Job deleted', true), array('action'=>'index'));
}
}
*/
*/
function __isNotEmptyDate($date) {
if($date == "0000-00-00") {
return true;
}
else {
return false;
}
if($date == "0000-00-00") {
return true;
}
else {
return false;
}
}
/**
* Need to fix the customer_id which hasn't been set for these 500odd records.
*
* Will fetch the right ID the same way the Index does, then update each record.
*/
function fixCustomerIDs() {
}

View file

@ -1,95 +1,99 @@
<?php
class Customer extends AppModel {
var $name = 'Customer';
var $name = 'Customer';
var $displayField = 'name';
var $displayField = 'name';
var $validate = array(
'name' => array(
'rule' => 'isUnique',
'message' => 'This Customer name is already taken or has been left blank',
'required' => true,
'allowEmpty' => false),
var $validate = array(
'name' => array(
'rule' => 'isUnique',
'message' => 'This Customer name is already taken or has been left blank',
'required' => true,
'allowEmpty' => false),
'abn' => array(
'rule' => 'checkABN',
'required' => false,
'message' => 'ABN must contain 11 digits',
'allowEmpty' => true,
)
);
'abn' => array(
'rule' => 'checkABN',
'required' => false,
'message' => 'ABN must contain 11 digits',
'allowEmpty' => true,
)
);
/* Custom Validation for ABN */
/* Custom Validation for ABN */
function checkABN($data) {
$numbers = preg_replace("/\s*\D*/", "", $data['abn']);
$length = strlen($numbers);
return $length == 11;
//ABNs must be exactly 11 digits long.
}
function checkABN($data) {
$numbers = preg_replace("/\s*\D*/", "", $data['abn']);
$length = strlen($numbers);
return $length == 11;
//ABNs must be exactly 11 digits long.
}
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'Address' => array('className' => 'Address',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Contact' => array('className' => 'User',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'Address' => array('className' => 'Address',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Contact' => array('className' => 'User',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'customer_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Invoice' => array('className'=>'Invoice',
'foreignKey' => 'customer_id'),
'Job' => array('className'=>'Job',
'foreignKey' => 'customer_id')
);
var $belongsTo = array('CustomerCategory'=>
array('className' => 'CustomerCategory','foreignKey' => 'customer_category_id'),
'Country' =>
array('className' =>'Country', 'foreignKey' => 'country_id')
);
var $belongsTo = array('CustomerCategory'=>
array('className' => 'CustomerCategory','foreignKey' => 'customer_category_id'),
'Country' =>
array('className' =>'Country', 'foreignKey' => 'country_id')
);
var $hasAndBelongsToMany = array (
'Industry' => array(
'className' => 'Industry',
'joinTable' => 'industries_customers',
'foreignKey' => 'customer_id',
'associationForeignKey' => 'industry_id'
)
);
var $hasAndBelongsToMany = array (
'Industry' => array(
'className' => 'Industry',
'joinTable' => 'industries_customers',
'foreignKey' => 'customer_id',
'associationForeignKey' => 'industry_id'
)
);
}
?>

View file

@ -118,7 +118,7 @@ class Enquiry extends AppModel {
),*/
'Contact' => array('className' => 'User',
'foreignKey' => 'contact_user_id',
'conditions' => '',
'conditions' => array('Contact.type'=>'contact'),
'fields' => '',
'order' => ''
),

View file

@ -41,5 +41,14 @@ class Invoice extends AppModel {
)
);
var $hasAndBelongsToMany = array(
'Email' => array(
'className' => 'Email',
'joinTable' => 'emails_invoices',
)
);
}
?>

View file

@ -3,15 +3,15 @@ class Job extends AppModel {
var $name = 'Job';
var $validate = array(
'title' => array('notempty'),
'title' => array('notempty'),
'enquiry_id' => array('numeric'),
'enquiry_id' => array('numeric'),
'date_order_received' => array('date'),
'date_order_received' => array('date'),
'domestic_freight_paid_by' => array('notempty'),
'sale_category' => array('notempty'),
'shipment_category' => array('notempty')
'domestic_freight_paid_by' => array('notempty'),
'sale_category' => array('notempty'),
'shipment_category' => array('notempty')
);
@ -20,25 +20,29 @@ 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(
'Enquiry' => array(
'className' => 'Enquiry',
'foreignKey' => 'enquiry_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => true
),
'Enquiry' => array(
'className' => 'Enquiry',
'foreignKey' => 'enquiry_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => true
),
'Currency'
'Currency'
);
var $hasAndBelongsToMany = array(
'PurchaseOrder' => array(
'className' => 'PurchaseOrder',
'joinTable' => 'jobs_purchase_orders',
'unique' => true
)
);
var $hasAndBelongsToMany = array(
'PurchaseOrder' => array(
'className' => 'PurchaseOrder',
'joinTable' => 'jobs_purchase_orders',
'unique' => true
),
'Email' => array(
'className' => 'Email',
'joinTable' => 'emails_jobs',
)
);
}
?>

View file

@ -1,59 +1,59 @@
<?php
class Principle extends AppModel {
var $name = 'Principle';
var $name = 'Principle';
var $recursive = 0;
var $recursive = 0;
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Country' => array('className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Currency' => array('className' => 'Currency',
'foreignKey' => 'currency_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Country' => array('className' => 'Country',
'foreignKey' => 'country_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Currency' => array('className' => 'Currency',
'foreignKey' => 'currency_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
var $hasMany = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'principle_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Product' => array('className' => 'Product',
'foreignKey' => 'principle_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'PrincipleAddress' => array('className' => 'PrincipleAddress',
'foreignKey' => 'principle_id'
),
var $hasMany = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'principle_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Product' => array('className' => 'Product',
'foreignKey' => 'principle_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'PrincipleAddress' => array('className' => 'PrincipleAddress',
'foreignKey' => 'principle_id'
),
'PrincipleContact' => array('className' => 'Users',
'foreignKey' => 'principle_id'
),
);
'PrincipleContact' => array('className' => 'Users',
'foreignKey' => 'principle_id'
),
);
}
?>

View file

@ -145,22 +145,6 @@
</div>
<div class="related">
<h3><?php __('Addresses');?><?php echo $html->image('x-office-address-book.png'); ?></h3>
<div class="actions">
<ul>
<li><?php echo $html->link(__('New Address for this Customer', true), array('controller'=> 'addresses', 'action'=>'add/customerid:'.$customer['Customer']['id']));?><?php echo $html->link($html->image('address-book-new.png'), array('controller'=> 'addresses', 'action'=>'add/customerid:'.$customer['Customer']['id']), null, null, false); ?> </li>
</ul>
</div>
<?php if (!empty($customer['Address'])) {
echo $this->element('address_table', $addresses);
}
else {
echo 'No Addresses for this Customer Yet';
}
?>
</div>
<div class="related">
<h3><?php __('Enquiries');?><?php echo $html->image('folder.png'); ?></h3>
<div class="actions">
@ -179,10 +163,37 @@
</div>
<div class="related">
<?=$this->element('job_table', array('jobs'=>$jobs));?>
</div>
<? debug($customer, true); ?>
<div class="related">
<?=$this->element('invoice_table', array('invoices'=>$invoices));?>
</div>
<?php debug($parent_industry_list); ?>
<div class="related">
<h3><?php __('Addresses');?><?php echo $html->image('x-office-address-book.png'); ?></h3>
<div class="actions">
<ul>
<li><?php echo $html->link(__('New Address for this Customer', true), array('controller'=> 'addresses', 'action'=>'add/customerid:'.$customer['Customer']['id']));?><?php echo $html->link($html->image('address-book-new.png'), array('controller'=> 'addresses', 'action'=>'add/customerid:'.$customer['Customer']['id']), null, null, false); ?> </li>
</ul>
</div>
<?php if (!empty($customer['Address'])) {
echo $this->element('address_table', $addresses);
}
else {
echo 'No Addresses for this Customer Yet';
}
?>
</div>
<? debug($jobs); ?>

View file

@ -52,7 +52,6 @@
<?php
//Allowed types to view in the browser.
$allowedTypes = array('text/plain', 'text/html');
$allowedTypes['text/plain'] = 1;
$allowedTypes['text/html'] = 1;
$thisType = $emailAttachment['type'];

View file

@ -1,5 +1,5 @@
<?php echo $javascript->link('email_table'); ?>
<? App::import('Sanitize'); ?>
<?php // if (!empty($emails)):?>
<div id="emailDiv">
@ -9,38 +9,41 @@
<th><?php __('Email Date'); ?></th>
<th><?php __('From'); ?></th>
<th><?php __('Subject'); ?></th>
<th>Action</th>
</tr>
<?php
$i = 0;
foreach ($emails as $email):
$class = null;
<?php
$i = 0;
foreach ($emails as $email):
$class = null;
if ($i % 2 == 0) {
$class = ' class="altrow"';
}
$i++;
if ($i % 2 == 0) {
$class = ' class="altrow"';
}
$i++;
?>
?>
<tr<?php echo $class;?>>
<td> <?php echo date('j M Y @ G:i', $email['Email']['udate']); ?></td>
<td><?php
if(!empty($email['User']['first_name']) && !empty($email['User']['last_name'])) {
echo $html->link($email['User']['first_name'].' '.$email['User']['last_name'], array('controller'=>'users','action'=>'view', $email['User']['id']));
}
else {
echo $html->link($email['User']['email'], array('controller'=>'users','action'=>'view', $email['User']['id']));
}
?>
if(!empty($email['User']['first_name']) && !empty($email['User']['last_name'])) {
echo $html->link($email['User']['first_name'].' '.$email['User']['last_name'], array('controller'=>'users','action'=>'view', $email['User']['id']));
}
else {
echo $html->link($email['User']['email'], array('controller'=>'users','action'=>'view', $email['User']['id']));
}
?>
</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>
</tr>
<?php endforeach; ?>
echo $text->highlight($html->link(Sanitize::clean($email['Email']['subject']), '#', array('class'=>'viewLink', 'id'=>$email['Email']['id'])), 'Quotation');?>
<span class='viewLink' id="<? echo $email['Email']['id']?>">(<? echo $email['Email']['id']?>)</span>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?php //endif; ?>

View file

@ -189,4 +189,3 @@
echo "<h2>No matching records found :( Try modifying your search terms</h2>";
}
?>

View file

@ -48,15 +48,12 @@
</dd>
</dl>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Invoice', true), array('action' => 'edit', $invoice['Invoice']['id'])); ?> </li>
<li><?php echo $html->link(__('Delete Invoice', true), array('action' => 'delete', $invoice['Invoice']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $invoice['Invoice']['id'])); ?> </li>
<li><?php echo $html->link(__('List Invoices', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Invoice', 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>
<li><?php echo $html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
</ul>
<div class="related">
<h3>
Emails for this Invoice<?php echo $html->image('internet-mail.png'); ?>
</h3>
<?php echo $this->element('email_table_ajax', array('emails' => $emails)); ?>
<?php //echo $this->element('email_table_ajax', $enquiry, array('cache'=>'+1 day')); ?>
</div>

View file

@ -122,4 +122,15 @@ foreach ($job['PurchaseOrder'] as $purchaseOrder):
<?php endif;?>
<div class="related">
<h3>
Emails for this Job<?php echo $html->image('internet-mail.png'); ?>
</h3>
<?php echo $this->element('email_table_ajax', array('emails' => $emails)); ?>
<?php //echo $this->element('email_table_ajax', $enquiry, array('cache'=>'+1 day')); ?>
</div>
<?php debug($job);?>

View file

@ -1260,3 +1260,8 @@ span.addLineItem {
width: 60%;
height: 30em;
}
.viewLink {
cursor: pointer;
}