Append job and enquiry numbers to outgoing PO email subjects
This commit is contained in:
parent
def7dc536d
commit
999fc10999
|
|
@ -46,15 +46,16 @@ ADD conf/ripmime /bin/ripmime
|
|||
|
||||
RUN chmod +x /bin/ripmime
|
||||
RUN a2dissite 000-default
|
||||
RUN a2ensite cmc-sales
|
||||
|
||||
RUN mkdir -p /var/www/cmc-sales/app/tmp/logs
|
||||
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||
|
||||
# Copy site into place.
|
||||
ADD . /var/www/cmc-sales
|
||||
RUN mkdir /var/www/cmc-sales/app/tmp
|
||||
RUN mkdir /var/www/cmc-sales/app/tmp/logs
|
||||
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||
RUN chmod +x /var/www/cmc-sales/run_vault.sh
|
||||
|
||||
RUN a2ensite cmc-sales
|
||||
|
||||
|
||||
# By default, simply start apache.
|
||||
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||
|
|
|
|||
|
|
@ -818,7 +818,49 @@ ENDINSTRUCTIONS;
|
|||
function email_format($a) {
|
||||
return "<".$a.">";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Do a bunch of queries to build a subject line for PO emails.
|
||||
function po_email_subject($document) {
|
||||
$id = $document['id'];
|
||||
|
||||
$subject = 'CMC Technologies Purchase Order: '.$document['title'];
|
||||
|
||||
$q = <<<EOT
|
||||
SELECT jobs.id, title FROM jobs
|
||||
JOIN jobs_purchase_orders as jpo ON (jpo.purchase_order_id = $id AND jpo.job_id = jobs.id)
|
||||
|
||||
EOT;
|
||||
|
||||
$jobs = $this->Document->query($q);
|
||||
if(count($jobs) <= 0) {
|
||||
return $subject;
|
||||
}
|
||||
$job_numbers = array();
|
||||
$job_ids = array();
|
||||
foreach($jobs as $job) {
|
||||
$job_numbers[] = $job["jobs"]["title"];
|
||||
$job_ids[] = $job["jobs"]["id"];
|
||||
}
|
||||
$job_ids_in = implode(",", $job_ids);
|
||||
|
||||
$q = <<<EOT
|
||||
SELECT enquiries.title from enquiries join jobs on enquiries.id = jobs.enquiry_id AND jobs.id IN($job_ids_in);
|
||||
EOT;
|
||||
|
||||
$enquiries = $this->Document->query($q);
|
||||
|
||||
$enquiry_numbers = array();
|
||||
foreach($enquiries as $enquiry) {
|
||||
$enquiry_numbers[] = $enquiry["enquiries"]["title"];
|
||||
}
|
||||
|
||||
$subject = $subject . ' ( ' .implode(" ", $job_numbers). ' )';
|
||||
$subject = $subject . ' ( ' .implode(" ", $enquiry_numbers) . ' )';
|
||||
|
||||
return $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Email the PDF(document + attachments) for this Document to a Recipient (Customer or Principle).
|
||||
*
|
||||
|
|
@ -876,6 +918,8 @@ ENDINSTRUCTIONS;
|
|||
case 'purchaseOrder':
|
||||
$subject .= " Purchase Order";
|
||||
|
||||
|
||||
|
||||
$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)) {
|
||||
|
||||
|
|
@ -883,8 +927,8 @@ ENDINSTRUCTIONS;
|
|||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||
return;
|
||||
}
|
||||
$this->Email->subject = 'CMC Technologies Purchase Order: '.$document['PurchaseOrder']['title'];
|
||||
|
||||
|
||||
$this->Email->subject = $this->po_email_subject($document['PurchaseOrder']);
|
||||
$this->Email->to = $this->email_format($primary_contact['User']['email']);
|
||||
$this->Email->replyTo = null;
|
||||
$this->Email->cc = null;
|
||||
|
|
@ -967,8 +1011,6 @@ ENDINSTRUCTIONS;
|
|||
}
|
||||
|
||||
|
||||
function costing() {
|
||||
}
|
||||
|
||||
|
||||
/** Helper function to make copying related models more DRY
|
||||
|
|
|
|||
Loading…
Reference in a new issue