function export_order($id) { global $FANNIE_OP_DB, $FANNIE_ROOT; $dbc = FannieDB::get($FANNIE_OP_DB); $order = new PurchaseOrderModel($dbc); $order->orderID($id); $order->load(); $items = new PurchaseOrderItemsModel($dbc); $items->orderID($id); $vendor = new VendorsModel($dbc); $vendor->vendorID($order->vendorID()); $vendor->load(); $contact = new VendorContactModel($dbc); $contact->vendorID($order->vendorID()); $contact->load(); if (!class_exists('FPDF')) { include_once $FANNIE_ROOT . 'src/fpdf/fpdf.php'; } $pdf = new FPDF('P', 'mm', 'Letter'); $pdf->AddPage(); $pdf->SetFont('Arial', '', '12'); $pdf->Cell(100, 5, 'Vendor: ' . $vendor->vendorName(), 0, 0); $pdf->Cell(100, 5, 'Date: ' . date('Y-m-d'), 0, 0); $pdf->Ln(); $pdf->Cell(100, 5, 'Phone: ' . $contact->phone(), 0, 0); $pdf->Cell(100, 5, 'Fax: ' . $contact->fax(), 0, 0); $pdf->Ln(); $pdf->Cell(100, 5, 'Email: ' . $contact->email(), 0, 0); $pdf->Cell(100, 5, 'Website: ' . $contact->website(), 0, 0); $pdf->Ln(); $pdf->MultiCell(0, 5, "Ordering Info:\n" . $contact->notes(), 'B'); $pdf->Ln(); $cur_page = 0; $pdf->SetFontSize(10); foreach ($items->find() as $obj) { if ($cur_page != $pdf->PageNo()) { $cur_page = $pdf->PageNo(); $pdf->Cell(25, 5, 'SKU', 0, 0); $pdf->Cell(20, 5, 'Order Qty', 0, 0); $pdf->Cell(30, 5, 'Brand', 0, 0); $pdf->Cell(65, 5, 'Description', 0, 0); $pdf->Cell(20, 5, 'Case Size', 0, 0); $pdf->Cell(20, 5, 'Est. Cost', 0, 0); $pdf->Ln(); } $pdf->Cell(25, 5, $obj->sku(), 0, 0); $pdf->Cell(20, 5, $obj->quantity(), 0, 0, 'C'); $pdf->Cell(30, 5, $obj->brand(), 0, 0); $pdf->Cell(65, 5, $obj->description(), 0, 0); $pdf->Cell(20, 5, $obj->caseSize(), 0, 0, 'C'); $pdf->Cell(20, 5, sprintf('%.2f', $obj->caseSize() * $obj->unitCost() * $obj->quantity()), 0, 0); $pdf->Ln(); } $pdf->Output('order_export.pdf', 'D'); }
{ //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);
$pdf->Image('./img/acb_logo_gross.jpg', 95, 10, 25); // Position auf der X- und Y-Achse $pdf->SetY(40); // Schriftart festlegen $pdf->SetFont('Times', 'BU', 14); $pdf->Cell(160, 7, utf8_decode('Telefonnummern der Flugleiter/-innen, Aero-Club Butzbach e.V.'), 0, 1, 'C'); // Schriftart festlegen $pdf->SetFont('Times', '', 11); $pdf->Cell(160, 5, sprintf(utf8_decode('Stand: %s %d'), utf8_decode($_monate[date('n')]), date('Y')), 0, 1, 'C'); // Position auf der X- und Y-Achse $pdf->SetXY(20, 280); // Schriftart und -farbe ändern $pdf->SetTextColor(128, 128, 128); $pdf->SetFont('Times', '', 8); // Ausgabe des Fusszeilentext $pdf->Cell(0, 10, 'Seite ' . $pdf->PageNo() . ' von {nb}', 0, 0, 'C'); // Position auf der X- und Y-Achse $x = 20; $y = 63; // alle Flugleiter des Vereins ermitteln $data = getFlugleiterliste(); // Schriftfarbe setzen $pdf->SetTextColor(0, 0, 0); foreach ($data as $mitglied) { // Schriftart festlegen $pdf->SetFont('Times', 'B', 11); // Schriftfarbe setzen $pdf->SetTextColor(0, 0, 0); $pdf->SetXY($x, $y); $pdf->Write(5, utf8_decode(mb_strtoupper($mitglied['nachname'], 'UTF-8'))); if ($mitglied['fl_dienst_wochentags'] == 'J') {
$pdf->Cell(40, 5, "Mata Pelajaran", 1, 0, 'C', true); $pdf->Cell(20, 5, "Kelas", 1, 0, 'C', true); $pdf->Cell(30, 5, "Nilai Akhir", 1, 0, 'C', true); $pdf->Cell(30, 5, "Predikat (NA)", 1, 0, 'C', true); $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0, 0, 0); //membuat halaman $no = 1; //fungsi mengatur dan posisi table x dan y $pdf->SetXY(15, 65); //membuat baris tabel while (list($kd_mapel, $mapel, $kelas, $nilai) = mysql_fetch_row($hasilnya2)) { $pdf->Cell(10, 5, $no, 1, 0, 'C'); $pdf->Cell(40, 5, $kd_mapel, 1, 0, 'C'); $pdf->Cell(40, 5, $mapel, 1, 0, 'C'); $pdf->Cell(20, 5, $kelas, 1, 0, 'C'); $pdf->Cell(30, 5, $nilai, 1, 0, 'C'); $pdf->Cell(30, 5, $nilai, 1, 0, 'C'); $y = 65 + 5 * $no; $no++; $pdf->SetXY(15, $y); } //fungsi show halaman $pdf->SetY(-15); //buat garis horizontal $pdf->Line(7, $pdf->GetY(), 200, $pdf->GetY()); //Arial italic 9 $pdf->SetFont('Arial', 'I', 7); //nomor halaman $pdf->Cell(0, -10, 'Halaman ' . $pdf->PageNo() . ' dari {nb}', 0, 0, 'R'); $pdf->Output();
/** * Генерирует 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 require_once 'fpdf16/fpdf.php'; $pdf = new FPDF('P', 'cm', 'A4'); $pdf->SetFont('Arial', '', 12); $pdf->AliasNbPages('{nb}'); $pdf->AddPage(); $pdf->Write(1, 'Texto de teste'); $pdf->Ln(1); $pdf->Write(1, utf8_decode('Página Atual: ' . $pdf->PageNo())); $pdf->Ln(1); $pdf->Write(1, utf8_decode(' Total de páginas: {nb}')); $pdf->AddPage(); $pdf->Write(1, 'Texto de teste'); $pdf->Output('/tmp/teste.pdf');
$vd2 = @$vd + $vd1; $vs2 = @$vs + $vs1; $vt2 = @$vt + $vt1; $vi2 = @$vi + $vi1; $pdf->ln(10); $pdf->Setx(5); $pdf->Cell(137, 5, "QUANTIDADE DE ITENS: " . $qtotal, 1, 0, "L", 0); $pdf->Cell(29, 5, trim(db_formatar($vs2, 'f')), 1, 0, "R", 0); $pdf->Cell(25, 5, trim(db_formatar($vd2, 'f')), 1, 0, "R", 0); $pdf->Cell(25, 5, trim(db_formatar($vb2, 'f')), 1, 0, "R", 0); $pdf->Cell(10, 5, "", 1, 0, "C", 0); $pdf->Cell(25, 5, db_formatar($vi2, 'f'), 1, 0, "R", 0); $pdf->Cell(10, 5, "", 1, 0, "C", 0); $pdf->Cell(25, 5, db_formatar($vt2, 'f'), 1, 1, "R", 0); $y = $pdf->GetY(); $pdf->SetY($y + 3); $pdf->Setx(5); // if(!isset($DB_mens1)){ // $DB_mens1 = ""; // } db_mensagem("issqnplan_cad", "issqnplan_rod"); $pdf->SetFont('Courier', '', 7); // $pdf->Cell(140,4,"Data: ".db_formatar(date("Y-m-d"),'d'),0,1,"L",0); $pdf->Cell(140, 4, "Local e Data: {$munic} " . db_formatar(date("Y-m-d"), 'd'), 0, 1, "L", 0); $pdf->MultiCell(260, 4, $DB_mens1, 0, "L", 0); $pdf->SetY(-26); $pdf->Setx(5); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(170, 5, $DB_mens2, 0, 0, "L", 0); $pdf->Cell(110, 5, "Página " . $pdf->PageNo() . " de {nb} ", 0, 0, "C", 0); $pdf->Output();
} $pdf->Ln(); $respUsuario = $cp->ejecutarSentencia(DBSentencias::BUSCAR_USUARIO_ID, array($idUsuario)); $usuarios = $respUsuario->fetchAll(PDO::FETCH_ASSOC); foreach ($usuarios as $usuario) { $pdf->SetFont('Arial', 'B', '20'); $pdf->SetFillColor(254, 254, 254); $pdf->SetTextColor(0, 0, 0); $pdf->Cell(150, 15, "USUARIO QUE REALIZO LA CARGA", 1, 0, 'C', true); $pdf->Ln(); $pdf->SetFont('Arial', '', '16'); $pdf->SetFillColor(229, 229, 229); $pdf->SetTextColor(3, 3, 3); $pdf->Cell(50, 15, utf8_decode($usuario['nombre_usuario']), 1, 0, 'C', true); $pdf->Cell(50, 15, utf8_decode($usuario['apellido_usuario']), 1, 0, 'C', true); $pdf->Cell(50, 15, utf8_decode($usuario['usuario_usuario']), 1, 0, 'C', true); $pdf->Ln(); } $consultaUsuarios = $cp->ejecutarSentencia(DBSentencias::BUSCAR_USUARIO_ID, array($idUsuario)); $usuarios = $consultaUsuarios->fetchAll(PDO::FETCH_ASSOC); foreach ($usuarios as $usuarioF) { $usuario = $usuarioF['usuario_usuario']; } // Posición: a 1,5 cm del final $pdf->SetY(380); // Arial italic 8 $pdf->SetFont('Arial', 'I', 12); // Número de página $pdf->Cell(0, 10, 'Practica Profesional Guirao Lazarte Bilyk--Pagina ' . $pdf->PageNo() . ' Usuario: ' . $usuario, 0, 0, 'C'); $pdf->Output(); }
$fpdf->Cell(8,7,"MANZANO", 1,0,'C',True); $fpdf->Cell(5,7,"LOTE", 1,0,'C',True); //FECHAS EXTREMAS $fpdf->Cell(15,7,"FECHA INICIAL", 1,0,'C',True); $fpdf->Cell(15,7,"FECHA FINAL", 1,0,'C',True); //UBICACION FISICA $fpdf->Cell(8,7,"AMBIENTE", 1,0,'C',True); $fpdf->Cell(8,7,"ESTANTE", 1,0,'C',True); $fpdf->Cell(7,7,"CUERPO", 1,0,'C',True); $fpdf->Cell(7,7,"BALDA", 1,0,'C',True); //AREA $fpdf->Cell(15,7,"PRODUCTOR", 1,0,'C',True); $fpdf->Cell(15,7,"OBSERVACION", 1,0,'C',True); $fpdf->Ln();*/ /*$fpdf->SetFont('Arial', '', 6); $counter=1; foreach ($archivo as $valor) { $fpdf->Cell(8, 4, $counter++, 0); $fpdf->Cell(12, 4, $valor->ref_arc, 0); $fpdf->Cell(45, 4, $valor->ncj_arc, 0); $fpdf->Cell(35, 4, $valor->ntm_arc, 0); $fpdf->Cell(40, 4, $valor->foj_arc, 0); $fpdf->Cell(30, 4, $valor->cub_arc, 0); $fpdf->Ln(); $fpdf->PageNo(); }*/ $fpdf->SetY(-15); $fpdf->SetFont('Arial', 'I', 8); $fpdf->Cell(0, 10, utf8_decode('Página ') . $fpdf->PageNo() . ' de {nb}', 0, 0, 'C'); //finaliza y muestra en pantalla pdf $fpdf->Output($nombre . ".pdf", "I");
public function viewVehicleBookingPDF(Request $request) { $error = true; $user = $request->session()->get('user'); if (is_null($user)) { return redirect()->action('MainController@index'); } elseif ($user[0]->type == "tenant") { if (isset($request['id'])) { $bookingid = $request['id']; $error = false; } else { $bookingid = false; $error = true; } if ($error == false) { $bookings = vehiclebookingModel::where('id', '=', $bookingid)->get(); $driver = $bookings[0]->vehicle->driver; if ($driver = 0) { $x = 'NO'; } else { $x = 'Yes'; } $vehicleName = $bookings[0]->vehicle->vehicleName; $vehicleModel = $bookings[0]->vehicle->models; $vehicleCat = $bookings[0]->vehicle->category->vehiclecatname; $vehicleImage = $bookings[0]->vehicle->image; include app_path() . '\\fpdf\\fpdf.php'; if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $id = $_REQUEST['id']; $pdf = new \FPDF(); $pdf->AddPage(); $pdf->Rect(5, 5, 200, 287, 'D'); //For A4 $pdf->SetFont("Arial", "B", 30); $pdf->SetFillColor(36, 96, 84); $pdf->write(6, $pdf->Image('images/logo.png', 145, 10, -100), 1, 1); $pdf->SetFont("Arial", "B", 8); $pdf->Ln(30); $pdf->Cell(135); $pdf->Write(10, "Phone: 2612205/57139151"); $pdf->Ln(10); $pdf->Cell(135); $pdf->Write(10, "Email: Lokeshpravin@gmail.com"); $pdf->SetFont("Arial", "B", 30); $pdf->Write(10, "Welcome to Lodgiify"); $pdf->Ln(20); $pdf->SetFont("Arial", "B", 12); $pdf->Cell(20); $pdf->MultiCell(25, 6, "Booking Form:", 'LRT', 'L', 0); $pdf->Cell(20); $pdf->Cell(75, 10, "Full Name :", 1, 0); $pdf->Cell(75, 10, $user[0]->FirstName . ' ' . $user[0]->LastName, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "From :", 1, 0); $pdf->Cell(75, 10, $bookings[0]->fromdate, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "To :", 1, 0); $pdf->Cell(75, 10, $bookings[0]->todate, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Price :", 1, 0); $pdf->Cell(75, 10, 'Rs' . $bookings[0]->price, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Vehicle Name :", 1, 0); $pdf->Cell(75, 10, $vehicleName, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Type :", 1, 0); $pdf->Cell(75, 10, $vehicleCat, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Model : ", 1, 0); $pdf->Cell(75, 10, $vehicleModel, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "With driver : ", 1, 0); $pdf->Cell(75, 10, $x, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 10, "Transmission : ", 1, 0); $pdf->Cell(75, 10, $bookings[0]->vehicle->transmission, 1, 1); $pdf->Cell(20); $pdf->Cell(75, 60, "Image : ", 1, 0); $pdf->Cell(75, 60, $pdf->Image('upload' . "/" . $vehicleImage, 118, 187, 50, 50), 1, 1); $pdf->Ln(45); $pdf->SetFont("Arial", "B", 10); $pdf->Cell(155); $pdf->Cell(0, 5, "Page " . $pdf->PageNo(), 0, 1); $pdf->output(); die; } } } else { return response()->view('pages.404', ['user' => $user], 404); } }
/** * muestra el pdf del pedido en cuestion * @param type $idPedido */ function pdf($idPedido) { $metodo = 'F'; $datosPedido = $this->Tienda_model->datosPedido($idPedido); $email = $this->session->userdata('username'); $datos = $this->Usuarios_model->getUsuario($email); $lineas = $this->Tienda_model->getLinea($idPedido); //nos falta el nombre del libro para ello deberemos consultar su nombre por cada uno $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial', 'B', 20); //cabecera $pdf->Image(base_url() . 'Assets/img/logo.png', 10, 8, 100); $pdf->Cell(60); $pdf->Cell(80, 100, 'PEDIDO'); $pdf->Ln(15); $pdf->Cell(100, 100, 'Datos cliente'); $pdf->Cell(40, 100, 'Datos librosweb'); $pdf->Ln(8); $pdf->SetFont('Arial', 'B', 12); $pdf->Cell(100, 100, 'Cliente: ' . $datos['username'] . ' ' . $datos['apellidos']); $pdf->Cell(40, 100, 'Librosweb'); $pdf->Ln(5); $pdf->Cell(100, 100, utf8_decode('Dirección: ' . $datos['direccion'])); $pdf->Cell(40, 100, 'Avda Europa, Parcela 2-5 y 2-6'); $pdf->Ln(5); $pdf->Cell(100, 100, utf8_decode('Población: ' . $datos['provincia'] . ' ' . $datos['cp'])); $pdf->Cell(40, 100, 'Murcia'); $pdf->Ln(5); $pdf->Cell(100, 100, utf8_decode('NIF/CIF: ' . $datos['dni'])); $pdf->Cell(40, 100, 'CIF: B-73347494'); $pdf->Ln(65); //Datos $header = array('LIBRO', 'PRECIO', 'IVA', 'CANTIDAD', 'TOTAL'); $w = array(83, 25, 22, 35, 25); for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, utf8_decode($header[$i]), 1, 0, true); } $pdf->Ln(); $pdf->SetFont('Arial', 'B', 10); // Datos foreach ($lineas as $linea) { $titulo = $this->Tienda_model->datos_libro($linea['producto_idproducto']); $cantidad = $linea['cantidad'] * $linea['precio']; $pdf->Cell(83, 40, utf8_decode($titulo['nombre']), 1); $pdf->Cell(25, 40, utf8_decode($linea['precio']) . " " . iconv('UTF-8', 'windows-1252', '€'), 1); $pdf->Cell(22, 40, utf8_decode('21%'), 1); $pdf->Cell(35, 40, utf8_decode($linea['cantidad']), 1); $pdf->Cell(25, 40, utf8_decode($cantidad) . " " . iconv('UTF-8', 'windows-1252', '€'), 1); $pdf->Ln(); if ($pdf->GetY() > 264) { $pdf->AddPage(); } } $pdf->SetFont('Arial', 'B', 12); $pdf->Cell(40, 40, 'El importe total del pedido es de: ' . $datosPedido['importe'] . " " . iconv('UTF-8', 'windows-1252', '€')); //pie $pdf->SetY(-15); $pdf->Cell(0, 10, 'Page ' . $pdf->PageNo() . '/{nb}', 0, 0, 'C'); $pdf->Output($metodo, 'Assets/img/' . $idPedido . 'pedido.pdf', true); }