Changed the logic a little bit in the customer model saveCustomer function, such that we can provide a default customer name if otherwise unspecified. Changed the page titles to reflect Customer vs Contact, since they can easily have the same names.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@228 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-06 16:57:23 +00:00
parent aa12a1efa4
commit 1d82e263ad
3 changed files with 50 additions and 26 deletions

View File

@@ -256,7 +256,7 @@ class CustomersController extends AppController {
}
// Prepare to render.
$title = $customer['Customer']['name'];
$title = 'Customer: ' . $customer['Customer']['name'];
$this->set(compact('customer', 'title',
'outstanding_balance',
'outstanding_deposit'));
@@ -281,6 +281,20 @@ class CustomersController extends AppController {
return;
}
// Make sure we have at least one contact
if (!isset($this->data['Contact']) || count($this->data['Contact']) == 0) {
$this->Session->setFlash("MUST SPECIFY AT LEAST ONE CONTACT", true);
$this->redirect(array('action'=>'view', $this->data['Customer']['id']));
return;
}
// Make sure there is a primary contact
if (!isset($this->data['Customer']['primary_contact_entry'])) {
$this->Session->setFlash("MUST SPECIFY A PRIMARY CONTACT", true);
$this->redirect(array('action'=>'view', $this->data['Customer']['id']));
return;
}
// Go through each customer and strip the bogus ID if new
foreach ($this->data['Contact'] AS &$contact) {
if (isset($contact['source']) && $contact['source'] === 'new')
@@ -303,7 +317,7 @@ class CustomersController extends AppController {
if ($id) {
$this->data = $this->Customer->details($id);
$title = $this->data['Customer']['name'] . " : Edit";
$title = 'Customer: ' . $this->data['Customer']['name'] . " : Edit";
}
else {
$title = "Enter New Customer";