From b77598749a205aba0f37da10858e39dbd942cee8 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Sat, 6 Feb 2010 18:09:57 -0700 Subject: [PATCH] jQuery edit in place for the Enquiry Register working nicely --- controllers/enquiries_controller.php | 769 +++++++++++++------------- controllers/line_items_controller.php | 4 +- views/elements/enquiry_table.ctp | 366 +++++++----- views/enquiries/update_status.ctp | 2 +- views/line_items/add.ctp | 76 +-- views/line_items/edit.ctp | 29 +- views/line_items/index.ctp | 38 +- views/line_items/product_options.ctp | 1 - views/line_items/view.ctp | 131 +++-- views/quotes/view.ctp | 6 +- webroot/js/add_costing.js | 1 - 11 files changed, 745 insertions(+), 678 deletions(-) diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 76b1edc6..0beda462 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -2,49 +2,50 @@ class EnquiriesController extends AppController { - var $name = 'Enquiries'; - var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax', 'Number', 'Text', 'Cache'); - - var $paginate = array( - - 'contain' => false, - 'limit' => 250, - 'order'=>array('Enquiry.id' => 'desc') + var $name = 'Enquiries'; + var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax', 'Number', 'Text', 'Cache'); -); + var $paginate = array( - var $components = array('RequestHandler', 'Email'); + 'contain' => false, + 'limit' => 250, + 'order'=>array('Enquiry.id' => 'desc') - var $cacheAction = "1 hour"; + ); + + var $components = array('RequestHandler', 'Email'); + + var $cacheAction = "1 hour"; - function index() { - $this->Enquiry->recursive = 0; - $this->set('enquiries', $this->paginate()); - $statuses = $this->Enquiry->Status->find('all', array('recursive'=>0)); - $status_list = array(); - foreach ($statuses as $status) { - $status_list[] = array($status['Status']['id'], $status['Status']['name']); - } - $this->set('status_list', $status_list); - //debug($this->paginate()); - // $this->set('status_list', $this->Enquiry->Status->find('list')); - } + function index() { + $this->Enquiry->recursive = 0; + $this->set('enquiries', $this->paginate()); + $statuses = $this->Enquiry->Status->find('all', array('recursive'=>0)); + $status_list = array(); + foreach ($statuses as $status) { + $statusid = $status['Status']['id']; + $status_list[$statusid] = $status['Status']['name']; + } + $this->set('status_list', $status_list); + //debug($this->paginate()); + // $this->set('status_list', $this->Enquiry->Status->find('list')); + } + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Enquiry.', true)); + $this->redirect(array('action'=>'index')); + } + //$enquiry = $this->Enquiry->read(null, $id); + $enquiry = $this->Enquiry->find('first', array('recursive' => 0, 'conditions' => array('Enquiry.id'=>$id) + )); + $this->set('enquiry', $enquiry); + + //$this->set('quotes', $enquiry['Quote']); + $this->set('quotes', $this->Enquiry->Quote->find('all', array('recursive' => 0, 'conditions'=>array('Quote.enquiry_id'=>$id), 'order'=>'Quote.revision DESC'))); + //$this->set('files', $this->Enquiry->EnquiryFile->find('all', array('conditions' => array('EnquiryFile.enquiry_id'=>$id), 'order' => 'EnquiryFile.created ASC'))); - function view($id = null) { - if (!$id) { - $this->Session->setFlash(__('Invalid Enquiry.', true)); - $this->redirect(array('action'=>'index')); - } - //$enquiry = $this->Enquiry->read(null, $id); - $enquiry = $this->Enquiry->find('first', array('recursive' => 0, 'conditions' => array('Enquiry.id'=>$id) - )); - $this->set('enquiry', $enquiry); - - //$this->set('quotes', $enquiry['Quote']); - $this->set('quotes', $this->Enquiry->Quote->find('all', array('recursive' => 0, 'conditions'=>array('Quote.enquiry_id'=>$id), 'order'=>'Quote.revision DESC'))); - //$this->set('files', $this->Enquiry->EnquiryFile->find('all', array('conditions' => array('EnquiryFile.enquiry_id'=>$id), 'order' => 'EnquiryFile.created ASC'))); - /* Trying to optimise the queries for this part of the view - it's currently getting bogged down checking Email Attachments. * Going to create an array describing whether a particular email ID has an attachment. Trying to avoid checking binary data in a find('all') call */ @@ -63,377 +64,403 @@ class EnquiriesController extends AppController { * Fix up Email Attachment icon on email box. Currently broken -KC 6/8/09 $this->set('number_of_emails', $this->Enquiry->Email->find('count', array('conditions'=>array('Email.enquiry_id'=>$id)))); */ - $this->set('number_of_quotes', $this->Enquiry->Quote->find('count', array('conditions'=>array('Quote.enquiry_id'=>$id)))); - //$this->set('number_of_files', $this->Enquiry->EnquiryFile->find('count', array('conditions' => array('EnquiryFile.enquiry_id'=>$id)))); - $this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id'])); + $this->set('number_of_quotes', $this->Enquiry->Quote->find('count', array('conditions'=>array('Quote.enquiry_id'=>$id)))); + //$this->set('number_of_files', $this->Enquiry->EnquiryFile->find('count', array('conditions' => array('EnquiryFile.enquiry_id'=>$id)))); + $this->set('principle_emails', $this->Enquiry->Principle->PrincipleContact->findAllByPrincipleId($enquiry['Enquiry']['principle_id'])); - - if($enquiry['Enquiry']['billing_address_id'] != 0) { - $this->set('billingaddress', $this->Enquiry->BillingAddress->findById($enquiry['Enquiry']['billing_address_id'])); - } - - if($enquiry['Enquiry']['shipping_address_id'] != 0) { - $this->set('shippingaddress', $this->Enquiry->ShippingAddress->findById($enquiry['Enquiry']['shipping_address_id'])); - } - - } - + if($enquiry['Enquiry']['billing_address_id'] != 0) { + $this->set('billingaddress', $this->Enquiry->BillingAddress->findById($enquiry['Enquiry']['billing_address_id'])); + } - function add() { - - if(empty($this->data)) { - if(isset($this->params['named']['customerid'])) { - $customer = $this->Enquiry->Customer->findById($this->params['named']['customerid']); - } - else { - $this->Session->setFlash(__('The customer must already exist in the database. Please add Enquiries to an existing Customer', true)); - $this->redirect(array('action'=>'index')); - } - } - - if(isset($customer)) { + if($enquiry['Enquiry']['shipping_address_id'] != 0) { + $this->set('shippingaddress', $this->Enquiry->ShippingAddress->findById($enquiry['Enquiry']['shipping_address_id'])); + } + + } + + + + function add() { + + if(empty($this->data)) { + if(isset($this->params['named']['customerid'])) { + $customer = $this->Enquiry->Customer->findById($this->params['named']['customerid']); + } + else { + $this->Session->setFlash(__('The customer must already exist in the database. Please add Enquiries to an existing Customer', true)); + $this->redirect(array('action'=>'index')); + } + } + + 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->__showPage2($customer); - $this->render(); - - } - - 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); - 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; - } - } - $this->Enquiry->set($this->data); - if($this->Enquiry->validates()) { + 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)) { + $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); + 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; + } + } + $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) { + $this->__sendNewEnquiryEmail($id); //Will change this to be the queue at some point. + } + 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'])); + } + } + else { + + $this->set('errors', $this->Enquiry->invalidFields()); + $this->__showPage2($customer); + $this->render(); + + + } + + } + } - $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) { - $this->__sendNewEnquiryEmail($id); //Will change this to be the queue at some point. - } - 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'])); - } - } - else { - - $this->set('errors', $this->Enquiry->invalidFields()); - $this->__showPage2($customer); - $this->render(); - - - } - - } - } - /* 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) { - + 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')); - $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()); + $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')); + $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'])) { - $billing_address_list[0] = "No Address Selected"; - 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'); - } - } - - - + + if(isset($customerAddresses[0]['BillingAddress'])) { + $billing_address_list[0] = "No Address Selected"; + 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'); + } + } + + + /* Add enquiry_id to the Email Queue */ - - function __addToQueue($id) { - $enquiry = $this->Enquiry->read(null, $id); - $this->Enquiry->EnquiryEmailQueue->create(); - $this->data['EnquiryEmailQueue']['enquiry_id'] = $enquiry['Enquiry']['id']; - if ($this->Enquiry->EnquiryEmailQueue->save($this->data)) { - $this->Session->setFlash(__('The Enquiry has been saved and the Enquiry notification email has been added to the Queue', true)); - $this->redirect(array('action'=>'view/'.$enquiry['Enquiry']['id']), null, false); - - } - else { - $this->Session->setFlash(__('The Enquiry has been saved but the notification email could not be added to the Queue.', true)); - $this->redirect(array('action'=>'view/'.$enquiry['Enquiry']['id']), null, false); - } - } - + + function __addToQueue($id) { + $enquiry = $this->Enquiry->read(null, $id); + $this->Enquiry->EnquiryEmailQueue->create(); + $this->data['EnquiryEmailQueue']['enquiry_id'] = $enquiry['Enquiry']['id']; + if ($this->Enquiry->EnquiryEmailQueue->save($this->data)) { + $this->Session->setFlash(__('The Enquiry has been saved and the Enquiry notification email has been added to the Queue', true)); + $this->redirect(array('action'=>'view/'.$enquiry['Enquiry']['id']), null, false); + + } + else { + $this->Session->setFlash(__('The Enquiry has been saved but the notification email could not be added to the Queue.', true)); + $this->redirect(array('action'=>'view/'.$enquiry['Enquiry']['id']), null, false); + } + } + /* Generate Enquiry number and return it as a string */ - - function __generateEnquiryNumber($data) { - $state = $this->Enquiry->State->findById($data['Enquiry']['state_id']); - $principle = $this->Enquiry->Principle->findById($data['Enquiry']['principle_id']); + + function __generateEnquiryNumber($data) { + $state = $this->Enquiry->State->findById($data['Enquiry']['state_id']); + $principle = $this->Enquiry->Principle->findById($data['Enquiry']['principle_id']); /* Generate the enquiry number for this enquiry */ /* CMC Enquiry number format is: * CMCE- * eg. CMC1245NE351234-456 */ - - $enquiryid = $this->Enquiry->findCount(); /* Find what number we are - CMCXXXX */ - $enquiryoffset = 7882; //What Number Enquiry we were at before using this package. - $enquiryid += $enquiryoffset; - $enquiryid++; + + $enquiryid = $this->Enquiry->findCount(); /* Find what number we are - CMCXXXX */ + $enquiryoffset = 7882; //What Number Enquiry we were at before using this package. + $enquiryid += $enquiryoffset; + $enquiryid++; /* Find how many enquiries have been for this principle code */ - $principleenquiries = $this->Enquiry->findCount('principle_code ='. $principle['Principle']['code']); - + $principleenquiries = $this->Enquiry->findCount('principle_code ='. $principle['Principle']['code']); + /* Principle Code Offsets - Existing Number of Enquiries for each Principle Code */ - $principlecode_offset = array( 15 => 207, //ELMAC, AMAL - 20 => 51, //T and B Electronic - 25 => 2062, //ATEX,Brilex,Marston - 35 => 2067, //Mid-West Instrument, DP - 36 => 47, //Reading Technologies - 37 => 2040, //Eldridge, Smart Measurement, Alia - 65 => 2212, //Papenmeier, Herberts Industrieglas - 85 => 586, //Analytical Systems, Misc - 95 => 181); //Comet, T and D. - $principleenquiries += $principlecode_offset[$principle['Principle']['code']]; //Add the offset. - $principleenquiries++; - - - + $principlecode_offset = array( 15 => 207, //ELMAC, AMAL + 20 => 51, //T and B Electronic + 25 => 2062, //ATEX,Brilex,Marston + 35 => 2067, //Mid-West Instrument, DP + 36 => 47, //Reading Technologies + 37 => 2040, //Eldridge, Smart Measurement, Alia + 65 => 2212, //Papenmeier, Herberts Industrieglas + 85 => 586, //Analytical Systems, Misc + 95 => 181); //Comet, T and D. + $principleenquiries += $principlecode_offset[$principle['Principle']['code']]; //Add the offset. + $principleenquiries++; + + + /* Find how many enquiries have been for this principle code in this state */ /* This aspect of the enquiry number is not useful anymore. Made redundant thanks to mySQL queries. * But this has been done for backwards-compatablity with existing enquiry numbers */ - $principleconditions = array - ( - "Enquiry.principle_code" => $principle['Principle']['code'], - "Enquiry.state_id" => $data['Enquiry']['state_id'] - ); - - $stateprincipleenquiries = $this->Enquiry->findCount($principleconditions); - + $principleconditions = array + ( + "Enquiry.principle_code" => $principle['Principle']['code'], + "Enquiry.state_id" => $data['Enquiry']['state_id'] + ); + + $stateprincipleenquiries = $this->Enquiry->findCount($principleconditions); + /*Add the offsets for the State Principle Enquiries for each Code */ - $stateprinciple_offset = array( - //Elmac, Amal - 15 => array("NSW" => 39, "VIC" => 38, "TAS" => 58, - "ACT" => 0, "QLD" => 30, "NT" => 0, - "WA" => 19, "SA" => 8, "Overseas" => 1), - //T and B Electronic - 20 => array("NSW" => 14, "VIC" => 6, "TAS" => 0, - "ACT" => 0, "QLD" => 8, "NT" => 0, - "WA" => 12, "SA" => 1, "Overseas" => 5), - //ATEX,Brilex,Marston - 25 => array("NSW" => 580, "VIC" => 599, "TAS" => 186, - "ACT" => 0, "QLD" => 254, "NT" => 3, - "WA" => 541, "SA" => 72, "Overseas" => 625), - //Mid-West Instrument, DP - 35 => array("NSW" => 549, "VIC" => 851, "TAS" => 9, - "ACT" => 0, "QLD" => 245, "NT" => 15, - "WA" => 470, "SA" => 508, "Overseas" => 154), - //Reading Technologies - 36 => array("NSW" => 1, "VIC" => 3, "TAS" => 0, - "ACT" => 0, "QLD" => 7, "NT" => 0, - "WA" => 0, "SA" => 4, "Overseas" => 2), - //Eldridge, Smart Measurement, Alia - 37 => array("NSW" => 204, "VIC" => 60, "TAS" => 1, - "ACT" => 0, "QLD" => 130, "NT" => 1, - "WA" => 44, "SA" => 25, "Overseas" => 18), - //Papenmeier, Herberts Industrieglas - 65 => array("NSW" => 498, "VIC" => 537, "TAS" => 44, - "ACT" => 0, "QLD" => 158, "NT" => 12, - "WA" => 138, "SA" => 25, "Overseas" => 174), - //Analytical Systems, Misc - 85 => array("NSW" => 3, "VIC" => 6, "TAS" => 0, - "ACT" => 0, "QLD" => 1, "NT" => 0, - "WA" => 2, "SA" => 2, "Overseas" => 0), - //Comet, T and D. - 95 => array("NSW" => 34, "VIC" => 28, "TAS" => 6, - "ACT" => 0, "QLD" => 29, "NT" => 0, - "WA" => 9, "SA" => 8, "Overseas" => 31), - ); - $stateprincipleenquiries += $stateprinciple_offset[$principle['Principle']['code']][$state['State']['shortform']]; - $stateprincipleenquiries++; + $stateprinciple_offset = array( + //Elmac, Amal + 15 => array("NSW" => 39, "VIC" => 38, "TAS" => 58, + "ACT" => 0, "QLD" => 30, "NT" => 0, + "WA" => 19, "SA" => 8, "Overseas" => 1), + //T and B Electronic + 20 => array("NSW" => 14, "VIC" => 6, "TAS" => 0, + "ACT" => 0, "QLD" => 8, "NT" => 0, + "WA" => 12, "SA" => 1, "Overseas" => 5), + //ATEX,Brilex,Marston + 25 => array("NSW" => 580, "VIC" => 599, "TAS" => 186, + "ACT" => 0, "QLD" => 254, "NT" => 3, + "WA" => 541, "SA" => 72, "Overseas" => 625), + //Mid-West Instrument, DP + 35 => array("NSW" => 549, "VIC" => 851, "TAS" => 9, + "ACT" => 0, "QLD" => 245, "NT" => 15, + "WA" => 470, "SA" => 508, "Overseas" => 154), + //Reading Technologies + 36 => array("NSW" => 1, "VIC" => 3, "TAS" => 0, + "ACT" => 0, "QLD" => 7, "NT" => 0, + "WA" => 0, "SA" => 4, "Overseas" => 2), + //Eldridge, Smart Measurement, Alia + 37 => array("NSW" => 204, "VIC" => 60, "TAS" => 1, + "ACT" => 0, "QLD" => 130, "NT" => 1, + "WA" => 44, "SA" => 25, "Overseas" => 18), + //Papenmeier, Herberts Industrieglas + 65 => array("NSW" => 498, "VIC" => 537, "TAS" => 44, + "ACT" => 0, "QLD" => 158, "NT" => 12, + "WA" => 138, "SA" => 25, "Overseas" => 174), + //Analytical Systems, Misc + 85 => array("NSW" => 3, "VIC" => 6, "TAS" => 0, + "ACT" => 0, "QLD" => 1, "NT" => 0, + "WA" => 2, "SA" => 2, "Overseas" => 0), + //Comet, T and D. + 95 => array("NSW" => 34, "VIC" => 28, "TAS" => 6, + "ACT" => 0, "QLD" => 29, "NT" => 0, + "WA" => 9, "SA" => 8, "Overseas" => 31), + ); + $stateprincipleenquiries += $stateprinciple_offset[$principle['Principle']['code']][$state['State']['shortform']]; + $stateprincipleenquiries++; /* Generate/set the enquiry number */ - $enquiryno = 'CMC'.$enquiryid.$state['State']['enqform'].'E'.$principle['Principle']['code'].$principleenquiries. - '-'.$stateprincipleenquiries; - return $enquiryno; - } - + $enquiryno = 'CMC'.$enquiryid.$state['State']['enqform'].'E'.$principle['Principle']['code'].$principleenquiries. + '-'.$stateprincipleenquiries; + return $enquiryno; + } + /* Autocomplete the customer name - Used in: add.ctp */ - function completeCustomer() { - - $this->set('customers', $this->Enquiry->Customer->find('all', array( - 'conditions' => array( - 'Customer.name LIKE' => '%'.$this->data['Customer']['name'].'%' - ),'fields' => array('Customer.name') - ))); - $this->layout = 'ajax'; + function completeCustomer() { + + $this->set('customers', $this->Enquiry->Customer->find('all', array( + 'conditions' => array( + 'Customer.name LIKE' => '%'.$this->data['Customer']['name'].'%' + ),'fields' => array('Customer.name') + ))); + $this->layout = 'ajax'; + + } - } - /* Moving this to the new Enquiry email sender. */ - function __sendNewEnquiryEmail($id) { - - //Setup the SMTP Options - $this->Email->smtpOptions = array( - 'port' => '25', - 'timeout' => '30', - 'host' => '192.168.0.8', - 'username' => 'sales', - 'password' => '2seng33+02'); - $this->Email->delivery = 'smtp'; - - $enquiry = $this->Enquiry->read(null, $id); - $this->Email->to = $enquiry['Contact']['email']; - $this->Email->cc = array($enquiry['User']['email']); - $this->Email->bcc = array('carpis@cmctechnologies.com.au'); - - $this->Email->subject = $enquiry['Enquiry']['title'].' - Your Enquiry has been Entered in our System - CMC Technologies'; - $this->Email->replyTo = $enquiry['User']['email']; - $this->Email->from = 'CMC Technologies - Sales '; - $this->Email->template = 'enquiry_added'; - $this->Email->sendAs = 'both'; - $this->Email->charset = 'iso-8859-1'; - $this->set('enquiry', $enquiry); - if($this->Email->send()) { - $this->Session->setFlash(__('The Enquiry has been added and the Contact has been emailed', true)); - $this->redirect(array('action'=>'view/'.$id), null, false); - } - else { - $this->set('smtp_errors', $this->Email->smtpError); - $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); - - } - - } - + function __sendNewEnquiryEmail($id) { + + //Setup the SMTP Options + $this->Email->smtpOptions = array( + 'port' => '25', + 'timeout' => '30', + 'host' => '192.168.0.8', + 'username' => 'sales', + 'password' => '2seng33+02'); + $this->Email->delivery = 'smtp'; + + $enquiry = $this->Enquiry->read(null, $id); + $this->Email->to = $enquiry['Contact']['email']; + $this->Email->cc = array($enquiry['User']['email']); + $this->Email->bcc = array('carpis@cmctechnologies.com.au'); + + $this->Email->subject = $enquiry['Enquiry']['title'].' - Your Enquiry has been Entered in our System - CMC Technologies'; + $this->Email->replyTo = $enquiry['User']['email']; + $this->Email->from = 'CMC Technologies - Sales '; + $this->Email->template = 'enquiry_added'; + $this->Email->sendAs = 'both'; + $this->Email->charset = 'iso-8859-1'; + $this->set('enquiry', $enquiry); + if($this->Email->send()) { + $this->Session->setFlash(__('The Enquiry has been added and the Contact has been emailed', true)); + $this->redirect(array('action'=>'view/'.$id), null, false); + } + else { + $this->set('smtp_errors', $this->Email->smtpError); + $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); + + } + + } + + + function edit($id = null) { + if (!$id && empty($this->data)) { + $this->Session->setFlash(__('Invalid Enquiry', true)); + $this->redirect(array('action'=>'index')); + } + if (!empty($this->data)) { + + if ($this->Enquiry->save($this->data)) { + $this->Session->setFlash(__('The Enquiry has been saved', true)); + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('The Enquiry could not be saved. Please try again.', true)); + $this->set('dump', $this->data); + } + } + if (empty($this->data)) { + $this->data = $this->Enquiry->read(null, $id); + } + $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('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']); + $statuses = $this->Enquiry->Status->find('list'); + $principles = $this->Enquiry->Principle->find('list', array('conditions' => array('Principle.code' => $enquiry['Principle']['code']))); + $customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $enquiry['Customer']['id']))); + $this->set('billing_addresses', $customerAddresses); + $this->set('shipping_addresses', $customerAddresses); - function edit($id = null) { - if (!$id && empty($this->data)) { - $this->Session->setFlash(__('Invalid Enquiry', true)); - $this->redirect(array('action'=>'index')); - } - if (!empty($this->data)) { - - if ($this->Enquiry->save($this->data)) { - $this->Session->setFlash(__('The Enquiry has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The Enquiry could not be saved. Please try again.', true)); - $this->set('dump', $this->data); - } - } - if (empty($this->data)) { - $this->data = $this->Enquiry->read(null, $id); - } - $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('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']); - $statuses = $this->Enquiry->Status->find('list'); - $principles = $this->Enquiry->Principle->find('list', array('conditions' => array('Principle.code' => $enquiry['Principle']['code']))); - $customerAddresses = $this->Enquiry->BillingAddress->find('all', array('conditions'=>array('BillingAddress.customer_id' => $enquiry['Customer']['id']))); - $this->set('billing_addresses', $customerAddresses); - $this->set('shipping_addresses', $customerAddresses); - /* Feels like an ugly hack. But it gets the desired effect and it will do for now */ - - if(isset($customerAddresses[0]['BillingAddress'])) { - $billing_address_list[0] = "No Address Selected"; - 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(compact('enquiry', 'users','contacts','principles','statuses', 'addresses')); - } - function update_status($enquiryid) { - $newid = $this->params['form']['value']; - if($newid) { - $this->Enquiry->id = $enquiryid; - $this->Enquiry->saveField('status_id', $newid); - $this->set('enquiry', $this->Enquiry->findById($enquiryid)); - $this->layout='ajax'; - $this->render(); - } - - } - - function search() { - if(empty($this->data)) { - $this->Session->setFlash('Enter part of the Enquiry number you want to find'); - } + if(isset($customerAddresses[0]['BillingAddress'])) { + $billing_address_list[0] = "No Address Selected"; + 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(compact('enquiry', 'users','contacts','principles','statuses', 'addresses')); + } - function mark_submitted($id = null) { - if($id == null) { - $this->Session->setFlash('Invalid Enquiry ID'); - $this->redirect(array('action'=>'index')); - } - else { - $this->Enquiry->id = $id; - $today = date("Y-m-d"); - $this->Enquiry->saveField('submitted', $today); - $this->Session->setFlash('The Enquiry has been marked as submitted today ('.date('j M Y').')'); - $this->redirect(array('action'=>'index')); - } + /* function update_status($enquiryid) { + $newid = $this->params['form']['value']; + + + if($newid) { + $this->Enquiry->id = $enquiryid; + $this->Enquiry->saveField('status_id', $newid); + $this->set('enquiry', $this->Enquiry->findById($enquiryid)); + $this->render('ajax'); + + } + + }*/ + + + function update_status() { + if($this->data) { + App::import('Core', 'Sanitize'); + $new_status = Sanitize::clean($this->data['Enquiry']['status_id']); + $this->Enquiry->id = $this->data['Enquiry']['id']; + $this->Enquiry->saveField('status_id', $new_status); + $this->set('enquiry', $this->Enquiry->findById($this->data['Enquiry']['id'])); + + } + + } + + function search() { + if(empty($this->data)) { + $this->Session->setFlash('Enter part of the Enquiry number you want to find'); + } + + + } + + function mark_submitted($id = null) { + if($id == null) { + $this->Session->setFlash('Invalid Enquiry ID'); + $this->redirect(array('action'=>'index')); + } + else { + $this->Enquiry->id = $id; + $today = date("Y-m-d"); + $this->Enquiry->saveField('submitted', $today); + $this->Session->setFlash('The Enquiry has been marked as submitted today ('.date('j M Y').')'); + $this->redirect(array('action'=>'index')); + } - } + } + + + function jsonStatus($id = null) { + if($id == null) { + return null; + } + + else { + + } + } + - } diff --git a/controllers/line_items_controller.php b/controllers/line_items_controller.php index ffeba97d..ce2b00ad 100644 --- a/controllers/line_items_controller.php +++ b/controllers/line_items_controller.php @@ -6,7 +6,7 @@ class LineItemsController extends AppController { function index() { $this->LineItem->recursive = 0; - $this->set('quoteProducts', $this->paginate()); + $this->set('lineItems', $this->paginate()); } function view($id = null) { @@ -14,7 +14,7 @@ class LineItemsController extends AppController { $this->Session->setFlash(__('Invalid LineItem.', true)); $this->redirect(array('action'=>'index')); } - $this->set('quoteProduct', $this->LineItem->read(null, $id)); + $this->set('lineItem', $this->LineItem->read(null, $id)); } function add($quoteid = null) { diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp index bba480de..2bf91c01 100755 --- a/views/elements/enquiry_table.ctp +++ b/views/elements/enquiry_table.ctp @@ -1,91 +1,94 @@ +link('jquery.jeditable.mini'); ?> + + options(array('url'=>$this->passedArgs)); ?> - counter(array( - 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) - )); - ?> - - - - - - echo $paginator->sort('Date Submitted', 'submitted'); */ ?> - - - - - - - - - - - - -counter(array( +'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) +)); ?> - id=""> - "; - ?> - + + + + echo $paginator->sort('Date Submitted', 'submitted'); */ ?> + + + + + + + + + + + + + + id="row"> + "; + ?> + - link($firstname[0].$lastname[0], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?> - + $firstname = $enquiry['User']['first_name']; + $lastname = $enquiry['User']['last_name']; ?> + link($firstname[0].$lastname[0], array('controller'=> 'users', 'action'=>'view', $enquiry['User']['id'])); ?> + - + echo date('j M Y',$time->toUnix($enquiry['Enquiry']['created'])); ?> + - - Change the date from MySQL DATETIME to a D M Y format @@ -102,78 +105,143 @@ foreach ($enquiries as $enquiry): */ -?> + ?> - - - - - - - - - - - - - - + + + + + + + + + + + + + +
sort('user_id');?>sort('Date', 'created');?>sort('principle_id');?>sort('Enquiry Number', 'title');?>sort('customer_id');?>sort('contact_id');?>sort('status_id');?>sort('comments');?>
sort('user_id');?>sort('Date', 'created');?>sort('principle_id');?>sort('Enquiry Number', 'title');?>sort('customer_id');?>sort('contact_id');?>sort('status_id');?>sort('comments');?>
- + toUnix($enquiry['Enquiry']['created'])); ?> - - link($enquiry['Principle']['short_name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); - } - else { - echo $html->link($enquiry['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); - } - ?> - - link($enquiry['Enquiry']['title'], array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); ?> - - link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?> - - link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?> - - - link($enquiry['Contact']['email'], 'mailto:'.$enquiry['Contact']['email'].'?subject='.$enquiry['Enquiry']['title'].'&bcc=carpis@cmctechnologies.com.au'); ?> - - -
- editor("statusupdate_$i", array('controller'=>'Enquiries', 'action'=>'update_status', $enquiry['Enquiry']['id']), array('update' => "statusupdate_$i", 'collection' => $status_list, 'okText'=>'Change Status', 'savingText' => 'Saving..', 'formId' => 'EnquiryStatusId', - 'formClassName' => 'MER-inplace-select')); - ?> -
-
- strlen($displayedComment) ) { - echo '.... '.$html->link('view all', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); - } - ?> -
-
- link(__('View', true), array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id'])); ?> - link(__('Edit', true), array('controller'=>'enquiries','action'=>'edit', $enquiry['Enquiry']['id'])); ?> - -
+ link($enquiry['Principle']['short_name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); + } + else { + echo $html->link($enquiry['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $enquiry['Principle']['id'])); + } + ?> + + link($enquiry['Enquiry']['title'], array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); ?> + + link($enquiry['Customer']['name'], array('controller'=> 'customers', 'action'=>'view', $enquiry['Customer']['id'])); ?> + + link($enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], array('controller'=> 'contacts', 'action'=>'view', $enquiry['Contact']['id'])); ?> + + + link($enquiry['Contact']['email'], 'mailto:'.$enquiry['Contact']['email'].'?subject='.$enquiry['Enquiry']['title'].'&bcc=carpis@cmctechnologies.com.au'); ?> + + +
+ codeBlock($jsblock); + ?> +
+
+ strlen($displayedComment) ) { + echo '.... '.$html->link('view all', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); + } + ?> +
+
+ link(__('View', true), array('controller'=>'enquiries','action'=>'view', $enquiry['Enquiry']['id'])); ?> + link(__('Edit', true), array('controller'=>'enquiries','action'=>'edit', $enquiry['Enquiry']['id'])); ?> + +
- - prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> - | numbers();?> - next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?> + + prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> + | numbers();?> + next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
diff --git a/views/enquiries/update_status.ctp b/views/enquiries/update_status.ctp index 3e682c43..67474705 100755 --- a/views/enquiries/update_status.ctp +++ b/views/enquiries/update_status.ctp @@ -1 +1 @@ - + \ No newline at end of file diff --git a/views/line_items/add.ctp b/views/line_items/add.ctp index b86c1111..9f385248 100755 --- a/views/line_items/add.ctp +++ b/views/line_items/add.ctp @@ -1,85 +1,29 @@ -
+
create('LineItem');?>
- -input('quote_id', array('type' => 'hidden', 'value' => $quote['Quote']['id'])); - - - echo $form->input('quantity', array('class' => 'required validate-number', 'title'=>'Please enter the quantity. It must be a number')); - - echo $form->input('option', array('label' => 'This item is optional')); - - echo $form->input('principle_id', array('empty' => 'Select a Principle')); - echo $ajax->observeField('LineItemPrincipleId', array( - 'url' => 'principle_products', - 'frequency' => 0.2, - 'update' => 'products' - )); - - - echo $form->input('product_id', array('type' => 'select', 'id'=>'products')); - - - - echo $ajax->observeField('products', array( - - 'url' => 'product_options', - 'frequency' => 0.2, - 'update' => 'productoptions' - )); - - - echo $ajax->div('productoptions'); - echo $ajax->divEnd('productoptions'); - - - - - //echo '
'; - //echo $form->select('QuoteProduct.product_id', null, null, array('id'=>'products')); - //*/ - -/* + + input('item_number'); echo $form->input('option'); echo $form->input('quantity'); - echo $form->input('cost_price'); - echo $form->input('currency_id'); - echo $form->input('our_discount'); - echo $form->input('packing'); - echo $form->input('shipping_weight'); - echo $form->input('shipping_cost'); - echo $form->input('exchange_rate'); - echo $form->input('duty'); - echo $form->input('finance'); - echo $form->input('misc'); - echo $form->input('gross_sell_price'); - echo $form->input('target_gp'); echo $form->input('title'); echo $form->input('description'); echo $form->input('quote_id'); echo $form->input('product_id'); - echo $form->input('discount'); - */ - -?> + echo $form->input('costing_id'); + echo $form->input('unit_price'); + ?>
-end('Submit'); - echo $javascript->codeBlock("new Validation('QuoteProductAddForm', {immediate : true, useTitles : true});", array('allowCache'=>true, 'safe'=>false)); - - -?> +end('Submit');?>
    -
  • link(__('List QuoteProducts', true), array('action' => 'index'));?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
  • link(__('List LineItems', true), array('action' => 'index'));?>
  • link(__('List Quotes', true), array('controller' => 'quotes', 'action' => 'index')); ?>
  • link(__('New Quote', true), array('controller' => 'quotes', 'action' => 'add')); ?>
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Costings', true), array('controller' => 'costings', 'action' => 'index')); ?>
  • +
  • link(__('New Costing', true), array('controller' => 'costings', 'action' => 'add')); ?>
diff --git a/views/line_items/edit.ctp b/views/line_items/edit.ctp index dee57c87..4eef0f41 100755 --- a/views/line_items/edit.ctp +++ b/views/line_items/edit.ctp @@ -1,42 +1,31 @@ -
-create('QuoteProduct');?> +
+create('LineItem');?>
- + input('id'); echo $form->input('item_number'); echo $form->input('option'); echo $form->input('quantity'); - echo $form->input('cost_price'); - echo $form->input('currency_id'); - echo $form->input('our_discount'); - echo $form->input('packing'); - echo $form->input('shipping_weight'); - echo $form->input('shipping_cost'); - echo $form->input('exchange_rate'); - echo $form->input('duty'); - echo $form->input('finance'); - echo $form->input('misc'); - echo $form->input('gross_sell_price'); - echo $form->input('target_gp'); echo $form->input('title'); echo $form->input('description'); echo $form->input('quote_id'); echo $form->input('product_id'); - echo $form->input('discount'); + echo $form->input('costing_id'); + echo $form->input('unit_price'); ?>
end('Submit');?>
    -
  • link(__('Delete', true), array('action' => 'delete', $form->value('QuoteProduct.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('QuoteProduct.id'))); ?>
  • -
  • link(__('List QuoteProducts', true), array('action' => 'index'));?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
  • link(__('Delete', true), array('action' => 'delete', $form->value('LineItem.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('LineItem.id'))); ?>
  • +
  • link(__('List LineItems', true), array('action' => 'index'));?>
  • link(__('List Quotes', true), array('controller' => 'quotes', 'action' => 'index')); ?>
  • link(__('New Quote', true), array('controller' => 'quotes', 'action' => 'add')); ?>
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?>
  • +
  • link(__('List Costings', true), array('controller' => 'costings', 'action' => 'index')); ?>
  • +
  • link(__('New Costing', true), array('controller' => 'costings', 'action' => 'add')); ?>
diff --git a/views/line_items/index.ctp b/views/line_items/index.ctp index 688548ce..d7424a1c 100755 --- a/views/line_items/index.ctp +++ b/views/line_items/index.ctp @@ -1,5 +1,5 @@ -
-

+
+

counter(array( @@ -17,11 +17,12 @@ echo $paginator->counter(array( sort('quote_id');?> sort('product_id');?> sort('costing_id');?> + sort('unit_price');?> > - + - + - + - + - + - + - link($quoteProduct['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $quoteProduct['Quote']['id'])); ?> + link($lineItem['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $lineItem['Quote']['id'])); ?> - link($quoteProduct['Product']['title'], array('controller' => 'products', 'action' => 'view', $quoteProduct['Product']['id'])); ?> + link($lineItem['Product']['title'], array('controller' => 'products', 'action' => 'view', $lineItem['Product']['id'])); ?> - + + + + - link(__('View', true), array('action' => 'view', $quoteProduct['QuoteProduct']['id'])); ?> - link(__('Edit', true), array('action' => 'edit', $quoteProduct['QuoteProduct']['id'])); ?> - link(__('Delete', true), array('action' => 'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?> + link(__('View', true), array('action' => 'view', $lineItem['LineItem']['id'])); ?> + link(__('Edit', true), array('action' => 'edit', $lineItem['LineItem']['id'])); ?> + link(__('Delete', true), array('action' => 'delete', $lineItem['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $lineItem['LineItem']['id'])); ?> @@ -71,9 +75,7 @@ foreach ($quoteProducts as $quoteProduct):

    -
  • link(__('New QuoteProduct', true), array('action' => 'add')); ?>
  • -
  • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
  • -
  • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
  • +
  • link(__('New LineItem', true), array('action' => 'add')); ?>
  • link(__('List Quotes', true), array('controller' => 'quotes', 'action' => 'index')); ?>
  • link(__('New Quote', true), array('controller' => 'quotes', 'action' => 'add')); ?>
  • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
  • diff --git a/views/line_items/product_options.ctp b/views/line_items/product_options.ctp index 86bbf2f9..f5f819e7 100755 --- a/views/line_items/product_options.ctp +++ b/views/line_items/product_options.ctp @@ -20,7 +20,6 @@ foreach ($options as $opt) { if($prodopt['default'] == 1) { $default_option = $prodopt['id']; - $drop_options[$prodopt['id']] .= " (Default)"; } diff --git a/views/line_items/view.ctp b/views/line_items/view.ctp index d6d75ad0..f2c48427 100755 --- a/views/line_items/view.ctp +++ b/views/line_items/view.ctp @@ -1,61 +1,64 @@ -
    -

    +
    +

    > > - +   > > - +   > > - +   > > - +   > > - +   > > - +   > > - link($quoteProduct['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $quoteProduct['Quote']['id'])); ?> + link($lineItem['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $lineItem['Quote']['id'])); ?>   > > - link($quoteProduct['Product']['title'], array('controller' => 'products', 'action' => 'view', $quoteProduct['Product']['id'])); ?> + link($lineItem['Product']['title'], array('controller' => 'products', 'action' => 'view', $lineItem['Product']['id'])); ?>   > > - + +   + + > + > +  
      -
    • link(__('Edit QuoteProduct', true), array('action' => 'edit', $quoteProduct['QuoteProduct']['id'])); ?>
    • -
    • link(__('Delete QuoteProduct', true), array('action' => 'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?>
    • -
    • link(__('List QuoteProducts', true), array('action' => 'index')); ?>
    • -
    • link(__('New QuoteProduct', true), array('action' => 'add')); ?>
    • -
    • link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?>
    • -
    • link(__('New Currency', true), array('controller' => 'currencies', 'action' => 'add')); ?>
    • +
    • link(__('Edit LineItem', true), array('action' => 'edit', $lineItem['LineItem']['id'])); ?>
    • +
    • link(__('Delete LineItem', true), array('action' => 'delete', $lineItem['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $lineItem['LineItem']['id'])); ?>
    • +
    • link(__('List LineItems', true), array('action' => 'index')); ?>
    • +
    • link(__('New LineItem', true), array('action' => 'add')); ?>
    • link(__('List Quotes', true), array('controller' => 'quotes', 'action' => 'index')); ?>
    • link(__('New Quote', true), array('controller' => 'quotes', 'action' => 'add')); ?>
    • link(__('List Products', true), array('controller' => 'products', 'action' => 'index')); ?>
    • @@ -66,97 +69,133 @@
    diff --git a/views/quotes/view.ctp b/views/quotes/view.ctp index b7ce2c8a..26c63a99 100755 --- a/views/quotes/view.ctp +++ b/views/quotes/view.ctp @@ -106,9 +106,9 @@ foreach ($quote['QuotePage'] as $quotePage): echo $quote['Currency']['symbol'].$thisNetPrice; ?> - link(__('View', true), array('controller'=> 'quote_products', 'action'=>'view', $quoteProduct['LineItem']['id'])); ?> - link(__('Edit', true), array('controller'=> 'quote_products', 'action'=>'edit', $quoteProduct['LineItem']['id'])); ?> - link(__('Delete', true), array('controller'=> 'quote_products', 'action'=>'delete', $quoteProduct['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['LineItem']['id'])); ?> + link(__('View', true), array('controller'=> 'line_items', 'action'=>'view', $quoteProduct['LineItem']['id'])); ?> + link(__('Edit', true), array('controller'=> 'line_items', 'action'=>'edit', $quoteProduct['LineItem']['id'])); ?> + link(__('Delete', true), array('controller'=> 'line_items', 'action'=>'delete', $quoteProduct['LineItem']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['LineItem']['id'])); ?> diff --git a/webroot/js/add_costing.js b/webroot/js/add_costing.js index a317b33e..42e04068 100644 --- a/webroot/js/add_costing.js +++ b/webroot/js/add_costing.js @@ -113,7 +113,6 @@ function buildup() { var netGPamount = grossGP - saleDiscountAmount; netGPamount = netGPamount.toFixed(2); $("#CostingNetGpAmount").val(netGPamount); - //Calculate net GP % var netGPpercent = (netGPamount / grossSellPrice) * 100; netGPpercent = netGPpercent.toFixed(2);