diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php
index 8891f91c..4be07d60 100755
--- a/controllers/contacts_controller.php
+++ b/controllers/contacts_controller.php
@@ -63,7 +63,7 @@ class ContactsController extends AppController {
}
function remove_one($customerid) {
$contacts = $this->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customerid)));
- $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0}, {1}', '{n}.Contact.first_name', '{n}.Contact.last_name'));
+ $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name'));
$this->set('contacts', $contacts);
$this->set('customerid', $customerid);
}
diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php
index fb3f1cb3..8fbf7246 100755
--- a/controllers/customers_controller.php
+++ b/controllers/customers_controller.php
@@ -52,7 +52,8 @@ class CustomersController extends AppController {
if (!empty($this->data)) {
if ($this->Customer->save($this->data)) {
$this->Session->setFlash(__('The Customer has been saved', true));
- $this->redirect(array('action'=>'index'));
+ $id = $this->Customer->id;
+ $this->redirect(array('action'=>'view/'.$id));
} else {
$this->Session->setFlash(__('The Customer could not be saved. Please, try again.', true));
}
@@ -62,6 +63,18 @@ class CustomersController extends AppController {
}
}
+ /* Autocomplete the customer name - Used in: add.ctp */
+ function completeCustomer() {
+
+ $this->set('customers', $this->Customer->find('all', array(
+ 'conditions' => array(
+ 'Customer.name LIKE' => '%'.$this->data['Customer']['name'].'%'
+ ),'fields' => array('Customer.name')
+ )));
+ $this->layout = 'ajax';
+
+ }
+
}
?>
diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php
index 37ab0a69..3bb92cd8 100755
--- a/controllers/enquiries_controller.php
+++ b/controllers/enquiries_controller.php
@@ -68,16 +68,7 @@ class EnquiriesController extends AppController {
}
if ( (!empty($this->data)) && ($this->data['Enquiry']['finished'] == 'true') ) {
- /*
- $this->Enquiry->set($this->data);
- /* Page to display if Validation Fails
- if( !($this->Enquiry->validates()) ) {
- $this->__showPage2($this->data);
-
- }
- *
- else {
- */
+
$this->Enquiry->create();
$enquiryno = $this->__generateEnquiryNumber($this->data);
$this->data['Enquiry']['title'] = $enquiryno;
@@ -94,8 +85,15 @@ class EnquiriesController extends AppController {
if ($this->Enquiry->save($this->data)) {
$id = $this->Enquiry->id;
- $this->__sendNewEnquiryEmail($id);
- } else {
+ if($this->data['Enquiry']['send_enquiry_email'] == 1) {
+ $this->__sendNewEnquiryEmail($id);
+ }
+ else {
+ $this->Session->setFlash(__('The Enquiry has been saved but the Contact has NOT been emailed, as you requested.', true));
+ $this->redirect(array('action'=>'view/'.$id), null, false);
+ }
+ }
+ else {
$this->Session->setFlash(__('The Enquiry could not be saved. Please, try again.', true));
$this->__showPage2($this->Enquiry->Customer->findById($this->data['Enquiry']['customer_id']));
}
@@ -324,15 +322,11 @@ class EnquiriesController extends AppController {
$this->set(compact('enquiry', 'users','customer','contacts','state','country','principles','principle','statuses', 'addresses'));
}
- function delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for Enquiry', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->Enquiry->del($id)) {
- $this->Session->setFlash(__('Enquiry deleted', true));
- $this->redirect(array('action'=>'index'));
+ function update_status($enquiryid) {
+ if(!empty($this->data)) {
+ $this->Enquiry->save($this->data);
}
+
}
diff --git a/tmp/.gitignore b/tmp/.gitignore
index 150f68c8..8b137891 100644
--- a/tmp/.gitignore
+++ b/tmp/.gitignore
@@ -1 +1 @@
-*/*
+
diff --git a/views/addresses/remove_another.ctp b/views/addresses/remove_another.ctp
index f169671b..daeea167 100644
--- a/views/addresses/remove_another.ctp
+++ b/views/addresses/remove_another.ctp
@@ -2,5 +2,6 @@
if($increment == 0) {
echo $ajax->link('Add an Address to this New Customer', array('controller' => 'addresses', 'action' => 'add_another',0), array('update'=>'addresses0'));
+ echo $html->image('address-book-new.png');
}
?>
diff --git a/views/contacts/remove_another.ctp b/views/contacts/remove_another.ctp
index beb40dea..8ca2ff6f 100644
--- a/views/contacts/remove_another.ctp
+++ b/views/contacts/remove_another.ctp
@@ -2,6 +2,7 @@
if($increment == 0) {
echo $ajax->link('Add A Contact to this New Customer', array('controller' => 'contacts', 'action' => 'add_another',0), array('update'=>'contacts0'));
+ echo $html->image('contact-new.png');
}
?>
diff --git a/views/contacts/remove_one.ctp b/views/contacts/remove_one.ctp
index 72888d3d..cd3d1e05 100644
--- a/views/contacts/remove_one.ctp
+++ b/views/contacts/remove_one.ctp
@@ -1,4 +1,6 @@
-echo $form->input('contact_id', array('options' => $contacts));
+echo $form->input('contact_id', array('options' => $contacts, 'div' => false));
+echo '
';
echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one', $customerid), array('update'=>'contact'));
+echo $html->image('contact-new.png');
?>
diff --git a/views/customers/add.ctp b/views/customers/add.ctp
index 2a06716c..b7064348 100755
--- a/views/customers/add.ctp
+++ b/views/customers/add.ctp
@@ -1,16 +1,25 @@
+element('tipbox', array('tip' => "Tip: When adding or removing Contact/Address entry forms, removing the first contact/address form will remove all of the dynamically added forms.
+
Also, don't submit blank Contacts or Addresses - it may cause validation to fail and you'll have to re-enter the data. Remove any Contacts/Address forms you don't need."));
+?>
-