function getPdf($image) { require JPATH_SITE . "/components/com_flexpaper/fpdf/fpdf.php"; $filePath = JPATH_SITE . "/components/com_flexpaper/output/certificate.pdf"; $pdf = new FPDF('L', 'mm'); $pdf->SetLeftMargin(0); $pdf->SetRightMargin(0); $pdf->SetTopMargin(0); $pdf->SetAutoPageBreak(false); $pdf->AddPage(); $pdf->Image($image); $pdf_file = $pdf->Output($filePath, 'F'); return $pdf_file; }
<?php //require ("fpdf/fpdf.php"); $uid = $this->session->userdata('uid'); if (!$uid) { die("You must login to do that."); } $sid = $this->db->query("SELECT `store` FROM `employees` WHERE `uniq_id` = (SELECT `employee_id` FROM `warnings` WHERE `warning_id` = {$warning_id} LIMIT 0,1)"); $sid = $sid->first_row(); $verified = $this->cpm_functions->verify_access($uid, $sid->store); if ($verified) { $pdf = new FPDF(); $pdf->addFont("barCode39fHR", "", "bar39fh.php"); $pdf->SetRightMargin(160); $pdf->SetTopMargin(118); $pdf->SetAutoPageBreak(TRUE, 62); $pdf->AddPage(); $pdf->addFont("BarCode39fHR", "", "bar39fh.php"); $bottom = $this->cpm_pdflayouts->warning_bottom($warning_id); $information = $this->cpm_pdflayouts->warning_info($warning_id); if ($information !== FALSE && $bottom !== FALSE) { foreach ($information as $val) { switch ($val["type"]) { case "SetRightMargin": $pdf->SetRightMargin($val[0]); break; case "SetTopMargin": $pdf->SetTopMargin($val[0]); break; case "MultiCell": $pdf->MultiCell($val[0], $val[1], $val[2], $val[3], $val[4]);
function genSalon() { global $options; # paramètres $mg = 5; // Marge de gauche => initial 17 $mh = 4; // Marge du haut => initial 9 $md = 15; // Marge de droite $mb = 9; // Marge du bas $largeur_etiquette = 42; // largeur_etiquette => initial 60 $espace_etiquettes = 13; // => initial 7 $nb_ligne_etiquettes = 4; $nb_etiquette_ligne = 5; // Préparation du document PDF. $pdf = new FPDF('L', 'mm', 'A4'); $pdf->Open(); $pdf->SetLeftMargin($mg); $pdf->SetTopMargin($mh); $pdf->SetAutoPageBreak(1, 0); $pdf->AddPage(); // Gestion des fonts $pdf->AddFont('code39', '', 'IDAutomation_Code_39.php'); $pdf->SetFont('times', '', 12); // Préparation des informations. $nom = strtoupper($this->patient->getNom()); $prenom = strtoupper($this->patient->getPrenom()); $date = new clDate($this->patient->getDateNaissance()); $duree = new clDuree(); $dateN = $date->getDate("d/m/Y"); $dateN .= " (" . $duree->getAge($date->getTimestamp()) . ")"; if ($this->patient->getSexe() == "F") { $sexe = "Féminin"; $e = "e"; } elseif ($this->patient->getSexe() == "M") { $sexe = "Masculin"; $e = ""; } else { $sexe = "Indéterminé"; $e = ""; } $date->setDate($this->patient->getDateAdmission()); $le = $date->getDate("d/m/Y H:i"); $led = $date->getDate("d/m/Y"); $leh = $date->getDate("H:i"); $ipp = $this->patient->getILP(); $nsej = $this->patient->getNSej(); $uf = $this->patient->getUF(); $sexe = $this->patient->getSexe(); if ($uf == $options->getOption('numUFexec')) { $loc = '(URGENCES)'; } else { $loc = '(UHCD)'; } $tel = $this->patient->getTel(); $adresse = $this->patient->getAdresse(); $cpv = $this->patient->getCodePostal() . " " . $this->patient->getVille(); $prev = $this->patient->getPrevenir(); $medt = $this->patient->getMedecinTraitant(); $modet = $this->patient->getMedecinTraitant(); $adresseur = $this->patient->getAdresseur(); $modeadm = $this->patient->getModeAdmission(); // Grosse étiquette $pdf->Cell(20, 4, "", 0, 0, L); // Ligne 1 $pdf->Cell(4 * $largeur_etiquette, 5, "CENTRE HOSPITALIER DE CARPENTRAS", 0, 1, L); // Ligne 2 $pdf->Cell(11, 5, "Date : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(23, 5, "{$led}", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(13, 5, "Heure : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(27, 5, "{$leh}", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(21, 5, "N° Patient : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(22, 5, "{$ipp}", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(18, 5, "N° URG : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(22, 5, "{$nsej}", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(18, 5, "N° ARCHIVE : ", 0, 1, L); // Ligne 3 $pdf->Cell(11, 5, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(63, 5, strtoupper($nom), 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(13, 5, "Nom naissance : ", 0, 1, L); // Ligne 4 $pdf->Cell(16, 5, "Prénom : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(58, 5, ucfirst(strtolower($prenom)), 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(12, 5, "Sexe : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(29, 5, "{$sexe}", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(12, 5, "N° S.S : ", 0, 1, L); // Ligne 5 $pdf->Cell(17, 5, "Né(e) le : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(57, 5, $dateN, 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(12, 5, "A : ", 0, 1, L); // Ligne 6 $pdf->Cell(17, 4, "Adresse : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(57, 4, $adresse, 0, 1, L); $pdf->SetFont('times', '', 12); // Ligne 5 $pdf->Cell(115, 4, "", 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(9, 4, "Tél : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(20, 4, $tel, 0, 1, L); $pdf->SetFont('times', '', 12); // Ligne 6 $pdf->Cell(17, 4, "", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(98, 4, $cpv, 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(9, 4, "Pays : ", 0, 1, L); // Ligne 7 $pdf->Cell(17, 5, "Nom du tuteur : ", 0, 1, L); // Ligne 8 $pdf->Cell(37, 5, "Personne à prévenir : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(98, 5, $prev, 0, 1, L); $pdf->SetFont('times', '', 12); // Ligne 9 $pdf->Cell(23, 5, "Adressé par : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(51, 5, $adresseur, 0, 0, L); $pdf->SetFont('times', '', 12); $pdf->Cell(30, 5, "Médecin traitant : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(98, 5, $medt, 0, 1, L); $pdf->SetFont('times', '', 12); // Ligne 10 $pdf->Cell(34, 5, "Mode de transport : ", 0, 0, L); $pdf->SetFont('times', 'B', 12); $pdf->Cell(98, 5, $modeadm, 0, 1, L); $pdf->SetFont('times', '', 12); // Saut $pdf->Cell(1, 5.8, "", 0, 1); $pdf->SetFont('times', '', 9); for ($i = 1; $i <= $nb_ligne_etiquettes; $i++) { // Entrée $pdf->Cell($largeur_etiquette, 4, "Entrée du : {$led} à {$leh}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Entrée du : {$led} à {$leh}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Entrée du : {$led} à {$leh}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Entrée du : {$led} à {$leh}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Entrée du : {$led} à {$leh}", 0, 1, L); // D/Nais $pdf->Cell($largeur_etiquette, 4, "D/nais : {$dateN}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "D/nais : {$dateN}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "D/nais : {$dateN}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "D/nais : {$dateN}", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "D/nais : {$dateN}", 0, 1, L); // Nom $pdf->Cell($largeur_etiquette - 30, 4, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 9); $pdf->Cell(43, 4, strtoupper($nom), 0, 0, L); $pdf->SetFont('times', '', 9); $pdf->Cell($largeur_etiquette - 30, 4, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 9); $pdf->Cell(43, 4, strtoupper($nom), 0, 0, L); $pdf->SetFont('times', '', 9); $pdf->Cell($largeur_etiquette - 30, 4, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 9); $pdf->Cell(43, 4, strtoupper($nom), 0, 0, L); $pdf->SetFont('times', '', 9); $pdf->Cell($largeur_etiquette - 30, 4, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 9); $pdf->Cell(43, 4, strtoupper($nom), 0, 0, L); $pdf->SetFont('times', '', 9); $pdf->Cell($largeur_etiquette - 30, 4, "Nom : ", 0, 0, L); $pdf->SetFont('times', 'B', 9); $pdf->Cell(43, 4, strtoupper($nom), 0, 1, L); $pdf->SetFont('times', '', 9); // Prénom $pdf->Cell($largeur_etiquette, 4, "Prénom : " . ucfirst(strtolower($prenom)), 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Prénom : " . ucfirst(strtolower($prenom)), 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Prénom : " . ucfirst(strtolower($prenom)), 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Prénom : " . ucfirst(strtolower($prenom)), 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "Prénom : " . ucfirst(strtolower($prenom)), 0, 1, L); // NJF $pdf->Cell($largeur_etiquette, 4, "NJF : ", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "NJF : ", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "NJF : ", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "NJF : ", 0, 0, L); $pdf->Cell($espace_etiquettes, 4, "", 0, 0, L); $pdf->Cell($largeur_etiquette, 4, "NJF : ", 0, 1, L); // N° SS $pdf->Cell(9, 4, "NSej : ", 0, 0, L); $pdf->Cell(46, 4, "{$nsej}", 0, 0, L); $pdf->Cell(9, 4, "NSej : ", 0, 0, L); $pdf->Cell(46, 4, "{$nsej}", 0, 0, L); $pdf->Cell(9, 4, "NSej : ", 0, 0, L); $pdf->Cell(46, 4, "{$nsej}", 0, 0, L); $pdf->Cell(9, 4, "NSej : ", 0, 0, L); $pdf->Cell(46, 4, "{$nsej}", 0, 0, L); $pdf->Cell(9, 4, "NSej : ", 0, 0, L); $pdf->Cell(46, 4, "{$nsej}", 0, 1, L); // inter _etiquettes $pdf->Cell(1, 11, "", 0, 1); } $pdf->Output(); }
function __construct($lineItems, $lineItemTotals, $filename, $save = false) { App::import('vendor', 'fpdf/fpdf'); $orientation = 'P'; $unit = 'pt'; $format = 'A4'; $margin = 40; $pdf = new FPDF($orientation, $unit, $format); App::import('Helper', 'Time'); $timeHelper = new TimeHelper(); setlocale(LC_MONETARY, 'th_TH'); $pdf->AddPage(); $pdf->SetTopMargin($margin); $pdf->SetLeftMargin($margin); $pdf->SetRightMargin($margin); $pdf->SetAutoPageBreak(true, $margin); $pdf->SetY($pdf->GetY() + 60); $pdf->SetFont('Arial', 'B', 10); $pdf->SetTextColor(0); $pdf->SetFillColor(255); $pdf->SetLineWidth(1); $pdf->SetFont('Arial', 'B', '10'); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 30; $pdf->MultiCell($cell_width, 25, "No.\n ", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $pdf->Cell(250, 25, "Description", 'LTR', 0, 'C'); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 48; $pdf->MultiCell($cell_width, 25, "# Ordered", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 48; $pdf->MultiCell($cell_width, 25, "# Supplied", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 70; $pdf->MultiCell($cell_width, 25, "Amount Wholesale", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 70; $pdf->MultiCell($cell_width, 25, "Amount Retail", 'LTR', 'C'); $pdf->SetY($pdf->GetY() - 25); $pdf->SetFont('Arial', ''); $pdf->SetFillColor(238); $pdf->SetLineWidth(0.2); $pdf->SetY($pdf->GetY() + 25); $num = 1; $number_ordered = 0; $number_supplied = 0; foreach ($lineItems as $lineItem) { $pdf->Cell(30, 20, $num++, 1, 0, 'L'); $pdf->Cell(250, 20, $lineItem['Product']['short_description'], 1, 0, 'L'); $pdf->Cell(48, 20, $lineItem['LineItem']['ordered'], 1, 0, 'R'); $pdf->Cell(48, 20, $lineItem['LineItem']['supplied'], 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $lineItem['LineItem']['amount_wholesale']), 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $lineItem['LineItem']['amount_retail']), 1, 1, 'R'); } $pdf->SetX($pdf->GetX() + 30); $pdf->SetFont('Arial', 'B'); $pdf->Cell(250, 20, "TOTALS", 1); $pdf->SetFont('Arial', ''); $pdf->Cell(48, 20, $lineItemTotals['LineItem']['ordered'], 1, 0, 'R'); $pdf->Cell(48, 20, $lineItemTotals['LineItem']['ordered'], 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $lineItemTotals['LineItem']['amount_wholesale']), 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $lineItemTotals['LineItem']['amount_retail']), 1, 1, 'R'); if ($save) { $pdf->Output($filename, 'F'); } else { $pdf->Output($filename, 'I'); } }
public function drawPDF() { $pdf = new \FPDF('P', 'mm', 'Letter'); if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) { $this->font = 'Gill'; $this->alt_font = 'GillBook'; define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/'); $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php'); $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php'); } $width = 52; // tag width in mm $bar_width = 50; $height = 31; // tag height in mm $left = 5.5; // left margin $top = 15; // top margin $pdf->SetTopMargin($top); //Set top margin of the page $pdf->SetLeftMargin($left); //Set left margin of the page $pdf->SetRightMargin($left); //Set the right margin of the page $pdf->SetAutoPageBreak(False); // manage page breaks yourself $data = $this->loadItems(); $num = 0; // count tags $x = $left; $y = $top; $sign = 0; foreach ($data as $item) { // extract & format data $price = $item['normal_price']; $desc = $item['description']; $brand = strtoupper($item['brand']); $price = $item['normal_price']; if ($item['scale']) { if (substr($price, 0, 1) != '$') { $price = sprintf('$%.2f', $price); } $price .= ' /lb.'; } else { $price = $this->formatPrice($item['normal_price']); } if ($num % 32 == 0) { $pdf->AddPage(); $x = $left; $y = $top; $sign = 0; } else { if ($num % 4 == 0) { $x = $left; $y += $height; } } $row = floor($sign / 4); $column = $sign % 4; $pdf->SetFillColor(86, 90, 92); $pdf->Rect($left + $width * $column, $top + $row * $height, $bar_width, 5, 'F'); $pdf->Rect($left + $width * $column, $top + $row * $height + 25, $bar_width, 2, 'F'); $pdf->SetXY($left + $width * $column, $top + $row * $height + 6); $pdf->SetFont($this->font, 'B', $this->SMALL_FONT); $pdf->MultiCell($width, 5, $brand, 0, 'C'); $pdf->SetX($left + $width * $column); $pdf->SetFont($this->font, '', $this->MED_FONT); $pdf->MultiCell($width, 5, $item['description'], 0, 'C'); $pdf->SetX($left + $width * $column); $pdf->SetFont($this->font, '', $this->BIG_FONT); $pdf->Cell($width, 8, $price, 0, 1, 'C'); // move right by tag width $x += $width; $num++; $sign++; } $pdf->Output('Tags4x8P.pdf', 'I'); }
//Posición: a 1,5 cm del final $this->SetY(-15); //Arial italic 8 $this->SetFont('Arial', 'I', 8); //Número de página $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C'); } } //$pdf->FPDF('P','mm','A4'); $pdf = new FPDF('P', 'cm', 'custom', 300.28, 458.92); //ingreso medida puntos //$pdf->Open(); $pdf->AliasNbPages(); $pdf->SetLeftMargin(0.7); $pdf->PageNo(); $pdf->SetTopMargin(5); $pdf->SetAutoPageBreak(0.6); $pdf->AddPage(); $pdf->SetFont('Arial', '', 9); $venta->ventas_ver($_REQUEST['venta']); $nro_documento = $venta->ven_nrodoc; $cliente_nombre = $venta->cli_razonsocial; $cliente_direccion = $venta->cli_direccion; $cliente_ruc = $venta->cli_ruc; $e_fecha = $venta->_util->obtiene_fecha($venta->ven_fecha); $fecha = explode("/", $e_fecha); //si fecha esta en formato dia-mes-año $dia = $fecha[0]; $mes = $venta->_util->ver_nombre_mes($fecha[1]); $mes_numero = substr($fecha[3], 2); $anio = substr($fecha[2], 3);
$total = Student::get_attendance($cond); $attendence = round($total * 100 / $total_session, 2); $marks = Student::get_marks($cond); $m = round($marks * 100 / ($total_session * $mr), 2); if ($m >= 40 && $attendence >= 50) { $c++; } if ($m < 40 && $attendence >= 50) { $c1++; } $pdf->Cell(30, 5, "{$sno}", 0, 1, "L"); $pdf->SetLeftMargin("22"); $pdf->Cell(0, -5, ucwords(strtolower($row['name'])), 0, 1, "L"); $pdf->SetLeftMargin(""); $pdf->Cell(145, 5, $attendence . " %", 0, 1, "C"); $pdf->SetTopMargin("50"); $pdf->Cell(185, -2.25, "", 0, 1, "R"); $pdf->Cell(135, 0, $m . " %", 0, 1, "R"); $pdf->SetLeftMargin("165.5"); $pdf->Cell(0, 0, Student::get_status($m, $attendence), 0, 1, "L"); $pdf->SetLeftMargin(""); $pdf->Cell(185, 1.25, "", 0, 1, "R"); $pdf->SetLeftMargin("10"); } $tc = $c + $c1; $pdf->Cell(0, 2, "", 0, 1); $pdf->Cell(0, 0, "", 1, 1); $pdf->Cell(0, 5, "Total Certificates Issued: {$tc}", 0, 1, "L"); $pdf->Cell(0, 5, "Successful Completion Certificates : {$c}", 0, 1, "L"); $pdf->Cell(0, 5, "Participation Certificates : {$c1}", 0, 1, "L"); $pdf->Output("Certificate", 'I');
public function drawPDF() { $pdf = new \FPDF('P', 'mm', 'Letter'); if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) { $this->font = 'Gill'; $this->alt_font = 'GillBook'; define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/'); $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php'); $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php'); } $width = 52; // tag width in mm $height = 31; // tag height in mm $left = 6; // left margin $top = 16; // top margin $pdf->SetTopMargin($top); //Set top margin of the page $pdf->SetLeftMargin($left); //Set left margin of the page $pdf->SetRightMargin($left); //Set the right margin of the page $pdf->SetAutoPageBreak(False); // manage page breaks yourself $data = $this->loadItems(); $num = 0; // count tags $x = $left; $y = $top; foreach ($data as $item) { // extract & format data $price = $item['normal_price']; $desc = strtoupper(substr($item['posDescription'], 0, 25)); $brand = ucwords(strtolower(substr($item['brand'], 0, 13))); $pak = $item['units']; $size = $item['units'] . "-" . $item['size']; $sku = $item['sku']; $ppu = $item['pricePerUnit']; $vendor = substr($item['vendor'], 0, 7); $upc = $item['upc']; if ($num % 32 == 0) { $pdf->AddPage(); $x = $left; $y = $top; } else { if ($num % 4 == 0) { $x = $left; $y += $height; } } $pdf->SetFont($this->font, '', 8); $pdf->SetXY($x, $y); // try normal wordwrap // but squeeze into two lines if needed $wrapped = wordwrap($desc, 12, "\n", true); if (count(explode("\n", $wrapped)) > 2) { $wrapped = substr($desc, 0, 12); if ($wrapped[11] != ' ') { $wrapped .= '-'; } $wrapped .= "\n"; $wrapped .= trim(substr($desc, 12)); } $pdf->MultiCell($width / 2, 3, $wrapped, 0, 'L'); $pdf->SetX($x); $pdf->Cell($width / 2, 3, date('n/j/y ') . $size, 0, 1, 'L'); $pdf->SetFont($this->font, 'B', 18); //change font for price $pdf->SetX($x); $pdf->Cell($width / 2, 8, $price, 0, 1, 'L'); $args = array('height' => 7, 'align' => 'L', 'fontsize' => 8, 'width' => 0.23, 'font' => $this->font); $b_y = $pdf->GetY(); $pdf = $this->drawBarcode($upc, $pdf, $x, $b_y, $args); // move right by tag width $x += $width; $num++; } $pdf->Output('Tags4x8P.pdf', 'I'); }
/** * generatePDF - Génère un fichier PDF à partir des données d'évaluation d'un service * * @category : eval_ccpc_functions * @param array $data Données d'évaluation récupérées à partir de la fonction {@link getEvaluationCCPCFullData()} * @param boolean $comment TRUE si on incut les commentaire, FALSE si on ne les inclut pas * @param boolean $commentMSG TRUE si on incut un message concernant la CSG, FALSE si on ne l'inclut pas * @return array Array contenant les informations du fichier généré * * @Author Ali Bellamine * * Contenu de l'array retourné :<br> * ['pdfPath'] => (string) Chemin local vers le fichier généré<br> * ['pdfURI'] => (string) URI pointant vers le fichier généré * */ function generatePDF($data, $comment = FALSE, $commentMSG = FALSE) { // Accès à la BDD global $db; // Array contenant les résultats $output = array(); // On vérifie l'existence des données if (isset($data) && count($data) > 0) { /* Mise en cache */ // Calcul du md5 $hashdata = $data; $hashdata['optionsPDF'] = array('comment' => $comment, 'commentMSG' => $commentMSG); $hash = md5(json_encode($hashdata)); $pdfPath = PLUGIN_PATH . 'cache/' . $hash . '.pdf'; $pdfPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.pdf'; if (is_file($pdfPath)) { $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } else { // On charge la librairie require_once PLUGIN_PATH . 'core/fpdf17/fpdf.php'; // On charge le fichier XML if (is_file(PLUGIN_PATH . 'formulaire.xml')) { $form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml'); } // Promotion if (count($data['service']['promotion']) > 1) { $promotion = false; } else { foreach ($data['service']['promotion'] as $promotionData) { $promotion = $promotionData['id']; } } try { ob_end_clean(); } catch (Exception $e) { } // On crée le PDF $A4Height = 842; $A4Width = 595; $titleSize = 15; $textSize = 11; $pdf = new FPDF('L', 'pt', 'A4'); $pdf->SetTopMargin(10); $pdf->SetLeftMargin(15); $pdf->SetAutoPageBreak(TRUE, 10); /** Page contenant le résumé des données d'évaluation **/ $pdf->AddPage(); $pdf->SetFont('Arial', 'B', $titleSize); // On affiche le titre $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Height)); $pdf->Cell(floor(0.8 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_TITLE), 'LRTB', 0, 'C', TRUE); // Première ligne $pdf->Ln(2 * $titleSize); $pdf->SetFont('Arial', '', $textSize); // On affiche les informations concernant le service // Récupération des données $textToDisplay = LANG_FORM_CCPC_FILTER_SERVICE_TITLE . ' : ' . $data['service']['FullName'] . PHP_EOL . LANG_FORM_CCPC_PDF_STAGEPERIODE . ' : ' . date('d/m/Y', $data['service']['date']['min']) . ' - ' . date('d/m/Y', $data['service']['date']['max']); // Nombre d'étudiants par promotion $nbEtudiantsService = array(); $sql = 'SELECT p.nom promotion, COUNT( ae.userId ) nombre FROM `affectationexterne` ae INNER JOIN user u ON u.id = ae.userId INNER JOIN promotion p ON p.id = u.promotion WHERE `dateDebut` >= "' . TimestampToDatetime($data['service']['date']['min']) . '" AND `dateFin` <= "' . TimestampToDatetime($data['service']['date']['max']) . '" AND service = ' . $data['service']['id'] . ' GROUP BY u.promotion'; $res = $db->query($sql); while ($res_f = $res->fetch()) { $nbEtudiantsService[$res_f['promotion']] = $res_f['nombre']; } $firstLoop = true; if (count($nbEtudiantsService) > 0) { $textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTPROMOTION . ' : '; foreach ($nbEtudiantsService as $promotionNom => $promotionNombre) { if (!$firstLoop) { $textToDisplay .= ', '; } else { $firstLoop = FALSE; } $textToDisplay .= $promotionNom . ' (' . $promotionNombre . ')'; } } $textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTNB . ' : ' . $data['service']['nbEvaluation'] . PHP_EOL . LANG_FORM_CCPC_PDF_EVALUATIONNB . ' : ' . $data['nb']; $textToDisplay = utf8_decode($textToDisplay); // Affichage $pdf->SetFillColor(231, 231, 231); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(floor(0.35 * $A4Height), $textSize + 5, $textToDisplay, 'LRTB', 'L', TRUE); // On affiche les graphiques : mainGraphPDF // Récupération des données // Liste des graphiques à afficher $input = $form->xpath('categorie/input[@mainPDFGraph="1"]'); $nbGraph = count($input); // Nombre de graphiques à intégrer // On génère $tempData, contenant les données utilisées pour génération du png foreach ($input as $select) { if ($select['type'] == 'select') { $categorie = $select->xpath('..')[0]; // Catégorie du graphique $tempData = array(); $tempData['settings'] = array('width' => 450, 'height' => 230); foreach ($select->option as $option) { if (isset($data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']])) { $value = $data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']]; if (is_numeric($value)) { $tempData['data'][constant((string) $option['text'])] = $value; } else { $tempData['data'][constant((string) $option['text'])] = 0; } } else { $tempData['data'][constant((string) $option['text'])] = 0; } } // On inclut l'image $pdf->Image(eval_ccpc_genGraphPie($tempData), 0.4 * $A4Height, 3 * $titleSize, floor(0.4 * $A4Height), 0, 'PNG'); break; } } // On affiche l'icone des filtres : maximum 4 $filtres = eval_ccpc_checkFilterExistence($data['service']['id'], $data['service']['date']['min'], $data['service']['date']['max'], $promotion); $numberOfIcons = 0; // Compte le nombre d'icones ajoutées $leftCornerX = 0.8 * $A4Height - 5; $leftCornerY = 3 * $titleSize - 5; if (is_array($filtres)) { foreach ($filtres as $filtre) { if (isset($filtre['icone']) && strlen($filtre['icone']) > 1 && $numberOfIcons < 4) { $pdf->Image($filtre['icone'], $leftCornerX, $leftCornerY, floor(0.1 * $A4Height), 0, 'PNG'); $numberOfIcons++; if ($numberOfIcons == 1) { $leftCornerX = 0.9 * $A4Height - 3; } else { if ($numberOfIcons == 2) { $leftCornerX = 0.8 * $A4Height - 5; $leftCornerY += 0.1 * $A4Height + 1; } else { if ($numberOfIcons == 3) { $leftCornerX = 0.9 * $A4Height - 3; } } } break; } } } if ($numberOfIcons == 0) { // On ajoute l'icone neutre si aucune icone n'est présente $pdf->Image(PLUGIN_PATH . '/css/img/neutral.png', $leftCornerX, $leftCornerY, floor(0.1 * $A4Height), 0, 'PNG'); } // Deuxième ligne $pdf->Ln(8 * $titleSize); // On affiche le radar sur 1 an de données $fullYearData = getEvaluationCCPCFullData($data['service']['id'], $promotion, $data['service']['date']['max'] - 31536000, $data['service']['date']['max'], FALSE); // Récupération des données // Titre $pdf->Cell(floor(0.4 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_FULLYEAR . ' (' . date('d/m/Y', $fullYearData['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $fullYearData['service']['date']['max']) . ')'), 0, 0, 'C', FALSE); // On affiche l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 680, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $fullYearData[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), 10, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // On affiche le radar sur la période du stage // On décale du 0.05*largeur $pdf->Cell(floor(0.05 * $A4Height)); // On crée un rectangle contenant les données $pdf->Rect($pdf->getX(), $pdf->getY() - 10, 0.5 * $A4Height, 0.3 * $A4Height, 'F'); // Titre $pdf->Cell(floor(0.5 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_START . ' ' . date('d/m/Y', $data['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $data['service']['date']['max'])), 0, 0, 'C', FALSE); // On ajoute l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 650, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), $pdf->getX() - 0.45 * $A4Height, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // Affiche du logo $pdf->Image(ROOT . 'theme/img/logo.png', 10, $A4Width - 100, 0, 50, 'PNG'); // Pied de Page $pdf->SetX(0.5 * $A4Height); $pdf->SetY($A4Width - 40); $textSize = 10; $pdf->SetFont('Arial', 'I', $textSize); // Ligne de demarcation $pdf->Line(15, $pdf->getY(), $A4Height - 15, $pdf->getY()); // Accès aux résultats $pdf->SetX(0.5 * $A4Height); $pdf->Cell(0.5 * $A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_FULLRESULT . ' ' . getPageUrl('evalView', array('evaluationType' => 1, 'service' => $data['service']['id']))), 0, 1, 'R', 0); // Coordonées CSG if ($commentMSG) { $pdf->SetFont('Arial', 'B', $textSize); $pdf->SetX(15); $pdf->Cell($A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_STRUCTURENAME . ' - ' . CONTACT_STAGE_MAIL), 0, 0, 'C', 0); } /** Commentaires **/ // Ajout des commentaires, points positifs et points négatifs : 'pdfComment' if ($comment) { $pdf->addPage('P', 'A4'); // Titre $pdf->SetFont('Arial', 'B', $titleSize); $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Width)); $pdf->Cell(floor(0.8 * $A4Width), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_COMMENT_TITLE), 'LRTB', 1, 'C', TRUE); $pdf->SetTextColor(0, 0, 0); $pdf->SetFillColor(245, 245, 245); // Les commentaires $input = $form->xpath('categorie/input[@pdfComment="1"]'); foreach ($input as $theinput) { $categorie = $theinput->xpath('..')[0]; if ($theinput['type'] == 'text') { // Création de l'array contenant les données à afficher sous forme [timestamp fin][timestamp début][timestamp commantaire][idMessage][] => message $tempData = array(); foreach ($theinput->text as $value) { if (isset($data[(string) $categorie['nom']][(string) $value['nomBDD']])) { foreach ($data[(string) $categorie['nom']][(string) $value['nomBDD']] as $idEval => $textValue) { if (isset($data['donnees'][$idEval]['infos'])) { $tempData[$data['donnees'][$idEval]['infos']['dateFin']][$data['donnees'][$idEval]['infos']['dateDebut']][$data['donnees'][$idEval]['infos']['date']][$idEval][] = $textValue; } } } } $textArea = ''; $firstLoop = TRUE; // On affiche les commentaires krsort($tempData); foreach ($tempData as $dateFin => $tempvalue) { krsort($tempvalue); foreach ($tempvalue as $dateDebut => $value2) { krsort($value2); foreach ($value2 as $date => $value3) { foreach ($value3 as $commentId => $comments) { foreach ($comments as $comment) { if ($comment != '') { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment . ' - ' . date('d/m/Y', $date) . ' #' . $commentId; } } } } } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } else { if ($theinput['type'] == 'textarea') { // Création de l'array contenant les données à afficher sous forme [timestamp fin][timestamp début][timestamp commantaire][idCommentaire] => commentaire $tempData = array(); foreach ($data[(string) $categorie['nom']][(string) $theinput['nomBDD']] as $commentId => $commentData) { if (isset($data['donnees'][$commentId]['infos'])) { $tempData[$data['donnees'][$commentId]['infos']['dateFin']][$data['donnees'][$commentId]['infos']['dateDebut']][$data['donnees'][$commentId]['infos']['date']][$commentId] = $commentData; } } $textArea = ''; $firstLoop = TRUE; // On affiche les commentaires krsort($tempData); foreach ($tempData as $dateFin => $tempvalue) { krsort($tempvalue); foreach ($tempvalue as $dateDebut => $value2) { krsort($value2); foreach ($value2 as $date => $value3) { foreach ($value3 as $commentId => $comment) { if ($comment != '') { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment . ' - ' . date('d/m/Y', $date) . ' #' . $commentId; } } } } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0 * $A4Width, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } } } } // On retourne le fichier PDF $pdf->Output($pdfPath, 'F'); $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } exit; } else { return FALSE; } }
public function drawPDF() { $pdf = new \FPDF('P', 'mm', 'Letter'); $width = 52; // tag width in mm $height = 31; // tag height in mm $left = 5.5; // left margin $top = 15; // top margin $pdf->SetTopMargin($top); //Set top margin of the page $pdf->SetLeftMargin($left); //Set left margin of the page $pdf->SetRightMargin($left); //Set the right margin of the page $pdf->SetAutoPageBreak(False); // manage page breaks yourself $data = $this->loadItems(); $num = 0; // count tags $x = $left; $y = $top; foreach ($data as $item) { // extract & format data $price = $item['normal_price']; $desc = strtoupper(substr($item['posDescription'], 0, 27)); $brand = strtoupper(substr($item['brand'], 0, 13)); $pak = $item['units']; $size = $item['units'] . "-" . $item['size']; $sku = $item['sku']; $ppu = $item['pricePerUnit']; $vendor = substr($item['vendor'], 0, 7); $upc = $item['upc']; if ($num % 32 == 0) { $pdf->AddPage(); $x = $left; $y = $top; } else { if ($num % 4 == 0) { $x = $left; $y += $height; } } $args = array('height' => 7, 'valign' => 'T', 'align' => 'L', 'suffix' => date(' n/j/y'), 'fontsize' => 8, 'font' => $this->font); $pdf = $this->drawBarcode($upc, $pdf, $x + 7, $y + 4, $args); $pdf->SetFont($this->font, '', 8); $pdf->SetXY($x, $y + 12); $pdf->Cell($width, 4, $desc, 0, 1, 'L'); $pdf->SetX($x); $pdf->Cell($width, 4, $brand, 0, 1, 'L'); $pdf->SetX($x); $pdf->Cell($width, 4, $size, 0, 1, 'L'); $pdf->SetX($x); $pdf->Cell($width, 4, $sku . ' ' . $vendor, 0, 0, 'L'); if (strstr($ppu, '/') && $ppu[strlen($ppu) - 1] != '/') { $pdf->SetX($x); $pdf->Cell($width - 5, 4, $ppu, 0, 0, 'R'); } $pdf->SetXY($x, $y + 16); $pdf->SetFont($this->font, 'B', 24); //change font size $pdf->Cell($width - 5, 8, $price, 0, 0, 'R'); // move right by tag width $x += $width; $num++; } $pdf->Output('Tags4x8P.pdf', 'I'); }
public function generar_pdf($id_cor, $id_direccion_gen) { $correspondencia = $this->ivss_model->core_parcial($id_cor)->result(); $direccion_general = $this->ivss_model->ver_direccion_general_especifica($id_direccion_gen); foreach ($correspondencia as $cor_item) { $id_cor_oficio = $cor_item->id_cor; $num_control_oficio = $cor_item->num_control; $dir_origen_oficio = $cor_item->dir_origen; $remitente_oficio = $cor_item->remitente; $dir_destino_oficio = $cor_item->dir_destino; $asunto_oficio = $cor_item->asunto; $descripcion_oficio = $cor_item->descripcion; $fecha_crea_oficio = $cor_item->fecha_creacion; } $datos_director = $this->ivss_model->ver_dir_gen_especifica2($dir_destino_oficio)->result(); foreach ($datos_director as $dir) { $nombre_director = $dir->nombre_director; $resolucion_director = $dir->resolucion_director; } $this->load->library('fpdf/fpdf'); $pdf = new FPDF('P'); $pdf->AddPage(); $pdf->SetTitle("correspondencia", true); $pdf->SetFont('Arial', 'B', 16); $pdf->Image($this->config->base_url() . 'fronted/img/banner_institucional.png', 20, 8, 170); $pdf->AliasNbPages(); $pdf->SetSubject("Sistema de correspondencia"); $pdf->Image($this->config->base_url() . 'fronted/img/logogrande.png', 20, 25, 17); $pdf->SetFont('Arial', '', 9); $pdf->Text(68, 30, "REPUBLICA BOLIVARIANA DE VENEZUELA"); $pdf->Text(42, 40, "MINISTERIO DEL PODER POPULAR PARA EL PROCESO SOCIAL DEL TRABAJO"); $pdf->Text(62, 50, "INSTITUTO VENEZOLANO DE LOS SEGUROS SOCIALES"); $pdf->SetLeftMargin(20.0); $pdf->SetRightMargin(20.0); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 70, "OFICIO:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 70, $num_control_oficio); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 80, "PARA:"); $pdf->SetFont('Arial', 'b', 12); #$pdf->Text(44,80,strtoupper(utf8_decode($nombre_director))); $pdf->Text(44, 80, strtoupper(utf8_decode("JACINTO PEREZ BONALDE SANCHEZ"))); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 90, utf8_decode($dir_destino_oficio)); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 100, "DE:"); $pdf->SetFont('Arial', 'b', 12); $pdf->Text(44, 100, utf8_decode($remitente_oficio)); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 110, utf8_decode(end(explode("-", $dir_origen_oficio)))); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 120, "FECHA:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 120, $fecha_crea_oficio); $pdf->SetFont('Arial', 'B', 12); $pdf->Text(20, 130, "ASUNTO:"); $pdf->SetFont('Arial', '', 12); $pdf->Text(44, 130, utf8_decode($asunto_oficio)); $pdf->SetXY(10, 140); $pdf->SetFont('Arial', '', 10); $pdf->SetTopMargin(2.0); $pdf->SetLeftMargin(20.0); $pdf->SetRightMargin(20.0); $pdf->MultiCell(0, 7, utf8_decode($descripcion_oficio)); $pdf->SetFont('Arial', 'b', 10); $pdf->Text(93, 245, "Atentamente"); $pdf->Line(50, 264, 160, 264); #$pdf->Image($this->config->base_url().'fronted/img/FIRMADIGITAL.png',52,230,115); $pdf->SetFont('Arial', '', 10); $pdf->Text(75, 268, utf8_decode($remitente_oficio)); $pdf->SetFont('Arial', '', 10); $pdf->Text(88, 272, utf8_decode("Director general")); $pdf->SetFont('Arial', '', 10); $pdf->Text(76, 276, utf8_decode("Según resolución:" . $resolucion_director)); $pdf->Output('oficio_' . $num_control_oficio, 'I'); #tabla /* $cabecera=array('Usuario', 'Total asignados', 'Ejecutados'); $pdf->SetXY(10,30); //Seleccionamos posición $pdf->SetFont('Arial','B',10); //Fuente, Negrita, tamaño foreach($cabecera as $columna){ //Parámetro con valor 2, cabecera vertical $pdf->Cell(50,7, utf8_decode($columna),1, 0,'L'); } $pdf->SetXY(10,31); $pdf->Ln();//Salto de línea para generar otra fila $pdf->Ln();//Salto de línea para generar otra fila foreach($cabecera as $fila){ //Atención!! el parámetro valor 0, hace que sea horizontal $pdf->Cell(50,7, utf8_decode($fila),1, 0 , '' ); } */ #llave clase. }
/** * generatePDF - Génère un fichier PDF à partir des données d'évaluation d'un service * * @category : eval_ccpc_functions * @param array $data Données d'évaluation récupérées à partir de la fonction {@link getEvaluationCCPCFullData()} * @param boolean $comment TRUE si on incut les commentaire, FALSE si on ne les inclut pas * @param boolean $commentMSG TRUE si on incut un message concernant la CSG, FALSE si on ne l'inclut pas * @return array Array contenant les informations du fichier généré * * @Author Ali Bellamine * * Contenu de l'array retourné :<br> * ['pdfPath'] => (string) Chemin local vers le fichier généré<br> * ['pdfURI'] => (string) URI pointant vers le fichier généré * */ function generatePDF($data, $comment = FALSE, $commentMSG = FALSE) { // Array contenant les résultats $output = array(); // On vérifie l'existence des données if (isset($data) && count($data) > 0) { /* Mise en cache */ // Calcul du md5 $hashdata = $data; $hashdata['optionsPDF'] = array('comment' => $comment, 'commentMSG' => $commentMSG); $hash = md5(json_encode($hashdata)); $pdfPath = PLUGIN_PATH . 'cache/' . $hash . '.pdf'; $pdfPathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.pdf'; if (is_file($pdfPath)) { $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } else { // On charge la librairie require_once PLUGIN_PATH . 'core/fpdf17/fpdf.php'; // On charge le fichier XML if (is_file(PLUGIN_PATH . 'formulaire.xml')) { $form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml'); } // Promotion if (count($data['service']['promotion']) > 1) { $promotion = false; } else { foreach ($data['service']['promotion'] as $promotionData) { $promotion = $promotionData['id']; } } ob_end_clean(); // On crée le PDF $A4Height = 842; $A4Width = 595; $titleSize = 15; $textSize = 11; $pdf = new FPDF('L', 'pt', 'A4'); $pdf->SetTopMargin(10); $pdf->SetLeftMargin(15); $pdf->SetAutoPageBreak(TRUE, 10); /** Page contenant le résumé des données d'évaluation **/ $pdf->AddPage(); $pdf->SetFont('Arial', 'B', $titleSize); // On affiche le titre $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Height)); $pdf->Cell(floor(0.8 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_TITLE), 'LRTB', 0, 'C', TRUE); // Première ligne $pdf->Ln(2 * $titleSize); $pdf->SetFont('Arial', '', $textSize); // On affiche les informations concernant le service // Récupération des données $textToDisplay = LANG_FORM_CCPC_FILTER_SERVICE_TITLE . ' : ' . $data['service']['FullName'] . PHP_EOL . LANG_FORM_CCPC_PDF_STAGEPERIODE . ' : ' . date('d/m/Y', $data['service']['date']['min']) . ' - ' . date('d/m/Y', $data['service']['date']['max']) . PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTPROMOTION . ' : '; $firstLoop = true; foreach ($data['service']['promotion'] as $promotionData) { if (!$firstLoop) { $textToDisplay .= ', '; } else { $firstLoop = FALSE; } $textToDisplay .= $promotionData['nom'] . ' (' . $promotionData['nb'] . ')'; } $textToDisplay .= PHP_EOL . LANG_FORM_CCPC_PDF_STUDENTNB . ' : ' . $data['service']['nbEvaluation'] . PHP_EOL . LANG_FORM_CCPC_PDF_EVALUATIONNB . ' : ' . $data['nb']; $textToDisplay = utf8_decode($textToDisplay); // Affichage $pdf->SetFillColor(231, 231, 231); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(floor(0.35 * $A4Height), $textSize + 5, $textToDisplay, 'LRTB', 'L', TRUE); // On affiche les graphiques : mainGraphPDF // Récupération des données // Liste des graphiques à afficher $input = $form->xpath('categorie/input[@mainPDFGraph="1"]'); $nbGraph = count($input); // Nombre de graphiques à intégrer // On génère $tempData, contenant les données utilisées pour génération du png foreach ($input as $select) { if ($select['type'] == 'select') { $categorie = $select->xpath('..')[0]; // Catégorie du graphique $tempData = array(); $tempData['settings'] = array('width' => 450, 'height' => 230); foreach ($select->option as $option) { if (isset($data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']])) { $value = $data[(string) $categorie['nom']][(string) $select['nomBDD']]['nb'][(string) $option['value']]; if (is_numeric($value)) { $tempData['data'][constant((string) $option['text'])] = $value; } else { $tempData['data'][constant((string) $option['text'])] = 0; } } else { $tempData['data'][constant((string) $option['text'])] = 0; } } // On inclut l'image $pdf->Image(eval_ccpc_genGraphPie($tempData), 0.4 * $A4Height, 3 * $titleSize, floor(0.4 * $A4Height), 0, 'PNG'); break; } } // On affiche l'icone des filtres $filtres = eval_ccpc_checkFilterExistence($data['service']['id'], $data['service']['date']['min'], $data['service']['date']['max'], $promotion); if (is_array($filtres)) { foreach ($filtres as $filtre) { if (isset($filtre['icone'])) { $pdf->Image($filtre['icone'], 0.8 * $A4Height, 3 * $titleSize, floor(0.2 * $A4Height), 0, 'PNG'); break; } } } // Deuxième ligne $pdf->Ln(8 * $titleSize); // On affiche le radar sur 1 an de données $fullYearData = getEvaluationCCPCFullData($data['service']['id'], $promotion, $data['service']['date']['max'] - 31536000, $data['service']['date']['max'], FALSE); // Récupération des données // Titre $pdf->Cell(floor(0.4 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_FULLYEAR . ' (' . date('d/m/Y', $fullYearData['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $fullYearData['service']['date']['max']) . ')'), 0, 0, 'C', FALSE); // On affiche l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 680, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $fullYearData[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), 10, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // On affiche le radar sur la période du stage // On décale du 0.05*largeur $pdf->Cell(floor(0.05 * $A4Height)); // On crée un rectangle contenant les données $pdf->Rect($pdf->getX(), $pdf->getY() - 10, 0.5 * $A4Height, 0.3 * $A4Height, 'F'); // Titre $pdf->Cell(floor(0.5 * $A4Height), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_STAGEPERIODE_START . ' ' . date('d/m/Y', $data['service']['date']['min']) . ' ' . LANG_FORM_CCPC_PDF_STAGEPERIODE_END . ' ' . date('d/m/Y', $data['service']['date']['max'])), 0, 0, 'C', FALSE); // On ajoute l'image // Liste des valeurs à afficher $input = $form->xpath('categorie/input[@radarPDFGraph="1"]'); // Préparation des données $tempData = array(); $tempData['settings'] = array('height' => 380, 'width' => 650, 'max' => 10); foreach ($input as $theinput) { // Récupération du parent $categorie = $theinput->xpath('..')[0]; // Catégorie du graphique if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'])) { $tempData['data'][constant($theinput['label'] . '_SHORT')] = $data[(string) $categorie['nom']][(string) $theinput['nomBDD']]['moyenne'] + 5; } } // Affichage de l'image $pdf->Image(eval_ccpc_genGraphRadar($tempData), $pdf->getX() - 0.45 * $A4Height, $pdf->getY() + 40, floor(0.4 * $A4Height), 0, 'PNG'); // Affiche du logo $pdf->Image(ROOT . 'theme/img/logo.png', 10, $A4Width - 100, 0, 50, 'PNG'); // Pied de Page $pdf->SetX(0.5 * $A4Height); $pdf->SetY($A4Width - 40); $textSize = 10; $pdf->SetFont('Arial', 'I', $textSize); // Ligne de demarcation $pdf->Line(15, $pdf->getY(), $A4Height - 15, $pdf->getY()); // Accès aux résultats $pdf->SetX(0.5 * $A4Height); $pdf->Cell(0.5 * $A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_FULLRESULT . ' ' . getPageUrl('evalView', array('evaluationType' => 1, 'service' => $data['service']['id']))), 0, 1, 'R', 0); // Coordonées CSG if ($commentMSG) { $pdf->SetFont('Arial', 'B', $textSize); $pdf->SetX(15); $pdf->Cell($A4Height - 15, $textSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_FOOTER_STRUCTURENAME . ' - ' . CONTACT_STAGE_MAIL), 0, 0, 'C', 0); } /** Commentaires **/ // Ajout des commentaires, points positifs et points négatifs : 'pdfComment' if ($comment) { $pdf->addPage('P', 'A4'); // Titre $pdf->SetFont('Arial', 'B', $titleSize); $pdf->SetFillColor(70, 70, 242); $pdf->SetTextColor(255, 255, 255); $pdf->SetX(floor(0.1 * $A4Width)); $pdf->Cell(floor(0.8 * $A4Width), $titleSize + 5, utf8_decode(LANG_FORM_CCPC_PDF_COMMENT_TITLE), 'LRTB', 1, 'C', TRUE); $pdf->SetTextColor(0, 0, 0); $pdf->SetFillColor(245, 245, 245); // Les commentaires $input = $form->xpath('categorie/input[@pdfComment="1"]'); foreach ($input as $theinput) { $categorie = $theinput->xpath('..')[0]; if ($theinput['type'] == 'text') { $textArea = ''; $firstLoop = TRUE; foreach ($theinput->text as $text) { if (isset($data[(string) $categorie['nom']][(string) $text['nomBDD']])) { foreach ($data[(string) $categorie['nom']][(string) $text['nomBDD']] as $comment) { if ($comment != '') { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment; } } } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } else { if ($theinput['type'] == 'textarea') { $textArea = ''; $firstLoop = TRUE; if (isset($data[(string) $categorie['nom']][(string) $theinput['nomBDD']])) { foreach ($data[(string) $categorie['nom']][(string) $theinput['nomBDD']] as $comment) { if (!$firstLoop) { $textArea .= PHP_EOL . PHP_EOL; } else { $firstLoop = FALSE; } // Saut de ligne $textArea .= $comment; } } if ($textArea != '') { // On affiche les textes dans le PDF $pdf->Ln(20); $pdf->SetX(20); $pdf->setFont('Arial', '', $titleSize); $pdf->Cell(0 * $A4Width, $titleSize + 5, utf8_decode(constant($theinput['label'] . '_SHORT')), 0, 1, 'L', FALSE); $pdf->setFont('Arial', '', $textSize); $pdf->SetX(20); $pdf->MultiCell($A4Width - 40, $textSize + 5, utf8_decode($textArea), 'LTRB', 'L', TRUE); } } } } } // On retourne le fichier PDF $pdf->Output($pdfPath, 'F'); $output['pdfPath'] = $pdfPath; $output['pdfURI'] = $pdfPathURI; return $output; } exit; } else { return FALSE; } }
/** * @Template() * * @Route("/statistique-participations/", name="statistiqueparticipations") */ public function statistiqueParticipationsAction(Request $request) { $em = $this->getDoctrine()->getManager(); if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { $user = $this->getUser(); $id = $user->getId(); $activites = $this->get("alb_inscriptions.alb_manager")->getActivitesAdherent($id); $bureau = $this->get("alb_inscriptions.alb_manager")->isBureau($id, $activites); if ($bureau) { $groupes = $this->get("alb_inscriptions.alb_manager")->getGroupesAdherent($id); $activitesgroupe = $em->getRepository('ALBInscriptionsBundle:Activites')->findByIdgroupes($groupes); foreach ($activitesgroupe as $activite) { $activites[] = $activite->getId(); } } $activites = $this->get("alb_inscriptions.alb_manager")->getListeActivites($activites); } else { $activites = $em->getRepository('ALBInscriptionsBundle:Activites')->findAll(); $groupes = $em->getRepository('ALBInscriptionsBundle:Groupes')->findAll(); } if ('POST' === $request->getMethod()) { $activite = $request->get('activite'); $groupe = $request->get('groupe'); if ($activite > 0) { $nomactivite = $em->getRepository('ALBInscriptionsBundle:Activites')->find($activite)->getActivite(); } elseif ($groupe > 0) { $nomactivite = $em->getRepository('ALBInscriptionsBundle:groupes')->find($groupe)->getGroupe(); } else { $nomactivite = 'Toutes'; } $datedebut = $request->get('datedebut'); $datefin = $request->get('datefin'); $nb = 0; if ($activite > 0) { $participants = $this->get("alb_inscriptions.alb_manager")->getListeParticipantsActivite($activite); } else { $participants = $this->get("alb_inscriptions.alb_manager")->getListeParticipants($groupe); } $nomfichier = 'statistiques/' . $activite . '.pdf'; $pdf = new \FPDF(); $pdf->Open(); $pdf->SetTopMargin(5); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 14); $pdf->Cell(0, 5, utf8_decode('Amicale Laïque de Billère'), 0, 1, 'C'); $pdf->ln(2); $pdf->SetFont('Arial', '', 12); $pdf->Cell(0, 5, utf8_decode('Liste des présences aux sorties ' . $nomactivite . ' entre le ' . substr($datedebut, 8, 2) . '/' . substr($datedebut, 5, 2) . '/' . substr($datedebut, 0, 4) . ' et le ' . substr($datefin, 8, 2) . '/' . substr($datefin, 5, 2) . '/' . substr($datefin, 0, 4)), 0, 1); $pdf->ln(2); $pdf->SetFont('Arial', '', 8); $pdf->SetFont('Arial', 'B', 8); $pdf->Cell(5, 4, '', 1, 0, 'C'); $pdf->Cell(50, 4, utf8_decode('Nom Prénom'), 1, 0, 'C'); //$pdf->Cell(20,4,utf8_decode('Activité'),1,0,'C'); $pdf->Cell(30, 4, utf8_decode('Nb de présence'), 1, 1, 'C'); $pdf->SetFont('Arial', '', 8); $i = 0; $encadrement = false; foreach ($participants as $participant) { if ($participant->getAidemeneur() and !$encadrement) { $pdf->Cell(55, 4, 'TOTAL', 1, 0, 'R'); $pdf->Cell(30, 4, $nb, 1, 1, 'C'); $nb = 0; $encadrement = true; $i = 0; $pdf->SetFont('Arial', 'B', 8); $pdf->Cell(85, 5, 'ENCADREMENT', 0, 1, 'C'); $pdf->SetFont('Arial', '', 8); $pdf->Cell(5, 4, '', 1, 0, 'C'); $pdf->Cell(50, 4, utf8_decode('Nom Prénom'), 1, 0, 'C'); //$pdf->Cell(20,4,utf8_decode('Activité'),1,0,'C'); $pdf->Cell(30, 4, utf8_decode('Nb de présence'), 1, 1, 'C'); } $i++; $pdf->Cell(5, 4, $i, 1, 0, 'C'); $pdf->Cell(50, 4, utf8_decode($participant->getIdadherent()->getNom() . ' ' . $participant->getIdadherent()->getPrenom()), 1, 0, ''); $id = $participant->getId(); if ($activite > 0) { $nbparticipation = $this->get("alb_inscriptions.alb_manager")->getNbParticipationActivite($activite, $id, $datedebut, $datefin); } else { $nbparticipation = $this->get("alb_inscriptions.alb_manager")->getNbParticipationGroupe($groupe, $id, $datedebut, $datefin); } $pdf->Cell(30, 4, $nbparticipation, 1, 1, 'C'); $nb = $nb + $nbparticipation; } $pdf->Cell(55, 4, 'TOTAL', 1, 0, 'R'); $pdf->Cell(30, 4, $nb, 1, 1, 'C'); $pdf->Output($nomfichier, 'F'); $response = new Response(); $response->setContent(file_get_contents($nomfichier)); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-disposition', 'filename=' . $nomfichier); return $response; } return array('activites' => $activites, 'groupes' => $groupes); }
<?php require 'fpdf16/fpdf.php'; require 'connection.php'; require 'functions.php'; $pdf = new FPDF(); $pdf->AliasNbPages(); $pdf->SetTopMargin(4); $pdf->SetLeftMargin(6); $pdf->SetAutoPageBreak(1, 0.5); $pdf->SetDisplayMode(100); $pdf->SetAutoPageBreak(true, 7); $pdf->AddPage(); //$pdf->AddPage('L'); $pdf->SetDisplayMode(110, "single"); $pdf->SetTitle("Netherhall House"); $border = 1; $pdf->SetFont('Arial', 'B', 10); $pdf->SetFillColor(255, 255, 255); //------------ $pdf->Cell(180, 5, "Netherhall House", 0, 0, '', true); $pdf->Ln(); $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(95, 5, $header, 0, 0, '', true); $pdf->SetFont('Arial', 'B', 8); $pdf->Cell(103, 5, date("d/m/Y"), 0, 0, 'R', true); $pdf->SetFont('Arial', '', 7); //ver_array("REQUEST", $request); $arrClasses = array(); //ver_array("arrClasses",$arrClasses); //The purpose of this page should only be to keep track of the residents who are currently in Netherhall.
if (isset($_GET['size'])) { $size = explode('-', $_GET['size']); $Pwidth = is_numeric($size[0]) ? $size[0] : $Pwidth; $Pheight = is_numeric($size[1]) ? $size[1] : $Pheight; } $fontSize = 16; $width = $Pwidth; $height = $Pheight; require $Fpdf_loc; $pdf = new FPDF('P', 'mm', array($width, $height)); $full = isset($_GET['full']); $marginLeft = $full ? 0 : $width / 21.59; $marginTop = $full ? 0 : $height / 13.97; $pdf->SetLeftMargin($marginLeft); $pdf->SetRightMargin($marginLeft); $pdf->SetTopMargin($marginTop / 2); $pdf->SetAutoPageBreak(true, $marginTop); $pages = 0; $files = json_decode($_GET['json']); if ($files == null) { $files = array(); } foreach ($files as $key => $val) { $file = $key; if (is_numeric(strpos($file, "/"))) { $file = substr($file, strrpos($file, "/") + 1); } $file = "Scan_{$file}"; if (!is_file("scans/file/{$file}")) { continue; }
function __construct($products, $order, $filename, $save = false) { App::import('vendor', 'fpdf/fpdf'); $orientation = 'P'; $unit = 'pt'; $format = 'A4'; $margin = 40; $pdf = new FPDF($orientation, $unit, $format); App::import('Helper', 'Time'); $timeHelper = new TimeHelper(); setlocale(LC_MONETARY, 'th_TH'); $pdf->AddPage(); $pdf->SetTopMargin($margin); $pdf->SetLeftMargin($margin); $pdf->SetRightMargin($margin); $pdf->SetAutoPageBreak(true, $margin); $pdf->SetY($pdf->GetY() + 60); $pdf->SetFont('Arial', 'B', 10); $pdf->SetTextColor(0); $pdf->SetFillColor(255); $pdf->SetLineWidth(1); $pdf->Cell(50, 25, "Order ID: ", 'LT', 0, 'L'); $pdf->SetFont('Arial', ''); $pdf->Cell(50, 25, $order['Order']['id'], 'T', 0, 'L'); $pdf->SetFont('Arial', 'B'); $pdf->Cell(100, 25, 'Customer Name: ', 'T', 0, 'L'); $pdf->SetFont('Arial', ''); $pdf->Cell(316, 25, $order['User']['name'], 'TR', 1, 'L'); $pdf->SetFont('Arial', 'B'); $pdf->Cell(100, 25, "Delivery Date: ", 'LT', 0, 'L'); $pdf->SetFont('Arial', ''); $pdf->Cell(416, 25, $timeHelper->format($format = 'd-m-Y', $order['Delivery']['date']), 'TR', 1, 'L'); $pdf->SetFont('Arial', 'B', '10'); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 30; $pdf->MultiCell($cell_width, 25, "No.\n ", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $pdf->Cell(250, 25, "Description", 'LTR', 0, 'C'); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 48; $pdf->MultiCell($cell_width, 25, "Number Ordered", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 48; $pdf->MultiCell($cell_width, 25, "Number Supplied", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 70; $pdf->MultiCell($cell_width, 25, "Amount per Unit", 'LTR', 'C'); $pdf->SetXY($current_x + $cell_width, $current_y); $current_y = $pdf->GetY(); $current_x = $pdf->GetX(); $cell_width = 70; $pdf->MultiCell($cell_width, 25, "Amount\n ", 'LTR', 'C'); $pdf->SetY($pdf->GetY() - 25); $pdf->SetFont('Arial', ''); $pdf->SetFillColor(238); $pdf->SetLineWidth(0.2); $pdf->SetY($pdf->GetY() + 25); $num = 1; $number_ordered = 0; $number_supplied = 0; foreach ($products as $product) { $pdf->Cell(30, 20, $num++, 1, 0, 'L'); $pdf->Cell(250, 20, $product['Product']['short_description'], 1, 0, 'L'); $pdf->Cell(48, 20, $product['LineItem']['quantity'], 1, 0, 'R'); $number_ordered += $product['LineItem']['quantity']; $pdf->Cell(48, 20, $product['LineItem']['quantity_supplied'], 1, 0, 'R'); $number_supplied += $product['LineItem']['quantity_supplied']; $pdf->Cell(70, 20, money_format("%i", $product['Product']['selling_price']), 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $product['LineItem']['total_price_supplied']), 1, 1, 'R'); } $pdf->SetX($pdf->GetX() + 30); $pdf->SetFont('Arial', 'B'); $pdf->Cell(250, 20, "TOTALS", 1); $pdf->SetFont('Arial', ''); $pdf->Cell(48, 20, $number_ordered, 1, 0, 'R'); $pdf->Cell(48, 20, $number_supplied, 1, 0, 'R'); $pdf->Cell(70, 20, "N.A.", 1, 0, 'R'); $pdf->Cell(70, 20, money_format("%i", $order['Order']['total_supplied']), 1, 1, 'R'); $pdf->SetY($pdf->GetY() + 25); $pdf->SetFont('Arial', 'B'); $pdf->Cell(80, 20, "Amount Paid: "); $pdf->SetFont('Arial', ''); $pdf->Cell(80, 20, money_format("%i", $order['Order']['total']), 0, 1); $pdf->SetFont('Arial', 'B'); $pdf->Cell(80, 20, "Actual Amount: "); $pdf->SetFont('Arial', ''); $pdf->Cell(80, 20, money_format("%i", $order['Order']['total_supplied']), 0, 1); $pdf->SetFont('Arial', 'B'); $pdf->Cell(80, 20, "Rebate Amount: "); $pdf->SetFont('Arial', ''); $pdf->Cell(80, 20, money_format("%i", $order['Order']['total'] - $order['Order']['total_supplied']), 0, 1); if ($save) { $pdf->Output($filename, 'F'); } else { $pdf->Output($filename, 'I'); } }
public function horaireGeneratePDF($idLigne) { $largeurNomArret = 35; $maxCourses = 15; $couleurPair = [236, 240, 241]; $couleurImpair = [255, 255, 255]; $couleurActuelle = 0; require public_path() . '/lib/fpdf/fpdf.php'; $date = date('d-m-Y'); $horaires = Horaire::getHorairesByLigne($idLigne, $date, '00', '00'); $idSemaine = array_keys($horaires)[0]; $arret = array_keys($horaires[$idSemaine]['aller'])[0]; $courses = count($horaires[$idSemaine]['aller'][$arret]); $largeurCol = (277 - $largeurNomArret) / $courses; $count = 0; $pdf = new FPDF('L'); $pdf->SetTopMargin(5); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 7); $pdf->SetFillColor($couleurImpair[0], $couleurImpair[1], $couleurImpair[2]); if ($courses <= $maxCourses) { foreach ($horaires[$idSemaine]['aller'] as $nomArret => $horaires) { $pdf->Cell($largeurNomArret, 6, $nomArret, 0, 0); foreach ($horaires as $horaire) { if ($horaire == '00:00:00') { $pdf->Cell($largeurCol, 6, str_limit('', 5, $end = ''), 0, 0, 'C', true); } else { $pdf->Cell($largeurCol, 6, str_limit($horaire, 5, $end = ''), 0, 0, 'C', true); } } $pdf->Ln(); if ($couleurActuelle) { $pdf->SetFillColor($couleurImpair[0], $couleurImpair[1], $couleurImpair[2]); $couleurActuelle = 0; } else { $pdf->SetFillColor($couleurPair[0], $couleurPair[1], $couleurPair[2]); $couleurActuelle = 1; } } } else { $largeurCol = (277 - $largeurNomArret) / round($courses / 2); foreach ($horaires[$idSemaine]['aller'] as $nomArret => $horairesArret) { $pdf->Cell($largeurNomArret, 5, $nomArret, 0, 0); for ($i = 0; $i < $courses / 2; $i++) { if ($horairesArret[$i] == '00:00:00') { $pdf->Cell($largeurCol, 5, str_limit('', 5, $end = ''), 0, 0, 'C', true); } else { $pdf->Cell($largeurCol, 5, str_limit($horairesArret[$i], 5, $end = ''), 0, 0, 'C', true); } } $pdf->Ln(); if ($couleurActuelle) { $pdf->SetFillColor($couleurImpair[0], $couleurImpair[1], $couleurImpair[2]); $couleurActuelle = 0; } else { $pdf->SetFillColor($couleurPair[0], $couleurPair[1], $couleurPair[2]); $couleurActuelle = 1; } } $pdf->AddPage(); foreach ($horaires[$idSemaine]['aller'] as $nomArret => $horairesArret) { $pdf->Cell($largeurNomArret, 5, $nomArret, 0, 0); for ($i = $courses / 2 + 1; $i < $courses; $i++) { if ($horairesArret[$i] == '00:00:00') { $pdf->Cell($largeurCol, 5, str_limit('', 5, $end = ''), 0, 0, 'C', true); } else { $pdf->Cell($largeurCol, 5, str_limit($horairesArret[$i], 5, $end = ''), 0, 0, 'C', true); } } $pdf->Ln(); if ($couleurActuelle) { $pdf->SetFillColor($couleurImpair[0], $couleurImpair[1], $couleurImpair[2]); $couleurActuelle = 0; } else { $pdf->SetFillColor($couleurPair[0], $couleurPair[1], $couleurPair[2]); $couleurActuelle = 1; } } } // dd($largeurCol); // dd($courses); return Response::make($pdf->Output())->header('Content-Type', 'application/pdf'); }
<?php require 'fpdf16/fpdf.php'; require 'connection.php'; validate_user(); $pdf = new FPDF(); $pdf->AliasNbPages(); $pdf->SetTopMargin(20); $pdf->SetLeftMargin(45); $pdf->SetAutoPageBreak(1, 0.5); $pdf->SetDisplayMode(100); $pdf->SetAutoPageBreak(true, 10); $pdf->AddPage(); //$pdf->AddPage('L'); $pdf->SetDisplayMode(110, "single"); $pdf->SetTitle("Netherhall House"); $border = 0; $pdf->SetFont('Arial', 'B', 10); $pdf->SetFillColor(255, 255, 255); $request = filter_input_array(INPUT_POST); if ($request[name] != "") { $r = mysql_query("SELECT * FROM residents LEFT JOIN countries on residents.country_id = countries.country_id WHERE name LIKE '%{$request[name]}%' OR surname LIKE '%{$request[name]}%'"); } else { $today = date("Y", time()) . "-" . date("m", time()) . "-" . date("d", time()); if (!isset($request[academic_year]) || $request[academic_year] == "current") { // >= 28 days = 4 weeks //$condition_search=" AND bookings.arrival <= '$today' AND bookings.departure >= '$today' AND DATEDIFF(bookings.departure,bookings.arrival) >= 28 "; // 06-Feb-2010 - They want to see all the residents in the current residents list. So I remove the condition about days. $condition_search = " AND bookings.arrival <= '{$today}' AND bookings.planned_departure >= '{$today}' "; } elseif ($request[academic_year] == "short") { // < 28 days = 4 weeks
/** * Генерирует PDF-документ на основании XML-файла. * * @param string $file Файл для обработки * @param mixed $replacements массив для подстановки значений * @return FPDF сформированный документ PDF или FALSE в случае неудачи */ public static function xml2pdf($file, $replacements = false) { // Новая обработка PDF require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/odt2pdf.php'; $tpl = basename($file, ".xml") . ".odt"; $t = new odt2pdf($tpl); $t->convert($replacements); return $t; /** * @deprecated */ if (!file_exists($file)) { return false; } require_once dirname(__FILE__) . '/fpdf/fpdf.php'; define('FPDF_FONTPATH', dirname(__FILE__) . '/fpdf/font/'); if (is_array($replacements)) { foreach ($replacements as &$val) { $val = htmlspecialchars_decode($val, ENT_QUOTES); } } $replacements['$tab'] = ' '; $xml = new DOMDocument('1.0', 'windows-1251'); $xml->load($file); $pdf = new FPDF(); // Загружаем шрифты $pdf->AddFont('ArialMT', '', 'c9bb7ceca00657d007d343f4e34b71a8_arial.php'); $pdf->AddFont('Arial-BoldMT', '', '9cb9fc616ba50d7ecc7b816984f2ffda_arialbd.php'); $pdf->AddFont('TimesNewRomanPSMT', '', '5f37f1915715e014ee2254b95c0b6cab_times.php'); $pdf->AddFont('TimesNewRomanPS-BoldMT', '', 'e07f6c05a47ebec50a80f29789c7f1f6_timesbd.php'); /* Загружаем XML-документ и читаем из него основные параметры лоя итогового PDF-документа */ $root = $xml->documentElement; $title = $root->getAttribute('title') ? iconv('windows-1251', 'utf-8', $root->getAttribute('title')) : ''; // заголовок документа $author = $root->getAttribute('author'); // автор $margin_left = $root->getAttribute('margin-left') ? $root->getAttribute('margin-left') : 20; // отступ слева $margin_right = $root->getAttribute('margin-right') ? $root->getAttribute('margin-right') : 20; // отступ справа $margin_top = $root->getAttribute('margin-top') ? $root->getAttribute('margin-top') : 20; // отступ сверху $font_name = $root->getAttribute('font-name') ? $root->getAttribute('font-name') : 'ArialMT'; // дефолтный шрифт (имя) $font_size = (int) $root->getAttribute('font-size') ? (int) $root->getAttribute('font-size') : 10; // дефолтный шрифт (размер) $text_width = (int) $root->getAttribute('width') ? (int) $root->getAttribute('width') : 170; // ширина печатной области документа $paragraph_indent = (int) $root->getAttribute('paragraph-indent') ? (int) $root->getAttribute('paragraph-indent') : 0; // отступ между параграфами $printable = $pdf->h - $margin_top - 20; $pdf->SetTitle($title, true); $pdf->SetAuthor($author); $pdf->SetLeftMargin($margin_left); $pdf->SetRightMargin($margin_right); $pdf->SetTopMargin($margin_top); $pdf->AddPage(); $pdf->SetFont($font_name, '', $font_size); $pdf->SetX($margin_left); $locates = array(); // разбор XML-документа $xpath = new DOMXPath($xml); $scale = $xpath->query('/document/page/*'); if ($scale->length) { $footer = $xpath->query('//footer'); $footer = $footer->length ? $footer->item(0) : NULL; $no_brake = $xpath->query('//nobreak'); $no_brake = $no_brake->length ? TRUE : FALSE; // если есть теги <nobreak>, то расставляем разрывы страниц руками if ($no_brake) { $pdf->SetAutoPageBreak(false); } $last_y = 0; $pages = array(); foreach ($scale as $node) { $last_y = intval($pdf->y); if ($node->tagName == 'nobreak' && $node->getAttribute('start')) { $max_h = $last_y; $loc_offset = 0; foreach ($xpath->query('//cell|locate[(following::nobreak)]') as $i => $nd) { if ($nd->tagName == 'nobreak' && $node->getAttribute('end')) { break; } $_h = $nd->getAttribute('height'); if ($i > 0 && !$loc_offset) { $_h = 0; } $max_h += intval($_h); $loc_offset = $nd->getAttribute('x_offset'); } $max_h += $last_y; if ($max_h > $printable) { if ($footer) { $pdf->SetY(-20); $pdf->SetFont($font_name, '', 9); $pdf->Cell(0, 10, self::prepareNodeText($footer), 0, 0, 'C'); $pages[] = $pdf->PageNo(); } $pdf->AddPage(); } } if ($no_brake && $pdf->y > $printable) { if ($footer && !in_array($pdf->PageNo(), $pages)) { $pdf->SetY(-20); $pdf->SetFont($font_name, '', 9); $pdf->Cell(0, 10, self::prepareNodeText($footer), 0, 0, 'C'); $pages[] = $pdf->PageNo(); } $pdf->AddPage(); } if (!(int) $node->getAttribute('keep-pos')) { $pdf->SetX($margin_left); } // сброс позиции по X-оси если <node keep-pos="0" или не задан if ((int) $node->getAttribute('offset-left')) { $pdf->SetX((int) $node->getAttribute('offset-left') + $margin_left); } if ($node->tagName == 'text') { // вывод строки if ($node->getAttribute('font-name')) { $font_name = $node->getAttribute('font-name'); } if ((int) $node->getAttribute('font-size')) { $font_size = (int) $node->getAttribute('font-size'); } $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'C'; $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width; $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5; $border = $node->getAttribute('border') ? strtoupper($node->getAttribute('border')) : 0; $text = self::prepareNodeText($node, $replacements); if (!($color = $node->getAttribute('color'))) { $color = '000000'; } $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2))); $pdf->SetFont($font_name, '', $font_size); $skip_empty = (int) $node->getAttribute('skip-empty') ? (int) $node->getAttribute('skip-empty') : 0; if ((int) $skip_empty) { if (!trim($text)) { continue; } } $pdf->Cell($width, $height, trim($text), $border, 1, $align); } elseif ($node->tagName == 'paragraph') { // выводит многострочный текстовый блок, можно указывать тип выравнивания текста (L, J, R, C) if (($show_if = $node->getAttribute('show-if')) && !$replacements[$show_if]) { continue; } if ($node->getAttribute('font-name')) { $font_name = $node->getAttribute('font-name'); } if ((int) $node->getAttribute('font-size')) { $font_size = (int) $node->getAttribute('font-size'); } $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'J'; $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width; $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5; $border = $node->getAttribute('border') ? strtoupper($node->getAttribute('border')) : 0; $keep_text_wrap = (int) $node->getAttribute('keep-text-wrap') ? (int) $node->getAttribute('keep-text-wrap') : 0; $text = self::prepareNodeText($node, $replacements, $keep_text_wrap); if (!($color = $node->getAttribute('color'))) { $color = '000000'; } $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2))); $pdf->SetFont($font_name, '', $font_size); $skip_empty = (int) $node->getAttribute('skip-empty') ? (int) $node->getAttribute('skip-empty') : 0; if ((int) $skip_empty) { if (!trim($text)) { continue; } } $pdf->MultiCell($width, $height, $text, $border, $align); if ($paragraph_indent) { $pdf->Ln($paragraph_indent); } } elseif ($node->tagName == 'ln') { // перевод строки $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5; $pdf->Ln($height); } elseif ($node->tagName == 'cell') { // рисует ячейку if ($node->getAttribute('font-name')) { $font_name = $node->getAttribute('font-name'); } if ((int) $node->getAttribute('font-size')) { $font_size = (int) $node->getAttribute('font-size'); } $align = $node->getAttribute('align') ? strtoupper($node->getAttribute('align')) : 'J'; $width = (int) $node->getAttribute('width') ? (int) $node->getAttribute('width') : $text_width; $height = (int) $node->getAttribute('height') ? (int) $node->getAttribute('height') : 5; $border = $node->getAttribute('border') != '' ? (int) $node->getAttribute('border') : 1; $keep_text_wrap = (int) $node->getAttribute('keep-text-wrap') ? (int) $node->getAttribute('keep-text-wrap') : 0; $text = self::prepareNodeText($node, $replacements, $keep_text_wrap); if (!($color = $node->getAttribute('color'))) { $color = '000000'; } $pdf->SetTextColor(hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2))); $pdf->SetFont($font_name, '', $font_size); $pdf->Cell($width, $height, $text, $border, 0, $align); } elseif ($node->tagName == 'locate') { // перемещает указатель в определенную позицию в документе $x = $node->getAttribute('x') ? $node->getAttribute('x') : 0; $y = $node->getAttribute('y') ? $node->getAttribute('y') : 0; $x_offset = (int) $node->getAttribute('x_offset') ? (int) $node->getAttribute('x_offset') : 0; $y_offset = (int) $node->getAttribute('y_offset') ? (int) $node->getAttribute('y_offset') : 0; if (strpos($x, '@') !== false) { $x = $locates['x'][$x] + $x_offset; } if (strpos($y, '@') !== false) { $y = $locates['y'][$y] + $y_offset; } if (!$x) { $x = $pdf->GetX() + $x_offset; } if (!$y) { $y = $pdf->GetY() + $y_offset; } $pdf->SetXY($x, $y); } elseif ($node->tagName == 'fix-locate') { // перемещает указатель в определенную позицию в документе if ($x = $node->getAttribute('x')) { $locates['x'][$x] = $pdf->GetX(); } if ($y = $node->getAttribute('y')) { $locates['y'][$y] = $pdf->GetY(); } } elseif ($node->tagName == 'line') { // рисует простую горизонтальную линию $x = (int) $node->getAttribute('x') ? (int) $node->getAttribute('x') : $margin_left; $y = (int) $node->getAttribute('y') ? (int) $node->getAttribute('y') : $margin_top; $len = (int) $node->getAttribute('len') ? (int) $node->getAttribute('len') : $text_width; if ($x) { $pdf->setX($x); } if ($y) { $pdf->setY($y); } $pdf->Cell($len, 0, '', 1); } elseif ($node->tagName == 'newpage') { //новая страница и перевод указателя на нее $pdf->AddPage(); } } } return $pdf; }
<?php //session_start(); require '../impresion/fpdf2.php'; //require('../impresion/pdf_codabar.php'); require_once '../clases/cargocourier_data.php'; $cargo = new cargocourierdata(); $auxiliares = new auxiliaresdata(); //$pdf=new PDF_Codabar('P','cm','custom',609.449,935.5); $pdf = new FPDF('P', 'cm', 'custom', 609.449, 935.5); //ingreso medida puntos $pdf->SetTopMargin(1.1); $pdf->SetAutoPageBreak(1); $pdf->AddPage(); $pdf->SetFont('Arial', '', 8); $rs = $cargo->cargocourier_listar('', $_REQUEST['cargo_codigo'], '', '', '', '2', ''); $rs = mysql_query($rs, $cargo->con->cn); $campo = mysql_fetch_array($rs); $codigo = $campo['carcou_id']; $fecha = $cargo->util->obtienefecha($campo['carcou_fecha']); $origen = $auxiliares->devuelve_ciudad($campo['carcou_ciudadorigen']); $destino = $auxiliares->devuelve_ciudad($campo['ciu_id']); $centrocosto = $campo['carcou_centrocosto']; $area = $campo['empcou_razonsocial']; $remite = $campo['emprem_razonsocial']; $consignado = $campo['carcou_consignadoa']; $direccionconsignado = $campo['carcou_direccion']; $distritodestino = $campo['carcou_distrito']; $areacargo = $campo['area_descripcion']; $contacto = $campo['carcou_contacto']; $forma_pago = $campo['formpago_descripcion'];
//require ('fpdf/fpdf.php'); $term = $this->db->query("SELECT `reason_desc`,`termination_details`,`no_rehire_desc`,`employee_id`,`users`.`first_name` AS `mfname`,`users`.`last_name` AS `mlname`,`employees`.`first_name` AS `efname`,`employees`.`last_name` AS `elname`,`manager_id`,`termination_date`,`last_day_worked`,`separation`,`reason`,`rehire`,`reference_warning`,`scanned`,`status`,`terminations`.`store` FROM\n\t`terminations` JOIN `employees` ON `employee_id` = `uniq_id` JOIN `users` ON `user_id` = `manager_id` JOIN `termination_descriptions` ON `terminations`.`termination_id` = `termination_descriptions`.`termination_id` JOIN `termination_definitions` ON `reason` = `reason_code` WHERE `terminations`.`termination_id` = {$tid}"); $term = $term->first_row(); $sName = $this->db->query("SELECT `store_name` FROM `stores` WHERE `store_id` = {$term->store}")->first_row()->store_name; $employee_name = ucwords(strtolower("{$term->efname} {$term->elname}")); $manager_name = ucwords(strtolower("{$term->mfname} {$term->mlname}")); $rehire = "No"; if ($term->rehire == 1) { $rehire = "Yes"; } elseif ($term->rehire == 2) { $rehire = "Conditionally"; } $pdf = new FPDF(); $pdf->addFont('barCode39fHR', '', 'bar39fh.php'); $pdf->SetRightMargin(160); $pdf->SetTopMargin(118); $pdf->SetAutoPageBreak(TRUE, 62); $pdf->AddPage(); $pdf->setFont('barCode39fHR', '', 24); $pdf->Text(10, 20, "*4-{$tid}*"); $pdf->setFont('Arial', 'B', 18); $pdf->Text(15, 35, 'Voluntary Termination'); $pdf->setFont('Arial', '', 10); $pdf->Text(15, 40, "Employee: {$employee_name} ({$term->employee_id})"); $pdf->Text(15, 45, "Issued by: {$manager_name} ({$term->manager_id}) / {$sName}"); $pdf->Text(15, 55, "Termination Date:\t{$term->termination_date}"); $pdf->Text(15, 60, "Last Day: \t\t\t{$term->last_day_worked}"); $pdf->Text(15, 65, "Reason: {$term->reason_desc}"); $pdf->Text(100, 40, "Would you rehire? {$rehire}"); $pdf->Text(15, 275, "______________________________________________________"); $pdf->Text(25, 280, "Manager Signature Date");
<?php //session_start(); require '../impresion/fpdf2.php'; //require('../impresion/pdf_codabar.php'); require_once '../clases/cargocourier_data.php'; $cargo = new cargocourierdata(); $auxiliares = new auxiliaresdata(); //$pdf=new PDF_Codabar('P','cm','custom',609.449,935.5); $pdf = new FPDF('P', 'cm', 'custom', 609.449, 935.5); //ingreso medida puntos $pdf->SetTopMargin(1.3); $pdf->SetAutoPageBreak(1); $pdf->AddPage(); $pdf->SetFont('Arial', '', 8); $rs = $cargo->cargocourier_listar('', $_REQUEST['cargo_codigo'], '', '', '', '2', ''); $rs = mysql_query($rs, $cargo->con->cn); $campo = mysql_fetch_array($rs); $codigo = $campo['carcou_id']; $fecha = $cargo->util->obtienefecha($campo['carcou_fecha']); $origen = $auxiliares->devuelve_ciudad($campo['carcou_ciudadorigen']); $destino = $auxiliares->devuelve_ciudad($campo['ciu_id']); $centrocosto = $campo['carcou_centrocosto']; $area = $campo['empcou_razonsocial']; $remite = $campo['emprem_razonsocial']; $consignado = $campo['carcou_consignadoa']; $direccionconsignado = $campo['carcou_direccion']; $distritodestino = $campo['carcou_distrito']; $areacargo = $campo['area_descripcion']; $contacto = $campo['carcou_contacto']; $forma_pago = $campo['formpago_descripcion'];
<?php //session_start(); require '../impresion/fpdf.php'; require_once '../clases/paciente_data.php'; $paciente = new Paciente(); $pdf = new FPDF('P', 'cm', 'A4', '', ''); //ingreso medida puntos //$pdf=new FPDF('P','cm','custom',595.4,842.3); $pdf->SetTopMargin(1.0); //margen superior $pdf->SetLeftMargin(1.4); //margen izquierdo $pdf->AddPage(); $pdf->SetFont('Arial', '', 10); $paciente->paciente_ver($_REQUEST['codigo']); $nro_historia = $paciente->pac_historia; $nombres = strtoupper($paciente->pac_nombres); $apellidos = strtoupper($paciente->pac_apellidos); $direccion = strtoupper($paciente->pac_direccion); $fecharegistro = $paciente->_util->obtiene_fecha($paciente->pac_fecharegistro); $fechanac = $paciente->_util->obtiene_fecha($paciente->pac_fechanac); if ($paciente->pac_estadocivil === '1') { $estadocivil = 'SOLTERO'; } elseif ($paciente->pac_estadocivil === '2') { $estadocivil = 'CASADO'; } elseif ($paciente->pac_estadocivil === '3') { $estadocivil = 'DIVORCIADO'; } else { $estadocivil = 'VIUDO'; }