Making quick add enquiry fix

This commit is contained in:
Karl Cordes 2011-07-15 16:33:31 +10:00
parent b382094091
commit 476be0674f
3 changed files with 39 additions and 44 deletions

View file

@ -23,10 +23,10 @@ class EnquiriesController extends AppController {
$this->Enquiry->recursive = 0; $this->Enquiry->recursive = 0;
$this->set('enquiries', $this->paginate()); $this->set('enquiries', $this->paginate());
$status_list = $this->Enquiry->Status->getJSON(); $status_list = $this->Enquiry->Status->getJSON();
$this->set('status_list', $status_list); $this->set('status_list', $status_list);
$classNames = $this->Enquiry->Status->getClassNamesJSON(); $classNames = $this->Enquiry->Status->getClassNamesJSON();
$this->set('class_names', $classNames); $this->set('class_names', $classNames);
//debug($this->paginate()); //debug($this->paginate());
// $this->set('status_list', $this->Enquiry->Status->find('list')); // $this->set('status_list', $this->Enquiry->Status->find('list'));
@ -77,18 +77,17 @@ class EnquiriesController extends AppController {
} }
function add() { /* function add() {
$this->set('users',$this->Enquiry->User->find('list', array('conditions'=>array('User.type'=>'user', 'User.enabled'=>true)))); $this->set('users',$this->Enquiry->User->find('list', array('conditions'=>array('User.type'=>'user', 'User.enabled'=>true))));
} }*/
/*
function add() { function add() {
if(empty($this->data)) { if(empty($this->data)) {
if(isset($this->params['named']['customerid'])) { if(isset($this->params['named']['customerid'])) {
$customer = $this->Enquiry->Cu $customer = $this->Enquiry->Customer->findById($this->params['named']['customerid']);
* stomer->findById($this->params['named']['customerid']);
} }
else { else {
$this->Session->setFlash(__('The customer must already exist in the database. Please add Enquiries to an existing Customer', true)); $this->Session->setFlash(__('The customer must already exist in the database. Please add Enquiries to an existing Customer', true));
@ -96,9 +95,9 @@ class EnquiriesController extends AppController {
} }
} }
if(isset($customer)) {*/ if(isset($customer)) {
/* Check if the customer exists in the database - otherwise send the user back to step 1*/ /* Check if the customer exists in the database - otherwise send the user back to step 1*/
/*if(!$customer) { if(!$customer) {
$this->Session->setFlash(__('The customer must already exist in the database. Please try again', true)); $this->Session->setFlash(__('The customer must already exist in the database. Please try again', true));
$this->redirect(array('action'=>'add')); $this->redirect(array('action'=>'add'));
} }
@ -150,15 +149,15 @@ class EnquiriesController extends AppController {
} }
} }
}*/ }
/* Internal function to display page 2 of the Add Enquiry Form Wizard /* Internal function to display page 2 of the Add Enquiry Form Wizard
* to help make the flow-control logic of the add function clearer. * to help make the flow-control logic of the add function clearer.
* */ * */
/* function __showPage2($customer) { */ function __showPage2($customer) {
/* Combine the first_name and last_name for the Contact Drop Down Box */ /* 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 = $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')); $contacts = Set::Combine($contacts, '{n}.Contact.id', array('{0} {1}', '{n}.Contact.first_name', '{n}.Contact.last_name'));
$states = $this->Enquiry->State->find('list'); $states = $this->Enquiry->State->find('list');
$countries = $this->Enquiry->Country->find('list', array('order'=> 'Country.name asc')); $countries = $this->Enquiry->Country->find('list', array('order'=> 'Country.name asc'));
@ -169,9 +168,9 @@ class EnquiriesController extends AppController {
$customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $customer['Customer']['id']))); $customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $customer['Customer']['id'])));
$this->set('billing_addresses', $customerAddresses); $this->set('billing_addresses', $customerAddresses);
$this->set('shipping_addresses', $customerAddresses); $this->set('shipping_addresses', $customerAddresses);
$this->set('errors', $this->Enquiry->invalidFields()); */ $this->set('errors', $this->Enquiry->invalidFields());
/* Feels like an ugly hack. But it gets the desired effect and it will do for now */ /* Feels like an ugly hack. But it gets the desired effect and it will do for now */
/*
if(isset($customerAddresses[0]['BillingAddress'])) { if(isset($customerAddresses[0]['BillingAddress'])) {
$billing_address_list[0] = "No Address Selected"; $billing_address_list[0] = "No Address Selected";
foreach ($customerAddresses as $address) { foreach ($customerAddresses as $address) {
@ -185,8 +184,7 @@ class EnquiriesController extends AppController {
$this->set('billing_addresses_list', 'No Addresses exist for this Customer. Please add one'); $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('shipping_addresses_list', 'No Addresses exist for this Customer. Please add one');
} }
}*/ }
/* Add enquiry_id to the Email Queue */ /* Add enquiry_id to the Email Queue */
@ -416,13 +414,13 @@ class EnquiriesController extends AppController {
function update_status() { function update_status() {
if($this->data) { if($this->data) {
$enquiry = $this->Enquiry->read(null, $this->data['Enquiry']['id']); $enquiry = $this->Enquiry->read(null, $this->data['Enquiry']['id']);
$enquiry['Enquiry']['status_id'] = $this->data['Enquiry']['status_id']; $enquiry['Enquiry']['status_id'] = $this->data['Enquiry']['status_id'];
$this->Enquiry->save($enquiry); $this->Enquiry->save($enquiry);
$this->set('enquiry', $this->Enquiry->read(null,$enquiry['Enquiry']['id'])); $this->set('enquiry', $this->Enquiry->read(null,$enquiry['Enquiry']['id']));
} }
} }
@ -522,7 +520,7 @@ class EnquiriesController extends AppController {
else { else {
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id))); $this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
$statuses = $this->Enquiry->Status->find('all', array('recursive'=>0)); $statuses = $this->Enquiry->Status->find('all', array('recursive'=>0));
$status_list = array(); $status_list = array();
foreach ($statuses as $status) { foreach ($statuses as $status) {
@ -530,7 +528,7 @@ class EnquiriesController extends AppController {
$status_list[$statusid] = $status['Status']['name']; $status_list[$statusid] = $status['Status']['name'];
} }
$this->set('status_list', $status_list); $this->set('status_list', $status_list);
$this->layout = 'ajax'; $this->layout = 'ajax';
} }
} }

View file

@ -69,7 +69,8 @@ h1 {
margin: 0.1em 0; margin: 0.1em 0;
} }
h2 { h2 {
color: #e32; /*color: #e32; */
color: #045FB4;
font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif; font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif;
font-size: 190%; font-size: 190%;
margin: 0; margin: 0;
@ -77,7 +78,7 @@ h2 {
} }
h2 a { h2 a {
color: #e32; color: #045FB4;
font-weight: normal; font-weight: normal;
} }

View file

@ -38,7 +38,7 @@ $(function() {
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) { $.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
if(data == 'SUCCESS') { if(data == 'SUCCESS') {
loadLineItems(); loadLineItems();
$( "#addLineItemModal" ).dialog('close'); $( "#addLineItemModal" ).dialog('close');
@ -53,7 +53,7 @@ $(function() {
}, },
Cancel: function() { Cancel: function() {
loadLineItems(); loadLineItems();
$( this ).dialog( "close" ); $( this ).dialog( "close" );
} }
} }
@ -66,29 +66,21 @@ $(function() {
modal: true, modal: true,
buttons: { buttons: {
"Edit Line Item": function() { "Edit Line Item": function() {
$('#LineItemDescription').ckeditor(function() { $('#LineItemDescription').ckeditor(function() {
this.updateElement(); this.updateElement();
this.destroy(); this.destroy();
}); });
var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea'); var thisLineItemInputs = $('#LineItemEditForm').find('input,select,textarea');
$.post('/line_items/ajax_edit', thisLineItemInputs, function(data) { $.post('/line_items/ajax_edit', thisLineItemInputs, function(data) {
if(data == 'SUCCESS') { if(data == 'SUCCESS') {
$( "#editLineItemModal" ).dialog('close'); $( "#editLineItemModal" ).dialog('close');
} }
else { else {
alert("Line Item could not be saved") alert("Line Item could not be saved")
$('#LineItemDescription').ckeditor(config); $('#LineItemDescription').ckeditor(config);
} }
}); });
}, },
@ -98,6 +90,10 @@ $(function() {
} }
}, },
close: function() { close: function() {
$('#LineItemDescription').ckeditor(function() {
this.destroy();
});
loadLineItems(); loadLineItems();
} }
@ -414,11 +410,11 @@ function loadLineItems() {
});*/ });*/
$.ajax({ $.ajax({
url: '/line_items/getTable/'+documentID, url: '/line_items/getTable/'+documentID,
cache: false, cache: false,
success: function(data) { success: function(data) {
$("#lineItems").html(data); $("#lineItems").html(data);
} }
}); });
} }