Fixed add enquiry old version.

This commit is contained in:
Karl Cordes 2011-03-11 09:56:01 +11:00
parent 3eb6ca2367
commit f5b2ed3c67
5 changed files with 40 additions and 7 deletions

View file

@ -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'])) {

View file

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

View file

@ -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' => ''
),

View file

@ -692,7 +692,7 @@ class VaultTwoShell extends Shell {
* 4.
*
* @param <type> $attachments
*/
function moveAttachments($attachments, $email_dir, $unix_time) {
$month_year = date('m-Y');
@ -708,7 +708,7 @@ class VaultTwoShell extends Shell {
}
die();
}
}*/
}

View file

@ -13,8 +13,8 @@ doesn't appear in the drop down list, click 'New Contact'")); ?>
echo '<div id="contact">';
echo $form->input('contact_id', array('div' => false));
echo '<br>';
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 '</div>';
echo '<span>The Contact will be emailed informing them of the new Enquiry</span>';
echo $form->input('state_id', array('label'=>'State', 'empty' => 'Please Choose A State'));