function preDisplay() { parent::preDisplay(); $tour = new Tour(); $html = file_get_contents("custom/modules/Tours/tpls/basic_pdf.tpl"); $html = str_replace("{NAME}", $this->bean->name, $html); $desc = html_entity_decode_utf8($this->bean->description); $desc = $tour->removeHtmlTags($desc); $html = str_replace("{TOUR_NOTE}", $desc, $html); $picture = '<img width="627" height="312" src="modules/images/' . $this->bean->picture . '">'; $html = str_replace("{PICTURE}", $picture, $html); $html = str_replace("{CODE}", $this->bean->tour_code, $html); $html = str_replace("{DURATION}", $this->bean->duration, $html); $html = str_replace("{TRANSPORT}", $this->bean->transport2, $html); $html = str_replace("{START_DATE}", $this->bean->start_date, $html); $program = html_entity_decode_utf8($tour->get_data_to_export2pdf($_GET['record'])); $html = str_replace("{TOUR_PROGRAM_LINES}", $program, $html); // Xuat ra pdf $mpdf = new mPDF("vi"); $mpdf->SetFooter('{PAGENO}'); $mpdf->WriteHTML($html); $mpdf->Output("Tour.pdf", "D"); exit; }
/** * Set the file name and manage the email attachement output * * @see TCPDF::Output() */ public function Output($name = "doc.pdf", $dest = 'I') { if (!empty($this->pdfFilename)) { $name = $this->pdfFilename; } // This case is for "email as PDF" if (isset($_REQUEST['to_email']) && $_REQUEST['to_email'] == "1") { // After the output the object is destroy $bean = $this->bean; $tmp = parent::Output('', 'S'); $badoutput = ob_get_contents(); if (strlen($badoutput) > 0) { ob_end_clean(); } file_put_contents('upload://' . $name, ltrim($tmp)); $email_id = $this->buildEmail($name, $bean); //redirect if ($email_id == "") { //Redirect to quote, since something went wrong echo "There was an error with your request"; exit; //end if email id is blank } else { SugarApplication::redirect("index.php?module=Emails&action=Compose&record=" . $email_id . "&replyForward=true&reply="); } } parent::Output($name, 'D'); }