Пример #1
0
 function checkStoreInvoice($orderDetails = 0)
 {
     JRequest::setVar('task', 'checkStoreInvoice');
     $force = true;
     //	@ini_set( 'max_execution_time', 5 );
     $path = VmConfig::get('forSale_path', 0);
     if ($path === 0) {
         vmError('No path set to store invoices');
         return false;
     } else {
         $path .= 'invoices' . DS;
         if (!file_exists($path)) {
             vmError('Path wrong to store invoices, folder invoices does not exist ' . $path);
             return false;
         } else {
             if (!is_writable($path)) {
                 vmError('Cannot store pdf, directory not writeable ' . $path);
                 return false;
             }
         }
     }
     $orderModel = VmModel::getModel('orders');
     $invoiceNumberDate = array();
     if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
         return 0;
     }
     if (!empty($invoiceNumberDate[0])) {
         $invoiceNumber = $invoiceNumberDate[0];
     } else {
         $invoiceNumber = FALSE;
     }
     if (!$invoiceNumber or empty($invoiceNumber)) {
         vmError('Cant create pdf, createInvoiceNumber failed');
         return 0;
     }
     if (shopFunctions::InvoiceNumberReserved($invoiceNumber)) {
         return 0;
     }
     $path .= 'vminvoice_' . $invoiceNumber . '.pdf';
     if (file_exists($path) and !$force) {
         return $path;
     }
     // 			$app = JFactory::getApplication('site');
     //We come from the be, so we need to load the FE langauge
     $jlang = JFactory::getLanguage();
     $jlang->load('com_virtuemart', JPATH_SITE, 'en-GB', true);
     $jlang->load('com_virtuemart', JPATH_SITE, $jlang->getDefault(), true);
     $jlang->load('com_virtuemart', JPATH_SITE, null, true);
     $this->addViewPath(JPATH_VM_SITE . DS . 'views');
     $format = 'html';
     $viewName = 'invoice';
     $view = $this->getView($viewName, $format);
     $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . 'invoice' . DS . 'tmpl');
     $view->invoiceNumber = $invoiceNumberDate[0];
     $view->invoiceDate = $invoiceNumberDate[1];
     $view->orderDetails = $orderDetails;
     $view->uselayout = 'invoice';
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     // create new PDF document
     $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator('Invoice by VirtueMart 2, used library tcpdf');
     $pdf->SetAuthor($view->vendor->vendor_name);
     $pdf->SetTitle(JText::_('COM_VIRTUEMART_INVOICE_TITLE'));
     $pdf->SetSubject(JText::sprintf('COM_VIRTUEMART_INVOICE_SUBJ', $view->vendor->vendor_store_name));
     $pdf->SetKeywords('Invoice by VirtueMart 2');
     //virtuemart.cloudaccess.net/index.php?option=com_virtuemart&view=invoice&layout=details&virtuemart_order_id=18&order_number=6e074d9b&order_pass=p_9cb9e2&task=checkStoreInvoice
     if (empty($view->vendor->images[0])) {
         vmError('Vendor image given path empty ');
     } else {
         if (empty($view->vendor->images[0]->file_url_folder) or empty($view->vendor->images[0]->file_name) or empty($view->vendor->images[0]->file_extension)) {
             vmError('Vendor image given image is not complete ' . $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension);
             vmdebug('Vendor image given image is not complete, the given media', $view->vendor->images[0]);
         } else {
             if (!empty($view->vendor->images[0]->file_extension) and strtolower($view->vendor->images[0]->file_extension) == 'png') {
                 vmError('Warning extension of the image is a png, tpcdf has problems with that in the header, choose a jpg or gif');
             } else {
                 $imagePath = DS . str_replace('/', DS, $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension);
                 if (!file_exists(JPATH_ROOT . $imagePath)) {
                     vmError('Vendor image missing ' . $imagePath);
                 } else {
                     $pdf->SetHeaderData($imagePath, 60, $view->vendor->vendor_store_name, $view->vendorAddress);
                 }
             }
         }
     }
     // set header and footer fonts
     $pdf->setHeaderFont(array('helvetica', '', 8));
     $pdf->setFooterFont(array('helvetica', '', 10));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //TODO include the right file (in libraries/tcpdf/config/lang set some language-dependent strings
     $l = '';
     $pdf->setLanguageArray($l);
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont('helvetica', '', 8, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     // Set some content to print
     // $html =
     // Print text using writeHTMLCell()
     $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     $pdf->Output($path, 'F');
     return $path;
 }
Пример #2
0
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Recaudacion');
$pdf->SetTitle('Programa de Servicio de Salud');
$pdf->SetSubject('Detalle programa paciente');
$pdf->SetKeywords('Paciente, PSS, Programa');
//$pdf->SetHeaderData('../../img/logo.jpg', PDF_HEADER_LOGO_WIDTH,'SERVICIO DE SALUD ARICA ','HOSPITAL REGIONAL DE ARICA Y PARINACOTA');
$pdf->setHeaderFont(array('helvetica', '', 18));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(4, 5, 5, 1);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(0);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setLanguageArray($l);
$pdf->setFontSubsetting(true);
$pdf->SetFont('helvetica', '', 9, '', true);
$pdf->setPrintFooter(false);
//CREA UNA PAGINA
$pdf->AddPage('L', 'A4');
//CARGA DE CLASES Y METODOS
require_once '../../class/Tipo_Producto.class.php';
$objTipPro = new Tipo_Producto();
require_once '../../class/Nota_Credito.class.php';
$objNot = new Nota_Credito();
require_once '../../class/Conectar.class.php';
$objCon = new Conectar();
require_once '../../class/Arqueo.class.php';
$objArq = new Arqueo();
require_once '../../class/Boleta.class.php';
$objBol = new Boleta();
Пример #3
0
    public function cetak($idquotationsales = null, $idrefstore = null)
    {
        if ($idquotationsales == null) {
            exit('Data Tidak Tersedia');
        }
        $data = $this->orm->quotationsales->where('idquotationsales', $idquotationsales)->fetch();
        if (count($this->orm->quotationsales->where('idquotationsales', $idquotationsales)) == 0) {
            echo "<h3>Data Tidak Tersedia</h3>";
            exit;
        }
        //check from web
        if ($idrefstore == null) {
            $email = $_SESSION['user']['email'];
            $idrefstore = $_SESSION['user']['idrefstore'];
        } else {
            //from mobile
            $email = $this->input->post('email');
        }
        ini_set('memory_limit', '512M');
        $this->load->library('TCPDF');
        // create new PDF document
        $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A4', true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(WEB_TITLE);
        $pdf->SetAuthor($email);
        $pdf->SetTitle("Quotation - " . $data['nomor']);
        $pdf->SetSubject($data['nomor']);
        $pdf->nomor = $data['nomor'];
        $pdf->tanggal = $data['tanggal'];
        $pdf->namaPelanggan = $data->pelanggan['namapelanggan'];
        $pdf->dibuat_oleh = $data['dibuat_oleh'];
        $pdf->oleh = $email;
        $pdf->store = $this->orm->refstore->where('idrefstore', $idrefstore)->fetch();
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        //set margins
        $pdf->SetMargins(5, 63, 5);
        $pdf->SetHeaderMargin(14);
        $pdf->SetFooterMargin(80);
        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, 80);
        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, 80);
        //set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // ---------------------------------------------------------
        // set default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // dejavusans is a UTF-8 Unicode font, if you only need to
        // print standard ASCII chars, you can use core fonts like
        // helvetica or times to reduce file size.
        // use the font
        $pdf->SetFont('times', '', 10, '', false);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $resolution = array(310, 210);
        $pdf->AddPage('L', $resolution);
        // Set some content to print
        $html = '
            
            <style>
            body {
            letter-spacing:5px;
            }      
            </style> 
            	<style type="text/css">
            .rotate-text
             {

            /* Safari */
            -webkit-transform: rotate(-90deg);

            /* Firefox */
            -moz-transform: rotate(-90deg);

            /* IE */
            -ms-transform: rotate(-90deg);

            /* Opera */
            -o-transform: rotate(-90deg);

            /* Internet Explorer */
            filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

            }
            .border-table{
            	border:0.5px solid #000;
            		
            }

            table {
            padding-top:2px;
            }

            </style>
            	
            <body>
              <table border="1">
             <tr><th style="text-align: center;" width="60"> No </th><th width="180" style="text-align: center;"> Nama Barang </th><th style="text-align: center;" width="100"> Jumlah Barang </th><th style="text-align: center;" width="300"> Harga Satuan </th><td style="text-align: center; "width="300"> Keterangan </td></tr>
            ';
        $no = 1;
        foreach ($this->orm->quotationsalesdetail->where('idquotationsales', $idquotationsales) as $row) {
            $html .= "<tr><td>" . $no . "</td><td>" . $row->refbarang['namabarang'] . "</td><td style=\"text-align: right;\">" . $row['jumlahbarang'] . "</td><td style=\"text-align: right;\">" . number_format($row['hargasatuan'], 0, ',', '.') . "</td><td>" . $row['keterangan'] . "</td></tr>";
            $no++;
        }
        $html .= '</table>
</body>';
        //print_r($html); exit;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
        //$pdf->writeHTML($html, true, 0, true, true);
        // ---------------------------------------------------------
        // Close and output PDF document
        // This method has several options, check the source code documentation for more information.
        $pdf->Output("Quotation - " . $data['nomor'], 'I');
        //============================================================+
        // END OF FILE
        //============================================================+
    }
 function generate_pdf_file($id, $forceDownload = false)
 {
     $post = get_post();
     $content = $post->the_content;
     if (has_shortcode($content, 'wpptopdfenh')) {
         if (!$this->options[$post->post_type]) {
             return false;
         }
     }
     // require_once(WPPTOPDFENH_PATH . '/tcpdf/config/lang/eng.php');
     // to avoid duplicate function error
     if (!class_exists('TCPDF')) {
         require_once WPPTOPDFENH_PATH . '/tcpdf/tcpdf.php';
     }
     if (!class_exists('MYPDF')) {
         require_once WPPTOPDFENH_PATH . '/wpptopdfenh_header.php';
     }
     // to avoid duplicate function error ( conflict with Lightbox Plus v2.4.6 )
     if (!class_exists('simple_html_dom')) {
         require_once WPPTOPDFENH_PATH . '/simplehtmldom/simple-html-dom.php';
     }
     $filePath = WPPTOPDFENH_CACHE_DIR . '/' . $post->post_name . '.pdf';
     // create new PDF document
     if (isset($this->options['pageSize'])) {
         $pagesize = $this->options['pageSize'];
     } else {
         $pagesize = PDF_PAGE_FORMAT;
     }
     if (isset($this->options['unitMeasure'])) {
         $unit = $this->options['unitMeasure'];
     } else {
         $unit = PDF_UNIT;
     }
     if (isset($this->options['orientation'])) {
         $orientation = $this->options['orientation'];
     } else {
         $unit = PDF_PAGE_ORIENTATION;
     }
     $pdf = new MYPDF($orientation, $unit, $pagesize, true, 'UTF-8', false);
     // Let other filter modify content if selected
     if (isset($this->options['otherPlugin'])) {
         $post->post_content = apply_filters('the_content', $post->post_content);
     } else {
         $post->post_content = wpautop($post->post_content);
     }
     // Process shortcodes if selected
     if (isset($this->options['processShortcodes'])) {
         $post->post_content = do_shortcode($post->post_content);
     } else {
         $post->post_content = strip_shortcodes($post->post_content);
     }
     // set document information
     $pdf->SetCreator('WP Post to PDF Enhanced plugin by Lewis Rosenthal (http://www.2rosenthals.net/wordpress/help/general-help/wp-post-to-pdf-enhanced/) with ' . PDF_CREATOR);
     $pdf->SetAuthor(get_bloginfo('name'));
     $pdf->SetTitle(apply_filters('the_title', $post->post_title));
     // Count width of logo for better presentation
     if (isset($this->options['headerlogoImage'])) {
         $logo = PDF_HEADER_LOGO;
         $logodata = getimagesize(PDF_HEADER_LOGO);
         if (isset($this->options['headerlogoImageFactor'])) {
             $logowidth = (int) ($this->options['headerlogoImageFactor'] * $logodata[0] / $logodata[1]);
         } else {
             $logowidth = (int) (14 * $logodata[0] / $logodata[1]);
         }
     }
     // new feature under development: specify header/footer text/separator color
     // some addtional header data which should be set in the admin UI; for testing, we're hiding the separator line (note the RGB array)
     //$header_text_color = array( 0,0,0 );
     //$header_line_color = array( 255,255,255 );
     // some addtional footer data which should be set in the admin UI; for testing, we're hiding the separator line (note the RGB array)
     //$footer_text_color = array( 0,0,0 );
     //$footer_line_color = array( 255,255,255 );
     //$pdf->SetSubject('TCPDF Tutorial');
     //$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data, as appropriate for PHP 5.4 or below
     if (version_compare(phpversion(), '5.4.0', '<')) {
         $pdf->SetHeaderData($logo, $logowidth, html_entity_decode(get_bloginfo('name'), ENT_COMPAT | ENT_QUOTES), html_entity_decode(get_bloginfo('description') . "\n" . home_url(), ENT_COMPAT | ENT_QUOTES), $header_text_color, $header_line_color);
     } else {
         $pdf->SetHeaderData($logo, $logowidth, html_entity_decode(get_bloginfo('name'), ENT_COMPAT | ENT_HTML401 | ENT_QUOTES), html_entity_decode(get_bloginfo('description') . "\n" . home_url(), ENT_COMPAT | ENT_HTML401 | ENT_QUOTES), $header_text_color, $header_line_color);
     }
     // set header and footer fonts
     $pdf->setHeaderFont(array($this->options['headerFont'], '', $this->options['headerFontSize']));
     $pdf->setFooterFont(array($this->options['footerFont'], '', $this->options['footerFontSize']));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     if ($this->options['marginLeft'] > 0) {
         $pdf->SetLeftMargin($this->options['marginLeft']);
     } else {
         $pdf->SetLeftMargin(PDF_MARGIN_LEFT);
     }
     if ($this->options['marginRight'] > 0) {
         $pdf->SetRightMargin($this->options['marginRight']);
     } else {
         $pdf->SetRightMargin(PDF_MARGIN_RIGHT);
     }
     if ($this->options['marginTop'] > 0) {
         $pdf->SetTopMargin($this->options['marginTop']);
     } else {
         $pdf->SetTopMargin(PDF_MARGIN_TOP);
     }
     if ($this->options['marginHeader'] > 0) {
         $pdf->SetHeaderMargin($this->options['marginHeader']);
     } else {
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     }
     if ($this->options['marginFooter'] > 0) {
         $pdf->SetFooterMargin($this->options['marginFooter']);
     } else {
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     }
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     if ($this->options['imageScale'] > 0) {
         $pdf->setImageScale($this->options['imageScale']);
     } else {
         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     }
     // ---------------------------------------------------------
     // Set the default LI image, if specified
     if (isset($this->options['liSymbol'])) {
         $lisymbol = 'img|' . $this->options['liSymbolType'] . '|' . $this->options['liSymbolWidth'] . '|' . $this->options['liSymbolHeight'] . '|' . WP_CONTENT_DIR . '/uploads/' . $this->options['liSymbolFile'];
         $pdf->setLIsymbol($lisymbol);
     }
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont($this->options['contentFont'], '', $this->options['contentFontSize'], '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     // Apply global css, if set in config
     if ($this->options['applyCSS']) {
         $html .= '<style>' . $this->options['customCss'] . '</style>';
     }
     // Set some content to print
     $html .= '<h1>' . html_entity_decode($post->post_title, ENT_QUOTES) . '</h1>';
     // Display author name is set in config
     if (isset($this->options['authorDetail']) and !$this->options['authorDetail'] == '') {
         $author = get_the_author_meta($this->options['authorDetail'], $post->post_author);
         $html .= '<p><strong>Author : </strong>' . $author . '</p>';
     }
     // Display category list is set in config
     if (isset($this->options['postCategories'])) {
         $categories = get_the_category_list(', ', '', $post);
         if ($categories) {
             $html .= '<p><strong>Categories : </strong>' . $categories . '</p>';
         }
     }
     // Display tag list is set in config
     if (isset($this->options['postTags'])) {
         $tags = get_the_tags($post->the_tags);
         if ($tags) {
             $html .= '<p><strong>Tagged as : </strong>';
             foreach ($tags as $tag) {
                 $tag_link = get_tag_link($tag->term_id);
                 $html .= '<a href="' . $tag_link . '">' . $tag->name . '</a>';
                 if (next($tags)) {
                     $html .= ', ';
                 }
             }
             $html .= '</p>';
         }
     }
     // Display date if set in config
     if (isset($this->options['postDate'])) {
         $date = get_the_date($post->the_date);
         $html .= '<p><strong>Date : </strong>' . $date . '</p>';
     }
     // Display featured image if set in config and post/page
     if (isset($this->options['featuredImage'])) {
         if (has_post_thumbnail($post->ID)) {
             $html .= get_the_post_thumbnail($post->ID);
         }
     }
     $html .= htmlspecialchars_decode(htmlentities($post->post_content, ENT_NOQUOTES, 'UTF-8', false), ENT_NOQUOTES);
     $dom = new simple_html_dom();
     $dom->load($html);
     foreach ($dom->find('img') as $e) {
         // Try to respect alignment of images
         // This code is under heavy development, so well-commented
         // First, try to determine the desired alignment from the class attribute inserted by WP.
         // Note that as we're still working with HTML vs CSS, and HTML uses "middle" for center, we
         // have two variables to fill for that possibility.
         if (preg_match('/alignleft/i', $e->class)) {
             $imgalign = 'left';
         } elseif (preg_match('/alignright/i', $e->class)) {
             $imgalign = 'right';
         } elseif (preg_match('/aligncenter/i', $e->class)) {
             $imgalign = 'center';
             $htmlimgalign = 'middle';
         } else {
             $imgalign = 'none';
         }
         // These options apply to all images. Remove any embedded class, which is ignored by TCPDF, anyway;
         // then set an align attribute inside the img tag (for HTML), and finally, a style tag (for CSS).
         $e->class = null;
         $e->align = $imgalign;
         if (isset($htmlimgalign)) {
             $e->style = 'float:' . $htmlimgalign;
         } else {
             $e->style = 'float:' . $imgalign;
         }
         // Try to identify SVG images vs JPG or PNG, so that we treat them correctly. Currently, we don't
         // handle these well, so we'll just swap them with placeholder links.
         // Note that we're still using div tags to (harshly) force images into some semblance of horizontal
         // position. This precludes text wrap, and ultimately (if we can get the above working) should be
         // replaced (unless we need the text link) with the CSS in the img tag (if TCPDF will respect it).
         if (strtolower(substr($e->src, -4)) == '.svg') {
             $e->src = null;
             $e->outertext = '<div style="text-align:' . $imgalign . '">[ SVG: ' . $e->alt . ' ]</div><br/>';
         } else {
             $e->outertext = '<div style="text-align:' . $imgalign . '">' . $e->outertext . '</div>';
         }
     }
     $html = $dom->save();
     $dom->clear();
     // Test TCPDF functions to include here.
     // Presently, we're working with trying to get PDF forms working. These options should go into the admin UI.
     // set default form properties
     $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
     // Print text using writeHTML
     $pdf->writeHTML($html, true, 0, true, 0);
     // ---------------------------------------------------------
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     // Create directory if not exist
     if (!is_dir(WPPTOPDFENH_CACHE_DIR)) {
         mkdir(WPPTOPDFENH_CACHE_DIR, 0777, true);
     }
     if ($forceDownload) {
         $pdf->Output($filePath, 'FI');
     } else {
         $pdf->Output($filePath, 'F');
     }
 }
Пример #5
0
// set margins
$pdf->SetMargins(15, 20, 15);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// borra la linea de arriba en el area del header
$pdf->setPrintHeader(false);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
    require_once dirname(__FILE__) . '/lang/eng.php';
    $pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->setFontSubsetting(false);
$pdf->SetFont('times', 'B', 11);
$nit = $invoice->nit;
$nfac = $invoice->invoice_number;
$nauto = $invoice->number_autho;
$sfc = "01";
// add a page
$pdf->AddPage();
//contenido del recuadro
$html = '
    <p style="line-height: 175% ">
        NIT &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: ' . $nit . ' <br>
        AUTORIZACIÓN Nº  &nbsp;: ' . $nauto . '  <br>
        FACTURA Nº &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: ' . $nfac . ' <br>
        SFC &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: ' . $sfc . ' <br>
    </p>';
Пример #6
0
function boookattach($results, $type = '')
{
    // Include the main TCPDF library (search for installation path).
    //require_once('tcpdf/examples/tcpdf_include.php');
    $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'utf-8', false);
    //$pdf->Footer('hello');
    // create new PDF document
    //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    //$pdf->SetAuthor('Nicola Asuni');
    //$pdf->SetTitle('TCPDF Example 001');
    //$pdf->SetSubject('<h1>TCPDF Tutorial</h1>');
    //$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    // set default header data
    //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
    //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '<div style="float:right">haoooooooo</div>', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
    $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
    // set header and footer fonts
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(20);
    //echo PDF_MARGIN_FOOTER;exit;
    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    // set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    // ---------------------------------------------------------
    // set default font subsetting mode
    $pdf->setFontSubsetting(true);
    // Set font
    // dejavusans is a UTF-8 Unicode font, if you only need to
    // print standard ASCII chars, you can use core fonts like
    // helvetica or times to reduce file size.
    //$pdf->SetFont('dejavusans', '', 10, '', true);
    $pdf->SetFont('Helvetica', '', 10, '', 'false');
    // Add a page
    // This method has several options, check the source code documentation for more information.
    $pdf->AddPage();
    // set text shadow effect
    $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 1, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 0, 'blend_mode' => 'Normal'));
    // Set some content to print
    $tbl = '<br /><br/><br/><br/>	
<table border="0" cellpadding="2" cellspacing="2" nobr="true">
 
 <tr>
  <td style="width:60%"><b>Your Personal Travel Advisor:</b>' . @$results['pdfdata']['adviser_info']['name'] . '</td>
  <td style="width:40%"><b>Quote Reference:</b>' . @$results['pdfdata']['adviser_info']['reference'] . '</td>
 </tr>
 <tr>  
  <td style="width:60%"><b>Phone Number:</b>' . @$results['pdfdata']['adviser_info']['phone'] . '</td>
  <td style="width:40%"><b>Date:</b> ' . @$results['pdfdata']['adviser_info']['date'] . '</td> 
 </tr>
 <tr>
  <td style="width:60%"><b>Email Address:</b>' . @$results['pdfdata']['adviser_info']['email'] . '</td>
  <td style="width:40%"><b>Adults:</b> ' . @$results['seg'][0]['num_adults'] . ' <b>Children:</b> ' . @$results['seg'][0]['num_children'] . '</td>  
 </tr>
</table>';
    $pdf->writeHTML($tbl, true, false, false, false, '');
    //$ci = $results['controller'];
    $t = json_decode($results['row'][0]['adults_info'], true);
    $tbl = '
<div>
	<span>Dear ' . $t['fname'][0] . '</span>
	</br>
	<p>
		I have pleasure in enclosing a quote in respect of your recent enquiry with Super Escapes. Please feel free to contact us, should you need any more information or advice.
	</p>
</div>';
    $pdf->writeHTML($tbl, true, false, false, false, '');
    if (isset($results['fobj'])) {
        $depts = fetch_departures();
        $arrivs = fetch_arrivals();
        $dep_arr = explode('-', $depts[$results['fobj']['@attributes']['depapt']]);
        $arr_arr = explode('-', $arrivs[$results['fobj']['@attributes']['arrapt']]);
        $ret_arr = explode('-', $depts[$results['fobj']['@attributes']['retapt']]);
        $dept_start_time = substr(explode(' ', $results['fobj']['@attributes']['outdep'])[1], 0, -3);
        $dept_arr_time = substr(explode(' ', $results['fobj']['@attributes']['outarr'])[1], 0, -3);
        $return_start_time = substr(explode(' ', $results['fobj']['@attributes']['indep'])[1], 0, -3);
        $return_arr_time = substr(explode(' ', $results['fobj']['@attributes']['inarr'])[1], 0, -3);
        $tbl = '
<b><u>Flight Details : </u></b><br><br>  
<table border="0" cellpadding="2" cellspacing="2" nobr="true">
	<tr>
		<th style="width:35%;text-align:center;font-weight:bold;">Route</th>
		<td style="width:13%;text-align:center;font-weight:bold;">Dep Date</td>
		<td style="width:13%;text-align:center;font-weight:bold;">Dep Time</td>
		<td style="width:13%;text-align:center;font-weight:bold;">Arr Date</td>
		<td style="width:13%;text-align:center;font-weight:bold;">Arr Time</td>
		<td style="width:13%;text-align:center;font-weight:bold;">Flight No</td>
	</tr>
    <tr>
        <td >' . current($dep_arr) . ' Airport ' . array_pop($arr_arr) . ' Airport</td>
        <td>' . explode(' ', $results['fobj']['@attributes']['outdep'])[0] . '</td>
		<td>' . $dept_start_time . '</td>
		<td>' . explode(' ', $results['fobj']['@attributes']['outarr'])[0] . '</td>
		<td>' . $dept_arr_time . '</td>
		<td>' . $results['fobj']['@attributes']['outfltnum'] . '</td>
    </tr>
    <tr>
         <td >' . array_pop($arr_arr) . ' Airport ' . current($ret_arr) . ' Airport</td>
		<td>' . explode(' ', $results['fobj']['@attributes']['indep'])[0] . '</td>    	
		<td>' . $return_start_time . '</td>
		<td>' . explode(' ', $results['fobj']['@attributes']['inarr'])[0] . '</td>
		<td>' . $return_arr_time . '</td>
		<td>' . $results['fobj']['@attributes']['infltnum'] . '</td>
    </tr>  
</table>';
        $pdf->writeHTML($tbl, true, false, false, false, '');
    }
    $ci = $results['controller'];
    if (!empty($results['hobjs'])) {
        $tbl = '
<b><u>Accommodation Details: </u></b><br><br>  
<table border="0" cellpadding="2" cellspacing="2" nobr="true">
	<tr>
		<th style="text-align:center;font-weight:bold;">Hotel</th>
		<td style="text-align:center;font-weight:bold;">Resort</td>
		<td style="text-align:center;font-weight:bold;">Board</td>
		<td style="text-align:center;font-weight:bold;">Room</td>
		<td style="text-align:center;font-weight:bold;">Rating</td>		
	</tr>
    <tr>
        <td style="text-align:center;">' . urldecode($results['hobjs'][0]['@attributes']['hotelname']) . '</td>
        <td style="text-align:center;">' . urldecode($results['hobjs'][0]['@attributes']['resort']) . '</td>
		<td style="text-align:center;">' . boardbasis($results['hobjs'][0]['@attributes']['boardbasis']) . '</td>
		<td style="text-align:center;">' . $results['seg'][0]['num_rooms'] . ' ' . $results['hobjs'][0]['@attributes']['suppname'] . '</td>
		<td style="text-align:center;">' . (int) $results['hobjs'][0]['@attributes']['starrating'] . ' KEY</td>		
    </tr>
    <tr>
		<td style="text-align:center;font-weight:bold;">Check In</td>
    	<td style="text-align:center;font-weight:bold;">Check Out</td>
		<td style="text-align:center;font-weight:bold;">Adults</td>
		<td style="text-align:center;font-weight:bold;">Children</td>
		<td style="text-align:center;font-weight:bold;">Infants</td>
    </tr>
	<tr>
		<td style="text-align:center;">' . $results['hobjs'][0]['@attributes']['checkindate'] . '</td>
    	<td style="text-align:center;">' . date('d/m/Y', strtotime('+' . $results['hobjs'][0]['@attributes']['nights'] . " day", $ci->cvtDt(str_date($results['hobjs'][0]['@attributes']['checkindate'])))) . '</td>
		<td style="text-align:center;">' . @$results['seg'][0]['num_adults'] . '</td>
		<td style="text-align:center;">' . @$results['seg'][0]['num_children'] . '</td>
		<td style="text-align:center;"></td>
    </tr>	
</table>';
        $pdf->writeHTML($tbl, true, false, false, false, '');
    }
    $tbl = <<<EOD
<div style="margin-top:20px;">
\t<b><u>Price Summary:</u></p>\t
\t<p>
\t\tThe total price inclusive of any discounts for the holiday described above is: £653.92 To make a firm reservation please call us on 01386298033 and quote the reference number at the top of this quote. Our friendly and experienced travel consultants will be happy to book the above holiday or look for any alternatives that may suit your needs. 
\t</p>
\t<p>\t\t
\t\tMay we take this opportunity of thanking you for your enquiry, and we do hope that we are able to assist you in fulfilling your requirements.
\t</p>
</div>
EOD;
    $pdf->writeHTML($tbl, true, false, false, false, '');
    $tbl = <<<EOD
<div style="margin-top:20px;text-align:center;">\t
\t<small>
\t\t* All costings are subject to a final confirmation which will be given upon making a firm reservation *
\t</small>
</div><br/><br/>
EOD;
    $pdf->writeHTML($tbl, true, false, false, false, '');
    /*$tbl = '
    <div style="margin-top:20px;width:100%;display:inline-flex;">	
    	<div style="color:blue;text-align:center;width:60%">BookItNow Travel is a trading name of broadway Travel Services (Wimbledon) Ltd. Whose registered office is at Unit 1,Finway,Dallow Road,Luton,Beds LUI 1WE</div>
    	<div> <img src="'.base_url().'/images/abta.png"/></div>
    </div>';
    $pdf->writeHTML($tbl, true, false, false, false, '');*/
    //echo $tbl;exit;
    $tbl = '
<div style="margin-top:20px;">
	<span>Yours sincerely</span>
	<p>' . @$results['pdfdata']['adviser_info']['name'] . '</p>
</div>';
    $pdf->writeHTML($tbl, true, false, false, false, '');
    if (!empty($results['hobjs'])) {
        // $hotel_meta = new SimpleXMLElement(download_page('http://87.102.127.86:8005/search/websearch.exe?pageid=7&compid=1&brochurecode=BEWE-AMTSES1CO0'));
        $hotel_meta = new SimpleXMLElement(download_page('http://87.102.127.86:8005/search/websearch.exe?pageid=7&compid=1&brochurecode=' . $results['hobjs'][0]['@attributes']['brocode']));
        $i = 1;
        $desc = urldecode($hotel_meta->HotelDescription);
        $ty = new tidy();
        $desc = $ty->repairString($desc);
        $tbl = '<br /><br/><br/><br/><h2 style="text-align:center; "pagebreak="true">Accommodation Info</h2><table>';
        foreach ($hotel_meta->Images->Url as $img) {
            $tbl .= '<tr>';
            //Allow_url_fopen must be On
            if (is_array(@getimagesize(urldecode($img)))) {
                $tbl .= '<td colspan="1"  style="margin-right: 30px !important;"><img src="' . urldecode($img) . '" /></td>';
            } else {
                $tbl .= '<td colspan="3"><img src="' . base_url() . '/images/destination_placeholder.jpg"/></td>';
            }
            $tbl .= '<td colspan="1"></td>';
            if ($i == 1) {
                $tbl .= '<td rowspan="' . count($hotel_meta->Images->Url) . '" colspan="8">' . $desc . '</td>';
            }
            $tbl .= '</tr>';
            //$tbl .= '<style>.desc{background:red;}</style>';
            $i++;
        }
        $tbl .= '</table>';
        //echo $tbl;exit;
        $pdf->writeHTML($tbl, true, false, false, false, '');
    }
    // ---------------------------------------------------------
    // Close and output PDF document
    // This method has several options, check the source code documentation for more information.
    //$pdf->Output('D:\xampp\htdocs\test_plugins\tcpdf\examples\example_001.pdf', 'F');
    if ($type == 'email') {
        $pdf->Output(getcwd() . '/booking_files/' . $results['pdfdata']['adviser_info']['reference'] . '.pdf', 'F');
        if (file_exists(getcwd() . '/booking_files/' . $results['pdfdata']['adviser_info']['reference'] . '.pdf')) {
            $subject = 'Quick Quote Ref: ' . $results['pdfdata']['adviser_info']['reference'] . ' - Book it now';
            $body = 'Dear ' . $t['fname'][0];
            $body .= '<p></p>';
            $body .= '<p>Please find the attached document</p>';
            $body .= '<p></p>';
            $body .= '<p>Cheers</p>';
            $body .= '<p>BootItNow</p>';
            $from = '*****@*****.**';
            $sendername = "BookItNow Admin";
            $list = array($results['row'][0]['email']);
            $config['protocol'] = "smtp";
            $config['smtp_host'] = 'mail.expertwebworx.in';
            $config['smtp_port'] = '25';
            $config['smtp_user'] = '******';
            $config['smtp_pass'] = '******';
            $config['smtp_crypto'] = 'tls';
            $config['charset'] = "iso-8859-1";
            $config['mailtype'] = "html";
            $ci->load->library('email', $config);
            $ci->email->set_newline("\r\n");
            $ci->email->from($from, $sendername);
            $ci->email->to($list);
            $ci->email->reply_to($from, $sendername);
            $ci->email->subject($subject);
            $ci->email->attach(getcwd() . '/booking_files/' . $results['pdfdata']['adviser_info']['reference'] . '.pdf');
            $ci->email->message($body);
            if ($ci->email->send()) {
            }
        }
    } else {
        $pdf->Output($results['pdfdata']['adviser_info']['reference'] . '.pdf', 'D');
        exit;
    }
    //============================================================+
    // END OF FILE
    //============================================================+
}
Пример #7
0
    function creatNewPdf()
    {
        $agru = func_get_arg(0);
        $logo = $agru['logo'];
        $link = $agru['link'];
        $target = $agru['target'];
        $logoExtention = $agru['logo_extention'];
        $date = $agru['date'];
        $title = $agru['title'];
        $disc = $agru['description'];
        $image = $agru['image'];
        $content = $agru['content'];
        $copyright = $agru['copyright'];
        $fileName = $agru['file_name'];
        $pdfCreator = $agru['pdf_creator'];
        $pdfAuthor = $agru['pdf_author'];
        $pdfTitle = $agru['pdf_title'];
        $pdfSubject = $agru['pdf_subject'];
        $pdfKeywords = $agru['pdf_keywords'];
        // create new PDF document
        $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf->setTempRTL('R');
        $pdf->image_file = $logo;
        $pdf->href = $target;
        $pdf->link = $link;
        $pdf->copyright = $copyright;
        $this->extention = $logoExtention;
        # must included in each decument[Must Include]
        // appear in document properties
        $pdf->SetCreator($pdfCreator);
        $pdf->SetAuthor($pdfAuthor);
        $pdf->SetTitle($pdfTitle);
        $pdf->SetSubject($pdfSubject);
        $pdf->SetKeywords($pdfKeywords);
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, ' ', ' ', array(0, 64, 255), array(0, 64, 128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        // header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // end of header
        # set default monospaced font[Must Include]
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        # set margins[Must Include]
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        // header & footer margin
        $pdf->SetHeaderMargin(50);
        $pdf->SetFooterMargin(20);
        $pdf->SetAutoPageBreak(TRUE, 30);
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        $pdf->setFontSubsetting(true);
        //$pdf->SetFont('almohanad', '', 13);
        $pdf->setRTL(true);
        // cehck here if ar or en
        $pdf->startPageGroup();
        $pdf->AddPage();
        $lg = array();
        $lg['a_meta_charset'] = 'UTF-8';
        $lg['a_meta_dir'] = 'rtl';
        $pdf->setLanguageArray($lg);
        $pdf->SetFont('almohanad', '', 13);
        $pdf->setRTL(true);
        // cehck here if ar or en
        $html = '

<div >
<br/>
  <span id="date"style="color:#008080"  > ' . $date . ' </span>        
  <h3 id="title" style="color:#191970"> ' . $title . ' </h3>        
  <h5 id="description" style="color:#6A5ACD"> ' . $disc . ' </h5> 
  <img src="' . $image . '" alt="' . $title . '"  /> 
   <div style="align:justify"> ' . $content . '  </div>   

</div>

               ';
        // $pdf->writeHTML($html, true, false, false, true, "");
        $pdf->writeHTMLCell($w = 170, $h = 0, $x = 0, $y = 0, $html, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = "R");
        $pdf->setRTL(true);
        #excute the file
        $pdf->Output(PDF_FILES . $fileName . '.pdf', 'F');
    }