Added emailPDF method. Sending doucment PDFs attached to emails is now working. Still Need to make the principle attachments fuctionaltiy and a nice editable form to finish it off
This commit is contained in:
parent
7989dd24ac
commit
29bb1b322d
|
|
@ -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 <int> $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 <sales@cmctechnologies.com.au>';
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
0
views/documents/email_pdf.ctp
Normal file
0
views/documents/email_pdf.ctp
Normal file
|
|
@ -4,6 +4,7 @@
|
|||
</div>
|
||||
<div class="docButtons">
|
||||
<?=$html->link('Generate PDF of this Order Acknowledgement', '/documents/pdf/'.$document['Document']['id']);?>
|
||||
<?=$html->link('Email PDF to Customer', '/documents/email_pdf/'.$document['Document']['id']);?>
|
||||
</div>
|
||||
|
||||
<div class="docOperations" style="display: none;">
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ echo $form->input('Document.id');
|
|||
echo $form->input('Job.customer_order_number');
|
||||
echo $form->end();
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<? //debug($this->data);?>
|
||||
|
|
|
|||
120
views/elements/email/html/email_pdf.ctp
Executable file
120
views/elements/email/html/email_pdf.ctp
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
Dear <?php echo $enquiry['Contact']['first_name']; ?>,<br /><br />
|
||||
|
||||
Please see the attached PDF of your <?=$DocFullName?>.<br />
|
||||
|
||||
If you have any enquiries, please contact <?php echo $html->link($enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?>
|
||||
(<?php echo $html->link($enquiry['User']['email'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?>).<br /><br />
|
||||
|
||||
Sincerely, <br /><br />
|
||||
|
||||
CMC Technologies<br />
|
||||
|
||||
<!--[if !mso]>
|
||||
<style>
|
||||
v\:* {behavior:url(#default#VML);}
|
||||
o\:* {behavior:url(#default#VML);}
|
||||
w\:* {behavior:url(#default#VML);}
|
||||
.shape {behavior:url(#default#VML);}
|
||||
</style>
|
||||
<![endif]-->
|
||||
<style>
|
||||
<!--
|
||||
/* Font Definitions */
|
||||
@font-face
|
||||
{font-family:Calibri;
|
||||
panose-1:2 15 5 2 2 2 4 3 2 4;}
|
||||
@font-face
|
||||
{font-family:"Rage Italic";
|
||||
panose-1:3 7 5 2 4 5 7 7 3 4;}
|
||||
/* Style Definitions */
|
||||
p.MsoNormal, li.MsoNormal, div.MsoNormal
|
||||
{margin:0cm;
|
||||
margin-bottom:.0001pt;
|
||||
font-size:11.0pt;
|
||||
font-family:"Calibri","sans-serif";}
|
||||
a:link, span.MsoHyperlink
|
||||
{mso-style-priority:99;
|
||||
color:blue;
|
||||
text-decoration:underline;}
|
||||
a:visited, span.MsoHyperlinkFollowed
|
||||
{mso-style-priority:99;
|
||||
color:purple;
|
||||
text-decoration:underline;}
|
||||
span.EmailStyle17
|
||||
{mso-style-type:personal-compose;
|
||||
font-family:"Calibri","sans-serif";
|
||||
color:windowtext;}
|
||||
.MsoChpDefault
|
||||
{mso-style-type:export-only;}
|
||||
@page Section1
|
||||
{size:612.0pt 792.0pt;
|
||||
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
|
||||
div.Section1
|
||||
{page:Section1;}
|
||||
-->
|
||||
</style><!--[if gte mso 9]><xml>
|
||||
<o:shapedefaults v:ext="edit" spidmax="1026" />
|
||||
</xml><![endif]--><!--[if gte mso 9]><xml>
|
||||
<o:shapelayout v:ext="edit">
|
||||
<o:idmap v:ext="edit" data="1" />
|
||||
</o:shapelayout></xml><![endif]-->
|
||||
<div>
|
||||
<div class="MsoNormal"><span style="font-size: 10pt;">
|
||||
<hr style="color: gray;" align="left" noshade="noshade" size="2"
|
||||
width="100%"></span></div>
|
||||
</div>
|
||||
<p class="MsoNormal"><b><span style="color: rgb(0, 0, 153);">CMC
|
||||
Technologies Pty Limited</span></b><span style="color: rgb(0, 0, 153);">
|
||||
</span><span style="font-size: 10pt;">- </span><span
|
||||
style="font-size: 7.5pt;">ACN: 085 991 224 , ABN: 47 085 991 224</span><span
|
||||
style="font-size: 10pt;"> <br>
|
||||
</span><span style="font-size: 10pt;">Engineering & Industrial
|
||||
Instrumentation</span><span style="font-size: 9pt;"> </span><span
|
||||
style="font-size: 10pt;"><br>
|
||||
<br>
|
||||
</span><o:p></o:p></p>
|
||||
<p class="MsoNormal">Unit 19, 77 Bourke Road<span
|
||||
style="font-size: 10pt;">
|
||||
|
||||
</span><b>Phone:</b>
|
||||
+61 2 9669 4000<span style="font-size: 10pt;"><br>
|
||||
</span>Alexandria, NSW, 2015<span style="font-size: 10pt;">
|
||||
|
||||
</span><b>Fax:
|
||||
</b>+61 2 9669 4111<span style="font-size: 10pt;"><br>
|
||||
</span>AUSTRALIA
|
||||
<b>Web:</b>
|
||||
<a href="http://www.cmctechnologies.com.au/"><b><span
|
||||
style="color: blue;">http://www.cmctechnologies.com.au</span></b></a><o:p></o:p></p>
|
||||
<p class="MsoNormal"><span style="font-size: 10pt;"> <o:p></o:p></span></p>
|
||||
<p class="MsoNormal">Specialising in <span
|
||||
style="color: rgb(148, 54, 52);">Fire and
|
||||
Explosion Prevention or Protection, Overpressure Protection</span>, <span
|
||||
style="color: rgb(49, 132, 155);">Vision in the Process</span><span
|
||||
style="color: teal;">, </span><span style="color: rgb(54, 95, 145);">Flow
|
||||
Measurement</span><span style="color: rgb(0, 176, 80);">,
|
||||
Pressure - Differential Pressure, and Temperature - Humidity
|
||||
Measurement/logging</span>, <span style="color: rgb(148, 138, 84);">On-Line
|
||||
Analysers</span><span style="font-size: 10pt;"><o:p></o:p></span></p>
|
||||
<div>
|
||||
<div class="MsoNormal"><span style="font-size: 10pt;">
|
||||
<hr style="color: gray;" align="left" noshade="noshade" size="2"
|
||||
width="100%"></span></div>
|
||||
</div>
|
||||
<p class="MsoNormal" style="margin-top: 6pt;"><span
|
||||
style="font-size: 10pt;">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</span><span style="font-size: 8pt;"><o:p></o:p></span></p>
|
||||
<div>
|
||||
<div class="MsoNormal"><span style="font-size: 10pt;">
|
||||
<hr style="color: gray;" align="left" noshade="noshade" size="2"
|
||||
width="100%"></span></div>
|
||||
</div>
|
||||
|
||||
48
views/elements/email/text/email_pdf.ctp
Executable file
48
views/elements/email/text/email_pdf.ctp
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
Dear <?php echo $enquiry['Contact']['first_name']; ?>,
|
||||
|
||||
Thank you for your enquiry. It has been entered in our system and will be actioned for you by <?php echo $enquiry['User']['first_name'].' '.$enquiry['User']['last_name']; ?>. Email: <?php echo $enquiry['User']['email']; ?>
|
||||
The reference number assigned to this enquiry is: <?php echo $enquiry['Enquiry']['title']; ?>
|
||||
|
||||
Please see below for the contact details we have for this enquiry and advise if there are any mistakes.
|
||||
|
||||
Company Name: <?php echo $enquiry['Customer']['name']; ?>
|
||||
|
||||
Contact Name: <?php echo $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name']; ?>
|
||||
|
||||
Contact Email: <?php echo $enquiry['Contact']['email']; ?>
|
||||
|
||||
Telephone: <?php echo $enquiry['Contact']['phone']; ?>
|
||||
|
||||
Mobile: <?php echo $enquiry['Contact']['mobile']; ?>
|
||||
|
||||
Fax: <?php echo $enquiry['Contact']['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.
|
||||
*****************************************************************************************
|
||||
|
||||
Loading…
Reference in a new issue