diff --git a/controllers/documents_controller.php b/controllers/documents_controller.php index f2ca2879..4212d804 100755 --- a/controllers/documents_controller.php +++ b/controllers/documents_controller.php @@ -13,6 +13,8 @@ class DocumentsController extends AppController { ); + var $components = array('Email'); + function index() { $this->Document->recursive = 0; $this->set('documents', $this->paginate()); @@ -561,6 +563,58 @@ class DocumentsController extends AppController { $this->set('enquiry', $enquiry); } + /** + * Email the PDF(document + attachments) for this Document to a Recipient (Customer or Principle). + * + * + * @param $id - Document ID + */ + function email_pdf($id) { + + //Setup the SMTP Options + $this->Email->smtpOptions = Configure::read('smtp_settings'); + $this->Email->delivery = 'smtp'; + + $document = $this->Document->read(null,$id); + + if(empty($document['Document']['pdf_filename'])) { + $this->Session->setFlash(__('Error. Please generate the PDF before attempting to email it', true)); + return; + } + else { + $pdf_dir = Configure::read('pdf_directory'); + $this->Email->attachments = array($pdf_dir.'/'.$document['Document']['pdf_filename']); + } + + $enquiry = $this->Document->getEnquiry($document); + + $this->Email->to = $enquiry['Contact']['email']; + +//Uncomment this when going live +// $this->Email->cc = array($enquiry['User']['email']); +// $this->Email->bcc = array('carpis@cmctechnologies.com.au'); + + $this->Email->subject = $enquiry['Enquiry']['title'].' '; + $this->Email->replyTo = $enquiry['User']['email']; + $this->Email->from = 'CMC Technologies - Sales '; + $this->Email->template = 'email_pdf'; + $this->Email->sendAs = 'both'; + $this->Email->charset = 'iso-8859-1'; + $this->set('enquiry', $enquiry); + $this->set('DocFullName', $this->Document->getDocFullName($document['Document']['type'])); + if($this->Email->send()) { + $this->Session->setFlash(__('The Email has been sent', true)); + // $this->redirect(array('action'=>'view/'.$id), null, false); + } + else { + $this->set('smtp_errors', $this->Email->smtpError); + $this->Session->setFlash(__('The Email has NOT been sent. Something went wrong.', true)); + // $this->redirect(array('action'=>'view/'.$id), null, false); + + } + + } + diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index 110cb03f..e85a3930 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -309,12 +309,9 @@ class EnquiriesController extends AppController { 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->smtpOptions = Configure::read('smtp_settings'); + + $this->Email->delivery = 'smtp'; $enquiry = $this->Enquiry->read(null, $id); diff --git a/views/documents/email_pdf.ctp b/views/documents/email_pdf.ctp new file mode 100644 index 00000000..e69de29b diff --git a/views/elements/document_orderack_view.ctp b/views/elements/document_orderack_view.ctp index 499b554a..45c41bbb 100644 --- a/views/elements/document_orderack_view.ctp +++ b/views/elements/document_orderack_view.ctp @@ -4,6 +4,7 @@
link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?> + link('Email PDF to Customer', '/documents/email_pdf/'.$document['Document']['id']);?>
data);?> diff --git a/views/elements/email/html/email_pdf.ctp b/views/elements/email/html/email_pdf.ctp new file mode 100755 index 00000000..667c901a --- /dev/null +++ b/views/elements/email/html/email_pdf.ctp @@ -0,0 +1,120 @@ +Dear ,

+ +Please see the attached PDF of your .
+ +If you have any enquiries, please contact link($enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?> +(link($enquiry['User']['email'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?>).

+ +Sincerely,

+ +CMC Technologies
+ + + +
+
+
+
+

CMC +Technologies Pty Limited +- ACN: 085 991 224 , ABN: 47 085 991 224
+
Engineering & Industrial +Instrumentation
+
+

+

Unit 19, 77 Bourke Road +                               +Phone: ++61 2 9669 4000
+
Alexandria, NSW, 2015 +                                 +Fax: ++61 2 9669 4111
+
AUSTRALIA                                                         +Web: +http://www.cmctechnologies.com.au

+

 

+

Specialising in Fire and +Explosion Prevention or Protection, Overpressure Protection, Vision in the Process, Flow +Measurement, +Pressure - Differential Pressure, and Temperature - Humidity +Measurement/logging, On-Line +Analysers

+
+
+
+
+

The +information in this message is confidential and may be priveleged. If +you are +not the intended recipient then access, disclosure, copying or other +dissemination of the contents of this message is unauthorised and may +be +priveledged. Please inform the sender immediately if you are not the +intended +addressee.All correspondence is subject to CMC Technologies' Terms and +Conditions of Sale - July 1, 2006

+
+
+
+
+ diff --git a/views/elements/email/text/email_pdf.ctp b/views/elements/email/text/email_pdf.ctp new file mode 100755 index 00000000..ee2a36d0 --- /dev/null +++ b/views/elements/email/text/email_pdf.ctp @@ -0,0 +1,48 @@ +Dear , + +Thank you for your enquiry. It has been entered in our system and will be actioned for you by . Email: +The reference number assigned to this enquiry is: + +Please see below for the contact details we have for this enquiry and advise if there are any mistakes. + +Company Name: + +Contact Name: + +Contact Email: + +Telephone: + +Mobile: + +Fax: + + +Depending on the nature of your request, we may need input from our manufacturers overseas. This will usually take 24 to 48 hours, but if your enquiry is non-standard, it may take a little longer. + +Sincerely, + +CMC Technologies + +***************************************************************************************** +CMC Technologies Pty Limited +ACN: 085 991 224 , ABN: 47 085 991 224 +Engineering & Industrial Instrumentation +Unit 19, 77 Bourke Road +Alexandria, NSW, 2015 +AUSTRALIA +phone: +61 2 9669 4000 +fax:+61 2 9669 4111 +web: http://www.cmctechnologies.com.au +Specialising in Fire and Explosion Prevention or Protection, Overpressure +Protection, Vision in the Process, Flow Measurement, Pressure - Differential Pressure, and Temperature - Humidity measurement/logging +On-Line Analysers. +***************************************************************************************** +The information in this message is +confidential and may be priveleged. If you are not the intended recipient then +access, disclosure, copying or other dissemination of the contents of this +message is unauthorised and may be priveledged. Please inform the sender +immediately if you are not the intended addressee.All correspondence is subject +to CMC Technologies' Terms and Conditions of Sale - July 1, 2006. +***************************************************************************************** +