Hopefully fix merge conflict
This commit is contained in:
parent
018b2b0c1b
commit
affda516e4
|
|
@ -897,86 +897,6 @@ ENDINSTRUCTIONS;
|
|||
|
||||
}
|
||||
|
||||
$this->Session->setFlash(__('Error. Please generate the PDF before attempting to email it', true));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$pdf_dir = Configure::read('pdf_directory');
|
||||
|
||||
$attachment_files = array($pdf_dir.$document['Document']['pdf_filename']);
|
||||
foreach($document['DocumentAttachment'] as $document_attachment) {
|
||||
$attachment = $this->Document->DocumentAttachment->Attachment->read(null, $document_attachment['attachment_id']);
|
||||
$attachment_files[] = $attachment['Attachment']['file'];
|
||||
}
|
||||
$this->Email->attachments = $attachment_files;
|
||||
|
||||
}
|
||||
$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>';
|
||||
|
||||
$docType = $this->Document->getDocType($document);
|
||||
|
||||
switch($docType) {
|
||||
case 'quote':
|
||||
$this->Email->subject .= 'Quotation';
|
||||
break;
|
||||
case 'invoice':
|
||||
$this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id']))));
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
$primary_contact = $this->Document->User->find('first', array('conditions'=>array('User.principle_id' => $document['PurchaseOrder']['principle_id'],'User.primary_contact' => 1)));
|
||||
if(empty($primary_contact)) {
|
||||
|
||||
$this->Session->setFlash(__('Unable to send. No primary Principle Contact', true));
|
||||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||
return;
|
||||
}
|
||||
$this->Email->subject = 'CMC Technologies Purchase Order: '.$document['PurchaseOrder']['title'];
|
||||
|
||||
$this->Email->to = $primary_contact['User']['email'];
|
||||
$this->Email->replyTo = null;
|
||||
$this->Email->cc = null;
|
||||
|
||||
$this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
break;
|
||||
case 'orderAck':
|
||||
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
}
|
||||
|
||||
|
||||
$template = $docType.'_email';
|
||||
$this->Email->template = $template;
|
||||
|
||||
|
||||
$this->Email->sendAs = 'both';
|
||||
$this->Email->charset = 'iso-8859-1';
|
||||
$this->set('enquiry', $enquiry);
|
||||
$this->set('document', $document);
|
||||
$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 {
|
||||
print_r($this->Email->smtpError);
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function add_job_items_to_po($job_id, $document_id) {
|
||||
$this->layout = 'ajax';
|
||||
$job = $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id' => $job_id)));
|
||||
|
|
@ -1048,5 +968,3 @@ ENDINSTRUCTIONS;
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue