From f5b2ed3c679127929cf4350941ff6cc131a82202 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Fri, 11 Mar 2011 09:56:01 +1100 Subject: [PATCH] Fixed add enquiry old version. --- controllers/email_attachments_controller.php | 3 +- controllers/enquiries_controller.php | 34 +++++++++++++++++++- models/enquiry.php | 2 +- vendors/shells/vault_two.php | 4 +-- views/enquiries/add.ctp | 4 +-- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/controllers/email_attachments_controller.php b/controllers/email_attachments_controller.php index f87c92d1..ab5d7f81 100755 --- a/controllers/email_attachments_controller.php +++ b/controllers/email_attachments_controller.php @@ -12,7 +12,8 @@ class EmailAttachmentsController extends AppController { $file = $this->EmailAttachment->findById($id); $file_path = Configure::read('email_directory'); - + echo $file_path."/".$file['EmailAttachment']['name']; + die(); if(file_exists($file_path."/".$file['EmailAttachment']['name'])) { diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 979a5fc6..d066121f 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -83,6 +83,38 @@ class EnquiriesController extends AppController { } + function add_enquiry() { + + Configure::write('debug', 0); + $this->layout = 'ajax'; + if (!empty($this->data)) { + $this->Enquiry->create(); + $this->Enquiry->set($this->data['Enquiry']); + if($this->User->validates()) { + if ($this->User->save($this->data)) { + $message = __('The User has been saved.', true); + $data = $this->data; + $this->set('success', compact('message', 'data')); + } + } + else { + $message = __('The User could not be saved. Please, try again.', true); + $User = $this->User->invalidFields(); + $data = compact('User'); + $this->set('errors', compact('message', 'data')); + } + + + } + else { + $this->redirect('/'); + } + + + + } + + function add() { @@ -164,7 +196,7 @@ class EnquiriesController extends AppController { $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'))); + $users = $this->Enquiry->User->find('list', array('fields' => array('User.id', 'User.username'), 'conditions'=>array('User.type'=>'user'))); $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); diff --git a/models/enquiry.php b/models/enquiry.php index 1bd645d1..8b02b5ec 100755 --- a/models/enquiry.php +++ b/models/enquiry.php @@ -100,7 +100,7 @@ class Enquiry extends AppModel { var $belongsTo = array( 'User' => array('className' => 'User', 'foreignKey' => 'user_id', - 'conditions' => '', + 'conditions' => array('User.type'=>'user'), 'fields' => '', 'order' => '' ), diff --git a/vendors/shells/vault_two.php b/vendors/shells/vault_two.php index e59b30b4..6b598b23 100755 --- a/vendors/shells/vault_two.php +++ b/vendors/shells/vault_two.php @@ -692,7 +692,7 @@ class VaultTwoShell extends Shell { * 4. * * @param $attachments - */ + function moveAttachments($attachments, $email_dir, $unix_time) { $month_year = date('m-Y'); @@ -708,7 +708,7 @@ class VaultTwoShell extends Shell { } die(); - } + }*/ } diff --git a/views/enquiries/add.ctp b/views/enquiries/add.ctp index d38ac6a7..712aee9a 100755 --- a/views/enquiries/add.ctp +++ b/views/enquiries/add.ctp @@ -13,8 +13,8 @@ doesn't appear in the drop down list, click 'New Contact'")); ?> echo '
'; echo $form->input('contact_id', array('div' => false)); echo '
'; - echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one',$customer['Customer']['id']), array('update'=>'contact')); - echo $html->image('contact-new.png'); + //echo $ajax->link('New Contact', array('controller' => 'contacts', 'action' => 'add_one',$customer['Customer']['id']), array('update'=>'contact')); + //echo $html->image('contact-new.png'); echo '
'; echo 'The Contact will be emailed informing them of the new Enquiry'; echo $form->input('state_id', array('label'=>'State', 'empty' => 'Please Choose A State'));