diff --git a/Dockerfile b/Dockerfile index 070f0cda..e66297e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/app/controllers/documents_controller.php b/app/controllers/documents_controller.php index c429e160..f79106bb 100755 --- a/app/controllers/documents_controller.php +++ b/app/controllers/documents_controller.php @@ -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 = <<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 = <<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