Changed Enquiry Adding. Cleaned up cruft left over from previous method of adding
This commit is contained in:
parent
ebfced738a
commit
eb556f9780
|
|
@ -52,18 +52,7 @@ class EnquiriesController extends AppController {
|
|||
|
||||
function add() {
|
||||
|
||||
/*
|
||||
* These were depreciated by the move to only add enquiries from the Customer View page.
|
||||
* if(empty($this->data)) {
|
||||
$this->set('step', 1);
|
||||
}
|
||||
|
||||
elseif( (!empty($this->data)) && ($this->data['Enquiry']['step'] == 1) ) {
|
||||
$customer = $this->Enquiry->Customer->findByName($this->data['Customer']['name']);
|
||||
} */
|
||||
|
||||
if(empty($this->data)) {
|
||||
|
||||
if(isset($this->params['named']['customerid'])) {
|
||||
$customer = $this->Enquiry->Customer->findById($this->params['named']['customerid']);
|
||||
}
|
||||
|
|
@ -85,11 +74,8 @@ class EnquiriesController extends AppController {
|
|||
|
||||
}
|
||||
|
||||
if ( (!empty($this->data)) && ($this->data['Enquiry']['finished'] == 'true') ) {
|
||||
|
||||
$this->Enquiry->create();
|
||||
$enquiryno = $this->__generateEnquiryNumber($this->data);
|
||||
$this->data['Enquiry']['title'] = $enquiryno;
|
||||
if (!empty($this->data)) {
|
||||
$customer = $this->Enquiry->Customer->findById($this->data['Enquiry']['customer_id']);
|
||||
$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);
|
||||
|
|
@ -99,8 +85,12 @@ class EnquiriesController extends AppController {
|
|||
$this->data['Enquiry']['contact_id'] = $this->Enquiry->Contact->id;
|
||||
}
|
||||
}
|
||||
$this->Enquiry->set($this->data);
|
||||
if($this->Enquiry->validates()) {
|
||||
|
||||
|
||||
$enquiryno = $this->__generateEnquiryNumber($this->data);
|
||||
$this->data['Enquiry']['title'] = $enquiryno;
|
||||
$this->Enquiry->create();
|
||||
if ($this->Enquiry->save($this->data)) {
|
||||
$id = $this->Enquiry->id;
|
||||
if($this->data['Enquiry']['send_enquiry_email'] == 1) {
|
||||
|
|
@ -116,6 +106,16 @@ class EnquiriesController extends AppController {
|
|||
$this->__showPage2($this->Enquiry->Customer->findById($this->data['Enquiry']['customer_id']));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$this->set('errors', $this->Enquiry->invalidFields());
|
||||
$this->__showPage2($customer);
|
||||
$this->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Internal function to display page 2 of the Add Enquiry Form Wizard
|
||||
|
|
@ -132,7 +132,6 @@ class EnquiriesController extends AppController {
|
|||
$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);
|
||||
$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);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ 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,
|
||||
|
|
|
|||
|
|
@ -3,25 +3,12 @@
|
|||
doesn't appear in the drop down list, click 'New Contact'")); ?>
|
||||
|
||||
<div class="enquiries form">
|
||||
<?php echo $form->create('Enquiry');?>
|
||||
<?php echo $form->create('Enquiry', array('action' => 'add/customerid:'.$customer['Customer']['id']));?>
|
||||
<fieldset>
|
||||
<legend><?php __("New Enquiry: Step $step");?></legend>
|
||||
<legend><?php __("New Enquiry for: ".$customer['Customer']['name']);?></legend>
|
||||
<?php
|
||||
|
||||
if($step == 1) {
|
||||
echo '<div class="input text">';
|
||||
echo '<span>Start typing the Company name and it should appear in a list below. It must already exist in the database</span>';
|
||||
echo $form->label('Customer.name', 'Company Name');
|
||||
echo $ajax->autoComplete('Customer.name', '/enquiries/completeCustomer');
|
||||
echo '</div>';
|
||||
echo $form->input('step', array('type'=>'hidden', 'value' => $step));
|
||||
echo $form->input('finished', array('type' => 'hidden', 'value' => 'false'));
|
||||
echo $form->end('Proceed to Step 2');
|
||||
}
|
||||
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 '<div id="contact">';
|
||||
echo $form->input('contact_id', array('div' => false));
|
||||
|
|
@ -30,24 +17,19 @@ doesn't appear in the drop down list, click 'New Contact'")); ?>
|
|||
echo $html->image('contact-new.png');
|
||||
echo '</div>';
|
||||
echo '<span>The Contact will be emailed informing them of the new Enquiry</span>';
|
||||
echo $form->input('state_id');
|
||||
echo $form->input('state_id', array('label'=>'State', 'empty' => 'Please Choose A State'));
|
||||
echo $form->input('country_id');
|
||||
|
||||
echo $form->input('gst', array('label' => 'Is GST Applicable', 'options' => array('1' => 'Yes', '0' => 'No')));
|
||||
echo $form->input('principle_id');
|
||||
echo $form->input('principle_id', array('label'=>'Principle', 'empty'=>'Please Choose the Principle'));
|
||||
echo $form->input('status_id');
|
||||
echo $form->input('comments', array('maxlength' => '250000'));
|
||||
echo $form->input('customer_id', array('type'=>'hidden', 'value' => $customer['Customer']['id']));
|
||||
echo $form->input('finished', array('type' => 'hidden', 'value' => 'true'));
|
||||
|
||||
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->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 '<span>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.</span>';
|
||||
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
|
|
@ -58,3 +40,4 @@ doesn't appear in the drop down list, click 'New Contact'")); ?>
|
|||
<li><?php echo $html->link(__('New Customer', true), array('controller'=> 'customers', 'action'=>'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php pr($errors); ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue