From f3eadaecbafb83267399c489719d3e0b8f0419c7 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Wed, 4 Feb 2009 12:49:44 +1100 Subject: [PATCH] Nice changes. Cleaned up Enquiry adding, AJAXified it so you can add a new contact while adding an enquiry. Awesome commit. Hope it deploys well --- .gitignore | 7 +- controllers/addresses_controller.php | 26 ++--- controllers/contacts_controller.php | 22 +++- controllers/currencies_controller.php | 5 +- controllers/customers_controller.php | 7 +- controllers/enquiries_controller.php | 141 ++++++++++++-------------- models/address.php | 40 +++++++- models/enquiry.php | 9 +- tmp/.gitignore | 1 + views/addresses/add_another.ctp | 16 +++ views/addresses/index.ctp | 4 - views/addresses/remove_another.ctp | 6 ++ views/contacts/add.ctp | 1 - views/contacts/add_another.ctp | 19 ++++ views/contacts/add_one.ctp | 17 ++++ views/contacts/index.ctp | 5 +- views/contacts/remove_another.ctp | 7 ++ views/contacts/remove_one.ctp | 4 + views/customers/add.ctp | 43 ++++---- views/customers/view.ctp | 2 +- views/elements/enquiry_table.ctp | 4 +- views/enquiries/add.ctp | 15 ++- views/enquiries/view.ctp | 2 +- webroot/css/quotenik.css | 20 +++- webroot/img/edit-undo.png | Bin 0 -> 1601 bytes 25 files changed, 286 insertions(+), 137 deletions(-) create mode 100644 tmp/.gitignore create mode 100644 views/addresses/add_another.ctp create mode 100644 views/addresses/remove_another.ctp create mode 100644 views/contacts/add_another.ctp create mode 100644 views/contacts/add_one.ctp create mode 100644 views/contacts/remove_another.ctp create mode 100644 views/contacts/remove_one.ctp create mode 100644 webroot/img/edit-undo.png diff --git a/.gitignore b/.gitignore index c72753c9..be3f36d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ -tmp/* +tmp/logs/* +tmp/cache/models/* +tmp/cache/persistent/* +tmp/cache/views/* +tmp/sessions/* +tmp/tests/* *.tar.gz diff --git a/controllers/addresses_controller.php b/controllers/addresses_controller.php index 191cc839..7799b1a1 100755 --- a/controllers/addresses_controller.php +++ b/controllers/addresses_controller.php @@ -2,8 +2,8 @@ class AddressesController extends AppController { var $name = 'Addresses'; - var $helpers = array('Html', 'Form'); - + var $helpers = array('Html', 'Form', 'Ajax'); + var $components = array('RequestHandler'); function index() { $this->Address->recursive = 0; $this->set('addresses', $this->paginate()); @@ -41,6 +41,18 @@ class AddressesController extends AppController { $this->set(compact('customer', 'states', 'countries')); } + function add_another($increment) { + $this->set('increment', $increment); + $states = $this->Address->State->find('list'); + $countries = $this->Address->Country->find('list'); + $this->set('states', $states); + $this->set('countries', $countries); + } + function remove_another($increment) { + $this->set('increment', $increment); + } + + function edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash(__('Invalid Address', true)); @@ -63,16 +75,6 @@ class AddressesController extends AppController { $this->set(compact('customers','states','countries')); } - function delete($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid id for Address', true)); - $this->redirect(array('action'=>'index')); - } - if ($this->Address->del($id)) { - $this->Session->setFlash(__('Address deleted', true)); - $this->redirect(array('action'=>'index')); - } - } } ?> diff --git a/controllers/contacts_controller.php b/controllers/contacts_controller.php index f6f77e16..8891f91c 100755 --- a/controllers/contacts_controller.php +++ b/controllers/contacts_controller.php @@ -2,8 +2,8 @@ class ContactsController extends AppController { var $name = 'Contacts'; - var $helpers = array('Html', 'Form'); - + var $helpers = array('Html', 'Form', 'Ajax'); + var $components = array('RequestHandler'); var $paginate = array( 'Contact' => array('order' => array('Contact.customer_id' => 'asc')), 'Enquiry' => array('order' => array('Enquiry.id' => 'asc')) @@ -37,7 +37,7 @@ class ContactsController extends AppController { $this->redirect(array('controller'=>'Enquiries', 'action'=>'index')); } if (!empty($this->data)) { - $this->data['Contact']['name'] = $this->data['Contact']['first_name'].' '.$this->data['Contact']['last_name']; + $this->Contact->create(); if ($this->Contact->save($this->data)) { $this->Session->setFlash(__('The Contact has been saved', true)); @@ -51,6 +51,22 @@ class ContactsController extends AppController { $this->set(compact('customer')); } + function add_another($increment) { + $this->set('increment', $increment); + + } + function remove_another($increment) { + $this->set('increment', $increment); + } + function add_one($customerid) { + $this->set('customerid', $customerid); + } + 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')); + $this->set('contacts', $contacts); + $this->set('customerid', $customerid); + } function edit($id = null) { if (!$id && empty($this->data)) { diff --git a/controllers/currencies_controller.php b/controllers/currencies_controller.php index 4ee38ccb..cff4f706 100755 --- a/controllers/currencies_controller.php +++ b/controllers/currencies_controller.php @@ -2,7 +2,8 @@ class CurrenciesController extends AppController { var $name = 'Currencies'; - var $helpers = array('Html', 'Form'); + var $helpers = array('Html', 'Form'), 'Ajax'; + var $components = array('RequestHandler'); function index() { $this->Currency->recursive = 0; @@ -59,4 +60,4 @@ class CurrenciesController extends AppController { } } -?> \ No newline at end of file +?> diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index 7adfb1d2..fb3f1cb3 100755 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -2,8 +2,8 @@ class CustomersController extends AppController { var $name = 'Customers'; - var $helpers = array('Html', 'Form', 'Time'); - + var $helpers = array('Html', 'Form', 'Time', 'Ajax'); + var $components = array('RequestHandler'); var $paginate = array( 'Customer' => array('order' => array('Customer.name' => 'asc'), 'limit' => 200 @@ -28,8 +28,7 @@ class CustomersController extends AppController { function add() { if (!empty($this->data)) { - - + if($this->Customer->saveAll($this->data, array('validate'=>'first')) ) { $newcustomerid = $this->Customer->id; $this->Session->setFlash(__('The Customer has been saved', true)); diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 9c74fde1..37ab0a69 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -42,15 +42,6 @@ class EnquiriesController extends AppController { function add() { - - $states = $this->Enquiry->State->find('list'); - $countries = $this->Enquiry->Country->find('list', array('order'=> 'Country.name asc')); - $principles = $this->Enquiry->Principle->find('list', array('order' => 'Principle.name asc')); - $statuses = $this->Enquiry->Status->find('list'); - $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'))); - $this->set(compact('users', 'customers', 'states', 'countries', 'principles', 'statuses')); - - if(empty($this->data)) { $this->set('step', 1); } @@ -65,22 +56,71 @@ class EnquiriesController extends AppController { if(isset($customer)) { - /* Check if the customer exists in the database - otherwise send the user back to step 1*/ - if(!$customer) { - $this->Session->setFlash(__('The customer must already exist in the database. Please try again', true)); - $this->redirect(array('action'=>'add')); - } - $this->set('customer', $customer); - $contacts = $this->Enquiry->Contact->find('list', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id']))); + if(!$customer) { + $this->Session->setFlash(__('The customer must already exist in the database. Please try again', true)); + $this->redirect(array('action'=>'add')); + } + + $this->__showPage2($customer); + $this->render(); + + } + + 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; + $principle = $this->Enquiry->Principle->findById($this->data['Enquiry']['principle_id']); + $this->data['Enquiry']['principle_code'] = $principle['Principle']['code']; //Store which principle code this enquiry belongs to. + Sanitize::clean($this->data); + if(isset($this->data['Contact']['new'])) { + if($this->data['Contact']['new']) { + $this->Enquiry->Contact->save($this->data); + $this->data['Enquiry']['contact_id'] = $this->Enquiry->Contact->id; + } + } + + + if ($this->Enquiry->save($this->data)) { + $id = $this->Enquiry->id; + $this->__sendNewEnquiryEmail($id); + } 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'])); + } + } + } + + /* Internal function to display page 2 of the Add Enquiry Form Wizard + * to help make the flow-control logic of the add function clearer. + * */ + function __showPage2($customer) { + + /* Combine the first_name and last_name for the Contact Drop Down Box */ + $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id']))); + $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name')); + $states = $this->Enquiry->State->find('list'); + $countries = $this->Enquiry->Country->find('list', array('order'=> 'Country.name asc')); + $principles = $this->Enquiry->Principle->find('list', array('order' => 'Principle.name asc')); + $statuses = $this->Enquiry->Status->find('list'); + $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'))); + $this->set(compact('users', 'customers', 'states', 'countries', 'principles', 'statuses', 'contacts', 'customer')); $this->set('step',2); - - $this->set('contacts', $contacts); - $customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $customer['Customer']['id']))); $this->set('billing_addresses', $customerAddresses); $this->set('shipping_addresses', $customerAddresses); - + $this->set('errors', $this->Enquiry->invalidFields()); /* Feels like an ugly hack. But it gets the desired effect and it will do for now */ if(isset($customerAddresses[0]['BillingAddress'])) { @@ -95,62 +135,9 @@ class EnquiriesController extends AppController { $this->set('billing_addresses_list', 'No Addresses exist for this Customer. Please add one'); $this->set('shipping_addresses_list', 'No Addresses exist for this Customer. Please add one'); } - $this->render(); - - } - - if ( (!empty($this->data)) && ($this->data['Enquiry']['finished'] == 'true') ) { - $this->Enquiry->set($this->data); - if( !($this->Enquiry->validates()) ) { - $customer = $this->Enquiry->Customer->findByName($this->data['Customer']['name']); - - /* Feels like an ugly hack. But it gets the desired effect and it will do for now */ - - if(isset($customerAddresses[0]['BillingAddress'])) { - foreach ($customerAddresses as $address) { - $i = $address['BillingAddress']['id']; - $billing_address_list[$i] = $address['BillingAddress']['address'].'
'.$address['BillingAddress']['city'].' '.$address['State']['name'].' '.$address['BillingAddress']['postcode'].'
'.up($address['Country']['name']).'

'; - } - $this->set('billing_addresses_list', $billing_address_list); - $this->set('shipping_addresses_list', $billing_address_list); - } - else { - $this->set('billing_addresses_list', 'No Addresses exist for this Customer. Please add one'); - $this->set('shipping_addresses_list', 'No Addresses exist for this Customer. Please add one'); - } - - - $this->set('customer', $customer); - $contacts = $this->Enquiry->Contact->find('list', array('conditions' => array('Contact.customer_id' => $customer['Customer']['id']))); - $this->set('contacts', $contacts); - $this->set('billing_addresses', $this->Enquiry->BillingAddress->find('list', array('conditions'=>array('BillingAddress.customer_id' => $customer['Customer']['id'])))); - $this->set('shipping_addresses', $this->Enquiry->ShippingAddress->find('list', array('conditions'=>array('ShippingAddress.customer_id' => $customer['Customer']['id'])))); - $this->set('errors', $this->Enquiry->invalidFields()); - $this->set('step',2); - $this->render(); - - - } - else { - $this->Enquiry->create(); - - $enquiryno = $this->__generateEnquiryNumber($this->data); - $this->data['Enquiry']['title'] = $enquiryno; - $principle = $this->Enquiry->Principle->findById($this->data['Enquiry']['principle_id']); - $this->data['Enquiry']['principle_code'] = $principle['Principle']['code']; //Store which principle code this enquiry belongs to. - Sanitize::clean($this->data); - } - - if ($this->Enquiry->save($this->data)) { - $id = $this->Enquiry->id; - $this->__sendNewEnquiryEmail($id); - } else { - $this->Session->setFlash(__('The Enquiry could not be saved. Please, try again.', true)); - } - } - } + /* Generate Enquiry number and return it as a string */ function __generateEnquiryNumber($data) { @@ -278,7 +265,7 @@ class EnquiriesController extends AppController { $this->redirect(array('action'=>'view/'.$id), null, false); } else { - $this->Session->setFlash(__('The Enquiry has been added abut email to the contact has NOT been sent. Something went wrong.', true)); + $this->Session->setFlash(__('The Enquiry has been added but email to the contact has NOT been sent. Something went wrong.', true)); $this->redirect(array('action'=>'view/'.$id), null, false); $this->set('smtp-errors', $this->Email->smtpError); } @@ -306,7 +293,9 @@ class EnquiriesController extends AppController { $enquiry = $this->Enquiry->read(null, $id); $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'))); $customer = $this->Enquiry->Customer->findById($enquiry['Enquiry']['customer_id']); - $contacts = $this->Enquiry->Contact->find('list', array('conditions' => array('Contact.customer_id' => $enquiry['Enquiry']['customer_id'] ))); + + $contacts = $this->Enquiry->Contact->find('all', array('conditions' => array('Contact.customer_id' => $enquiry['Enquiry']['customer_id']))); + $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name')); $state = $this->Enquiry->State->findById($enquiry['Enquiry']['state_id']); $country = $this->Enquiry->Country->findById($enquiry['Enquiry']['country_id']); $principle = $this->Enquiry->Principle->findById($enquiry['Enquiry']['principle_id']); diff --git a/models/address.php b/models/address.php index 63d91e1c..d0f698c7 100755 --- a/models/address.php +++ b/models/address.php @@ -3,7 +3,45 @@ class Address extends AppModel { var $name = 'Address'; - + var $validate = array( + 'address' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please Enter the Addess', + 'required' => true, + 'allowEmpty' => false + ), + + 'city' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please Enter the City', + 'required' => true, + 'allowEmpty' => false + ), + 'state_id' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please select the State', + 'required' => true, + 'allowEmpty' => false + ), + 'postcode' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please enter the Post Code', + 'required' => true, + 'allowEmpty' => false + ), + 'country_id' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please select the Country', + 'required' => true, + 'allowEmpty' => false + ), + 'type' => array( + 'rule' => array('notEmpty'), + 'message' => 'Please select the Type of Address', + 'required' => true, + 'allowEmpty' => false + ), + ); diff --git a/models/enquiry.php b/models/enquiry.php index d4f60863..f30fe428 100755 --- a/models/enquiry.php +++ b/models/enquiry.php @@ -10,7 +10,11 @@ class Enquiry extends AppModel { 'message' => 'User ID must be selected', 'on' => 'create' ), - + 'title' => array( + 'rule' => 'notEmpty', + 'required' => true, + 'on' => 'create' + ), 'customer_id' => array( 'rule' => 'numeric', 'required' => true, @@ -24,6 +28,7 @@ class Enquiry extends AppModel { 'message' => 'Must choose a Contact for this Enquiry', 'on' => 'create' ), + 'customer_id' => array( 'rule' => 'numeric', 'required' => true, @@ -65,7 +70,7 @@ class Enquiry extends AppModel { 'gst' => array( 'rule' => 'numeric', 'required' => true, - 'message' => 'Must slect whether GST is applicable for this Enquiry', + 'message' => 'Must select whether GST is applicable for this Enquiry', 'on' => 'create' ) ); diff --git a/tmp/.gitignore b/tmp/.gitignore new file mode 100644 index 00000000..150f68c8 --- /dev/null +++ b/tmp/.gitignore @@ -0,0 +1 @@ +*/* diff --git a/views/addresses/add_another.ctp b/views/addresses/add_another.ctp new file mode 100644 index 00000000..97354cbd --- /dev/null +++ b/views/addresses/add_another.ctp @@ -0,0 +1,16 @@ + link('Remove this', array('controller' => 'addresses', 'action' => 'remove_another', $increment), array('update' => 'addresses'.$increment)); ?> + input("Address.$increment.address", array('label' => 'Address', 'title' => 'The Address to be added')); + echo $form->input("Address.$increment.city", array('label' => 'City', 'title' => 'Name of the City/Suburb for this Address')); + echo $form->input("Address.$increment.state_id", array('value' => $states)); + echo $form->input("Address.$increment.postcode", array('label' => 'Post Code', 'title' => 'The Post Code for this Address. Eg. 2015 for Alexandria')); + echo $form->input("Address.$increment.country_id", array('value' => $countries)); + echo $form->input("Address.$increment.type", array('label' => 'Address Type (Billing,Shipping or Both)', 'options' => array('Billing','Shipping', 'Both Shipping and Billing', 'Other'))); + + + $next = $increment; + $next++; + echo $ajax->link('Add another Address to this New Customer', array('controller' => 'addresses', 'action' => 'add_another',$next), array('update'=>'addresses'.$next)); + ?> +
diff --git a/views/addresses/index.ctp b/views/addresses/index.ctp index 5c5c5db3..78c82815 100755 --- a/views/addresses/index.ctp +++ b/views/addresses/index.ctp @@ -9,7 +9,6 @@ echo $paginator->counter(array( - @@ -30,9 +29,6 @@ foreach ($addresses as $address): - diff --git a/views/addresses/remove_another.ctp b/views/addresses/remove_another.ctp new file mode 100644 index 00000000..f169671b --- /dev/null +++ b/views/addresses/remove_another.ctp @@ -0,0 +1,6 @@ +link('Add an Address to this New Customer', array('controller' => 'addresses', 'action' => 'add_another',0), array('update'=>'addresses0')); +} +?> diff --git a/views/contacts/add.ctp b/views/contacts/add.ctp index bb0f14fa..18515e9c 100755 --- a/views/contacts/add.ctp +++ b/views/contacts/add.ctp @@ -4,7 +4,6 @@ input('customer_id'); - echo $form->input('name'); echo $form->input('first_name'); echo $form->input('last_name'); echo $form->input('email'); diff --git a/views/contacts/add_another.ctp b/views/contacts/add_another.ctp new file mode 100644 index 00000000..ca4634a0 --- /dev/null +++ b/views/contacts/add_another.ctp @@ -0,0 +1,19 @@ + + link('Remove this', array('controller' => 'contacts', 'action' => 'remove_another', $increment), array('update' => 'contacts'.$increment)); + + ?> + input("Contact.$increment.first_name"); + echo $form->input("Contact.$increment.last_name"); + echo $form->input("Contact.$increment.email"); + echo $form->input("Contact.$increment.phone"); + echo $form->input("Contact.$increment.mobile"); + echo $form->input("Contact.$increment.fax"); + echo $form->input("Contact.$increment.notes"); + + $next = $increment; + $next++; + echo $ajax->link('Add another Contact to this New Customer', array('controller' => 'contacts', 'action' => 'add_another',$next), array('update'=>'contacts'.$next)); + ?> +
diff --git a/views/contacts/add_one.ctp b/views/contacts/add_one.ctp new file mode 100644 index 00000000..86bb0273 --- /dev/null +++ b/views/contacts/add_one.ctp @@ -0,0 +1,17 @@ + + +link('Remove this', array('controller' => 'contacts', 'action' => 'remove_one', $customerid), array('update' => 'contact')); + + ?> + input("Contact.new", array('type'=>'hidden', 'value' => 'yes')); + echo $form->input("Contact.first_name"); + echo $form->input("Contact.last_name"); + echo $form->input("Contact.email"); + echo $form->input("Contact.phone"); + echo $form->input("Contact.mobile"); + echo $form->input("Contact.fax"); + echo $form->input("Contact.notes"); + echo $form->input("Contact.customer_id", array('type'=>'hidden', 'value' => $customerid)); + ?> diff --git a/views/contacts/index.ctp b/views/contacts/index.ctp index 484771f5..14782ce2 100755 --- a/views/contacts/index.ctp +++ b/views/contacts/index.ctp @@ -10,7 +10,6 @@ echo $paginator->counter(array( - @@ -34,9 +33,7 @@ foreach ($contacts as $contact): - + diff --git a/views/contacts/remove_another.ctp b/views/contacts/remove_another.ctp new file mode 100644 index 00000000..beb40dea --- /dev/null +++ b/views/contacts/remove_another.ctp @@ -0,0 +1,7 @@ +link('Add A Contact to this New Customer', array('controller' => 'contacts', 'action' => 'add_another',0), array('update'=>'contacts0')); +} +?> + diff --git a/views/contacts/remove_one.ctp b/views/contacts/remove_one.ctp new file mode 100644 index 00000000..72888d3d --- /dev/null +++ b/views/contacts/remove_one.ctp @@ -0,0 +1,4 @@ +input('contact_id', array('options' => $contacts)); +echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one', $customerid), array('update'=>'contact')); +?> diff --git a/views/customers/add.ctp b/views/customers/add.ctp index f7dcf50c..2a06716c 100755 --- a/views/customers/add.ctp +++ b/views/customers/add.ctp @@ -1,37 +1,40 @@ + +
+Tip: When adding/removing Contact/Address entry forms, removing the first contact/address form will remove all of the dynamically added forms.

Also note, do not submit blank Contacts or Addresses - it may cause validation to fail and you'll have to reenter the data. Remove any Contacts/Address forms you don't need.
+
+ create('Customer', array('action'=>'add'));?>
input('name', array('label'=>'Company Name', 'title' => 'The Company Name. Eg. XYZ Business Pty Ltd')); echo $form->input('abn', array('label'=>'ABN', 'title' => 'The 11-digit Australian Business Number for the new Customer. Enter numbers only, no dashes or punctuation')); - echo '
You will be able to add Contacts and Addresses to this Customer after it has been created'; - echo "

Please make sure that the Customer you are adding doesn't already exist on the ".$html->link('Customers Index', array('action' => 'index')).""; - /* - echo '
Add a Contact to this new Customer'; - echo $form->input('Contact.0.first_name'); - echo $form->input('Contact.0.last_name'); - echo $form->input('Contact.0.email'); - echo $form->input('Contact.0.phone'); - echo $form->input('Contact.0.mobile'); - echo $form->input('Contact.0.fax'); - echo $form->input('Contact.0.notes'); - */ - /*echo '
Add an Address for this Customer'; - echo $form->input('Address.0.name', array('label'=>'Short Name', 'title' => 'Short Name for this Address. eg. \'Head Quarters\', \'Manufacturing Plant No 7\' ')); - echo $form->input('Address.0.address'); - echo $form->input('Address.0.city'); - echo $form->input('Address.0.state_id'); - echo $form->input('Address.0.country_id'); - echo $form->input('Address.0.type', array('label' => 'Address Type (Billing,Shipping or Both)', 'options' => array('Billing','Shipping', 'Both Shipping and Billing'))); - */ + echo "

Please make sure that the Customer you are adding doesn't already exist on the ".$html->link('Customers Index', array('action' => 'index')).""; + echo '

'; + ?> +
+ link('Add A Contact to this New Customer', array('controller' => 'contacts', 'action' => 'add_another',0), array('update'=>'contacts0')); + echo $html->image('contact-new.png'); + ?> +
+ +
+ link('Add an Address to this New Customer', array('controller' => 'addresses', 'action' => 'add_another',0), array('update'=>'addresses0')); ?> + image('address-book-new.png'); ?> +
+ + end('Submit'); ?>
+
+
+ diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp index 4f817d49..208fc53c 100644 --- a/views/elements/enquiry_table.ctp +++ b/views/elements/enquiry_table.ctp @@ -88,8 +88,8 @@ foreach ($enquiries as $enquiry): -
sort('id');?>sort('name');?> sort('address');?> sort('city');?> sort('state_id');?> - -
sort('customer_id');?> sort('id');?>sort('name');?> sort('first_name');?> sort('last_name');?> sort('email');?> - - link($contact['email'], 'mailto:'.$contact['email']);?> link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?> - link($enquiry['Contact']['name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?> + + link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?> diff --git a/views/enquiries/add.ctp b/views/enquiries/add.ctp index a77df2c6..bcafd6d4 100755 --- a/views/enquiries/add.ctp +++ b/views/enquiries/add.ctp @@ -1,3 +1,10 @@ +
+ +Tip: You can add a new Contact to an Existing Customer while creating the enquiry. If the Contact you want to assign to the enquiry +doesn't appear in the drop down list, click 'New Contact' + +
+
create('Enquiry');?>
@@ -17,8 +24,14 @@ else { //echo $form->select('Contact.id', array(), null, array('id'=>'contacts')); echo $form->input('Customer.name', array('readonly'=>'readonly', 'value'=>$customer['Customer']['name'])); + echo $form->input('user_id', array('label' =>'Assigned to User'), $users); - echo $form->input('contact_id'); + echo '
'; + echo $form->input('contact_id', array('div' => false)); + echo '
'; + echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one',$customer['Customer']['id']), array('update'=>'contact')); + echo $html->image('contact-new.png'); + echo '
'; echo 'The Contact will be emailed informing them of the new Enquiry'; echo $form->input('state_id'); echo $form->input('country_id'); diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp index 1a1c3d69..8511d5a8 100755 --- a/views/enquiries/view.ctp +++ b/views/enquiries/view.ctp @@ -19,7 +19,7 @@ > > - link($enquiry['Contact']['name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?> + link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?>   > diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index f667ae05..0dbe21a6 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -390,7 +390,7 @@ dd.altrow { /* Forms */ form { - clear: both; + clear: left; margin-right: 20px; padding: 0; width: 50%; @@ -671,6 +671,14 @@ div.auto_complete { margin :0px; padding :0px; } + +div.tipbox { + float: right; + width: 30%; + border: 1px dashed #000000; + background: #90EE90; +} + li.selected { background-color: #ffb; } span { @@ -681,7 +689,15 @@ span { span.note { font-size: 85%; - } + } +span.warning { + font-size: 80%; + color: #FF0000; + } + +span.tip { + color: #000000; + } div#qTip { padding: 3px; diff --git a/webroot/img/edit-undo.png b/webroot/img/edit-undo.png new file mode 100644 index 0000000000000000000000000000000000000000..61b2ce9a5310fb03eac84ae2710e20bfca3f9e75 GIT binary patch literal 1601 zcmV-H2EO@;P)jN5&vp3=Xo2yjp{$HjMoWQ8Y47Fs_P(5#-{T+cy=VU(0=Vr23Vn)*n=t&##vteH1lGz-Hp)1QD^r zHWv@PAaR6q8t{8Dyt;O)o|-Ozlxjp>d*mDC(WOrnj*Be=;v5?9`Hhx`BKt8w4(JRZ4cn-0$iU~jub!Zz&-7OsDwq4}#34f;`k2mr+g z^(FyaFdk~I68J-4#t^FtyX>QgQ_tw&zx_*nhcccw`e^GWeQ{aX4OS|6}Qz#}-6Ce5dV?@56Wl`02MnQvgJ2cYp?{ra?1kFp8f! zfpJd*LH=2G*~jqA8tpywT>rcX%U5jFYub0oPS~F;%YR#R5l1QaW^rj^@#nODKSnGzZxMj0m z&ibsmeD=-P&K~_;+Nt^?c4YPc7O02sWde6Rwk|Pz;lWF1kAJK8P{+mhj%KHHeH51Wrp|^FbzWS*x zx-%Z5F)B-KQGQMAdU3LcmCKw@9=7=S%ni0U{R(0)WecVmQzx-}zM=F~R5vtmN znsJJgux-0$TOQIK8f2dsIJqxng&IJ@s7d04K;a{^0GP0rE&77-yw9FF`r6g_KMff}Ak zUA^Logu$vHGd7F}@5~B7Cd?8M`_o$(=di&4W;JWPYzd#5mEBqe_XMLh-EI|W2*AN>@ z_?FKvuhS}QL?R-SP&t>Pd9f3XB8fyk8x_#In{a;i1P7Ni)zy|)g@VD;Bi6`B=IPHo z%#Q)1swSuD6o^|z;-y?Df=MLu!nx6WeH(3+)gd<&F{g$GV)Nti%z+)d*~P@igiLPK zsH%#p=5}rui4|WL{#FQ*GXt1szsuUDrPd>L_2E=1?nXz4&B^clf~Vd(PAa!%(gRgB zIe;4pPiHQGxqT7#laI2lv4PcqSg@y(s=yL1V+P&hYN)u1o}rFLB^3fDwn z^(rdv`8YLqHF5hbbu9FK#$qvs_8#QKuU_Fwv1q|{kUxUS9Jmq0HHlbNgD5-j;W zPyjO(Kz><~cy7!`pjdR;08>Df5}#0>;RF8*=LG0fU`oJY00000NkvXXu0mjfTzv$L literal 0 HcmV?d00001