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 @@ 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.")); +?> -
-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('name', array('label'=>'Company Name', 'title' => 'The Company Name. Eg. XYZ Business Pty Ltd')); + echo '
'; + echo $form->label('Customer.name', 'Company Name'); + echo $ajax->autoComplete('name', '/customers/completeCustomer'); + echo "

If the Customer you are adding appears automatically, it already exists in the ".$html->link('Customers Index', array('action' => 'index')). "
Do Not Add Duplicates.
"; + echo '
'; 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 "

Please make sure that the Customer you are adding doesn't already exist on the ".$html->link('Customers Index', array('action' => 'index')).""; + + echo $this->element('payment_terms_box'); + echo $form->input('discount_pricing_policies', array('label'=>'Discount and Pricing Policies')); + echo $form->input('notes', array('label' => 'Notes about this Customer')); + echo '

'; ?>
diff --git a/views/customers/complete_customer.ctp b/views/customers/complete_customer.ctp new file mode 100644 index 00000000..766e1aa3 --- /dev/null +++ b/views/customers/complete_customer.ctp @@ -0,0 +1,6 @@ +
    + +
  • + +
+ diff --git a/views/customers/edit.ctp b/views/customers/edit.ctp index 7f61bcdd..c0a16c85 100755 --- a/views/customers/edit.ctp +++ b/views/customers/edit.ctp @@ -6,6 +6,8 @@ echo $form->input('id'); echo $form->input('name'); echo $form->input('abn'); + echo $this->element('payment_terms_box'); + echo $form->input('discount_pricing_policies', array('label'=>'Discount and Pricing Policies')); echo $form->input('notes'); ?>
diff --git a/views/customers/view.ctp b/views/customers/view.ctp index 7f753f0f..65f40d17 100755 --- a/views/customers/view.ctp +++ b/views/customers/view.ctp @@ -16,6 +16,16 @@ nice($customer['Customer']['created']); ?>   + > + > + +   + + > + > + +   + > > diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp index 208fc53c..270f373b 100644 --- a/views/elements/enquiry_table.ctp +++ b/views/elements/enquiry_table.ctp @@ -95,7 +95,7 @@ foreach ($enquiries as $enquiry): link($enquiry['Contact']['email'], 'mailto:'.$enquiry['Contact']['email'].'?subject='.$enquiry['Enquiry']['title'].'&bcc=carpis@cmctechnologies.com.au'); ?> - + diff --git a/views/elements/payment_terms_box.ctp b/views/elements/payment_terms_box.ctp new file mode 100644 index 00000000..73d031f9 --- /dev/null +++ b/views/elements/payment_terms_box.ctp @@ -0,0 +1,5 @@ +input('payment_terms', array('options' => array( +'100% Payment with Order' => '100% Payment with Order', +'Net 30 Days for Approved Accounts' => 'Net 30 Days for Approved Accounts'))); +?> diff --git a/views/elements/tipbox.ctp b/views/elements/tipbox.ctp new file mode 100644 index 00000000..469e2cdc --- /dev/null +++ b/views/elements/tipbox.ctp @@ -0,0 +1,6 @@ +
+image('tip.png'); ?> + + + +
diff --git a/views/enquiries/add.ctp b/views/enquiries/add.ctp index bcafd6d4..eaba3f98 100755 --- a/views/enquiries/add.ctp +++ b/views/enquiries/add.ctp @@ -1,9 +1,6 @@ -
- -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' - -
+element('tipbox', array('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');?> @@ -46,8 +43,9 @@ doesn't appear in the drop down list, click 'New Contact' echo $form->input('step', array('type'=>'hidden', 'value' => $step)); echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio')); echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio')); - echo $form->end('Add Enquiry and Email Customer'); - echo 'After submitting it will take a moment to email the customer before you are redirected to the new Enquiry.'; + echo $form->input('send_enquiry_email', array('label' => 'Send the Contact an Enquiry Confirmation Email', 'type' => 'select', 'selected' => 1, 'options' => array(1 => 'Yes', 0 => 'No'))); + echo $form->end('Add Enquiry'); + echo 'After submitting it will take a moment to email the customer, if you selected the checkbox above, before you are redirected to the new Enquiry.'; } ?> diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index 0dbe21a6..df7bd867 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -380,7 +380,7 @@ dt.altrow { background: #E6F0F0; } dd { - margin-left: 15em; + margin-left: 20em; margin-top: -2em; vertical-align: top; } @@ -676,7 +676,7 @@ div.tipbox { float: right; width: 30%; border: 1px dashed #000000; - background: #90EE90; + background: #DBFFB4; } li.selected { background-color: #ffb; } diff --git a/webroot/img/tip.png b/webroot/img/tip.png new file mode 100644 index 00000000..2ac57475 Binary files /dev/null and b/webroot/img/tip.png differ