Ability to turn off Auto-Email

This commit is contained in:
Karl Cordes 2009-02-04 16:28:46 +11:00
parent f3eadaecba
commit f92d9d17bf
17 changed files with 87 additions and 40 deletions

View file

@ -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);
}

View file

@ -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';
}
}
?>

View file

@ -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;
if($this->data['Enquiry']['send_enquiry_email'] == 1) {
$this->__sendNewEnquiryEmail($id);
} else {
}
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);
}
}

2
tmp/.gitignore vendored
View file

@ -1 +1 @@
*/*

View file

@ -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');
}
?>

View file

@ -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');
}
?>

View file

@ -1,4 +1,6 @@
<?
echo $form->input('contact_id', array('options' => $contacts));
echo $form->input('contact_id', array('options' => $contacts, 'div' => false));
echo '<br>';
echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one', $customerid), array('update'=>'contact'));
echo $html->image('contact-new.png');
?>

View file

@ -1,16 +1,25 @@
<?php echo $this->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.
<br><br>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."));
?>
<div class="tipbox">
<span class="tip">Tip: When adding/removing Contact/Address entry forms, removing the first contact/address form will remove all of the dynamically added forms. <br><br>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.</span>
</div>
<div class="customers form">
<?php echo $form->create('Customer', array('action'=>'add'));?>
<fieldset>
<legend><?php __('Add Customer');?></legend>
<?php
echo $form->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 '<div class="input text">';
echo $form->label('Customer.name', 'Company Name');
echo $ajax->autoComplete('name', '/customers/completeCustomer');
echo "<br><br><span class=\"warning\">If the Customer you are adding appears automatically, it already exists in the ".$html->link('Customers Index', array('action' => 'index')). "<br>Do Not Add Duplicates.</span>";
echo '</div>';
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 "<br><br><span class=\"warning\">Please <i>make sure</i> that the Customer you are adding doesn't already exist on the ".$html->link('Customers Index', array('action' => 'index'))."</span>";
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 '<br><br>';
?>
<div id="contacts0">

View file

@ -0,0 +1,6 @@
<ul>
<?php foreach($customers as $customer): ?>
<li><?php echo $customer['Customer']['name']; ?></li>
<?php endforeach; ?>
</ul>

View file

@ -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');
?>
</fieldset>

View file

@ -16,6 +16,16 @@
<?php echo $time->nice($customer['Customer']['created']); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Discount and Pricing Policies'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $customer['Customer']['discount_pricing_policies']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Payment Terms'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $customer['Customer']['payment_terms']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $customer['Customer']['notes']; ?>

View file

@ -95,7 +95,7 @@ foreach ($enquiries as $enquiry):
<? //BCC address to Con is hardcoded in here. ?>
<?php echo $html->link($enquiry['Contact']['email'], 'mailto:'.$enquiry['Contact']['email'].'?subject='.$enquiry['Enquiry']['title'].'&bcc=carpis@cmctechnologies.com.au'); ?>
</td>
<td class = "nowrap">
<td>
<?php echo $enquiry['Contact']['phone']; ?>
</td>
<td>

View file

@ -0,0 +1,5 @@
<?
echo $form->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')));
?>

View file

@ -0,0 +1,6 @@
<div class="tipbox">
<?php echo $html->image('tip.png'); ?>
<span class="tip">
<?php echo $tip; ?>
</span>
</div>

View file

@ -1,9 +1,6 @@
<div class="tipbox">
<span class="tip">
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'
</span>
</div>
<?php echo $this->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'")); ?>
<div class="enquiries form">
<?php echo $form->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 '<span>After submitting it will take a moment to email the customer before you are redirected to the new Enquiry.</span>';
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>';
}
?>

View file

@ -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; }

BIN
webroot/img/tip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB