function generate_mitgliedsbescheinigung($titleAndName, $strasse, $plz, $ort, $land, $jahr, $vorstand, $datum)
{
    // initiate FPDI
    $pdf = new FPDI();
    // add a page
    $pdf->AddPage();
    // set the source file
    $pdf->setSourceFile(HOME_DIRECTORY . 'alumpiHP_libraries/Mitgliedsbestaetigung_blank.pdf');
    // import page 1
    $tplIdx = $pdf->importPage(1);
    // use the imported page and place it at position 0,0 with a width of 210 mm (full page)
    $pdf->useTemplate($tplIdx, 0, 0, 210);
    // add the font DejaVu
    $pdf->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);
    $pdf->AddFont('DejaVuSans-Bold', '', 'DejaVuSans-Bold.ttf', true);
    // text settings
    $pdf->SetTextColor(0, 0, 0);
    // add address of the member
    $addressString = $titleAndName . "\n";
    $addressString .= $strasse . "\n";
    $addressString .= $plz . " " . $ort . "\n";
    $addressString .= $land;
    $pdf->SetFont('DejaVuSans');
    $pdf->SetFontSize(12);
    $pdf->SetXY(20, 23);
    $pdf->Multicell(80, 6, $addressString);
    //add heading
    $headingString = "Mitgliedsbescheinigung " . $jahr;
    $pdf->SetFont('DejaVuSans-Bold');
    $pdf->SetFontSize(16);
    $pdf->SetXY(20, 80);
    $pdf->Multicell(170, 6, $headingString);
    // add main text
    $textString = "Hiermit wird bestätigt, dass " . $titleAndName . " im Kalenderjahr " . $jahr;
    $textString .= " ordentliches Mitglied des Absolventen- und Förderverein MPI Uni Bayreuth e.V. (aluMPI) ist.\n";
    $textString .= "\n";
    $pdf->SetFont('DejaVuSans');
    $pdf->SetFontSize(12);
    $pdf->SetXY(20, 100);
    $pdf->Multicell(170, 6, $textString);
    // add signature text
    $signatureString = "Absolventen- und Förderverein MPI Uni Bayreuth e.V.\n";
    $signatureString .= "1. Vorstand: " . $vorstand . "\n";
    $pdf->SetXY(20, 140);
    $pdf->Multicell(170, 6, $signatureString);
    // add signature
    $pdf->Image(HOME_DIRECTORY . 'alumpiHP_libraries/unterschrift_krinninger.png', 20, 155, 50);
    // add place and date
    $dateString = "Bayreuth, " . $datum;
    $pdf->SetXY(20, 180);
    $pdf->Multicell(170, 6, $dateString);
    ob_clean();
    $pdf->Output();
}
Example #2
1
function generate_philosophy_certificate($confirmation, $form, $entry, $ajax)
{
    // print_r( $entry ); die;
    if ($entry['gquiz_is_pass']) {
        $upload_dir = wp_upload_dir();
        // initiate FPDI
        $pdf = new FPDI();
        // set the sourcefile
        $pdf->setSourceFile(get_template_directory() . '/library/certificate.pdf');
        // import page 1
        $tplIdx = $pdf->importPage(1);
        // get the width and height of the template
        $specs = $pdf->getTemplateSize($tplIdx);
        // add a page
        $pdf->AddPage("L", array($specs['w'], $specs['h']));
        // use the imported page as the template
        $pdf->useTemplate($tplIdx, 0, 0);
        // now write some text above the imported page
        $pdf->SetY(101);
        $pdf->SetFont("dejavuserifbi", 'I', 35);
        $pdf->SetTextColor(0, 54, 99);
        $text = $entry['2.3'] . " " . $entry['2.6'];
        $pdf->MultiCell(260, 40, $text, 0, 'C');
        // now write some text above the imported page
        $pdf->SetY(165);
        $pdf->SetFont("dejavuserifbi", 'I', 22);
        $pdf->SetTextColor(0, 54, 99);
        $text = date('F j, Y');
        $pdf->MultiCell(260, 22, $text, 0, 'C');
        // save the pdf out to file
        $pdf->Output($upload_dir['basedir'] . '/certificates/' . $entry['id'] . '.pdf', 'F');
    }
    return array('redirect' => '/philosophy-results/?id=' . $entry['id']);
}
 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 #4
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 #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 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 #8
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 #9
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 #10
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $id = $input->getArgument('id');
     $pdffile = $input->getArgument('pdf');
     $em = $this->getContainer()->get('doctrine');
     $tab = $this->csv($pdffile);
     $template = $em->getRepository('PrintBundle:Template')->find($id);
     $path = $this->getContainer()->get('kernel')->getRootDir() . '/../web/uploads/pdf/' . $template->getPdffile();
     $width = $template->getWidth();
     $height = $template->getHeight();
     $orientation = $height > $width ? 'P' : 'L';
     $custom_layout = array($width, $height);
     $i = 1;
     foreach ($tab as $key => $value) {
         $pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
         $pdf->setPageOrientation($orientation);
         $pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(true, 40);
         $pdf->setFontSubsetting(false);
         // add a page
         $pdf->AddPage($orientation);
         $pdf->setSourceFile($path);
         $_tplIdx = $pdf->importPage(1);
         $size = $pdf->useTemplate($_tplIdx, 0, 0, $width, true);
         foreach ($template->getChildactivity() as $opt) {
             $pdf->SetXY($opt->getX(), $opt->getY());
             $pdf->SetFont($opt->getFont(), '', $opt->getFontsize() * 2);
             // echo $opt->getFontsize()."\n";
             $pdf->Cell($opt->getWidth(), $opt->getHeight(), $value[$opt->getName()]);
         }
         //$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
         // echo $template->getId();
         $pdf->Output($this->getContainer()->get('kernel')->getRootDir() . '/../web/folder/pdf' . $template->getId() . "-{$i}.pdf", 'F');
         $i++;
     }
 }
Example #11
0
 /**
  * Simple helper function which actually merges a given array of document-paths
  * @param $paths
  * @return string The created document's url
  */
 private function mergeDocuments($paths)
 {
     include_once 'engine/Library/Fpdf/fpdf.php';
     include_once 'engine/Library/Fpdf/fpdi.php';
     $pdf = new FPDI();
     foreach ($paths as $path) {
         $numPages = $pdf->setSourceFile($path);
         for ($i = 1; $i <= $numPages; $i++) {
             $template = $pdf->importPage($i);
             $size = $pdf->getTemplateSize($template);
             $pdf->AddPage('P', array($size['w'], $size['h']));
             $pdf->useTemplate($template);
         }
     }
     $hash = md5(uniqid(rand()));
     $pdf->Output($hash . '.pdf', "D");
 }
 /**
  * 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;
 }
Example #13
0
    //write divider
    $data_footer .= '<tr><td colspan="12"><hr></td></tr>';
    //add last page
    if ($p >= 55) {
        $pdf->AddPage('L', array($page_width, $page_height));
    }
    //output remaining data
    $data_body_chunk = $data_start . $data_head;
    foreach ($data_body as $data_body_row) {
        $data_body_chunk .= $data_body_row;
    }
    $data_body_chunk .= $data_footer . $data_end;
    $pdf->writeHTML($data_body_chunk, true, false, false, false, '');
    unset($data_body_chunk);
    //define file name
    $pdf_filename = "cdr_" . $_SESSION['domain_name'] . "_" . date("Ymd_His") . ".pdf";
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Description: File Transfer");
    header('Content-Disposition: attachment; filename="' . $pdf_filename . '"');
    header("Content-Type: application/pdf");
    header('Accept-Ranges: bytes');
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    // date in the past
    // push pdf download
    $pdf->Output($pdf_filename, 'D');
    // Display [I]nline, Save to [F]ile, [D]ownload
}
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
	public function view_sign_oc(){
		require_once('./assets/fpdf17/fpdf.php');
		require_once('./assets/fpdf17/fpdi.php');
		$oc_id=$this->uri->segment(3,'');
		
		// init pce data                       
		$oc_dat=$this->m_oc->get_oc_by_id($oc_id);
		$project=$this->m_project->get_project_by_id($oc_dat->project_id);
        //init sign pic
        $ae_sign_user_dat=$this->m_user->get_user_by_login_name($project->project_cs);
        $ae_sign_filename="no";
        if (isset($ae_sign_user_dat->sign_filename)) {
          $ae_sign_filename=$ae_sign_user_dat->sign_filename;
        }
        $finance_sign_dat=$this->m_user->get_user_by_login_name($oc_dat->fc_sign);
        $finance_sign_filename="no";
        if (isset($finance_sign_dat->sign_filename)) {
          $finance_sign_filename=$finance_sign_dat->sign_filename;
        }
        // initiate FPDI
        $pdf = new FPDI();

        // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','','angsa.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','B','angsab.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','I','angsai.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','BI','angsaz.php');


        // get the page count
        $pageCount = $pdf->setSourceFile("./media/real_pdf/".$oc_dat->filename);
        // iterate through all pages
        for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
            // import a page
            $templateId = $pdf->importPage($pageNo);
            // 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);

            $pdf->SetTextColor(0,0,0);
            $pdf->SetFont('angsana','B',14);
            $pdf->SetXY(5, 5);
            //$pdf->Write(8, 'A complete document imported with FPDI');

            //// temporaly disable 
            if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) {
              //$pdf->Image("./media/sign_photo/".$finance_sign_filename,100,10,40,0);
            }
            if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) {
              //$pdf->Image("./media/sign_photo/".$ae_sign_filename,100,110,40,0);
            }
            //$pdf->Image("images/play.png",100,100,100,0);
        }
        $new_filename=$oc_dat->oc_no."_A.pdf";

        // Output the new PDF
        //@unlink("./media/real_pdf/".$new_filename);
        $pdf->Output($new_filename,"I");
        //redirect("media/real_pdf/".$new_filename);
	}
Example #16
0
 public function pdfImg($file)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdf/fpdf.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdi/fpdi.php';
     $pdf = new FPDI();
     $pageCount = $pdf->setSourceFile($file);
     for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
         $templateId = $pdf->importPage($pageNo);
         $size = $pdf->getTemplateSize($templateId);
         if ($size['w'] > $size['h']) {
             $pdf->AddPage('L', array($size['w'], $size['h']));
         } else {
             $pdf->AddPage('P', array($size['w'], $size['h']));
         }
         if ($pageNo == $pageCount) {
             $img = $_SERVER['DOCUMENT_ROOT'] . get_save_url() . D('user')->where('id = ' . get_user_id())->getField('pic_yin');
             $pdf->Image($img, 150, 250, 0, 20);
         }
         $pdf->useTemplate($templateId);
         $pdf->SetFont('Helvetica');
         $pdf->SetXY(5, 5);
     }
     $pdf->Output($file);
 }
Example #17
0
 private function _generatePdfSamplePage($filePath)
 {
     //error_reporting(E_ALL);
     //Zend_Loader::registerAutoload(false);
     //require_once('TCPDF.php');
     require_once 'PdfTool/fpdf/fpdf.php';
     require_once 'PdfTool/fpdi/fpdi.php';
     // initiate FPDI
     $pdf = new FPDI();
     // add a page
     $pdf->AddPage();
     // set the sourcefile
     $pageCount = $pdf->setSourceFile($filePath);
     //print_r($pageCount);
     //die();
     // 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, 10, 10, 100);
     // now write some text above the imported page
     $pdf->SetFont('Arial');
     $pdf->SetTextColor(255, 0, 0);
     $pdf->SetXY(10, 10);
     $pdf->Write(0, "SAMPLE FOR VIEWING ONLY");
     $pdf->Output('sample.pdf', 'I');
     /*$pdf=new FPDF();
     		$pdf->AddPage();
     		$pdf->SetFont('Arial','B',16);
     		$pdf->Cell(40,10,'Hello World!');
     		$pdf->Output();*/
     die;
 }
 /**
  * Determine if the email should actually be sent and setup email merge variables
  *
  * @since 0.1
  * @param int $order_id
  */
 public function trigger($order_id)
 {
     global $woocommerce;
     // bail if no order ID is present
     if (!$order_id) {
         return;
     }
     // setup order object
     $this->object = new WC_Order($order_id);
     //check if is downloadbale
     if (!$this->object->has_downloadable_item()) {
         return;
     }
     // replace variables in the subject/headings
     $this->find[] = '{order_date}';
     $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date));
     $this->find[] = '{order_number}';
     $this->replace[] = $this->object->get_order_number();
     //To get the dir, use: dirname($path)
     require_once 'fpdf/fpdf.php';
     require_once 'fpdi/fpdi.php';
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $upload_dir = wp_upload_dir();
     // Array of key => value pairs
     //cosntruct ticket temp dir
     $tickettemp = $upload_dir['basedir'] . '/tickets_temp';
     if (!file_exists($tickettemp)) {
         mkdir($tickettemp, 0755, true);
     }
     $items = $this->object->get_items();
     $varation_ids = array();
     $metaorder = get_post_meta($this->object->id);
     $emaailid = $this->object->billing_email;
     $downloadlinks = array();
     $i = 0;
     foreach ($items as $key => $value) {
         $x = 1;
         $getprod = $this->object->get_product_from_item($value);
         $getdownload = $this->object->get_item_downloads($value);
         if ($getprod->product_type != 'ticket') {
             break;
         }
         if (empty($getdownload)) {
             break;
         }
         $qty = intval($value['qty']);
         while ($x <= $qty) {
             $x++;
             foreach ($getdownload as $keysub => $valuesub) {
                 $downlink = $valuesub['file'];
             }
             $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($downlink, PHP_URL_PATH);
             $pdfout = $tickettemp . '/ticket_' . $this->object->id . '' . $value['product_id'] . '' . $x . '.pdf';
             $downloadlinks[$i] = $pdfout;
             $pagenum = 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($pagenum);
             //Use this page as template
             $pdf->useTemplate($tpl);
             $getfooterY = $pdf->h - 35;
             //Select Arial italic 8
             $pdf->SetY($getfooterY);
             $pdf->SetFont('Arial', 'I', 10);
             $pdf->Cell(0, 10, 'Ticket id: ' . $this->object->id . '' . $value['product_id'] . '' . $x, 0, 0, 'C');
             $pdf->Output($pdfout, "F");
             $i++;
         }
     }
     /*
                 $email_class = new WC_Email();
                 remove_action( 'woocommerce_after_resend_order_email', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
                 remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
                 echo "<pre>";
                   var_dump( $this->emails );
                 echo "</pre>";
                   var_dump( $downloadlinks );
                   var_dump( $items );
                   var_dump( $emaailid);
                   var_dump( $this->object );
     */
     // woohoo, send the email!
     $this->send($this->get_recipient() . ', ' . $this->object->billing_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $downloadlinks);
     //Delete the temp tickets
     foreach ($downloadlinks as $key => $value) {
         chmod($value, 0777);
         if (file_exists($value)) {
             unlink($value);
         }
     }
     //die();
 }
Example #19
0
		$pdf->Cell(10);
		$pdf->Cell(36, 0, $row["DOMICILIOPRESTADOR"]);

		$pdf->Cell(13.6);
		$pdf->Cell(11, 0, $row["CPPRESTADOR"], 0, 0, "C");

		$pdf->Cell(9);
		$pdf->Cell(25, 0, $row["LOCALIDADPRESTADOR"]);

		$pdf->Cell(2);
		$pdf->Cell(16, 0, $row["TELEFONOPRESTADOR"]);
	}
	$pdf->SetFont("Arial", "", 8);

	$pdf->Ln(19.6);
	$pdf->Cell(15);
	$pdf->Cell(24, 0, $row["EW_LUGARDENUNCIA"].(($row["EW_LUGARDENUNCIA"] == "")?"":", "));
	$pdf->Cell(18, 0, $row["EW_FECHADENUNCIA"]);

	$pdf->Cell(84);
	$pdf->Cell(40, 0, $row["EW_DENUNCIANTE"].(($row["EW_DNIDENUNCIANTE"] == "")?"":" - ".$row["EW_DNIDENUNCIANTE"]));

	$pdf->Output("Denuncia_de_Siniestro.pdf", "I");
	//	*******  FIN - Armado del reporte..  *******
}
catch (Exception $e) {
	DBRollback($conn);
	echo "<script type='text/javascript'>alert(unescape('".rawurlencode($e->getMessage())."'));</script>";
	exit;
}
?>
Example #20
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 #21
0
/**
 * Creates a PDF form for the copy center to print
 *
 * @param unknown $context            
 * @param unknown $exam            
 * @param unknown $userrequests            
 * @param unknown $useraccepts            
 * @param unknown $category            
 * @param unknown $totalpages            
 * @param unknown $course            
 */
function emarking_create_printform($context, $exam, $userrequests, $useraccepts, $category, $course)
{
    global $CFG;
    require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php";
    require_once $CFG->dirroot . "/mod/assign/feedback/editpdf/fpdi/fpdi.php";
    $originalsheets = $exam->totalpages + $exam->extrasheets;
    $copies = $exam->totalstudents + $exam->extraexams;
    $totalpages = emarking_exam_total_pages_to_print($exam);
    $pdf = new FPDI();
    $pdf->setSourceFile($CFG->dirroot . "/mod/emarking/img/printformtemplate.pdf");
    // Adds the form page from the template
    $pdf->AddPage();
    $tplIdx = $pdf->importPage(1);
    $pdf->useTemplate($tplIdx, 0, 0, 0, 0, $adjustPageSize = true);
    // Copy / Printing
    $pdf->SetXY(32, 48.5);
    $pdf->Write(1, "x");
    // Date
    $pdf->SetXY(153, 56);
    $pdf->Write(1, core_text::strtoupper(date('d')));
    $pdf->SetXY(163, 56);
    $pdf->Write(1, core_text::strtoupper(date('m')));
    $pdf->SetXY(173, 56);
    $pdf->Write(1, core_text::strtoupper(date('Y')));
    // Requested by
    $pdf->SetXY(95, 69);
    $pdf->Write(1, core_text::strtoupper($useraccepts->firstname . " " . $useraccepts->lastname));
    // Cost center
    $pdf->SetXY(95, 75.5);
    $pdf->Write(1, core_text::strtoupper($category->idnumber));
    // UAI campus
    $pdf->SetXY(95, 80.8);
    $pdf->Write(1, core_text::strtoupper(""));
    // Originals
    $pdf->SetXY(35, 106.5);
    $pdf->Write(1, core_text::strtoupper($originalsheets));
    // Copies
    $pdf->SetXY(60, 106.5);
    $pdf->Write(1, core_text::strtoupper("--"));
    // Number of printings
    $pdf->SetXY(84, 106.5);
    $pdf->Write(1, core_text::strtoupper($copies));
    // Black and white
    $pdf->SetXY(106, 106.5);
    $pdf->Write(1, "x");
    // Total pages
    $pdf->SetXY(135, 106.5);
    $pdf->Write(1, core_text::strtoupper($totalpages));
    // Number of printings Total
    $pdf->SetXY(84, 133.8);
    $pdf->Write(1, core_text::strtoupper(""));
    // Total pages Total
    $pdf->SetXY(135, 133.8);
    $pdf->Write(1, core_text::strtoupper(""));
    // Páginas totales Total
    $pdf->SetXY(43, 146);
    $pdf->Write(1, core_text::strtoupper($course->fullname . " , " . $exam->name));
    // Recepcionado por Nombre
    $pdf->SetXY(30, 164.5);
    $pdf->Write(1, core_text::strtoupper(""));
    // Recepcionado por RUT
    $pdf->SetXY(127, 164.5);
    $pdf->Write(1, core_text::strtoupper(""));
    $pdf->Output("PrintForm" . $exam->id . ".pdf", "I");
    // se genera el nuevo pdf
}
		$pdf->Rect($pdf->GetX(), $pdf->GetY(), 194, 44, "DF");
	}


	if (($id == 328723) or ($id == 334890)) {		// Harcodeado por ticket 41756..
		$pdf->Rect(92, 110, 104, 8, "DF");	
		$pdf->Ln(-102);
		$pdf->SetFont("Arial", "", 8);
		$pdf->Cell(80);
		$pdf->Cell(0, 0, "Claúsula penal por incumplimientos de denuncias del empleador $2.000- (dos mil)", 0, 0);	
	}

	if ($row["ILTEMPLEADOR"] != "S")
		$pdf->Rect(12, 123, 104, 4, "DF");	

	$pdf->Output($file, "F");
	//	*******  FIN - Armado del reporte..  *******
}
catch (Exception $e) {
	DBRollback($conn);
	echo "<script type='text/javascript'>alert(unescape('".rawurlencode($e->getMessage())."'));</script>";
	exit;
}
?>
<iframe id="iframePdf" name="iframePdf" src="<?php 
echo getFile($file);
?>
" style="height:376px; width:752px;"></iframe>
<p style="margin-left:696px;">
	<input class="btnVolver" type="button" value="" onClick="history.back(-1);" />
</p>
function generatePatientTrendReport($conn)
{
    global $gTEXT;
    $CountryName = $_POST['CountryName'];
    require_once 'tcpdf/tcpdf.php';
    require_once 'fpdf/fpdi.php';
    $pdf = new FPDI();
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    $StartMonthId = $_POST['StartMonthId'];
    $StartYearId = $_POST['StartYearId'];
    $EndMonthId = $_POST['EndMonthId'];
    $EndYearId = $_POST['EndYearId'];
    $frequencyId = 1;
    if ($_POST['MonthNumber'] != 0) {
        $months = $_POST['MonthNumber'];
        $monthIndex = date("m");
        $yearIndex = date("Y");
        settype($yearIndex, "integer");
        if ($monthIndex == 1) {
            $monthIndex = 12;
            $yearIndex = $yearIndex - 1;
        } else {
            $monthIndex = $monthIndex - 1;
        }
        $months = $months - 1;
        $d = cal_days_in_month(CAL_GREGORIAN, $monthIndex, $yearIndex);
        $EndYearMonth = $yearIndex . "-" . str_pad($monthIndex, 2, "0", STR_PAD_LEFT) . "-" . $d;
        $EndYearMonth = date('Y-m-d', strtotime($EndYearMonth));
        $StartYearMonth = $yearIndex . "-" . str_pad($monthIndex, 2, "0", STR_PAD_LEFT) . "-" . "01";
        $StartYearMonth = date('Y-m-d', strtotime($StartYearMonth));
        $StartYearMonth = date("Y-m-d", strtotime(date("Y-m-d", strtotime($StartYearMonth)) . "-" . $months . " month"));
    } else {
        $startDate = $StartYearId . "-" . $StartMonthId . "-" . "01";
        $StartYearMonth = date('Y-m-d', strtotime($startDate));
        $d = cal_days_in_month(CAL_GREGORIAN, $EndMonthId, $EndYearId);
        $endDate = $EndYearId . "-" . $EndMonthId . "-" . $d;
        $EndYearMonth = date('Y-m-d', strtotime($endDate));
    }
    $monthListShort = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec');
    $quarterList = array(3 => 'Jan-Mar', 6 => 'Apr-Jun', 9 => 'Jul-Sep', 12 => 'Oct-Dec');
    $output = array('aaData' => array());
    $aData = array();
    $output2 = array();
    if ($frequencyId == 1) {
        $monthQuarterList = $monthListShort;
    } else {
        $monthQuarterList = $quarterList;
    }
    $month_list = array();
    $startDate = strtotime($StartYearMonth);
    $endDate = strtotime($EndYearMonth);
    $index = 0;
    // while ($endDate >= $startDate) {
    // $month_list[$index] = date('M Y',$startDate);
    // $index++;
    // $startDate = strtotime( date('Y/m/d',$startDate).' 1 month');
    // }
    while ($endDate >= $startDate) {
        if ($frequencyId == 1) {
            $monthid = date('m', $startDate);
            settype($monthid, "integer");
            $ym = $monthListShort[$monthid] . ' ' . date('Y', $startDate);
            $month_list[$index] = $ym;
            $output['Categories'][] = $ym;
            $index++;
        } else {
            $monthid = date('m', $startDate);
            settype($monthid, "integer");
            if ($monthid == 3 || $monthid == 6 || $monthid == 9 || $monthid == 12) {
                $ym = $quarterList[$monthid] . ' ' . date('Y', $startDate);
                $month_list[$index] = $ym;
                $output['Categories'][] = $ym;
                $index++;
            }
        }
        $startDate = strtotime(date('Y/m/d', $startDate) . ' 1 month');
    }
    $html = '
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
    </style>
    <body>
        <h4 style="text-align:left;"><b>' . $gTEXT['Patient Trend Time Series Report of'] . '  ' . $CountryName . ' ' . $gTEXT['from'] . ' ' . date('M,Y', strtotime($StartYearMonth)) . ' ' . $gTEXT['to'] . ' ' . date('M,Y', strtotime($EndYearMonth)) . '</b></h4>
    </body>';
    $pdf->writeHTMLCell(0, 0, 17, '', $html, '', 1, 1, false, 'L', true, $spacing = 0);
    $pdf->setSourceFile("pdfslice/PatientTrendChart.pdf");
    $tplIdx = $pdf->importPage(1);
    $pdf->useTemplate($tplIdx, 0, 0, 200);
    //=====================================================Patient Trend Time Series Table=======================================================
    $lan = $_REQUEST['lan'];
    $countryId = $_POST['Country'];
    $itemGroupId = $_POST['ItemGroupId'];
    //$frequencyId = 1;// $_POST['FrequencyId'];
    if ($lan == 'en-GB') {
        $serviceTypeName = 'ServiceTypeName';
    } else {
        $serviceTypeName = 'ServiceTypeNameFrench';
    }
    // //////////////////
    $sQuery = "SELECT a.ServiceTypeId, IFNULL(SUM(c.TotalPatient),0) TotalPatient\n\t\t\t, {$serviceTypeName} ServiceTypeName, a.STL_Color,c.Year,c.MonthId\n                FROM t_servicetype a\n                INNER JOIN t_formulation b ON a.ServiceTypeId = b.ServiceTypeId\n                Inner JOIN t_cnm_patientoverview c \t\n\t\t\t\t\tON (c.FormulationId = b.FormulationId \n\t\t\t\t\t\tand STR_TO_DATE(concat(year,'/',monthid,'/02'), '%Y/%m/%d') \n\t\t\t\t\t\tbetween '" . $StartYearMonth . "' and '" . $EndYearMonth . "'\n                \t\tAND (c.CountryId = " . $countryId . " OR " . $countryId . " = 0)\n\t\t\t\t\t\tAND (c.ItemGroupId = " . $itemGroupId . " OR " . $itemGroupId . " = 0))  \t\t                       \n                GROUP BY a.ServiceTypeId, {$serviceTypeName}, a.STL_Color\n\t\t\t\t, c.Year, c.MonthId\n\t\t\t\tHAVING TotalPatient > 0\n\t\t        ORDER BY a.ServiceTypeId asc,c.Year asc, c.MonthId asc;";
    //echo $sQuery;
    $rResult = safe_query($sQuery);
    $total = mysql_num_rows($rResult);
    $tmpServiceTypeId = -1;
    $countServiceType = 1;
    $count = 1;
    $preServiceTypeName = '';
    if ($total == 0) {
        return;
    }
    //echo 'Rubel';
    if ($total > 0) {
        while ($row = mysql_fetch_assoc($rResult)) {
            if (!is_null($row['TotalPatient'])) {
                settype($row['TotalPatient'], "integer");
            }
            if ($tmpServiceTypeId != $row['ServiceTypeId']) {
                if ($count > 1) {
                    array_unshift($output2, $countServiceType, $preServiceTypeName);
                    $aData[] = $output2;
                    unset($output2);
                    $countServiceType++;
                }
                $count++;
                $preServiceTypeName = $row['ServiceTypeName'];
                $count = 0;
                while ($count < count($month_list)) {
                    $output2[] = null;
                    $count++;
                }
                $dataMonthYear = $monthQuarterList[$row['MonthId']] . ' ' . $row['Year'];
                $count = 0;
                while ($count < count($month_list)) {
                    if ($month_list[$count] == $dataMonthYear) {
                        $output2[$count] = $row['TotalPatient'];
                    }
                    $count++;
                }
                $tmpServiceTypeId = $row['ServiceTypeId'];
            } else {
                $dataMonthYear = $monthQuarterList[$row['MonthId']] . ' ' . $row['Year'];
                $count = 0;
                while ($count < count($month_list)) {
                    if ($month_list[$count] == $dataMonthYear) {
                        $output2[$count] = $row['TotalPatient'];
                    }
                    $count++;
                }
                $tmpServiceTypeId = $row['ServiceTypeId'];
            }
        }
        array_unshift($output2, $countServiceType, $preServiceTypeName);
        $aData[] = $output2;
        //print_r($month_list);
        $col = '<tr><th width="20" align="center"><b>SL</b></th>';
        $col .= '<th width="35" align="left"><b>' . $gTEXT['Patient Type'] . '</b></th>';
        $f = 0;
        for ($f = 0; $f < count($month_list); $f++) {
            $col .= '<th width="30" align="right"><b>' . $month_list[$f] . '</b></th>';
        }
        $col .= '</tr>';
        $p = 0;
        for ($p = 0; $p < count($aData); $p++) {
            $col .= '<tr>';
            for ($i = 0; $i < count($aData[$p]); $i++) {
                $col .= '<td>' . $aData[$p][$i] . '</td>';
            }
            $col .= '</tr>';
        }
        $i = 1;
        /*  $col = '<tr><th width="38" align="center"><b>SL</b></th>';
            $col.= '<th width="38" align="left"><b>'.$gTEXT['Patient Type'].'</b></th>';	
            $f=0;
            for($f = 0; $f<count($rmonth_name); $f++){       
                $col.= '<th width="38" align="right"><b>'.$rmonth_name[$f].'</b></th>';             
            }
        	$col.='</tr><tr>';
              
            $x=0;
            for($x = 0; $x<count($art); $x++){       
                $col.= '<td width="38" align="right"><b>'.$art[$x].'</b></td>';             
            }   
                  
            $col.='</tr><tr>'; 
            
            $x=0;
            for($x = 0; $x<count($rtk); $x++){       
                $col.= '<td width="38" align="right"><b>'.$rtk[$x].'</b></td>';             
            }   
                  
            $col.='</tr><tr>';
            
            $x=0;
            for($x = 0; $x<count($pmtct); $x++){       
                $col.= '<td width="38" align="right"><b>'.$pmtct[$x].'</b></td>';             
            }   
                  
            $col.='</tr>';     */
        $html_head = "<span><b>" . $gTEXT['Patient Trend Time Series Data List'] . "</b></span>";
        $pdf->SetFont('dejavusans', '', 9);
        $pdf->writeHTMLCell(0, 0, 17, 125, $html_head, '', 0, 0, false, 'L', true);
        $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
         td{
             height: 6px;
             line-height:3px;
         }
        </style>
        <body>
        <table width="550px" border="0.5" style="margin:0px auto;">' . $col . '</table></body>';
        $pdf->SetFont('dejavusans', '', 7);
        $pdf->writeHTMLCell(0, 0, 15, 140, $html, '', 1, 1, false, 'C', true);
        $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/PatientTrendReport.pdf';
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $pdf->Output('pdfslice/PatientTrendReport.pdf', 'F');
        echo 'PatientTrendReport.pdf';
    } else {
        echo 'Processing Error';
    }
}
}
if ($row['study_type'] == "Заочна") {
    $pdf->SetFontSize(11);
    $pdf->SetXY(110, 197);
    $pdf->Write(5, date("d", $row2['ending_date_zao']));
    $pdf->SetXY(125, 197);
    $pdf->Write(5, $months[date("m", $row2['ending_date_zao'])]);
    $pdf->SetXY(163, 197);
    $pdf->Write(5, date("y", $row2['ending_date_zao']));
}
if ($row['flat_number'] != "") {
    $row['build_number'] = $row['build_number'] . " кв. " . $row['flat_number'];
}
$pdf->SetFontSize(10);
$pdf->SetXY(37, 225);
$address = array();
$address[] = $row['nationality'];
$address[] = $row['state'];
$address[] = $row['district'];
$address[] = $row['city'];
$address[] = $row['street'] . ' ' . $row['build_number'];
$address[] = "тел. " . $row['phone'];
$pdf->Write(5, implode(', ', array_filter($address)));
$pdf->SetXY(37, 234);
$pdf->Write(5, $row['pasp_serial'] . " " . $row['pasp_number']);
$pdf->SetXY(27, 243);
$pdf->Write(5, "виданий " . $row['pasp_issue'] . " " . date("d.m.Y", $row['pasp_date']));
$pdf->SetFontSize(8);
//Output the document
$pdf->Output("agreement.pdf", "I");
$pdf->useTemplate($tplIdx);

$pdf->SetFont("Arial", "", 10);
$pdf->Ln(15);
$pdf->Cell(196, 0, setNumeroSolicitud($row2["CUITSUSCRIPCION"], $row2["FO_FORMULARIO"]), 0, 0, "C");

$pdf->SetFont("Arial", "B", 8);
$pdf->Ln(240.4);
$pdf->Cell(144);
$pdf->Cell(0, 0, ponerGuiones($row2["SC_CUIT"]));


//Página 3..
$pdf->AddPage();
$tplIdx = $pdf->importPage(3);
$pdf->useTemplate($tplIdx);

$pdf->SetFont("Arial", "", 10);
$pdf->Ln(15);
$pdf->Cell(196, 0, setNumeroSolicitud($row2["CUITSUSCRIPCION"], $row2["FO_FORMULARIO"]), 0, 0, "C");

$pdf->SetFont("Arial", "B", 8);
$pdf->Ln(177.6);
$pdf->Cell(148);
$pdf->Cell(0, 0, ponerGuiones($row2["SC_CUIT"]));


if ($autoPrint)
	$pdf->AutoPrint(false);
$pdf->Output();
?>
Example #26
0
                        $pagecount = $pdf->setSourceFile($tmp_name);
                        $tplidx = $pdf->importPage($pagecount, '/MediaBox');
                        $pdf->addPage('P');
                        $pdf->useTemplate($tplidx, 0, 0);
                    }
                }
            }
            if (!$save) {
                break;
            }
        }
        //}
        if ($save && $count_docs) {
            $sql = "INSERT INTO letters(\n                                            title,\n                                            user_add,\n                                            user_1,\n                                            user_2,\n                                            user_status_2,\n                                            date_add,\n                                            date_change_status,\n                                            is_user_1_company,\n                                            delivery\n                                        ) VALUES (\n                                            ?,\n                                            ?i,\n                                            ?i,\n                                            ?i,\n                                            ?i,\n                                            NOW(),\n                                            NOW(),\n                                            't',\n                                            1\n                                        ) RETURNING id";
            $letter['id'] = $DB->val($sql, $letter['title'], $letter['user_add'], $letter['user_1'], $letter['user_2'], $letter['user_status_2']);
            $pdf->Output($pdf_name, 'F');
            $cfile = new CFile(array('tmp_name' => $pdf_name, 'name' => $pdf_name, 'size' => filesize($pdf_name)));
            $cfile->server_root = 1;
            $cfile->max_size = 5000000;
            $cfile->MoveUploadedFile('letters/');
            $sql = 'UPDATE letters SET file_id = ?i WHERE id = ?i';
            $DB->query($sql, $cfile->id, $letter['id']);
            ++$res['s'];
            echo "{$row['sbr_id']} - OK\n";
        } else {
            $res['e'][] = $row['sbr_id'];
            echo "{$row['sbr_id']} - PDF Convert Error!\n";
        }
    }
}
echo "-- Haven't address -------------------------------------\n";
Example #27
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();
     //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);
                 $fpdi->AddPage('P', 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);
                 $fpdi->AddPage('P', 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 #28
0
     }
     //message
     $pdf->Rect($x + 0.5, $y + 3.4, 7.5, 6.25, 'D');
     if ($fax_message != '') {
         $pdf->SetFont($pdf_font, "", 12);
         $pdf->SetXY($x + 0.75, $y + 3.65);
         $pdf->MultiCell(7, 5.75, $fax_message, 0, 'L', false);
     }
     //footer
     if ($fax_footer != '') {
         $pdf->SetFont("helvetica", "", 8);
         $pdf->SetXY($x + 0.5, $y + 9.9);
         $pdf->MultiCell(7.5, 0.75, $fax_footer, 0, 'C', false);
     }
     // save cover pdf
     $pdf->Output($dir_fax_temp . '/' . $fax_instance_uuid . '_cover.pdf', "F");
     // Display [I]nline, Save to [F]ile, [D]ownload
     //convert pdf to tif, add to array of pages, delete pdf
     if (file_exists($dir_fax_temp . '/' . $fax_instance_uuid . '_cover.pdf')) {
         chdir($dir_fax_temp);
         $cmd = gs_cmd("-q -sDEVICE=tiffg3 -r" . $gs_r . " -g" . $gs_g . " -dNOPAUSE -sOutputFile=" . correct_path($fax_instance_uuid) . "_cover.tif -- " . correct_path($fax_instance_uuid) . "_cover.pdf -c quit");
         // echo($cmd . "<br/>\n");
         exec($cmd);
         if (is_array($tif_files) && sizeof($tif_files) > 0) {
             array_unshift($tif_files, $dir_fax_temp . '/' . $fax_instance_uuid . '_cover.tif');
         } else {
             $tif_files[] = $dir_fax_temp . '/' . $fax_instance_uuid . '_cover.tif';
         }
         @unlink($dir_fax_temp . '/' . $fax_instance_uuid . '_cover.pdf');
     }
 }
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';
 }