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('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('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)); $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']); $contents = file_get_contents($file_path."/".$file['EmailAttachment']['name']);
if($file['EmailAttachment']['type'] == 'text/plain') {
$contents = nl2br($contents, true);
}
$this->set('contents', $contents); $this->set('contents', $contents);
} }

View file

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

View file

@ -2,7 +2,7 @@
class InvoicesController extends AppController { class InvoicesController extends AppController {
var $name = 'Invoices'; var $name = 'Invoices';
var $helpers = array('Html', 'Form', 'Time'); var $helpers = array('Html', 'Form', 'Time', 'Text','Javascript');
var $paginate = array( var $paginate = array(
@ -21,7 +21,17 @@ class InvoicesController extends AppController {
$this->Session->setFlash(__('Invalid Invoice.', true)); $this->Session->setFlash(__('Invalid Invoice.', true));
$this->redirect(array('action'=>'index')); $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,156 +2,167 @@
class JobsController extends AppController { class JobsController extends AppController {
var $name = 'Jobs'; var $name = 'Jobs';
var $helpers = array('Html', 'Form'); var $helpers = array('Html', 'Form', 'Text', 'Javascript');
var $components = array('RequestHandler'); var $components = array('RequestHandler');
var $paginate = array(
'contain' => false, var $paginate = array(
'limit' => 100,
'order'=>array('Job.id' => 'desc') 'contain' => false,
'limit' => 100,
'order'=>array('Job.id' => 'desc')
); );
function index() { function index() {
//$this->Job->recursive = 1; //$this->Job->recursive = 1;
$this->set('jobs', $this->paginate()); $this->set('jobs', $this->paginate());
$this->set('customers', $this->Job->Enquiry->Customer->find('list')); $this->set('customers', $this->Job->Enquiry->Customer->find('list'));
$this->set('currencies', $this->Job->Currency->find('list')); $this->set('currencies', $this->Job->Currency->find('list'));
} }
function view($id = null) { function view($id = null) {
if (!$id) { if (!$id) {
$this->flash(__('Invalid Job', true), array('action'=>'index')); $this->flash(__('Invalid Job', true), array('action'=>'index'));
} }
$job = $this->Job->read(null, $id); $job = $this->Job->read(null, $id);
$this->set('job', $job);
$this->set('customer', $this->Job->Enquiry->Customer->findById($job['Enquiry']['customer_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->set('principles', $this->Job->PurchaseOrder->Principle->find('list'));
$this->pageTitle = $job['Job']['title']; $this->pageTitle = $job['Job']['title'];
} }
function add() { function add() {
if (!empty($this->data)) {
$this->Job->create();
$job_offset = 6141; if (!empty($this->data)) {
$this->Job->create();
$number_of_jobs = $this->Job->findCount(); $job_offset = 6141;
$new_job_number = $job_offset + $number_of_jobs;
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']); $number_of_jobs = $this->Job->findCount();
$new_job_number = $job_offset + $number_of_jobs;
$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)) { if ($this->Job->save($this->data)) {
$jobid = $this->Job->id; $jobid = $this->Job->id;
//$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won'; //$this->Job->Enquiry->set('status_id', 3); //Change status to 'Job Won';
$enquiry['Enquiry']['status_id'] = 3; $enquiry['Enquiry']['status_id'] = 3;
$this->Job->Enquiry->save($enquiry); $this->Job->Enquiry->save($enquiry);
$this->Session->setFlash(__('Job Saved', true)); $this->Session->setFlash(__('Job Saved', true));
$this->redirect(array('action'=>'view', $jobid)); $this->redirect(array('action'=>'view', $jobid));
} else { } else {
$this->Session->setFlash(__('Please Fix the Errors Below', true)); $this->Session->setFlash(__('Please Fix the Errors Below', true));
$enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']); $enquiry = $this->Job->Enquiry->findById($this->data['Job']['enquiry_id']);
$this->set(compact('enquiry')); $this->set(compact('enquiry'));
} }
} }
else { else {
if(isset($this->params['named']['enquiryid'])) { 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'));
}
}
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer"); $this->set(compact('enquiry'));
$this->set('freight_paid_options', $freight_paid_options); }
else {
$this->Session->setFlash(__('Invalid Enquiry ID', true));
$this->redirect(array('action'=>'index'));
}
}
$sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); $freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
$this->set('sale_category_options', $sale_category_options); $this->set('freight_paid_options', $freight_paid_options);
$shipment_category_options = array( $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION");
"AUSTRALIA"=>"AUSTRALIA", $this->set('sale_category_options', $sale_category_options);
"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) { function edit($id = null) {
if (!$id && empty($this->data)) { if (!$id && empty($this->data)) {
$this->flash(__('Invalid Job', true), array('action'=>'index')); $this->flash(__('Invalid Job', true), array('action'=>'index'));
} }
if (!empty($this->data)) { if (!empty($this->data)) {
$jobid = $this->data['Job']['id']; $jobid = $this->data['Job']['id'];
if ($this->Job->save($this->data)) { if ($this->Job->save($this->data)) {
// $this->flash(__('The Job has been saved.', true), array('action'=>'view', $jobid)); // $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 { } else {
} }
} }
if (empty($this->data)) { if (empty($this->data)) {
$job = $this->Job->read(null, $id); $job = $this->Job->read(null, $id);
$this->data = $job; $this->data = $job;
$this->set('currencies', $this->Job->Currency->find('list')); $this->set('currencies', $this->Job->Currency->find('list'));
} }
$freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer"); $freight_paid_options = array("CMC"=>"CMC", "Customer"=>"Customer");
$this->set('freight_paid_options', $freight_paid_options); $this->set('freight_paid_options', $freight_paid_options);
$sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION"); $sale_category_options = array("INDENT"=>"INDENT", "STOCK"=>"STOCK", "COMMISSION"=>"COMMISSION");
$this->set('sale_category_options', $sale_category_options); $this->set('sale_category_options', $sale_category_options);
$shipment_category_options = array( $shipment_category_options = array(
"AUSTRALIA"=>"AUSTRALIA", "AUSTRALIA"=>"AUSTRALIA",
"EXPORT"=>"EXPORT", "EXPORT"=>"EXPORT",
"DIRECT-INTL"=>"DIRECT-INTL", "DIRECT-INTL"=>"DIRECT-INTL",
"DIRECT-AUST"=>"DIRECT-AUST", "DIRECT-AUST"=>"DIRECT-AUST",
"NO-SHIP"=>"NO-SHIP" "NO-SHIP"=>"NO-SHIP"
); );
$this->set('shipment_category_options', $shipment_category_options); $this->set('shipment_category_options', $shipment_category_options);
} }
/* /*
function delete($id = null) { function delete($id = null) {
if (!$id) { if (!$id) {
$this->flash(__('Invalid Job', true), array('action'=>'index')); $this->flash(__('Invalid Job', true), array('action'=>'index'));
@ -160,18 +171,27 @@ class JobsController extends AppController {
$this->flash(__('Job deleted', true), array('action'=>'index')); $this->flash(__('Job deleted', true), array('action'=>'index'));
} }
} }
*/ */
function __isNotEmptyDate($date) { function __isNotEmptyDate($date) {
if($date == "0000-00-00") { if($date == "0000-00-00") {
return true; return true;
} }
else { else {
return false; 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 <?php
class Customer extends AppModel { class Customer extends AppModel {
var $name = 'Customer'; var $name = 'Customer';
var $displayField = 'name'; var $displayField = 'name';
var $validate = array( var $validate = array(
'name' => array( 'name' => array(
'rule' => 'isUnique', 'rule' => 'isUnique',
'message' => 'This Customer name is already taken or has been left blank', 'message' => 'This Customer name is already taken or has been left blank',
'required' => true, 'required' => true,
'allowEmpty' => false), 'allowEmpty' => false),
'abn' => array(
'rule' => 'checkABN',
'required' => false,
'message' => 'ABN must contain 11 digits',
'allowEmpty' => true,
)
);
/* 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.
}
//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' => ''
)
);
var $belongsTo = array('CustomerCategory'=> 'abn' => array(
array('className' => 'CustomerCategory','foreignKey' => 'customer_category_id'), 'rule' => 'checkABN',
'Country' => 'required' => false,
array('className' =>'Country', 'foreignKey' => 'country_id') 'message' => 'ABN must contain 11 digits',
); 'allowEmpty' => true,
)
);
/* Custom Validation for ABN */
var $hasAndBelongsToMany = array (
'Industry' => array( function checkABN($data) {
'className' => 'Industry', $numbers = preg_replace("/\s*\D*/", "", $data['abn']);
'joinTable' => 'industries_customers', $length = strlen($numbers);
'foreignKey' => 'customer_id', return $length == 11;
'associationForeignKey' => 'industry_id' //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' => ''
),
'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 $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', 'Contact' => array('className' => 'User',
'foreignKey' => 'contact_user_id', 'foreignKey' => 'contact_user_id',
'conditions' => '', 'conditions' => array('Contact.type'=>'contact'),
'fields' => '', 'fields' => '',
'order' => '' 'order' => ''
), ),

View file

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

View file

@ -3,42 +3,46 @@ class Job extends AppModel {
var $name = 'Job'; var $name = 'Job';
var $validate = array( 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'), 'domestic_freight_paid_by' => array('notempty'),
'sale_category' => array('notempty'), 'sale_category' => array('notempty'),
'shipment_category' => array('notempty') 'shipment_category' => array('notempty')
); );
//The Associations below have been created with all possible keys, those that are not needed can be removed //The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array( var $belongsTo = array(
'Enquiry' => array( 'Enquiry' => array(
'className' => 'Enquiry', 'className' => 'Enquiry',
'foreignKey' => 'enquiry_id', 'foreignKey' => 'enquiry_id',
'conditions' => '', 'conditions' => '',
'fields' => '', 'fields' => '',
'order' => '', 'order' => '',
'counterCache' => true 'counterCache' => true
), ),
'Currency' 'Currency'
); );
var $hasAndBelongsToMany = array( var $hasAndBelongsToMany = array(
'PurchaseOrder' => array( 'PurchaseOrder' => array(
'className' => 'PurchaseOrder', 'className' => 'PurchaseOrder',
'joinTable' => 'jobs_purchase_orders', 'joinTable' => 'jobs_purchase_orders',
'unique' => true 'unique' => true
) ),
); 'Email' => array(
'className' => 'Email',
'joinTable' => 'emails_jobs',
)
);
} }
?> ?>

View file

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

View file

@ -145,22 +145,6 @@
</div> </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"> <div class="related">
<h3><?php __('Enquiries');?><?php echo $html->image('folder.png'); ?></h3> <h3><?php __('Enquiries');?><?php echo $html->image('folder.png'); ?></h3>
<div class="actions"> <div class="actions">
@ -179,10 +163,37 @@
</div> </div>
<div class="related">
<?=$this->element('job_table', array('jobs'=>$jobs));?>
</div> </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 <?php
//Allowed types to view in the browser. //Allowed types to view in the browser.
$allowedTypes = array('text/plain', 'text/html');
$allowedTypes['text/plain'] = 1; $allowedTypes['text/plain'] = 1;
$allowedTypes['text/html'] = 1; $allowedTypes['text/html'] = 1;
$thisType = $emailAttachment['type']; $thisType = $emailAttachment['type'];

View file

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

View file

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

View file

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

View file

@ -122,4 +122,15 @@ foreach ($job['PurchaseOrder'] as $purchaseOrder):
<?php endif;?> <?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);?> <?php debug($job);?>

View file

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