Example #1
1
 /**
  * Handle the event.
  *
  * @param  BookPublished $event
  * @return void
  */
 public function handle(CreateChapter $event)
 {
     // create PDF
     $fpdi = new \FPDI();
     // count the book page
     $pageCount = $fpdi->setSourceFile($this->uploadPath . $event->chapter->url);
     // this one is used within the CreatePDF to include it within the template
     Session::put('total_pages', $pageCount);
     // update the database with total page count
     $event->chapter->update(['total_pages' => $pageCount]);
     $event->chapter->save();
 }
Example #2
0
/**
 *      Return a PDF instance object. We create a FPDI instance that instanciate TCPDF (or FPDF if MAIN_USE_FPDF is on)
 *      @param      format          Array(width,height)
 *      @param      metric          Unit of format ('mm')
 *      @param      pagetype        'P' or 'l'
 *      @return     PDF object
 */
function pdf_getInstance($format, $metric = 'mm', $pagetype = 'P')
{
    global $conf;
    // Protection et encryption du pdf
    if ($conf->global->PDF_SECURITY_ENCRYPTION) {
        /* Permission supported by TCPDF
           - print : Print the document;
           - modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
           - copy : Copy or otherwise extract text and graphics from the document;
           - annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
           - fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
           - extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
           - assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
           - print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
           - owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
           */
        if ($conf->global->MAIN_USE_FPDF) {
            $pdf = new FPDI_Protection($pagetype, $metric, $format);
            // For FPDF, we specify permission we want to open
            $pdfrights = array('print');
        } else {
            $pdf = new FPDI($pagetype, $metric, $format);
            // For TCPDF, we specify permission we want to block
            $pdfrights = array('modify', 'copy');
        }
        $pdfuserpass = '';
        // Mot de passe pour l'utilisateur final
        $pdfownerpass = NULL;
        // Mot de passe du proprietaire, cree aleatoirement si pas defini
        $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass);
    } else {
        $pdf = new FPDI($pagetype, $metric, $format);
    }
    return $pdf;
}
Example #3
0
 public function createPDF(FPDI $fpdi, $filename)
 {
     $fpdi->setSourceFile(__DIR__ . '/A.pdf');
     $template = $fpdi->importPage(1);
     $size = $fpdi->getTemplateSize($template);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     $template = $fpdi->importPage(1);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     file_put_contents($filename, $fpdi->Output('', 'S'));
 }
 public function testMerge()
 {
     $fpdi = new FPDI();
     $fpdi->setSourceFile(__DIR__ . '/A.pdf');
     $template = $fpdi->importPage(1);
     $size = $fpdi->getTemplateSize($template);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     $template = $fpdi->importPage(1);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     file_put_contents(__DIR__ . '/AA.pdf', $fpdi->Output('', 'S'));
 }
Example #5
0
 function _putcatalog()
 {
     parent::_putcatalog();
     if (!empty($this->javascript)) {
         $this->_out('/Names <</JavaScript ' . $this->n_js . ' 0 R>>');
     }
 }
Example #6
0
function split_pdf($filename, $end_directory = false, $num = 1)
{
    require_once 'fpdf/fpdf.php';
    require_once 'fpdi/fpdi.php';
    $end_directory = $end_directory ? $end_directory . date("d-m-Y__H-i-s") . "/" : './';
    $new_path = preg_replace('/[\\/]+/', '/', $end_directory . '/' . substr($filename, 0, strrpos($filename, '/')));
    if (!is_dir($new_path)) {
        // Will make directories under end directory that don't exist
        // Provided that end directory exists and has the right permissions
        mkdir($new_path, 0777, true);
    }
    $pdf = new FPDI();
    $pagecount = $pdf->setSourceFile($filename);
    // How many pages?
    $j = 0;
    // Split each page into a new PDF
    $new_pdf = new FPDI();
    for ($i = 1; $i <= $pagecount; $i++) {
        $new_pdf->AddPage();
        $new_pdf->setSourceFile($filename);
        $new_pdf->useTemplate($new_pdf->importPage($i));
        if ($i != 1 && $i % $num == 0 || $num == 1) {
            try {
                $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . $i . ".pdf";
                $new_pdf->Output($new_filename, "F");
                $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
                echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
            } catch (Exception $e) {
                echo 'Caught exception: ', $e->getMessage(), "\n";
            }
            unset($new_pdf);
            $new_pdf = new FPDI();
            $j = 0;
        }
        $j++;
    }
    if ($j != 0) {
        try {
            $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . ($i - 1) . ".pdf";
            $new_pdf->Output($new_filename, "F");
            $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
            echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
    }
}
Example #7
0
 function _endpage()
 {
     if ($this->angle != 0) {
         $this->angle = 0;
         $this->_out('Q');
     }
     parent::_endpage();
 }
 function SetHeader()
 {
     $this->SetFont('Arial', 'B', 16);
     $this->Image(image_url() . '/ufma.png', 10, 10);
     parent::Ln(7);
     $this->Cell(0, 7, specialChars('UNIVERSIDADE FEDERAL DO MARANHƃO'), 0, 0, 'C');
     parent::Ln(7);
     $this->SetFont('Arial', '', 11);
     $this->Cell(0, 7, specialChars('FundaĆ§Ć£o InstituĆ­da nos termos da Lei 5.152 de 21/10/1966'), 0, 0, 'C');
     parent::Ln(7);
     $this->Cell(0, 7, specialChars('SĆ£o LuĆ­s - MaranhĆ£o'), 0, 0, 'C');
     parent::Ln(7);
 }
Example #9
0
 /**
  * Merges your provided PDFs and outputs to specified location.
  * @param $outputmode
  * @param $outputname
  * @return PDF
  */
 public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
 {
     if (!isset($this->_files) || !is_array($this->_files)) {
         throw new exception("No PDFs to merge.");
     }
     $fpdi = new FPDI();
     $fpdi->setPrintHeader(FALSE);
     $fpdi->setPrintFooter(FALSE);
     //merger operations
     foreach ($this->_files as $file) {
         $filename = $file[0];
         $filepages = $file[1];
         $count = $fpdi->setSourceFile($filename);
         //add the pages
         if ($filepages == 'all') {
             for ($i = 1; $i <= $count; $i++) {
                 $template = $fpdi->importPage($i);
                 $size = $fpdi->getTemplateSize($template);
                 $orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
                 $fpdi->AddPage($orientation, array($size['w'], $size['h']));
                 $fpdi->useTemplate($template);
             }
         } else {
             foreach ($filepages as $page) {
                 if (!($template = $fpdi->importPage($page))) {
                     throw new exception("Could not load page '{$page}' in PDF '{$filename}'. Check that the page exists.");
                 }
                 $size = $fpdi->getTemplateSize($template);
                 $orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
                 $fpdi->AddPage($orientation, array($size['w'], $size['h']));
                 $fpdi->useTemplate($template);
             }
         }
     }
     //output operations
     $mode = $this->_switchmode($outputmode);
     if ($mode == 'S') {
         return $fpdi->Output($outputpath, 'S');
     } else {
         if ($fpdi->Output($outputpath, $mode) == '') {
             return true;
         } else {
             throw new exception("Error outputting PDF to '{$outputmode}'.");
             return false;
         }
     }
 }
Example #10
0
function renderPDF($id,$mode)
{
	$pdf = new FPDI();
	
	$db_catalogue_pages = new catalogue_pages;
	$db_catalogue_pages->get_one_catalogue_pages($id);
	$db_catalogue_pages->load();
	$template_id = $db_catalogue_pages->get_pag_template();
	
	$template = new catalogue_templates;

	$template->getOne($template_id);
	$template->load();

	$pdf->addPage("Landscape","Letter");

	$db_catalogue_objects = new catalogue_objects;
	$db_catalogue_objects->get_all($id);

	$pdf->SetFont('Arial','',14);

	$pdf->Image("pdftemplates/".$template->get_tem_file().".jpg",0,0);
	while($db_catalogue_objects->load())
	{
		$var = explode("_",$db_catalogue_objects->get_obj_var());
		if($var[0] == "image")
		{
			if(file_exists($db_catalogue_objects->field->obj_image)) $pdf->Image($db_catalogue_objects->field->obj_image,($db_catalogue_objects->field->obj_posx*0.353),($db_catalogue_objects->field->obj_posy*0.353),"50","50");
		}
		$pdf->SetXY($db_catalogue_objects->field->obj_posx*0.353,($db_catalogue_objects->field->obj_posy*0.35) + 60);
		$pdf->Write(5,$db_catalogue_objects->field->obj_text);
	}

	$db_catalogue_objects->close();
	$db_catalogue_pages->close();
	//if($mode=="I") $pdf->Output("page_".$id.".pdf", "I");
	//else $pdf->Output("pages/page_".$id.".pdf", "F");
	$pdf->Output("pages/page_".$id.".pdf", "F");
	
}
Example #11
0
function carl_merge_pdfs_fpdi($pdffiles, $titles = array(), $metadata = array(), $metadata_encoding = 'UTF-8')
{
    // FPDI throws some notices that break the PDF
    $old_error = error_reporting(E_ERROR | E_WARNING | E_PARSE);
    include_once INCLUDE_PATH . 'pdf/tcpdf/tcpdf.php';
    include_once INCLUDE_PATH . 'pdf/fpdi/fpdi.php';
    if (gettype($pdffiles) != 'array') {
        trigger_error('$pdffiles must be an array');
        return false;
    }
    if (!(class_exists('TCPDF') && class_exists('FPDI'))) {
        trigger_error('You must have TCPDF/FPDI installed in order to run carl_merge_pdfs()');
        return false;
    }
    if (empty($pdffiles)) {
        return NULL;
    }
    $fpdi = new FPDI();
    foreach ($pdffiles as $pdffile) {
        if (file_exists($pdffile)) {
            $count = $fpdi->setSourceFile($pdffile);
            for ($i = 1; $i <= $count; $i++) {
                $template = $fpdi->importPage($i);
                $size = $fpdi->getTemplateSize($template);
                $fpdi->AddPage('P', array($size['w'], $size['h']));
                $fpdi->useTemplate($template, null, null, null, null, true);
                if ($i == 1) {
                    if (isset($titles[$pdffile])) {
                        $bookmark = html_entity_decode($titles[$pdffile]);
                    } else {
                        $bookmark = $pdffile;
                    }
                    $fpdi->Bookmark($bookmark, 1, 0, '', '', array(0, 0, 0));
                }
            }
        }
    }
    error_reporting($old_error);
    return $fpdi->Output('ignored.pdf', 'S');
}
Example #12
0
 function split_multi_pdf($arrayOfFiles)
 {
     $new_path = storage_path() . '/Macyspos';
     if (!is_dir($new_path)) {
         // Will make directories under end directory that don't exist
         // Provided that end directory exists and has the right permissions
         mkdir($new_path, 0777, true);
     }
     foreach ($arrayOfFiles as $file) {
         $tempArrayOfPos = array();
         $tempArrayOfPos = $this->getArrayOfPOs($file);
         $pdf = new FPDI();
         $pagecount = $pdf->setSourceFile($file);
         // How many pages?
         for ($i = 1; $i <= $pagecount; $i++) {
             $singleItem = $tempArrayOfPos[$i - 1];
             //   dd($singleItem);
             $tempPackingList = MacysPackingList::where('po', '=', $singleItem['PO'])->first();
             if ($tempPackingList == null) {
                 $new_pdf = new FPDI();
                 $new_pdf->AddPage();
                 $new_pdf->setSourceFile($file);
                 $newPackingList = new MacysPackingList();
                 $newPackingList->po = trim($singleItem['PO']);
                 $newPackingList->shipterms = trim($singleItem['shipterms']);
                 $new_pdf->useTemplate($new_pdf->importPage($i));
                 try {
                     $new_filename = storage_path() . '/Macyspos/' . $singleItem['PO'] . '.pdf';
                     $newPackingList->pathToFile = $new_filename;
                     $new_pdf->Output($new_filename, "F");
                     $newPackingList->save();
                 } catch (Exception $e) {
                     echo 'Caught exception: ', $e->getMessage(), "\n";
                 }
             }
         }
     }
 }
Example #13
0
         break;
     case 'legal':
         $page_width = 14;
         //in
         $page_height = 8.5;
         //in
         break;
     case 'letter':
     default:
         $page_width = 11;
         //in
         $page_height = 8.5;
         //in
 }
 // initialize pdf
 $pdf = new FPDI('L', 'in');
 $pdf->SetAutoPageBreak(false);
 $pdf->setPrintHeader(false);
 $pdf->setPrintFooter(false);
 $pdf->SetMargins(0.5, 0.5, 0.5, true);
 //set default font
 $pdf->SetFont('helvetica', '', 7);
 //add new page
 $pdf->AddPage('L', array($page_width, $page_height));
 $chunk = 0;
 //write the table column headers
 $data_start = '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
 $data_end = '</table>';
 $data_head = '<tr>';
 $data_head .= '<td width="7.5%"><b>' . $text['label-direction'] . '</b></td>';
 $data_head .= '<td width="15%"><b>' . $text['label-cid-name'] . '</b></td>';
Example #14
0
 public function save_design()
 {
     if ($this->input->post('mode') == 'edit') {
         $this->db->delete('designs', array('id' => $this->input->post('design_id')));
     }
     $faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket'));
     $backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket'));
     $face = $this->input->post('face');
     $back = $this->input->post('back');
     // get all fonts
     $query = $this->db->get('fonts');
     $fonts = array();
     foreach ($query->result() as $font) {
         $fonts[$font->family] = $font->source;
     }
     // generate pdf face template name and preview name
     $face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf';
     $face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg';
     // convert face image to pdf
     $img = new Imagick($faceMacket);
     $img->setresolution(300, 300);
     $img->setcolorspace(Imagick::COLORSPACE_CMYK);
     $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $img->setimageformat('pdf');
     $img->writeimage($face_pdf);
     // include TCPDF ana FPDI
     include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
     include_once APPPATH . 'libraries/tcpdf/fpdi.php';
     include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
     $fontMaker = new TCPDF_FONTS();
     // сŠ¾Š·Š“Š°Ń‘Š¼ Š»Šøст
     $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
     $pdf->SetMargins(0, 0, 0, true);
     $pdf->AddPage('L');
     // Š·Š°Š³Ń€ŃƒŠ·ŠøŠ¼ рŠ°Š½ŠµŠµ сŠ¾Ń…Ń€Š°Š½Ń‘Š½Š½Ń‹Š¹ шŠ°Š±Š»Š¾Š½
     $pdf->setSourceFile($face_pdf);
     $pdf->SetMargins(0, 0, 0, true);
     $tplIdx = $pdf->importPage(1);
     $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
     // устŠ°Š½Š¾Š²ŠøŠ¼ Š¾ŠæцŠøŠø Š“Š»Ń pdf
     $pdf->setCellHeightRatio(1);
     $pdf->setCellPaddings(0, 0, 0, 0);
     $pdf->setCellMargins(0, 0, 0, 0);
     $pdf->SetAutoPageBreak(false, 0);
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     if (!empty($face)) {
         // Š¾Ń‚Ń€ŠøсуŠµŠ¼ сŠ½Š°Ń‡Š°Š»Š° ŠøŠ·Š¾Š±Ń€Š°Š¶ŠµŠ½Šøя Š»ŠøцŠ°
         foreach ($face as $item) {
             if ($item['type'] == 'image') {
                 $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
             }
         }
         // ŠæŠ¾Ń‚Š¾Š¼ тŠµŠŗст Š½Š° Š»ŠøцŠµ
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $cmyk = $this->rgbToCmyk($item['color']);
                 $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                 // set font
                 $tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']]));
                 $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                 $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
             }
         }
     }
     // сŠ¾Ń…Ń€Š°Š½ŠøŠ¼ ŠæŠ“ф Š»ŠøцŠ°
     $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F');
     // сŠ“ŠµŠ»Š°ŠµŠ¼ ŠæрŠµŠ²ŃŒŃŽ Š“Š»Ń ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»Ń
     $im = new Imagick();
     $im->setResolution(300, 300);
     $im->readimage($face_pdf . '[0]');
     $im->flattenimages();
     $im->setImageFormat('jpg');
     $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $im->writeImage($face_preview);
     $im->clear();
     $im->destroy();
     //exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview);
     // ŠµŃŃ‚ŃŒ Š»Šø Š¾Š±Š¾Ń€Š¾Ń‚
     if (!empty($backMacket)) {
         // generate pdf back template name and preview name
         $back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf';
         $back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg';
         // convert back image to pdf
         $img = new Imagick($backMacket);
         $img->setresolution(300, 300);
         $img->setcolorspace(Imagick::COLORSPACE_CMYK);
         $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $img->setimageformat('pdf');
         $img->writeimage($back_pdf);
         // сŠ¾Š·Š“Š°Ń‘Š¼ Š»Šøст
         $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
         $pdf->AddPage('L');
         // Š·Š°Š³Ń€ŃƒŠ·ŠøŠ¼ рŠ°Š½ŠµŠµ сŠ¾Ń…Ń€Š°Š½Ń‘Š½Š½Ń‹Š¹ шŠ°Š±Š»Š¾Š½
         $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf);
         $pdf->SetMargins(0, 0, 0, true);
         $tplIdx = $pdf->importPage(1);
         $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
         // устŠ°Š½Š¾Š²ŠøŠ¼ Š¾ŠæцŠøŠø Š“Š»Ń pdf
         $pdf->SetMargins(0, 0, 0, true);
         $pdf->setCellHeightRatio(1);
         $pdf->setCellPaddings(0, 0, 0, 0);
         $pdf->setCellMargins(1, 1, 1, 1);
         $pdf->SetAutoPageBreak(false);
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         if (!empty($back)) {
             // Š¾Ń‚Ń€ŠøсуŠµŠ¼ сŠ½Š°Ń‡Š°Š»Š° ŠøŠ·Š¾Š±Ń€Š°Š¶ŠµŠ½Šøя Š¾Š±Š¾Ń€Š¾Ń‚Š°
             foreach ($back as $item) {
                 if ($item['type'] == 'image') {
                     $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
                 }
             }
             // ŠæŠ¾Ń‚Š¾Š¼ тŠµŠŗст Š½Š° Š¾Š±Š¾Ń€Š¾Ń‚Šµ
             foreach ($back as $item) {
                 if ($item['type'] == 'text') {
                     $cmyk = $this->rgbToCmyk($item['color']);
                     $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                     // set font
                     $tcpdfFont = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . '/fonts/redactor/' . $fonts[$item['font']]);
                     $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                     $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
                 }
             }
         }
         // сŠ¾Ń…Ń€Š°Š½ŠøŠ¼ ŠæŠ“ф Š¾Š±Š¾Ń€Š¾Ń‚Š°
         $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf, 'F');
         // сŠ“ŠµŠ»Š°ŠµŠ¼ ŠæрŠµŠ²ŃŒŃŽ Š“Š»Ń ŠæŠ¾Š»ŃŒŠ·Š¾Š²Š°Ń‚ŠµŠ»Ń
         $im = new Imagick();
         $im->setResolution(300, 300);
         $im->readimage($back_pdf . '[0]');
         $im->setImageFormat('jpg');
         $im->flattenimages();
         $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $im->writeImage($back_preview);
         $im->clear();
         $im->destroy();
     }
     $this->db->insert('products', array('name' => 'cards_pvc', 'tiraj' => 100, 'weight' => 0.5, 'price' => 0.49, 'cost' => 49, 'macket' => 'my_macket'));
     $product_id = $this->db->insert_id();
     $this->db->insert('designs', array('product_id' => $product_id, 'theme_id' => $this->input->post('theme'), 'face_background' => $faceMacket, 'back_background' => empty($backMacket) ? NULL : $backMacket, 'face' => $face_preview, 'back' => empty($back_preview) ? '' : $back_preview, 'type' => 'system'));
     $design_id = $this->db->insert_id();
     $options = array();
     if (!empty($face)) {
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (!empty($back)) {
         foreach ($back as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (count($options) > 0) {
         $this->db->insert_batch('design_options', $options);
     }
     echo 'OK';
 }
Example #15
0
 function SetMargins()
 {
     parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin);
 }
 function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false)
 {
     $result = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h, $adjustPageSize);
     // apply links from the template
     $tpl =& $this->tpls[$tplidx];
     if (isset($tpl['links'])) {
         foreach ($tpl['links'] as $link) {
             // $link[4] is either a string (external URL) or an integer (page number)
             if (is_int($link[4])) {
                 $l = $this->AddLink();
                 $this->SetLink($l, 0, $link[4]);
                 $link[4] = $l;
             }
             $this->Link($link[0] / $this->k, ($this->fhPt - $link[1] + $link[3]) / $this->k, $link[2] / $this->k, -$link[3] / $this->k, $link[4]);
         }
     }
     return $result;
 }
 /**
  * Save post metadata when a post is saved.
  *
  * @param int $post_id The post ID.
  * @param post $post The post object.
  * @param bool $update Whether this is an existing post being updated or not.
  */
 public function save_ticket_data($post_id, $post, $update)
 {
     global $product;
     /*
      * In production code, $slug should be set only once in the plugin,
      * preferably as a class property, rather than in each function that needs it.
      */
     $slug = 'product';
     // If this isn't a 'product' post, don't update it.
     if ($slug != $post->post_type) {
         return;
     }
     $getprod = get_product($post_id);
     //If it's not a ticket return aswell
     if ($getprod->product_type != 'ticket') {
         return;
     }
     $getmeta = get_post_meta($post_id, '_downloadable_files', true);
     //Traverse the return array since we don't know the first key
     foreach ($getmeta as $key => $value) {
         $url = $value['file'];
     }
     $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($url, PHP_URL_PATH);
     //To get the dir, use: dirname($path)
     require_once 'fpdf/fpdf.php';
     require_once 'fpdi/fpdi.php';
     //Get stuff to add to pdf :D
     $getmetaall = get_post_meta($post_id);
     $getcontent = get_post_meta($post_id, 'frs_woo_product_tabs', true);
     $i = 1;
     $pdf = new FPDI();
     //	$pdf->AddPage();
     //Set the source PDF file
     //$pagecount = $pdf->setSourceFile($path);
     //Import the first page of the file
     //$tpl = $pdf->importPage($i);
     //Use this page as template
     //$pdf->useTemplate($tpl);
     #Print Hello World at the bottom of the page
     //Clear all
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetY(1);
     $pdf->SetFont('Arial', 'I', 19);
     $pdf->Cell(0, $pdf->h - 2, ' ', 0, 0, 'C', true);
     //Go to 1.5 cm from bottom
     $pdf->SetY(1);
     //Select Arial italic 8
     $pdf->SetFont('Arial', 'I', 19);
     //Print centered cell with a text in it
     $pdf->Cell(0, 10, $post->post_title, 0, 0, 'C');
     /*
     
     
     			$pdf->SetY(10);
     			$pdf->SetFont('Arial','I',16);
     			$pdf->Cell(0, 10, gmdate("Y-m-d", $getmetaall["wpcf-event-start-date"][0]), 0, 0, 'C');
     
     			$pdf->SetY(20);
     			$pdf->SetFont('Arial','I',16);
     			$pdf->Cell(0, 10, 'Start time: ' . $getmetaall["wpcf-event-start-time"][0], 0, 0, 'C');
     
     			$pdf->SetY(27);
     			$pdf->SetFont('Arial','I',16);
     			$pdf->Cell(0, 10, 'End time: ' . $getmetaall["wpcf-event-end-time"][0], 0, 0, 'C');
     
     			$pdf->SetY(1);
     			$pdf->Image('http://dancenergy.zenutech.com/production/wp-content/uploads/2014/06/Logo.png', 5, 0, 33.78);
     */
     //Select Arial italic 8
     $pdf->SetY(20);
     $pdf->SetFont('Arial', 'I', 15);
     $pdf->WriteHTML($getcontent[0]['ticket_content']);
     $pdf->Output($path, "F");
     /*
     			echo "<pre>";
     				var_dump( $getmetaall );
     			echo "</pre>";
     */
     return;
 }
	$curs = null;
	$params = array(":nrosolicitud" => $numeroSolicitud);
	$sql = "BEGIN art.cotizacion.get_valor_carta(:nrosolicitud, :data); END;";
	$stmt = DBExecSP($conn, $curs, $sql, $params);
	$rowValorFinal = DBGetSP($curs, false);

	$cuotaInicial = $rowValorFinal["COSTOMENSUAL"];
	$porcentajeVariable = $rowValorFinal["PORCVARIABLE"];
	$sumaFija = $rowValorFinal["SUMAFIJA"];
}

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/solicitud_afiliacion.pdf");

//PƔgina 1..
$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont("Arial", "", 8);

if (($row2["SA_MOTIVOALTA"] == "03") or ($row2["SA_MOTIVOALTA"] == "04") or ($row2["SA_MOTIVOALTA"] == "05")) {
	$pdf->Ln(6);
	$pdf->Cell(-0.4);
	$pdf->Cell(0, 0, "X");

	$pdf->Ln(8.2);
		$rowValorFinal = DBGetSP($curs, false);

		// Hago el query de abajo para formatear 2 campos que salian mal..
		$sql = "SELECT TO_CHAR(".str_replace(array("$", ","), array("", "."), $rowValorFinal["COSTOANUAL"]).", '$9,999,999,990.00') costoanual, TO_CHAR(".str_replace(array("$", ","), array("", "."), $rowValorFinal["COSTOCAPITAS"]).", '$9,999,999,990.00') costocapitas FROM DUAL";
		$stmt = DBExecSql($conn, $sql, array());
		$row2 = DBGetQuery($stmt, 1, false);

		$row["CUOTAANUAL"] = $row2["COSTOANUAL"];
		$row["CUOTAMENSUAL"] = $rowValorFinal["COSTOMENSUAL"];
		$row["CUOTATRABAJADOR"] = $row2["COSTOCAPITAS"];
		$row["PORCENTAJEVARIABLETRABAJADOR"] = $rowValorFinal["PORCVARIABLE"];
		$row["SUMAFIJATRABAJADOR"] = $rowValorFinal["SUMAFIJA"];
	}


	$pdf = new FPDI();

	// Dibujo la hoja de anƔlisis comparativo de costos..
	if ($row["DIFPORCENTUALSINFORMATO"] < -5) {
		// INICIO - GeneraciĆ³n de grĆ”fico que va incrustado en el reporte..
		try {
			$_REQUEST["actual"] = $row["PRIMAANUALCOMPSINFORMATO"];
			$_REQUEST["archivo"] = "W_".$_SESSION["usuario"]."_".date("YmdHis").".png";
			$_REQUEST["provart"] = $row["PRIMAANUALSINFORMATO"];

			require_once($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/generar_grafico_comparativo.php");
			$graficoOk = true;
		}
		catch (Exception $e) {
			$graficoOk = false;
		}
    $sql = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($sql) == 1) {
        $row = mysql_fetch_assoc($sql);
    } else {
        print "<meta http-equiv=\"Refresh\" content=\"0;URL=MainPage.php\">";
        exit;
    }
}
if ($_SESSION['status'] == "admin") {
    $query = "SELECT * FROM `abiturients` WHERE `ab_id` = '" . $id . "'";
    $sql = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($sql) == 1) {
        $row = mysql_fetch_assoc($sql);
    }
}
$pdf = new FPDI();
$pageCount = $pdf->setSourceFile("img/ugoda2014.pdf");
$pageNo = 1;
$templateId = $pdf->importPage($pageNo);
$size = $pdf->getTemplateSize($templateId);
$pdf->AddPage('P', array($size['w'], $size['h']));
$pdf->useTemplate($templateId);
$pdf->AddFont('Times', '', 'times.php');
$pdf->SetFont('Times', '', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFontSize(11);
$pdf->SetXY(35, 61);
$pdf->Write(5, $row['lastname'] . " " . $row['firstname'] . " " . $row['patronymic']);
$pdf->SetXY(55, 70);
if ($row['type'] == "mag") {
    $pdf->Write(5, "6-Š¹ Šŗурс, " . $row['faculty']);
Example #21
0
         }
         //add file to array
         $tif_files[] = $dir_fax_temp . '/' . $fax_name . '.tif';
     }
     //if
 }
 //foreach
 // unique id for this fax
 $fax_instance_uuid = uuid();
 //generate cover page, merge with pdf
 if ($fax_subject != '' || $fax_message != '') {
     //load pdf libraries
     require_once "resources/tcpdf/tcpdf.php";
     require_once "resources/fpdi/fpdi.php";
     // initialize pdf
     $pdf = new FPDI('P', 'in');
     $pdf->SetAutoPageBreak(false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetMargins(0, 0, 0, true);
     if (strlen($fax_cover_font) > 0) {
         if (substr($fax_cover_font, -4) == '.ttf') {
             $pdf_font = TCPDF_FONTS::addTTFfont($fax_cover_font);
         } else {
             $pdf_font = $fax_cover_font;
         }
     }
     if (!$pdf_font) {
         $pdf_font = 'times';
     }
     //add blank page
Example #22
0
             ($recipient['form_type']==1 ? $recipient[1]['country'] : $recipient[2]['country']).", ".
             ($recipient['form_type']==1 ? $recipient[1]['city'] : $recipient[2]['city']).", ".
             ($recipient['form_type']==1 ? $recipient[1]['address'] : $recipient[2]['address']);
 $pdf = new FPDF('L', 'mm', 'A4');
 $pdf->AddFont('TimesNewRomanPSMT','','5f37f1915715e014ee2254b95c0b6cab_times.php');
 $pdf->SetFont('TimesNewRomanPSMT','',12);
 $pdf->SetTextColor(0,0,0);
 
 $pdf->AddPage('L');
 $pdf->SetXY(197,145);
 $pdf->SetDrawColor(50,60,100);
 $pdf->MultiCell(65,6,"ŠšŠ¾Š¼Ńƒ: ".html_entity_decode($user_name)."\nŠšŃƒŠ“Š°: ".html_entity_decode($address),0,'L');
 $pdf->Output($pdf_f_name, "F");
 */
 $pdf_name = '/tmp/' . uniqid() . '.pdf';
 $pdf = new FPDI();
 $pagecount = 1;
 /*
 $pagecount = $pdf->setSourceFile($pdf_f_name);
 $tplidx = $pdf->importPage($pagecount, '/MediaBox');
 $pdf->addPage('L');
 $pdf->useTemplate($tplidx, 0, 0);
 */
 $save = true;
 $access = is_emp($user->role) ? 2 : 1;
 $fnames = array();
 $count_docs = 0;
 //foreach($sbr->getStages() as $stage) {
 $doc_act = $DB->rows('select * from sbr_docs where is_deleted <> true AND sbr_id = ?', $row['sbr_id']);
 //	$doc_act = $sbr->getDocs(NULL, NULL, true, $stage->id, true);
 if ($doc_act) {
else
	$sql = "SELECT sr_idformulario FROM asr_solicitudreafiliacion WHERE sr_id = :id";
$idFormulario = valorSql($sql, "", $params);

$params = array(":idformulario" => $idFormulario);
$sql =
	"SELECT art.utiles.armar_cuit(sa_cuit) cuit, sa_nombre
		 FROM asa_solicitudafiliacion
		WHERE sa_idformulario = :idformulario";
$stmt = DBExecSql($conn, $sql, $params);
$row2 = DBGetQuery($stmt, 1, false);

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/nomina_personal_expuesto.pdf");

$pdf->AddPage("L");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
$pdf->SetFont("Arial", "B", 9);

$pdf->Ln(17);
$pdf->Cell(14);
$pdf->Cell(226, 0, $row2["SA_NOMBRE"]);

$pdf->Cell(16);
$pdf->Cell(0, 0, $row2["CUIT"]);
 public function runProcessStep($dokument)
 {
     $file = $dokument->getLatestRevision()->getFile();
     $extension = array_pop(explode(".", $file->getExportFilename()));
     #$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename());
     // Print Metainfo for PDFs
     if (strtolower($extension) == "pdf") {
         try {
             $fpdf = new FPDI();
             $pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename());
             $fpdf->SetMargins(0, 0, 0);
             $fpdf->SetFont('Courier', '', 8);
             $fpdf->SetTextColor(0, 0, 0);
             $documentSize = null;
             for ($i = 0; $i < $pagecount; $i++) {
                 $string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")";
                 $fpdf->AddPage();
                 $tpl = $fpdf->importPage($i + 1);
                 $size = $fpdf->getTemplateSize($tpl);
                 // First Page defines documentSize
                 if ($documentSize === null) {
                     $documentSize = $size;
                 }
                 // Center Template on Document
                 $fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true);
                 $fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string);
             }
             $this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S"));
         } catch (Exception $e) {
             $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
         }
     } else {
         $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
     }
 }
Example #25
0
 protected function splitPages($pages)
 {
     if (!isset($pages) || empty($pages) || !is_array($pages)) {
         static::raiseError(__METHOD__ . '(), $pages parameter is invalid!');
         return false;
     }
     try {
         $pdf = new \FPDI();
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . '(), failed to load FPDI!');
         return false;
     }
     if (($fqfn = $this->tempItem->getFilePath()) === false) {
         static::raiseError(get_class($this->tempItem) . '::getFilePath() returned false!');
         return false;
     }
     try {
         $page_count = $pdf->setSourceFile($fqfn);
     } catch (\Exception $e) {
         static::raiseError(getClass($pdf) . '::setSourceFile() has thrown an exception! ' . $e->getMessage());
         return false;
     }
     if ($page_count == count($pages)) {
         try {
             @$pdf->cleanUp();
         } catch (\Exception $e) {
             static::raiseError(get_class($pdf) . '::cleanUp() has thrown an exception! ' . $e->getMessage());
             return false;
         }
         return true;
     }
     for ($page_no = 1; $page_no <= $page_count; $page_no++) {
         if (!in_array($page_no, $pages)) {
             continue;
         }
         // import a page
         $templateId = $pdf->importPage($page_no);
         // get the size of the imported page
         $size = $pdf->getTemplateSize($templateId);
         // create a page (landscape or portrait depending on the imported page size)
         if ($size['w'] > $size['h']) {
             $pdf->AddPage('L', array($size['w'], $size['h']));
         } else {
             $pdf->AddPage('P', array($size['w'], $size['h']));
         }
         // use the imported page
         $pdf->useTemplate($templateId);
     }
     try {
         $pdf->Output($fqfn, 'F');
     } catch (\Exception $e) {
         static::raiseError(get_class($pdf) . '::Output() returned false!');
         return false;
     }
     if (!$this->tempItem->refresh()) {
         static::raiseError(get_class($this->tempItem) . '::refresh() returned false!');
         return false;
     }
     return true;
 }
else
	$sql = "SELECT sr_idformulario FROM asr_solicitudreafiliacion WHERE sr_id = :id";
$idFormulario = ValorSql($sql, "", $params);

$params = array(":sa_idformulario" => $idFormulario);
$sql =
	"SELECT art.utiles.armar_cuit(sa_cuit) cuit, sa_nombre
		 FROM asa_solicitudafiliacion
		WHERE sa_idformulario = :sa_idformulario";
$stmt = DBExecSql($conn, $sql, $params);
$row2 = DBGetQuery($stmt, 1, false);

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/ventanilla_electronica.pdf");

$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont("Arial", "B", 9);

$pdf->Ln(34.5);
$pdf->Cell(38);
$pdf->Cell(136, 0, $row2["SA_NOMBRE"]);

$pdf->Ln(5.2);
$pdf->Cell(31);
$pdf->Cell(32, 0, $row2["CUIT"]);
Example #27
0
			AND sa_idactividad = actafip.ac_id
			AND sa_idformulario = fo_id
			AND se_id = :idsolicitudestablecimiento";
$stmt = DBExecSql($conn, $sql, $params);
$row = DBGetQuery($stmt, 1, false);


if (!isset($_REQUEST["ap"]))
	$autoPrint = false;
else
	$autoPrint = ($_REQUEST["ap"] == "t");

if ($autoPrint)
	$pdf = new PDF_AutoPrint("P", "mm", array(216, 320));
else
	$pdf = new FPDI("P", "mm", array(216, 320));

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/rgrl.pdf");

$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pagina = 1;
dibujarPie($pagina);

// Cabecera..
setNumeroSolicitud($row["CUIT"], $row["FO_FORMULARIO"]);

$pdf->SetFont("Arial", "B", 8);
$pdf->Ln(-7.2);
$pdf->Cell(4);
Example #28
0
 function showForm($data = "", $msg = "")
 {
     global $t, $db, $sesIdUsuario, $hoy, $usuario;
     $idReg = $data[idReg];
     $idPedido = $data[idPedido];
     //echo "ID_PEDIDO : $idPedido <hr>";
     $t->set_file("page", "opGuia.inc.html");
     // -----------------------------------------
     // Datos del Pedido
     // -----------------------------------------
     $sql = "select id_cliente,ori,des,mov,bkg,pos_fec,pos_hor,pos_min,ori,des, ";
     $sql .= "destinatario,destinatario_dom ";
     $sql .= "from PEDIDO where id_pedido='{$idPedido}' ";
     $db->query($sql);
     while ($db->next_record()) {
         $idCliente = $db->f(id_cliente);
         $cliente = getValueTable("cliente", "CLIENTE", "id_cliente", $idCliente);
         $ori = $db->f(ori);
         $des = $db->f(des);
         $mov = $db->f(mov);
         $bkg = $db->f(bkg);
         $posFec = $db->f(pos_fec);
         $posHor = $db->f(pos_hor);
         $posMin = $db->f(pos_min);
         $pos = "{$posFec} {$posHor}:{$posMin}";
         $ori = $db->f(ori);
         $des = $db->f(des);
         $ruta = "{$ori} / {$des}";
         $destinatario = $db->f(destinatario);
         $destinatarioDom = $db->f(destinatario_dom);
     }
     $t->set_var(array("ID_REG" => $idReg, "ID_PEDIDO" => $idPedido, "ACTION" => $PHP_SELF, "MENSAJE" => "", "CLIENTE" => $cliente, "ORI" => $ori, "DES" => $des, "MOV" => $mov, "CANCELADO_DETALLE" => "", "IMPRIMIR" => "<a href=\"javascript:ventanaNueva('opGuiaImp.php?idReg={$idReg}',850,600)\"><img src=\"../images/imp.png\" border=\"0\" height=\"30\" width=\"30\"></a>", "PDF" => ""));
     // Consultar si esta cancelada la Guia de embarque.
     $stRegGE = getValueTable("st_reg", "GUIA", "id_guia", $idReg);
     $bajaIdUsr = getValueTable("baja_id_usr", "GUIA", "id_guia", $idReg);
     $bajaFec = getValueTable("baja_fec", "GUIA", "id_guia", $idReg);
     if ($stRegGE == "B") {
         $bajaUsr = getValueTable("usuario", "USUARIO", "id_usuario", $bajaIdUsr);
         $bajaDetalle = "<font color=red>**CANCELADO**<br>Por: {$bajaUsr}<br>Fecha : {$bajaFec}</font>";
         $t->set_var("CANCELADO_DETALLE", "{$bajaDetalle}");
     } else {
         $stRegColor = "class=\"color3\"";
         $bajaDetalle = "";
         $t->set_var("BAJA", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idGuia}','baja')\"><img src=\"../images/b_del.png\" border=0></a>");
     }
     if (empty($idReg) || $idReg == 0) {
         $op = "nuevo";
     } elseif ($stRegGE == "B") {
         $op = "cancelado";
         $t->set_var("GUARDAR", "");
         $t->set_var("ACTUALIZAR", "");
         $t->set_var("IMPRIMIR", "");
     } else {
         $op = "editar";
     }
     switch ($op) {
         case "editar":
             if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) {
                 // 9 : [Transporte] Captura Pedidos
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idReg}','update')\">Actualizar Datos</a>");
             } else {
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "");
             }
             break;
         case "nuevo":
             if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) {
                 if (!empty($idPedido)) {
                     $t->set_var("GUARDAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','','rec')\">Guardar</a>");
                     $t->set_var("ACTUALIZAR", "");
                 } else {
                     $t->set_var("GUARDAR", "<font color=\"red\"><b>ERROR : PRIMERO SELECCIONE UN PEDIDO Y LUEGO CREE UNA GUIA DE EMBARQUE.</b></font>");
                     $t->set_var("ACTUALIZAR", "");
                 }
             } else {
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "");
             }
             break;
     }
     // --------------------------
     // CONSULTA DE GUIA
     // --------------------------
     if ($idReg > 0) {
         $sql = "select * from GUIA where id_guia='{$idReg}'";
         $db->query($sql);
         while ($db->next_record()) {
             $serie = $db->f(serie);
             $folio = $db->f(folio);
             $data[folio] = $serie . $folio;
             //$data[facturaS] = $db->f(factura_s);
             $data[factura] = $db->f(factura);
             $idConte = $db->f(id_contenedor);
             $idEquipo = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte);
             $data[conte] = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte);
             $data[equipo] = getValueTable("equipo", "EQUIPO", "id_equipo", $idEquipo);
             $data[sello] = $db->f(sello);
             $data[flete] = $db->f(flete);
             $data[seguro] = $db->f(seguro);
             $data[otroCosto] = $db->f(otro_costo);
             $data[diceContener] = $db->f(dice_contener);
             $data[mercancia] = $db->f(mercancia);
             $data[bulto] = $db->f(bulto);
             $data[operador] = $db->f(operador);
             $data[nota] = $db->f(nota);
             $data[traUni] = $db->f(tra_uni);
             $data[traPla] = $db->f(tra_pla);
             $data[chaUni] = $db->f(cha_uni);
             $data[chaPla] = $db->f(cha_pla);
             $data[terLlega] = $db->f(ter_llega);
             $data[terSale] = $db->f(ter_sale);
             $data[terVacLlega] = $db->f(ter_vac_llega);
             $data[terVacSale] = $db->f(ter_vac_sale);
             $data[referencia] = $db->f(referencia);
             $data[tonelaje] = $db->f(tonelaje);
             $data[valorDec] = $db->f(valor_dec);
             $capIdUsr = $db->f(cap_id_usr);
             $capFec = $db->f(cap_fec);
             $modIdUsr = $db->f(mod_id_usr);
             $modFec = $db->f(mod_fec);
             $capUsr = getValueTable("usuario", "USUARIO", "id_usuario", $capIdUsr);
             $modUsr = getValueTable("usuario", "USUARIO", "id_usuario", $modIdUsr);
             $data[maniobra] = $db->f(maniobra);
             $data[autopista] = $db->f(autopista);
             $data[clase] = $db->f(clase);
             $data[ruta] = $db->f(ruta);
             $data[gastosViaje] = $db->f(gastos_viaje);
             $data[dollyNum] = $db->f(dolly_num);
             $data[dollyPla] = $db->f(dolly_pla);
         }
     }
     // Combos
     if ($data[maniobra] == "M") {
         $t->set_var("MANI_SEL_M", "selected");
     }
     if ($data[maniobra] == "C") {
         $t->set_var("MANI_SEL_C", "selected");
     }
     if ($data[autopista] == "S") {
         $t->set_var("AUTOPISTA_SEL_S", "selected");
     }
     if ($data[autopista] == "N") {
         $t->set_var("AUTOPISTA_SEL_N", "selected");
     }
     // Combo Bulto
     if ($data[bulto] == "20-DC") {
         $t->set_var("20DCSEL", "selected");
     }
     if ($data[bulto] == "40-DC") {
         $t->set_var("40DCSEL", "selected");
     }
     if ($data[bulto] == "40-HC") {
         $t->set_var("40HCSEL", "selected");
     }
     if ($data[bulto] == "20-RF") {
         $t->set_var("20RFSEL", "selected");
     }
     if ($data[bulto] == "40-RF") {
         $t->set_var("40RFSEL", "selected");
     }
     if ($data[bulto] == "20-OT") {
         $t->set_var("20OTSEL", "selected");
     }
     if ($data[bulto] == "40-OT") {
         $t->set_var("40OTSEL", "selected");
     }
     if ($data[bulto] == "20-FL") {
         $t->set_var("20FLSEL", "selected");
     }
     if ($data[bulto] == "40-FL") {
         $t->set_var("40FLSEL", "selected");
     }
     if ($data[bulto] == "20-TK") {
         $t->set_var("20TKSEL", "selected");
     }
     if ($data[bulto] == "40-TK") {
         $t->set_var("40TKSEL", "selected");
     }
     // Combo Clase de contenedor
     if ($data[clase] == "A") {
         $t->set_var("CLASESELA", "selected");
     }
     if ($data[clase] == "B") {
         $t->set_var("CLASESELB", "selected");
     }
     if ($data[clase] == "C") {
         $t->set_var("CLASESELC", "selected");
     }
     if ($data[clase] == "D") {
         $t->set_var("CLASESELD", "selected");
     }
     if ($data[clase] == "FG") {
         $t->set_var("CLASESELFG", "selected");
     }
     if ($data[clase] == "GC") {
         $t->set_var("CLASESELGC", "selected");
     }
     $folioX = $data[folio];
     $t->set_var(array("FOLIO" => $folioX, "FACTURA_S" => $data[facturaS], "FACTURA" => $data[factura], "REFERENCIA" => $data[referencia], "TONELAJE" => $data[tonelaje], "VALOR_DEC" => $data[valorDec], "CONTENEDOR" => $data[conte], "EQUIPO" => $data[equipo], "SELLO" => $data[sello], "FLETE" => $data[flete], "MANIOBRA" => $data[maniobra], "SEGURO" => $data[seguro], "AUTOPISTA" => $data[autopista], "OTRO_COSTO" => $data[otroCosto], "MERCANCIA" => $data[mercancia], "DICE_CONTENER" => $data[diceContener], "OPERADOR" => $data[operador], "NOTA" => $data[nota], "TRA_UNI" => $data[traUni], "TRA_PLA" => $data[traPla], "CHA_UNI" => $data[chaUni], "CHA_PLA" => $data[chaPla], "TER_LLEGA" => $data[terLlega], "TER_SALE" => $data[terSale], "TER_VAC_LLEGA" => $data[terVacLlega], "TER_VAC_SALE" => $data[terVacSale], "CAPTURO" => "{$capUsr} / {$capFec}", "MODIFICO" => "{$modUsr} / {$modFec}", "RUTA" => $data[ruta], "GASTOS_VIAJE" => $data[gastosViaje], "DOLLY_NUM" => $data[dollyNum], "DOLLY_PLA" => $data[dollyPla]));
     // ""=>$data[],
     //$facS = $data[facturaS];
     $facX = $data[factura];
     if (preg_match("/(.{0,2})(.*)/", $facX, $parts)) {
         $facS = $parts[1];
         $facN = $parts[2];
     }
     if ($idReg > 0 && !empty($facN)) {
         // ----------------------------------------------
         // PROCESO DE EDICION DE FACTURA-PDF
         //
         // 1. Comprobar que exista la factura original.
         // 2. Buscar todas las GE que tengan la misma factura relacionada.
         // 3. Consultar (Folio_serie,Folio,Contenedor,Tipo,Bkg,Posicionamiento,Ruta,etc.
         // 4. Generar nuevo PDF.
         // ----------------------------------------------
         $facN2 = str_pad($facN, 7, 0, STR_PAD_LEFT);
         $filePdfOri = "OPE0606129RAF" . $facS . $facN2 . ".pdf";
         $filePdfEdi = "OPE0606129RAF" . $facS . $facN2 . "_.pdf";
         // Consultar datos GE con la misma Factura.
         unset($txtFac);
         unset($txtFac2);
         $numConte = 0;
         $sql = "select folio,id_contenedor ";
         $sql .= "from GUIA ";
         //$sql.="where factura_s='$facS' and factura='$facN' and st_reg<>'B' ";
         $sql .= "where factura='{$facX}' and st_reg<>'B' ";
         $db->query($sql);
         while ($db->next_record()) {
             $numConte++;
             $folioX = $db->f(folio);
             $folioS = substr($folioX, 0, 2);
             $folioN = substr($folioX, 2, 10);
             $idConte = $db->f(id_contenedor);
             $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte);
             $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte);
             $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq);
             // Si la cantidad de contenedores es mayor al limite, entonces 2do arreglo.
             $maxConte = 17;
             if ($numConte > $maxConte) {
                 $txtFac2[] = "{$folioS} {$folioN} {$conte} {$equipo}";
             } else {
                 $txtFac[] = "{$folioS} {$folioN} {$conte} {$equipo}";
             }
         }
         // ---------------------------------------------------
         // Editar factura.
         if (file_exists("../facturas/{$filePdfOri}")) {
             //$pdf =& new FPDI();
             $pdf = new FPDI();
             $pdf->AddPage();
             //Set the source PDF file
             $pagecount = $pdf->setSourceFile("../facturas/{$filePdfOri}");
             //Import the first page of the file
             $tpl = $pdf->importPage(1);
             //Use this page as template
             $pdf->useTemplate($tpl);
             $pdf->SetFont('Arial', '', 7);
             // PAGINA #1
             // Inicializa la posiciĆ³n
             $destinatarioDom = str_replace("\n", "", $destinatarioDom);
             $destinatarioDom = str_replace("\r", "", $destinatarioDom);
             $pdf->SetXY(60, 90);
             $pdf->Cell(45, 5, "BKG : {$bkg} ", 0, 0, 'L');
             $pdf->SetXY(60, 93);
             $pdf->Cell(45, 5, "POSICIONAMIENTO : {$pos} ", 0, 0, 'L');
             $pdf->SetXY(60, 96);
             $pdf->Cell(45, 5, "RUTA : {$ruta}", 0, 0, 'L');
             $pdf->SetXY(60, 99);
             $pdf->Cell(45, 5, "SALIDA DE VACIO : ? ", 0, 0, 'L');
             $pdf->SetXY(60, 105);
             $pdf->Cell(60, 5, $destinatario, 0, 0, 'L');
             // Seccionar a varias Cell, el domicilio del destinatario
             // Direccion de destinatario
             $s = $destinatarioDom;
             $s = strtoupper($s);
             $lenTl = strlen($s);
             // Conocer el numero de lineas
             $nlDes = $lenTl / 15;
             // El total de caracteres entre el ancho de 35 que es el max de caracteres x linea.
             $posIni = 0;
             $y = 109;
             for ($i = 1; $i <= $nlDes; $i++) {
                 $txtX = substr($s, $posIni, 35);
                 $pdf->SetXY(60, $y);
                 $pdf->Cell(60, 4, $txtX, 0, 0, 'L');
                 $posIni = $posIni + 35;
                 $y = $y + 3;
             }
             // ---------------------------
             $y = 90;
             foreach ($txtFac as $txt) {
                 $pdf->SetXY(10, $y);
                 $pdf->Cell(45, 5, $txt, 0, 0, 'L');
                 $y = $y + 3;
             }
             if ($numConte > $maxConte) {
                 $pdf->SetXY(60, 130);
                 $pdf->Cell(45, 5, "*** VER ANEXO *** VER ANEXO ***", 0, 0, 'L');
                 // PAGINA #2
                 $pdf->AddPage();
                 $y = 20;
                 foreach ($txtFac2 as $txt2) {
                     $pdf->SetXY(10, $y);
                     $pdf->Cell(45, 5, "{$txt2}", 0, 0, 'L');
                     $y = $y + 3;
                     if ($y == 266) {
                         $y = 20;
                         $pdf->AddPage();
                     }
                 }
             }
             // Grabar archivo
             //echo "[$filePdfEdi]";
             $pdf->Output("../facturas/{$filePdfEdi}", "F");
             //$x  = file_exists("../facturas/$filePdfEdi");
             if (file_exists("../facturas/{$filePdfEdi}")) {
                 $pdfImg = "<a href=\"javascript:ventanaNueva('../facturas/{$filePdfEdi}',800,600)\"><img src=\"../images/pdf.gif\" width=\"25\" hight=\"20\" border=0></a>";
             } else {
                 $pdfImg = "";
             }
             $t->set_var("PDF", "{$pdfImg}");
         } else {
             $t->set_var("PDF", "");
         }
     }
     // -----------------------------------------------
     //  Control de mensajes
     // -------------------------------------------
     if (!empty($msg)) {
         $canMsg = count($msg);
         if ($canMsg > 0) {
             foreach ($msg as $val) {
                 $cadMsg .= $val . " <br>";
             }
             $t->set_var(array("MENSAJE" => $cadMsg));
         }
     }
     $t->pparse("out", "page");
 }
Example #29
-1
 public function generateCoupon($coupon_image_url, $user_id, $email_id)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdf.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdi.php';
     $pdf = new FPDI();
     $pageCount = $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . "/application/libraries/coupon.pdf");
     $tplIdx = $pdf->importPage(1, '/MediaBox');
     $count = 0;
     $y = 145.5;
     $i = 1;
     $amt = 0;
     $pdf->addPage();
     $pdf->useTemplate($tplIdx, 3, 3, 210, 300);
     $pdf->SetFont('Arial', '', '9');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Text(50, 80, 'User ID :');
     $pdf->Text(100, 80, $user_id);
     $pdf->Text(50, 90, 'Email ID :');
     $pdf->Text(100, 90, $email_id);
     $pdf->Image($coupon_image_url, 50, 100);
     $save_status = 1;
     if (!$save_status) {
         $pdf->Output();
     } else {
         $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/images/coupons/' . 'coupon_' . $user_id . '.pdf', 'F');
     }
 }
Example #30
-2
 function page4($employee_id)
 {
     $this->load->helper('settings');
     $this->load->library('fpdf');
     //define('FPDF_FONTPATH',$this->config->item('fonts_path'));
     $this->load->library('fpdi');
     //print_r($personal_info);
     // initiate FPDI
     $pdf = new FPDI('P', 'mm', 'Legal');
     // add a page
     $pdf->AddPage();
     // set the sourcefile
     $pdf->setSourceFile('dtr/template/pds/page4.pdf');
     // import page 1
     $tplIdx = $pdf->importPage(1);
     // use the imported page and place it at point 10,10 with a width of 100 mm
     $pdf->useTemplate($tplIdx, 1, 1, 210);
     // now write some text above the imported page
     $pdf->SetFont('Arial');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(8, 14);
     $q = new Question();
     $q->order_by('question_no');
     $questions = $q->get_by_employee_id($employee_id);
     foreach ($questions as $question) {
         if ($question->question_no == 1) {
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 2) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 3) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 4) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 5) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 6) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 7) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 8) {
             $pdf->Ln(35);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 9) {
             $pdf->Ln(12);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 10) {
             $pdf->Ln(13);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
     }
     $pdf->SetXY(8, 233);
     //$pdf->Write(0, 'X');
     $r = new Reference();
     $references = $r->get_by_employee_id($employee_id);
     foreach ($references as $reference) {
         $pdf->SetX(8);
         $pdf->Write(0, $reference->name);
         $pdf->SetX(72);
         $pdf->Write(0, $reference->address);
         $pdf->SetX(134);
         $pdf->Write(0, $reference->tel_no);
         $pdf->Ln(4);
     }
     // CTC NO
     $pdf->SetXY(15, 275);
     $pdf->Write(0, $reference->ctc_no);
     $pdf->Ln(13);
     $pdf->SetX(15);
     $pdf->Write(0, $reference->issue_at);
     $pdf->Ln(13);
     $pdf->SetX(15);
     $pdf->Write(0, $reference->issue_on);
     $pdf->SetX(90);
     $pdf->Write(0, date('F d, Y'));
     // Output
     $pdf->Output('dtr/template/pds/page4_' . $employee_id . '.pdf', 'F');
     //header("location:".base_url()."resources/pdfs/archives/page4_".$employee_id.'.pdf');
     $this->pds[] = 'dtr/template/pds/page4_' . $employee_id . '.pdf';
 }