diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index d99f762b..2b059018 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -4,7 +4,7 @@ App::import('Core', 'Sanitize'); class EnquiriesController extends AppController { var $name = 'Enquiries'; - var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax'); + var $helpers = array('Html', 'Form', 'Javascript', 'Time', 'Ajax', 'Number'); var $paginate = array( 'limit' => 250, @@ -24,6 +24,7 @@ class EnquiriesController extends AppController { } $this->set('enquiry', $this->Enquiry->read(null, $id)); $this->set('quotes', $this->Enquiry->Quote->find('all', array('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'))); } diff --git a/controllers/quote_products_controller.php b/controllers/quote_products_controller.php index b62e9758..b35b73ce 100644 --- a/controllers/quote_products_controller.php +++ b/controllers/quote_products_controller.php @@ -27,7 +27,7 @@ class QuoteProductsController extends AppController { $this->Session->setFlash(__('The QuoteProduct could not be saved. Please, try again.', true)); } } - $principles = $this->QuoteProduct->Principle->find('list'); + $principles = $this->QuoteProduct->Product->Principle->find('list'); $currencies = $this->QuoteProduct->Currency->find('list'); $quotes = $this->QuoteProduct->Quote->find('list'); $products = $this->QuoteProduct->Product->find('list'); @@ -69,4 +69,4 @@ class QuoteProductsController extends AppController { } } -?> \ No newline at end of file +?> diff --git a/controllers/quotes_controller.php b/controllers/quotes_controller.php index a6920de8..fcb88571 100755 --- a/controllers/quotes_controller.php +++ b/controllers/quotes_controller.php @@ -45,28 +45,6 @@ class QuotesController extends AppController { } - function addold($id = null) { - - if(isset($this->params['named']['enquiryid'])) { - $enquiryid = $this->params['named']['enquiryid']; - } - if (!empty($this->data)) { - $this->Quote->create(); - - $number_of_revisions = $this->Quote->findCount('enquiry_id ='. $this->data['Quote']['enquiry_id']); - $number_of_revisions++; - $this->data['Quote']['revision'] = $number_of_revisions; - if ($this->Quote->save($this->data)) { - $this->Session->setFlash(__('The Quote has been saved', true)); - $this->redirect(array('action'=>'index')); - } else { - $this->Session->setFlash(__('The Quote could not be saved. Please, try again.', true)); - } - } - $enquiries = $this->Quote->Enquiry->find('list'); - $this->set(compact('enquiries')); - } - function edit($id = null) { if (!$id && empty($this->data)) { @@ -76,16 +54,18 @@ class QuotesController extends AppController { if (!empty($this->data)) { if ($this->Quote->save($this->data)) { $this->Session->setFlash(__('The Quote has been saved', true)); - $this->redirect(array('action'=>'index')); + $thisquote = $this->Quote->id; + $this->redirect(array('action' =>'view/'.$id), null, false); } else { $this->Session->setFlash(__('The Quote could not be saved. Please, try again.', true)); } } if (empty($this->data)) { - $this->data = $this->Quote->read(null, $id); + $quote = $this->Quote->read(null, $id); + $this->data = $quote; } - $enquiries = $this->Quote->Enquiry->find('list'); - $this->set(compact('enquiries')); + $enquiry = $this->Quote->Enquiry->findById($quote['Quote']['enquiry_id']); + $this->set(compact('enquiry', 'quote')); } diff --git a/models/enquiry.php b/models/enquiry.php index e19256ed..d4f60863 100755 --- a/models/enquiry.php +++ b/models/enquiry.php @@ -169,7 +169,11 @@ class Enquiry extends AppModel { 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' - ) + ), + 'EnquiryFile' => array('className' => 'EnquiryFile', + 'foreignKey' => 'enquiry_id', + 'dependent' => false + ) ); } diff --git a/views/elements/enquiry_table.ctp b/views/elements/enquiry_table.ctp index e11b3abd..547e66ce 100644 --- a/views/elements/enquiry_table.ctp +++ b/views/elements/enquiry_table.ctp @@ -111,7 +111,7 @@ foreach ($enquiries as $enquiry): $displayedComment = substr($enquiry['Enquiry']['comments'], 0, 260); echo $displayedComment; if(strlen($enquiry['Enquiry']['comments']) > strlen($displayedComment) ) { - echo '.... '.$html->link('view full comment', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); + echo '.... '.$html->link('view all', array('controller'=>'enquiries', 'action'=>'view', $enquiry['Enquiry']['id'])); } ?> diff --git a/views/enquiries/add.ctp b/views/enquiries/add.ctp index 4be9633d..a77df2c6 100755 --- a/views/enquiries/add.ctp +++ b/views/enquiries/add.ctp @@ -26,7 +26,7 @@ echo $form->input('gst', array('label' => 'Is GST Applicable', 'options' => array('1' => 'Yes', '0' => 'No'))); echo $form->input('principle_id'); echo $form->input('status_id'); - echo $form->input('comments'); + echo $form->input('comments', array('maxlength' => '250000')); echo $form->input('customer_id', array('type'=>'hidden', 'value' => $customer['Customer']['id'])); echo $form->input('finished', array('type' => 'hidden', 'value' => 'true')); diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp index e4aa76b8..af612831 100755 --- a/views/enquiries/view.ctp +++ b/views/enquiries/view.ctp @@ -72,3 +72,8 @@
element('quote_table', $quotes); ?> + + diff --git a/views/quotes/edit.ctp b/views/quotes/edit.ctp index cbf20bda..7bc96a8d 100755 --- a/views/quotes/edit.ctp +++ b/views/quotes/edit.ctp @@ -1,28 +1,26 @@