diff --git a/controllers/enquiries_controller.php b/controllers/enquiries_controller.php index a24ef106..76b1edc6 100755 --- a/controllers/enquiries_controller.php +++ b/controllers/enquiries_controller.php @@ -310,8 +310,10 @@ class EnquiriesController extends AppController { //Setup the SMTP Options $this->Email->smtpOptions = array( 'port' => '25', - 'timeout' => '15', - 'host' => '192.168.0.8'); + 'timeout' => '30', + 'host' => '192.168.0.8', + 'username' => 'sales', + 'password' => '2seng33+02'); $this->Email->delivery = 'smtp'; $enquiry = $this->Enquiry->read(null, $id); @@ -331,9 +333,10 @@ class EnquiriesController extends AppController { $this->redirect(array('action'=>'view/'.$id), null, false); } else { - $this->Session->setFlash(__('The Enquiry has been added but email to the contact has NOT been sent. Something went wrong.', true)); + $this->set('smtp_errors', $this->Email->smtpError); + $this->Session->setFlash(__('The Enquiry has been added but email to the contact has NOT been sent. Something went wrong.', true)); $this->redirect(array('action'=>'view/'.$id), null, false); - $this->set('smtp-errors', $this->Email->smtpError); + } } diff --git a/controllers/quote_products_controller.php b/controllers/quote_products_controller.php index 11ba43da..b3068c8f 100644 --- a/controllers/quote_products_controller.php +++ b/controllers/quote_products_controller.php @@ -30,7 +30,7 @@ class QuoteProductsController extends AppController { $product = $this->QuoteProduct->Product->findById($this->data['QuoteProduct']['product_id']); $this->data['QuoteProduct']['description'] = $product['Product']['description']; - debug($this->data); + if ($this->QuoteProduct->save($this->data)) { $quoteid = $this->data['QuoteProduct']['quote_id']; @@ -48,6 +48,7 @@ class QuoteProductsController extends AppController { $currencies = $this->QuoteProduct->Currency->find('list'); $quote = $this->QuoteProduct->Quote->read(null, $quoteid); $this->set(compact('principles', 'currencies', 'quote', 'products')); + } diff --git a/vendors/tcpdf/images/cmcfooter.jpg b/vendors/tcpdf/images/cmcfooter.jpg new file mode 100644 index 00000000..6a551cee Binary files /dev/null and b/vendors/tcpdf/images/cmcfooter.jpg differ diff --git a/vendors/xtcpdf.php b/vendors/xtcpdf.php index 871d2e07..3c723a27 100644 --- a/vendors/xtcpdf.php +++ b/vendors/xtcpdf.php @@ -75,7 +75,7 @@ class XTCPDF extends TCPDF function Page1Footer() { $this->SetY(-20); - $this->Image(K_PATH_IMAGES.'cmcfooter.png', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C'); + $this->Image(K_PATH_IMAGES.'cmcfooter.jpg', null, 255, 200, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'C'); } /** @@ -88,7 +88,7 @@ class XTCPDF extends TCPDF $boxYstart = 45; $boxXstart = 10; $firstColWidth = 40; - $secondColWidth = 80; + $secondColWidth = 70; $thirdColWidth = 30; $fourthColWidth = -10; @@ -166,9 +166,14 @@ class XTCPDF extends TCPDF } - function continuedHeader() { - $this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 10, 10, 15, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L'); - $this->MultiCell(0,0, 'CMC Technologies Quote Continued'); + function continuedHeader($cmcRef) { + $this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 10, 10, 15, 13.6, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L'); + $this->SetFontSize(10); + $pageNo = $this->PageNoFormatted(); + $this->MultiCell(0,13.6, "$cmcRef PAGE $pageNo OF {nb}", '', 'R'); + //$this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml) + //$this->Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi) + } diff --git a/views/enquiries/view.ctp b/views/enquiries/view.ctp index dedc7499..05dfba23 100755 --- a/views/enquiries/view.ctp +++ b/views/enquiries/view.ctp @@ -137,4 +137,7 @@ $boxdata['enquirynumber'] = $enquiry['Enquiry']['title']; element('quote_table', $quotes); ?> + diff --git a/views/quotes/pdf.ctp b/views/quotes/pdf.ctp index c37f1810..3e7d6463 100644 --- a/views/quotes/pdf.ctp +++ b/views/quotes/pdf.ctp @@ -1,16 +1,13 @@ setPrintFooter(false); -// - -// Now you position and print your page content -// example: -/*$tcpdf->SetTextColor(0, 0, 0); -$tcpdf->SetFont($textfont,'B',20); -$tcpdf->Cell(0,14, "Hello World", 0,1,'L'); -*/ - $page1done = false; //Have we already made the first page? If so, don't show the CMC header/footer foreach ($quote['QuotePage'] as $page) { - $tcpdf->AddPage(); + $tcpdf->AddPage(); - if($page1done == false) { - $tcpdf->Page1Header(); - - if( (!$enqury['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) { + if($page1done == false) { + $tcpdf->Page1Header(); - $enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created'])); + if( (!$enqury['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) { + + $enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created'])); - $enquiry['Enquiry']['customer_reference'] = "Enquiry on $enquiry_date"; + $enquiry['Enquiry']['customer_reference'] = "Enquiry on $enquiry_date"; + } + + if ($quote['Quote']['revision'] > 0) { + $cmcRef = $enquiry['Enquiry']['title'].' rev '.$quote['Quote']['revision']; + } + else { + $cmcRef = $enquiry['Enquiry']['title']; + } + + + $tcpdf->DetailsBox($enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], + $enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef, + $enquiry['Enquiry']['customer_reference']); + + } + else { + $tcpdf->continuedHeader($enquiry['Enquiry']['title']); } - $tcpdf->DetailsBox($enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], - $enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $quote['Enquiry']['title'], - $enquiry['Enquiry']['customer_reference']); - + $currentX = $tcpdf->GetX(); + $currentY = $tcpdf->GetY(); + + $tcpdf->SetTextColor(0); + $tcpdf->SetFont('times', '', 12); - } - else { - $tcpdf->continuedHeader(); + $tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], 'LTRB', 1, 0, true, 'L', true); + + + /* Only show the footer if it's the first page */ + if($page1done == false) { + $tcpdf->Page1Footer(); + $page1done = true; } -$currentX = $tcpdf->GetX(); -$currentY = $tcpdf->GetY(); - -$tcpdf->SetTextColor(0); -$tcpdf->SetFont('times', '', 12); - - -$tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], 'LTRB', 1, 0, true, 'L', true); - - -/* Only show the footer if it's the first page */ -if($page1done == false) { - $tcpdf->Page1Footer(); - $page1done = true; } - -} - - - - - - //DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber) - - $tcpdf->AliasNbPages(); $tcpdf->lastPage(); @@ -110,7 +96,7 @@ $tcpdf->lastPage(); $output_dir = '/var/www/cake/app/webroot/pdf/'; if($quote['Quote']['revision'] > 0) { - $filename = $enqury['Enquiry']['title'].'Rev'.$quote['Quote']['revision'].'.pdf'; + $filename = $enquiry['Enquiry']['title'].'rev'.$quote['Quote']['revision'].'.pdf'; } else { $filename = $enquiry['Enquiry']['title'].'.pdf'; @@ -122,6 +108,4 @@ $tcpdf->Output($output_dir.$filename, 'F'); //$tcpdf->Output('cmcquote.pdf', 'D'); - - ?> \ No newline at end of file