示例#1
0
 /**
  * PDF Text renderer
  *
  * @param PDF $pdf
  *
  * @return void
  */
 function render($pdf)
 {
     // Set up the style
     if ($pdf->getCurrentStyle() != $this->styleName) {
         $pdf->setCurrentStyle($this->styleName);
     }
     $temptext = str_replace("#PAGENUM#", $pdf->PageNo(), $this->text);
     // underline «title» part of Source item
     $temptext = str_replace(array('«', '»'), array('<u>', '</u>'), $temptext);
     // Paint the text color or they might use inherited colors by the previous function
     $match = array();
     if (preg_match("/#?(..)(..)(..)/", $this->color, $match)) {
         $r = hexdec($match[1]);
         $g = hexdec($match[2]);
         $b = hexdec($match[3]);
         $pdf->SetTextColor($r, $g, $b);
     } else {
         $pdf->SetTextColor(0, 0, 0);
     }
     $temptext = spanLTRRTL($temptext, "BOTH");
     $temptext = str_replace(array('<br><span dir="rtl" >', '<br><span dir="ltr" >', '> ', ' <'), array('<span dir="rtl" ><br>', '<span dir="ltr" ><br>', '>&nbsp;', '&nbsp;<'), $temptext);
     $pdf->writeHTML($temptext, false, false, true, false, "");
     //change height - line break etc. - the form is mirror on rtl pages
     // Reset the text color to black or it will be inherited
     $pdf->SetTextColor(0, 0, 0);
 }
示例#2
0
 function __construct($datos)
 {
     $pdf = new PDF();
     // [ Establesco Todos los datos que conendra la Factura ]
     $pdf->set_data($datos);
     $pdf->FPDF('P', 'mm', 'Letter');
     // Esta funcion la uso cuando voy a imprimir  al final el numero de la paguina $pdf->AliasNbPages();
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', 12);
     //$pdf->SetTextColor(20,20,250); COLOR AZUL
     $pdf->SetTextColor(0, 0, 0);
     $pdf->menbrete();
     $pdf->detalle($datos['productos']);
     $pdf->Output();
 }
//while
class PDF extends PDF_MySQL_Table
{
    function Header()
    {
        //Title
        //Ensure table header is output
        parent::Header();
    }
}
//Connect to database
mysql_connect("{$db_hostname}", "{$db_username}", "{$db_password}");
mysql_select_db('remsdb');
$pdf = new PDF("L", "mm", array(400, 200));
$pdf->AddPage();
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Times', 'B', 16);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Times', 'B', 14);
$pdf->SetY(8);
$pdf->SetX(10);
$pdf->Cell(0, 3, $pdfAgencyName, 0, 1, 'L');
$pdf->Ln(5);
$pdf->SetFont('Times', 'B', 12);
$pdf->SetTextColor(131, 130, 139);
$pdf->Cell(0, 3, "Powered by Getchs;", 0, 1, 'L');
$pdf->tdheight = 5;
$pdf->Ln(30);
$pdf->SetFont('Times', 'B', 24);
$pdf->SetTextColor(64, 64, 64);
$pdf->Cell(0, 3, "LIST OF ALL ENDORSED APPLICANT", 0, 1, 'C');
        }
        return $json[$themeasure]["style"]["prefix"] . $data . $json[$themeasure]["style"]["units"];
    }
}
// Create PDF
$pdf = new PDF('P', 'in', 'Letter');
/************************************************************
Cover Page
************************************************************/
$pdf->AddPage();
// title page image background
$pdf->Image('reportCoverPageCompass.png', 0, 0, 8.5);
// White text on top of title page
// $pdf->SetTextColor(255,255,255);
// Title page header
$pdf->SetTextColor(0, 0, 45);
$pdf->SetFont('Arial', 'B', 50);
$pdf->Ln(5.35);
$pdf->Cell(0.3);
$pdf->Cell(0, 0, "Compass Profile Area");
if ($reportRadioValue == 'census') {
    $pdf->SetTextColor(0, 0, 45);
    $pdf->SetFont('Arial', 'B', 40);
    $pdf->Ln(1);
    // $aryPrettyBlock = explode(" - ", $censusBlock);
    // $prettyBlock = $aryPrettyBlock[1];
    $pdf->Cell(0.3);
    $pdf->Cell(0, 0, $censusBlock);
} elseif ($reportRadioValue == 'neighborhood') {
    $pdf->SetTextColor(0, 0, 45);
    $pdf->SetFont('Arial', 'B', 40);
        $prefix = $json[$themeasure]['style']['prefix'];
    }
    $average = round($measureSum / $count, 0, PHP_ROUND_HALF_UP);
    // return $average;
    return $prefix . $average . $suffix;
}
// Create PDF
$pdf = new PDF('P', 'in', 'Letter');
/************************************************************
Cover Page
************************************************************/
$pdf->AddPage();
// title page image background
$pdf->Image('reportCoverPageCompass.png', 0, 0, 8.5);
// White text on top of title page
$pdf->SetTextColor(255, 255, 255);
if ($reportRadioValue == 'census') {
    $features = $censusBlocks;
} elseif ($reportRadioValue == 'neighborhood') {
    $features = $neighborhoods;
}
foreach ($features as $key => $feature) {
    // $key = array_search('green', $array);
    $theOID = $OIDs[$key];
    $theName = $Names[$key];
    $theNPAData = $npadataset[$key];
    if ($key == 0) {
        // Title page header
        $pdf->SetTextColor(0, 0, 45);
        $pdf->SetFont('Arial', 'B', 40);
        $pdf->Ln(5.35);
示例#6
0
// Add pdf page
$orientation = "L";
$pdf = new PDF($orientation, 'pt', 'Letter');
$pdf->SetProtection(array('print'));
$pdf->AddPage();
if (ini_get('magic_quotes_gpc') == '1') {
    $customtext = stripslashes($customtext);
}
// Add images and lines
print_border_letter($certificate->borderstyle, $orientation);
draw_frame_letter($certificate->bordercolor, $orientation);
print_watermark_letter($certificate->printwmark, $orientation);
print_seal($certificate->printseal, $orientation, 590, 425, '', '');
print_signature($certificate->printsignature, $orientation, 110, 450, '', '');
// Add text
$pdf->SetTextColor(0, 0, 120);
cert_printtext(150, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string("titleletterlandscape", "certificate")));
$pdf->SetTextColor(0, 0, 0);
cert_printtext(150, 180, 'C', 'Times', 'B', 20, utf8_decode(get_string("introletterlandscape", "certificate")));
cert_printtext(150, 230, 'C', 'Helvetica', '', 30, utf8_decode($studentname));
cert_printtext(150, 280, 'C', 'Helvetica', '', 20, utf8_decode(get_string("statementletterlandscape", "certificate")));
cert_printtext(150, 330, 'C', 'Helvetica', '', 20, utf8_decode($course->fullname));
cert_printtext(150, 380, 'C', 'Helvetica', '', 14, utf8_decode($certificatedate));
cert_printtext(150, 420, 'C', 'Times', '', 10, utf8_decode($grade));
cert_printtext(150, 431, 'C', 'Times', '', 10, utf8_decode($outcome));
cert_printtext(150, 442, 'C', 'Times', '', 10, utf8_decode($credithours));
cert_printtext(150, 500, 'C', 'Times', '', 10, utf8_decode($code));
$i = 0;
if ($certificate->printteacher) {
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if ($teachers = get_users_by_capability($context, 'mod/certificate:printteacher')) {
/////////header
$pdf->SetFont('Arial', 'B', 10);
/////////medio
$pdf->SetFont('Amble-Regular', '', 10);
$pdf->Text(30, 42, maxCaracter(utf8_decode($cliente), 80), 1, 0, 'L', 0);
/////cliente
$pdf->Text(30, 48, maxCaracter(utf8_decode($fecha), 20), 1, 0, 'L', 0);
/////fecha
$pdf->Text(30, 53, maxCaracter(utf8_decode($direccion), 35), 1, 0, 'L', 0);
////direccion
$pdf->Text(155, 42, maxCaracter(utf8_decode($ci_ruc), 20), 1, 0, 'L', 0);
////ruc ci
$pdf->Text(155, 48, maxCaracter(utf8_decode($telefono), 20), 1, 0, 'L', 0);
////telefono
if ($estado == 'Pasivo') {
    $pdf->SetTextColor(249, 33, 33);
    $pdf->RotatedImage('../images/circle.png', 110, 42, 30, 10, 45);
    $pdf->RotatedText(120, 41, 'ANULADO!', 45);
    $pdf->RotatedImage('../images/circle.png', 260, 42, 30, 10, 45);
    $pdf->RotatedText(269, 41, 'ANULADO!', 45);
}
////////detalles
$sql = pg_query("select cantidad,articulo,precio_venta,total_venta from  detalle_factura_venta,productos where id_factura_venta = '" . $_GET['id'] . "' and detalle_factura_venta.cod_productos = productos.cod_productos and productos.incluye_iva= 'Si'");
$yy = 66;
$iva_base = 1.12;
$pdf->SetTextColor(0, 0, 0);
while ($row = pg_fetch_row($sql)) {
    $total_si = 0;
    $total_sit = 0;
    $total_si = $row[3] / $iva_base;
    $total_sit = $total_si / $row[0];
     $pdf->SetX(1);
     // $pdf->Cell(22, 6, utf8_decode('Comprobante'),1,0, 'C',0);
     $pdf->Cell(20, 6, utf8_decode('Fecha'), 1, 0, 'C', 0);
     $pdf->Cell(50, 6, utf8_decode('Nro Factura'), 1, 0, 'C', 0);
     $pdf->Cell(15, 6, utf8_decode('Subtotal'), 1, 0, 'C', 0);
     $pdf->Cell(17, 6, utf8_decode('Descuento'), 1, 0, 'C', 0);
     $pdf->Cell(16, 6, utf8_decode('Tarifa 0%'), 1, 0, 'C', 0);
     $pdf->Cell(17, 6, utf8_decode('Tarifa 12%'), 1, 0, 'C', 0);
     $pdf->Cell(15, 6, utf8_decode('Iva 12%'), 1, 0, 'C', 0);
     $pdf->Cell(15, 6, utf8_decode('Total'), 1, 0, 'C', 0);
     $pdf->Cell(20, 6, utf8_decode('Fecha Pago'), 1, 0, 'C', 0);
     $pdf->Cell(20, 6, utf8_decode('Tipo Pago'), 1, 1, 'C', 0);
     $repetido = 1;
 }
 if ($row1[14] == "Activo") {
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetX(1);
     // $pdf->Cell(22, 6, utf8_decode($row1[13]),0,0, 'C',0);
     $pdf->Cell(20, 6, utf8_decode($row1[1]), 0, 0, 'C', 0);
     $pdf->Cell(50, 6, utf8_decode(substr($row1[0], 8)), 0, 0, 'C', 0);
     $sub = $sub + ($row1[10] - $row1[8] - $row1[9]);
     $pdf->Cell(15, 6, $row1[10] - $row1[8] - $row1[9], 0, 0, 'C', 0);
     $desc = $desc + $row1[9];
     $pdf->Cell(17, 6, $row1[9], 0, 0, 'C', 0);
     $pdf->Cell(16, 6, $row1[6], 0, 0, 'C', 0);
     $pdf->Cell(17, 6, $row1[7], 0, 0, 'C', 0);
     $ivaT = $ivaT + $row1[8];
     $pdf->Cell(15, 6, $row1[8], 0, 0, 'C', 0);
     $total = $total + $row1[10];
     $t0 = $row1[6];
     $pdf->Cell(15, 6, $row1[10], 0, 0, 'C', 0);
/*
$pdf->setXY($abs_x , $y_absolute +  ($r*33)  );
$pdf->SetFont('angsana','I',15);
$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' ,'                       '.'Center of Cleft Lip - Cleft Palate and Craniofacial Deformities ,Khon Kaen University '  ));
$pdf->setXY($abs_x , $y_absolute +  ($r*34)  );
$pdf->SetFont('angsana','I',15);
$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' ,'                                     '.'in Association with "Tawanchai Project" (Tawanchai Cleft Center) '  ));
$pdf->setXY($abs_x , $y_absolute +  ($r*35)  );
$pdf->SetFont('angsana','I',15);
$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' ,'                                                             '.'http://www.tawanchai-foundation.org/'  ));
$pdf->setXY($abs_x , $y_absolute +  ($r*36)  );
$pdf->SetFont('angsana','I',15);
$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , '                                                        '.'Registration date : '.$today  ));
*/
$pdf->setXY($abs_x, $y_absolute + $r * 33);
$pdf->SetTextColor(0, 0, 255);
#blue color
$pdf->SetFont('angsana', '', 14);
$pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', '                      ' . 'ใบเสร็จอิเล็กทรอนิกส์ฉบับนี้สามารถนำไปเบิกจ่ายค่าลงทะเบียนจากต้นสังกัดคืนได้'));
$pdf->SetTextColor(0);
$pdf->setXY($abs_x, $y_absolute + $r * 34);
$pdf->SetFont('angsana', '', 13);
$pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', '              ' . ' 8th Annual Meeting of the Thai Cleft Lip-Palate and Craniofacial Association: Internation Congress '));
$pdf->setXY($abs_x, $y_absolute + $r * 35);
$pdf->SetFont('angsana', '', 13);
$pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', '                                                              ' . 'http://www.thaicleft2015.org'));
////Put watermark
$pdf->SetFont('angsana', 'B', 60);
$pdf->SetTextColor(211, 211, 211);
//red,green,blue   211,211,211  gray color
$pdf->Rotate(30, 150, 150);
示例#10
0
    {
    }
    function Footer()
    {
        //Position at 1.5 cm from bottom
        $this->SetXY(90, -15);
        //Arial italic 8
        $this->SetFont('Arial', 'I', 10);
        //Page number
        $this->Cell(0, 5, 'Powered by ', 0, 0, 'C');
        $this->Image('images/xlogo10.jpg', 160, 280, 22);
    }
}
$mypdf = new PDF();
$mypdf->AddPage();
$mypdf->SetTextColor(51, 51, 51);
$mypdf->SetFont('Arial', 'I', 10);
try {
    include 'dbcon.php';
    $sql1 = "SELECT * from tbluserdetails Where `UserName`= '{$User}'";
    $result = $dbh->prepare($sql1);
    $result->execute();
    $row1 = $result->fetch();
    $sql = "SELECT * from tbluserexpenses Where `UserName`= '{$User}'";
    $result = $dbh->prepare($sql);
    $result->execute();
    $row = $result->fetch();
    $sql2 = "SELECT * from tblreportstore Where `UserID`= '{$UserID}'";
    $result1 = $dbh->prepare($sql2);
    $result1->execute();
    $row3 = $result1->fetch();
示例#11
0
        $this->Cell(0, 6, "{$num} {$label}", 0, 1, 'L', true);
        $this->Ln(0);
    }
    function ChapterTitle2($num, $label)
    {
        $this->SetFont('Arial', '', 12);
        $this->SetFillColor(249, 249, 249);
        $this->Cell(0, 6, "{$num} {$label}", 0, 1, 'L', true);
        $this->Ln(0);
    }
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times', '', 12);
$pdf->SetTextColor(32);
$pdf->Cell(0, 5, $company, 0, 1, 'R');
$pdf->Cell(0, 5, $address, 0, 1, 'R');
$pdf->Cell(0, 5, $email, 0, 1, 'R');
$pdf->Cell(0, 5, 'Tel: ' . $telephone, 0, 1, 'R');
$pdf->Cell(0, 30, '', 0, 1, 'R');
$pdf->SetFillColor(200, 220, 255);
//$pdf->ChapterTitle('Invoice Number ',$number);
$pdf->ChapterTitle('Invoice Date ', date('d-m-Y'));
$pdf->Cell(0, 20, '', 0, 1, 'R');
$pdf->SetFillColor(224, 235, 255);
$pdf->SetDrawColor(192, 192, 192);
$pdf->Cell(170, 7, 'Item', 1, 0, 'L');
$pdf->Cell(20, 7, 'Price', 1, 1, 'C');
while ($row = $result->fetch_array()) {
    $pdf->Cell(20, 7, $row[0], 1, 0, 'L', 0);
         $this->Cell(2.7 / 100 * $width, $height, '', 'BRL', 0, 'C', 1);
         $this->Ln();
     }
     function Footer()
     {
         $this->SetY(-15);
         $this->SetFont('Arial', 'I', 8);
         $this->Cell(10, 10, 'Page ' . $this->PageNo() . " Print Time:" . date('Y-m-d H:i:s') . " By:" . $_SESSION['empl']['name'], 0, 0, 'L');
     }
 }
 $pdf = new PDF('L', 'pt', 'Legal');
 $width = $pdf->w - $pdf->lMargin - $pdf->rMargin;
 $height = 12;
 $pdf->AddPage();
 $pdf->SetFillColor(255, 255, 255);
 $pdf->SetTextColor(0, 0, 0);
 $pdf->SetFont('Arial', '', 7);
 $no = 0;
 if (!empty($karyawan)) {
     foreach ($karyawan as $kar) {
         $hadir = 0;
         $telat = 0;
         $cuti = 0;
         $dinas = 0;
         $mangkir = 0;
         $no += 1;
         // LINE PERTAMA
         $pdf->Cell(2 / 100 * $width, $height, $no, 'TRL', 0, 'R', 1);
         $pdf->Cell(9.5 / 100 * $width, $height, $kar['nama'], 'TRL', 0, 'L', 1);
         if (!empty($tanggaltanggal)) {
             foreach ($tanggaltanggal as $tang) {
示例#13
0
 /**
  * Main
  *
  * @param object $order Order
  * @param string $mode Download or display (optional)
  */
 public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
 {
     global $cookie, $ecotax;
     if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
         die('Invalid order or invalid order state');
     }
     self::$order = $order;
     self::$orderSlip = $slip;
     self::$delivery = $delivery;
     self::$_iso = strtoupper(Language::getIsoById(intval(self::$order->id_lang)));
     if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
         die(self::l('No price display method defined for the customer group'));
     }
     if (!$multiple) {
         $pdf = new PDF('P', 'mm', 'A4');
     }
     $pdf->SetAutoPageBreak(true, 35);
     $pdf->StartPageGroup();
     self::$currency = Currency::getCurrencyInstance(intval(self::$order->id_currency));
     $pdf->AliasNbPages();
     $pdf->AddPage();
     /* Display address information */
     $invoice_address = new Address(intval($order->id_address_invoice));
     $invoiceState = $invoice_address->id_state ? new State($invoice_address->id_state) : false;
     $delivery_address = new Address(intval($order->id_address_delivery));
     $deliveryState = $delivery_address->id_state ? new State($delivery_address->id_state) : false;
     $shop_country = Configuration::get('PS_SHOP_COUNTRY');
     $invoice_customer = new Customer(intval($invoice_address->id_customer));
     $width = 100;
     $pdf->SetX(10);
     $pdf->SetY(25);
     $pdf->SetFont(self::fontname(), '', 12);
     $pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
     $pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
     $pdf->Ln(5);
     $pdf->SetFont(self::fontname(), '', 9);
     if (!empty($delivery_address->company) or !empty($invoice_address->company)) {
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->company), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->company), 0, 'L');
         $pdf->Ln(5);
     }
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->lastname), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->lastname), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address1), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address1), 0, 'L');
     $pdf->Ln(5);
     if (!empty($invoice_address->address2) or !empty($delivery_address->address2)) {
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address2), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address2), 0, 'L');
         $pdf->Ln(5);
     }
     $pdf->Cell($width, 10, $delivery_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->city), 0, 'L');
     $pdf->Cell($width, 10, $invoice_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->city), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->country . ($deliveryState ? ' - ' . $deliveryState->name : '')), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->country . ($invoiceState ? ' - ' . $invoiceState->name : '')), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, $delivery_address->phone, 0, 'L');
     if ($invoice_customer->dni != NULL) {
         $pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_customer->dni), 0, 'L');
     }
     if (!empty($delivery_address->phone_mobile)) {
         $pdf->Ln(5);
         $pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L');
     }
     /*
      * display order information
      */
     $carrier = new Carrier(self::$order->id_carrier);
     if ($carrier->name == '0') {
         $carrier->name = Configuration::get('PS_SHOP_NAME');
     }
     $history = self::$order->getHistory(self::$order->id_lang);
     foreach ($history as $h) {
         if ($h['id_order_state'] == _PS_OS_SHIPPING_) {
             $shipping_date = $h['date_add'];
         }
     }
     $pdf->Ln(12);
     $pdf->SetFillColor(240, 240, 240);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont(self::fontname(), '', 9);
     if (self::$orderSlip) {
         $pdf->Cell(0, 6, self::l('SLIP #') . sprintf('%06d', self::$orderSlip->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
     } elseif (self::$delivery) {
         $pdf->Cell(0, 6, self::l('DELIVERY SLIP #') . Configuration::get('PS_DELIVERY_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$delivery) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
     } else {
         $pdf->Cell(0, 6, self::l('INVOICE #') . Configuration::get('PS_INVOICE_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$order->invoice_number) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
     }
     $pdf->Cell(55, 6, self::l('Order #') . sprintf('%06d', self::$order->id), 'L', 0);
     $pdf->Cell(70, 6, self::l('Carrier:') . ($order->gift ? ' ' . Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
     $pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
     $pdf->Ln(5);
     $pdf->Cell(55, 6, isset($shipping_date) ? self::l('Shipping date:') . ' ' . Tools::displayDate($shipping_date, self::$order->id_lang) : ' ', 'LB', 0);
     $pdf->Cell(70, 6, $order->gift ? self::l('Gift-wrapped order') : Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
     $pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
     $pdf->Ln(15);
     $pdf->ProdTab(self::$delivery ? true : '');
     /* Exit if delivery */
     if (!self::$delivery) {
         if (!self::$orderSlip) {
             $pdf->DiscTab();
         }
         $priceBreakDown = array();
         $pdf->priceBreakDownCalculation($priceBreakDown);
         if (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost) {
             $priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
             $priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
         }
         if (!self::$orderSlip) {
             $taxDiscount = self::$order->getTaxesAverageUsed();
             if ($taxDiscount != 0) {
                 $priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
             } else {
                 $priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
             }
             $priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
         }
         /*
          * Display price summation
          */
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax excl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products ') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (!self::$orderSlip and self::$order->total_discounts != '0.00') {
             $pdf->Cell($width, 0, self::l('Total discounts (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_wrapping) and floatval(self::$order->total_wrapping) > 0) {
             $pdf->Cell($width, 0, self::l('Total wrapping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (self::$order->total_shipping != '0.00' and (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost)) {
             $pdf->Cell($width, 0, self::l('Total shipping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Cell($width, 0, self::l('Total') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if ($ecotax != '0.00' and !self::$orderSlip) {
             $pdf->Cell($width, 0, self::l('Eco-participation') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, self::convertSign(Tools::displayPrice($ecotax, self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(5);
         }
         $pdf->TaxTab($priceBreakDown);
     }
     Hook::PDFInvoice($pdf, self::$order->id);
     if (!$multiple) {
         return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode);
     }
 }
示例#14
0
 /**
  *   Show table for lines
  *
  *   @param		PDF			$pdf     		Object PDF
  *   @param		string		$tab_top		Top position of table
  *   @param		string		$tab_height		Height of table (rectangle)
  *   @param		int			$nexY			Y
  *   @param		Translate	$outputlangs	Langs object
  *   @param		int			$hidetop		Hide top bar of array
  *   @param		int			$hidebottom		Hide bottom bar of array
  *   @return	void
  */
 function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 {
     global $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $pdf->SetDrawColor(128, 128, 128);
     // Rect prend une longueur en 3eme param
     $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
     // line prend une position y en 3eme param
     $pdf->line($this->marge_gauche, $tab_top + 6, $this->page_largeur - $this->marge_droite, $tab_top + 6);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size);
     $pdf->SetXY($this->posxref, $tab_top + 1);
     $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
     $pdf->SetXY($this->posxlabel, $tab_top + 1);
     $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
     $pdf->SetXY($this->posxworkload, $tab_top + 1);
     $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R');
     $pdf->SetXY($this->posxprogress, $tab_top + 1);
     $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R');
     $pdf->SetXY($this->posxdatestart, $tab_top + 1);
     $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C');
     $pdf->SetXY($this->posxdateend, $tab_top + 1);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
 }
示例#15
0
 $descon = utf8_decode($row['descon']);
 $obscon = utf8_decode($row['obscon']);
 $fotos = explode(",", $row['fotos']);
 //Creación del objeto de la clase heredada
 //$pdf=new PDF();
 //$pdf->AliasNbPages();
 /*	if (!isset($pdf)) {
 			$pdf=new PDF();
 			$pdf->AliasNbPages();
 		}
 	*/
 $pdf->AddPage();
 $pdf->SetDisplayMode('fullpage');
 $pdf->SetMargins(20, 20, 20);
 $pdf->SetFont('Arial', 'BU', 14);
 $pdf->SetTextColor(70, 125, 25);
 $pdf->Cell(0, 10, 'FICHA DE CHECK DOMICILIARIO', 0, 1, 'C');
 $pdf->Ln(2);
 $pdf->SetTextColor(0, 0, 0);
 $pdf->SetFont('Arial', 'B', 12);
 $pdf->Cell(55, 7, 'NOMBRES Y APELLIDOS', 1, 0, 'L');
 $pdf->SetFont('Arial', '', 12);
 $pdf->Cell(0, 7, $nombre, 1, 1, 'C');
 $pdf->SetFont('Arial', 'B', 12);
 $pdf->Cell(55, 7, 'DIRECCION', 1, 0, 'L');
 $pdf->SetFont('Arial', '', 12);
 $pdf->MultiCell(0, 7, $domicilio, 1, 'C');
 //$pdf->Ln(2);
 //$pdf->Image('../files/images_dni/imagen1.png',40,null,0,130);
 $pdf->Ln(2);
 $pdf->SetFont('Arial', 'B', 12);
示例#16
0
$settel2 = $_SESSION['startdate']." to ".$_SESSION['todate'];
$pdf->SetX(65);
$pdf->Write(5,"Your invoice details from ".$settel2."");
$pdf->ln(8);

$pdf->FancyTable($header,$result_array);

	if($pdf->GetY() >= 242.00125){
	
	$pdf->AddPage();
	$pdf->FancyTable1($head_valur,$caption,$increasewidth,"bottom");
	}else
	{
		
	$pdf->FancyTable1($head_valur,$caption,$increasewidth,"bottom");
	$pdf->SetTextColor(0,0,0);
	}
 
$save = "Bill ID 1.pdf";

if(isset($_POST["sendas"]) && $_POST["sendas"]=="mail") {

$email = $_POST['biller_mailer_id'];
$cusname = $_POST['cusname'];

$attachment= $pdf->Output($save, 'S');
	
$sendStatus = sendBillViaeMail($_GET['new_flag_already'],$attachment,$save,$_SESSION['startdate'],$_SESSION['todate'],$email,$cusname);

echo $sendStatus;
示例#17
0
$name = $_POST['name'];
$characteristics = $_POST['characteristics'];
$image = $_POST['image'];
$clues = explode(',', $_POST['clues']);
require 'MultiCellBlt2.php';
//Create pdf
$pdf = new PDF();
$pdf->AddPage();
//set document properties
$pdf->SetAuthor('Anon');
$pdf->SetTitle($name);
// Set the page break to 'true' and the bottom margin height
$pdf->SetAutoPageBreak(1, 10);
//set font for the entire document
$pdf->SetFont('Helvetica', 'B', 20);
$pdf->SetTextColor(50, 60, 100);
//insert Collage logo
$pdf->Image('logo.png', 10, 10, 33, 0);
//display the title without a border around it
$pdf->SetXY(50, 15);
$pdf->SetDrawColor(50, 60, 100);
$pdf->Cell(100, 10, $name, 0, 0, 'C', 0);
// Insert a dynamic image from a URL
$pdf->Image($image, 11, 30, 0, 50);
//Set x and y position for the main text, reduce font size and write content
$pdf->SetXY(65, 30);
$pdf->SetLeftMargin(65);
$pdf->SetFontSize(10);
$pdf->Write(5, $characteristics);
$pdf->Ln(8);
//Output the clues
示例#18
0
 /**
  *   Affiche la grille des lignes de factures
  *
  *   @param     PDF			$pdf     		Object PDF
  *   @param		int			$tab_top		Tab top
  *   @param		int			$tab_height		Tab height
  *   @param		int			$nexY			next y
  *   @param		Translate	$outputlangs	Output langs
  *   @return	void
  */
 function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
 {
     global $conf;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 2);
     $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
     $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
     $pdf->MultiCell($pdf->GetStringWidth($titre) + 3, 2, $titre);
     $pdf->SetDrawColor(128, 128, 128);
     // Rect prend une longueur en 3eme param
     $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
     // line prend une position y en 3eme param
     $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
     $pdf->SetFont('', '', 8);
     // Accountancy piece
     $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxdesc - $this->posxpiece - 1, 1, '', '', 'R');
     // Comments
     $pdf->line($this->posxdesc - 1, $tab_top, $this->posxdesc - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxdate - $this->posxdesc - 1, 1, $outputlangs->transnoentities("Description"), '', 'L');
     // Date
     $pdf->line($this->posxdate - 1, $tab_top, $this->posxdate - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxdate - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxtype - $this->posxdate - 1, 2, $outputlangs->transnoentities("Date"), '', 'C');
     // Type
     $pdf->line($this->posxtype - 1, $tab_top, $this->posxtype - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxtype - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxprojet - $this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C');
     // Project
     $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
     // VAT
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
         $pdf->SetXY($this->posxtva - 1, $tab_top + 1);
         $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
     }
     // Unit price
     $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxup - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C');
     // Quantity
     $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
     $pdf->MultiCell($this->postotalttc - $this->posxqty, 2, $outputlangs->transnoentities("Qty"), '', 'R');
     // Total with all taxes
     $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
     $pdf->SetXY($this->postotalttc - 1, $tab_top + 1);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R');
     $pdf->SetTextColor(0, 0, 0);
 }
示例#19
0
    $admin = 1;
}
//-----------------------------------------------------
// Print result
$pdf = new PDF($cn);
$pdf->setDossierInfo(dossier::name() . ' Sécurité');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetAuthor('NOALYSS');
$pdf->setTitle("Sécurité", true);
$str_user = sprintf("( %d ) %s %s [ %s ] - %s", $SecUser->id, $SecUser->first_name, $SecUser->name, $SecUser->login, $str);
$pdf->SetFont('DejaVu', 'B', 9);
$pdf->Cell(0, 7, $str_user, 'B', 0, 'C');
$pdf->Ln();
if ($SecUser->active == 0) {
    $pdf->SetTextColor(255, 0, 34);
    $pdf->Cell(0, 7, 'Bloqué', 0, 0, 'R');
    $pdf->Ln();
}
if ($SecUser->admin == 1) {
    $pdf->SetTextColor(0, 0, 0);
    $pdf->setFillColor(239, 251, 255);
    $pdf->Cell(40, 7, 'Administrateur', 1, 1, 'R');
    $pdf->Ln();
}
$pdf->SetTextColor(0, 0, 0);
//-----------------------------------------------------
// Journal
$pdf->Cell(0, 7, 'Accès journaux', 1, 0, 'C');
$pdf->Ln();
$pdf->SetFont('DejaVu', '', 6);
示例#20
0
require_once 'mysql_table.php';
include "comunes.php";
include "../conectar.php";
$pdf = new PDF();
$pdf->Open();
$pdf->AddPage();
//Nombre del Listado
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial', 'B', 16);
$pdf->SetY(40);
$pdf->SetX(0);
$pdf->MultiCell(290, 6, "Listado de Cobradores", 0, C, 0);
$pdf->Ln();
//Restauracin de colores y fuentes
$pdf->SetFillColor(224, 235, 255);
$pdf->SetTextColor(0);
$pdf->SetFont('Arial', 'B', 7);
//Buscamos y listamos las familias
$nombreentidad = $_POST["nombrecobrador"];
$codentidad = $_POST["codcobrador"];
$where = "1=1";
if ($codcobrador != "") {
    $where .= " AND codcobrador='{$codcobrador}'";
}
if ($nombrecobrador != "") {
    $where .= " AND nombrecobrador like '%" . $nombrecobrador . "%'";
}
$where2 .= " ORDER BY nombrecobrador ASC";
//Ttulos de las columnas
$header = array('Cod. Cobrador', 'Nombre Cobrador');
//Colores, ancho de lnea y fuente en negrita
示例#21
0
$pdf->Open();
$pdf->AddPage();
if ($fondofac == "SI") {
    $pdf->Header($imagenfac, 0, 0, 205, 295);
}
$codfactura = $_REQUEST["codfactura"];
$consulta = "Select * from facturas,clientes where facturas.codfactura='{$codfactura}' and facturas.codcliente=clientes.codcliente";
$resultado = mysql_query($consulta, $conexion);
$lafila = mysql_fetch_array($resultado);
$fecha = implota($lafila["fecha"]);
$dia1 = substr($fecha, 0, 2);
$mes1 = substr($fecha, 3, 2);
$mes1 = mes($mes1);
$ano1 = substr($fecha, 6, 4);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(18, 18, 239);
$pdf->SetDrawColor(0, 0, 0);
$pdf->SetLineWidth(0.2);
$pdf->SetFont('Arial', 'B', 11);
$pdf->Ln(31);
$pdf->Cell(115);
$pdf->Cell(10, 4, $codfactura, 0, 0, 'L', 0);
$pdf->Ln(22);
$pdf->Cell(60);
$pdf->Cell(42, 4, $CiudadActual, 0, 0, 'L', 0);
$pdf->Cell(20, 4, $dia1, 0, 0, 'L', 0);
$pdf->Cell(55, 4, $mes1, 0, 0, 'L', 0);
$pdf->Cell(10, 4, $ano1, 0, 0, 'L', 0);
$pdf->Ln(8);
$pdf->Cell(20);
$pdf->Cell(125, 4, $lafila["nombre"], 0, 0, 'L', 0);
示例#22
0
$img = "imagenes/log.jpg";
//Antes de pasar los datos al PDF, hay que pasar las variables por la función html_entity_decode para decodificar los caracteres especiales, los acentos y las ñ
// Siempre y cuando los datos extraídos de la BD sean UTF8 (no lo probe con otra codificación)
$nombre = html_entity_decode($nombre);
$descripcion = html_entity_decode($descripcion);
//Creamos una nueva instancia de la clase
$pdf = new PDF();
//Añádimos la primera página
$pdf->AddPage();
$pdf->Image('log.jpg', 8, 8, 30);
$pdf->Ln(12);
$pdf->SetFont('Helvetica', '', 20);
//$pdf->Ln(12);
$pdf->Line(10, 30, 200, 30);
$pdf->SetFontSize(17);
$pdf->SetTextColor(44, 62, 80);
$pdf->WriteHTML("Online Computer Shop");
$pdf->SetTextColor(0);
$pdf->SetLeftMargin(155);
$pdf->SetFontSize(14);
$pdf->Ln(-15);
$pdf->WriteHTML("<br><br><b>Fecha:</b> " . date("d/m/Y", time() - 25200));
$pdf->WriteHTML("<br><b>Hora:</b> " . date("H:i:s", time() - 25200) . "\n\n");
$pdf->SetLeftMargin(10);
$pdf->Ln(14);
// Otra parte importante, luego de pasar las variables por la función html_entity_decode, para que se vean bien los acentos y las ñ, hay que pasarlas por otra
// función que es utf8_decode
$pdf->SetFontSize(14);
$pdf->WriteHTML(utf8_decode($nombre));
$pdf->WriteHTML("<br>");
$pdf->WriteHTML(utf8_decode($descripcion));
 /**
  *   Show table for lines
  *
  *   @param		PDF			$pdf     		Object PDF
  *   @param		string		$tab_top		Top position of table
  *   @param		string		$tab_height		Height of table (rectangle)
  *   @param		int			$nexY			Y
  *   @param		Translate	$outputlangs	Langs object
  *   @param		int			$hidetop		Hide top bar of array
  *   @param		int			$hidebottom		Hide bottom bar of array
  *   @return	void
  */
 function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 {
     global $conf;
     // Force to disable hidetop and hidebottom
     $hidebottom = 0;
     if ($hidetop) {
         $hidetop = -1;
     }
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 1);
     // Output Rect
     $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
     // Rect prend une longueur en 3eme param et 4eme param
     $pdf->SetDrawColor(128, 128, 128);
     $pdf->SetFont('', '', $default_font_size - 1);
     if (empty($hidetop)) {
         $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
         $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
         $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
     }
     $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
     if (empty($hidetop)) {
         $pdf->SetXY($this->posxqtyordered, $tab_top + 1);
         $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
     }
     $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
     if (empty($hidetop)) {
         $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
         $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxqtytoship, 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
     }
 }
 $firstbox_xpos = $cellstart + 1;
 $firstbox_text_size = $cellsize - 3;
 $pdf->Cell($cellsize, $cell_height_col, '', 1, 0);
 $pdf->drawProductsImage($cellstart + 10, $ypos + 1, $p['products_image']);
 $pdf->setXY($firstbox_xpos, $ypos + 3);
 $pdf->setFont('Arial', 'B', '10');
 //$pdf->Cell($cellsize, $cell_height, $no++ . ". " . (($header) ? $p['categories_name'] : ''));
 //wrap categories name to fit with box
 $pdf->MultiCell(40, 3, $no++ . ". " . ($header ? $p['categories_name'] : ''), 0, 'L');
 $header = false;
 $pdf->setFont('Arial', '', '10');
 $pdf->drawStar($p['stars'], $cellstart + 15, $ypos + 29);
 $pdf->setXY($firstbox_xpos, $ypos + 35);
 $link = 'http://' . $server . '/?open=product-detail&products_id=' . $p['products_id'];
 $pdf->SetFont('Arial', 'U');
 $pdf->SetTextColor(0, 0, 255);
 $pdf->Cell($firstbox_text_size, $cell_height, $pid . ' / ' . $p['products_model'], 0, 0, 'C', 0, $link);
 $pdf->SetFont('Arial', '');
 $pdf->SetTextColor(0, 0, 0);
 $pdf->setXY($firstbox_xpos, $ypos + 40);
 $pdf->Cell($firstbox_text_size, $cell_height, 'Price: ' . displayCurrency('EUR', $p['products_price'], false), 0, 0, 'C');
 //$pdf->Cell($cellsize, $cell_height, 'Price/Margin: '.displayCurrency('EUR', $p['products_price'], false).' / '.$p['fmargin']);
 $pdf->setXY($firstbox_xpos, $ypos + 45);
 $pdf->Cell($firstbox_text_size, $cell_height, 'Margin: ' . $p['fmargin'], 0, 0, 'C');
 //$pdf->Cell($cellsize, $cell_height, 'Total Sold L30D: '.$p['last_30_days']);
 //$pdf->Cell($cellsize, $cell_height, 'Total Sold L4W: '.$p['total_sold_L4W']);
 $pdf->setXY($firstbox_xpos, $ypos + 50);
 $pdf->setFont('Arial', 'B');
 //$pdf->Cell($cellsize, $cell_height, 'Total Sold L30D: '.$p['last_30_days']);
 //$pdf->Cell($cellsize, $cell_height, 'Total Sold L4W: '.$p['total_sold_L4W']);
 $pdf->Cell($firstbox_text_size, $cell_height, 'Sold L4W/L30D: ' . $p['total_sold_L4W'] . ' / ' . $p['last_30_days'], 0, 0, 'C');
        $this->SetFont('Arial', 'B', 10);
    }
    function Footer()
    {
        $this->SetY(-25);
        //Arial bold 7
    }
}
// end function PDF class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage('p');
$pdf->SetFont('Arial', '', 10);
//identifiers
$pdf->SetFillColor(5, 66, 6);
$pdf->SetTextColor(255, 255, 255);
$fill = true;
$pdf->SetFont('Arial', '', 13);
$pdf->Cell(190, 7, 'Employee Clearance Checklist for ' . $person->formatName('f m l'), 0, 1, 'C', $fill);
$pdf->SetFont('Arial', '', 10);
$pdf->Cell(190, 6, 'Username:  '******'C', $fill);
$pdf->setTextColor(5, 66, 6);
$pdf->ln(5);
$checklist_items = array();
$categories = array();
$checklist = HRChecklist::get($person->pidm, $list);
$categories = HRChecklist::categories($checklist['type']);
$checklist_id = HRChecklist::get($person->pidm, $list, 'id');
$closed = HRChecklist::meta_exists($checklist_id, 'closed', 1);
if (IDMObject::authZ('permission', 'ape_checklist_employee_exit_hr')) {
    if ($_POST['checklist_closed'] && !$closed) {
示例#26
0
$pdf->AliasNbPages();
$pdf->AddPage('A', 'A3');
$cp = new ControladorPersistencia();
$listadoUsuarios = $cp->ejecutarSentencia(DBSentencias::BUSCAR_USUARIOS);
$alterna = true;
$tipo = "";
foreach ($listadoUsuarios as $usuarios) {
    if ($usuarios['tipoAcceso_usuario'] == 1) {
        $tipo = "Total";
    } else {
        $tipo = "Restringrido";
    }
    if ($alterna) {
        $pdf->SetFont('Arial', '', '12');
        $pdf->SetFillColor(229, 229, 229);
        $pdf->SetTextColor(3, 3, 3);
        $pdf->Cell(60, 10, utf8_decode($usuarios['nombre_usuario']), 1, 0, 'L', true);
        $pdf->Cell(60, 10, utf8_decode($usuarios['apellido_usuario']), 1, 0, 'L', true);
        $pdf->Cell(60, 10, utf8_decode($usuarios['usuario_usuario']), 1, 0, 'L', true);
        $pdf->Cell(60, 10, $tipo, 1, 0, 'L', true);
        $pdf->Cell(80, 10, utf8_decode($usuarios['fch_creacion']), 1, 0, 'L', true);
        $pdf->Cell(80, 10, utf8_decode($usuarios['fch_modificacion']), 1, 0, 'L', true);
        $pdf->Ln();
        $alterna = !$alterna;
    } else {
        $pdf->SetFont('Arial', '', '12');
        $pdf->SetFillColor(229, 229, 229);
        $pdf->SetTextColor(3, 3, 3);
        $pdf->Cell(60, 10, utf8_decode($usuarios['nombre_usuario']), 1, 0, 'L', FALSE);
        $pdf->Cell(60, 10, utf8_decode($usuarios['apellido_usuario']), 1, 0, 'L', FALSE);
        $pdf->Cell(60, 10, utf8_decode($usuarios['usuario_usuario']), 1, 0, 'L', FALSE);
示例#27
0
/**
 *      Add a draft watermark on PDF files
 *
 *      @param	PDF      	$pdf           Object PDF
 *      @param  Translate	$outputlangs	Object lang
 *      @param  int		    $h		        Height of PDF
 *      @param  int		    $w		        Width of PDF
 *      @param  string	    $unit           Unit of height (mm, pt, ...)
 *      @param  string		$text           Text to show
 *      @return	void
 */
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
    // Print Draft Watermark
    if ($unit == 'pt') {
        $k = 1;
    } elseif ($unit == 'mm') {
        $k = 72 / 25.4;
    } elseif ($unit == 'cm') {
        $k = 72 / 2.54;
    } elseif ($unit == 'in') {
        $k = 72;
    }
    $savx = $pdf->getX();
    $savy = $pdf->getY();
    $watermark_angle = atan($h / $w) / 2;
    $watermark_x_pos = 0;
    $watermark_y_pos = $h / 3;
    $watermark_x = $w / 2;
    $watermark_y = $h / 3;
    $pdf->SetFont('', 'B', 40);
    $pdf->SetTextColor(255, 192, 203);
    //rotate
    $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k));
    //print watermark
    $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
    $pdf->Cell($w - 20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0);
    //antirotate
    $pdf->_out('Q');
    $pdf->SetXY($savx, $savy);
}
示例#28
0
文件: pdf.php 项目: raalveco/Escuela
/**
 * Genera un reporte en PDF
 *
 * @param array $result
 * @param array $sumArray
 * @param string $title
 * @param array $weightArray
 * @param array $headerArray
 */
function pdf($result, $sumArray, $title, $weightArray, $headerArray)
{
    $config = Config::read('config');
    $active_app = Router::get_application();
    //Orientación
    if ($sumArray > 200) {
        $orientation = 'L';
    } else {
        $orientation = 'P';
    }
    $numRows = 140;
    //Tipo de Papel
    if ($sumArray > 250) {
        $paper = 'legal';
    } else {
        $paper = 'letter';
    }
    if ($paper == 'letter' && $orientation == 'P') {
        $widthPage = 220;
        $numRows = 42;
    }
    if ($paper == 'legal' && $orientation == 'L') {
        $widthPage = 355;
        $numRows = 30;
    }
    if ($paper == 'letter' && $orientation == 'L') {
        $widthPage = 270;
        $numRows = 30;
    }
    //Crear Documento PDF
    $pdf = new PDF($orientation, 'mm', $paper);
    $pdf->Open();
    $pdf->AddPage();
    //Nombre del Listado
    $pdf->SetFillColor(255, 255, 255);
    $pdf->AddFont('Verdana', '', 'verdana.php');
    $pdf->SetFont('Verdana', '', 14);
    $pdf->SetY(20);
    $pdf->SetX(0);
    $pdf->Ln();
    if ($config->{$active_app}->name) {
        $pdf->MultiCell(0, 6, strtoupper($config->{$active_app}->name), 0, "C", 0);
    }
    $pdf->MultiCell(0, 6, "REPORTE DE " . strtoupper($title), 0, "C", 0);
    $pdf->SetFont('Verdana', '', 12);
    if (isset($_SESSION['fecsis'])) {
        $pdf->MultiCell(0, 6, "FECHA " . date("Y-m-d"), 0, "C", 0);
    }
    $pdf->Ln();
    //Colores, ancho de línea y fuente en negrita
    $pdf->SetFillColor(0xf2, 0xf2, 0xf2);
    $pdf->SetTextColor(0);
    $pdf->SetDrawColor(0, 0, 0);
    $pdf->SetLineWidth(0.2);
    $pdf->SetFont('Arial', 'B', 10);
    if ($weightArray[0] < 11) {
        $weightArray[0] = 11;
    }
    //Parametros del Reporte
    $pos = floor($widthPage / 2 - $sumArray / 2);
    $pdf->SetX($pos);
    for ($i = 0; $i <= count($headerArray) - 1; $i++) {
        $pdf->Cell($weightArray[$i], 7, $headerArray[$i], 1, 0, 'C', 1);
    }
    $pdf->Ln();
    //Restauración de colores y fuentes
    $pdf->SetFillColor(224, 235, 255);
    $pdf->SetTextColor(0);
    $pdf->SetFont('Arial', 'B', 7);
    //print_r($weightArray);
    //Buscamos y listamos
    $n = 1;
    $p = 1;
    $t = 0;
    foreach ($result as $row) {
        //$pdf->Cell(Ancho, Alto, contenido, ?, ?, Align)
        if ($n > $numRows || $p == 1 && $n > $numRows - 3) {
            $pdf->AddPage($orientation);
            $pdf->SetY(30);
            $pdf->SetX($pos);
            $pdf->SetFillColor(0xf2, 0xf2, 0xf2);
            $pdf->SetTextColor(0);
            $pdf->SetDrawColor(0, 0, 0);
            $pdf->SetLineWidth(0.2);
            $pdf->SetFont('Arial', 'B', 10);
            for ($i = 0; $i < count($headerArray); $i++) {
                $pdf->Cell($weightArray[$i], 7, $headerArray[$i], 1, 0, 'C', 1);
            }
            $pdf->Ln();
            $pdf->SetFillColor(224, 235, 255);
            $pdf->SetTextColor(0);
            $pdf->SetFont('Arial', 'B', 7);
            $n = 1;
            $p++;
        }
        $pdf->SetX($pos);
        for ($i = 0; $i <= count($row) - 1; $i++) {
            if (is_numeric($row[$i])) {
                $pdf->Cell($weightArray[$i], 5, trim($row[$i]), 'LRTB', 0, 'C');
            } else {
                $pdf->Cell($weightArray[$i], 5, trim($row[$i]), 'LRTB', 0, 'L');
            }
        }
        $n++;
        $t++;
        $pdf->Ln();
    }
    $pdf->SetX($pos);
    $pdf->SetFont('Arial', 'B', 7);
    $pdf->SetFillColor(0xf2, 0xf2, 0xf2);
    $pdf->Cell($weightArray[0], 5, "TOTAL", 'LRTB', 0, 'R');
    $pdf->Cell($weightArray[1], 5, $t, 'LRTB', 0, 'L');
    /*print "<div style='background: url(img/bg2.jpg) #F2f2f2;border:1px solid #c0c0c0'>
    	<table><td><img src='img/information.gif' width='64' height='64'/></td><td>";
    	print "Papel: $paper<br>";
    	print "Orientación: $orientation<br>";
    	print "Ancho Página: $widthPage mm<br>";
    	print "Número Páginas: $p<br>";
    	print "</td></table></div><br>";*/
    $file = md5(uniqid());
    $pdf->Output(CORE_PATH . 'public/temp/' . $file . ".pdf", 'F');
    if (isset($raw_output)) {
        print "<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".pdf', null); </script>";
    } else {
        Generator::forms_print("<script type='text/javascript'> window.open('" . KUMBIA_PATH . "temp/" . $file . ".pdf', null); </script>");
    }
}
 /**
  *   Show table for lines
  *
  *   @param		PDF			$pdf     		Object PDF
  *   @param		string		$tab_top		Top position of table
  *   @param		string		$tab_height		Height of table (rectangle)
  *   @param		int			$nexY			Y (not used)
  *   @param		Translate	$outputlangs	Langs object
  *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
  *   @param		int			$hidebottom		Hide bottom bar of array
  *   @param		string		$currency		Currency code
  *   @return	void
  */
 function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
 {
     global $conf;
     // Force to disable hidetop and hidebottom
     $hidebottom = 0;
     if ($hidetop) {
         $hidetop = -1;
     }
     $currency = !empty($currency) ? $currency : $conf->currency;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 2);
     if (empty($hidetop)) {
         $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $currency));
         $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
         $pdf->MultiCell($pdf->GetStringWidth($titre) + 3, 2, $titre);
         //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
         if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
             $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
         }
     }
     $pdf->SetDrawColor(128, 128, 128);
     $pdf->SetFont('', '', $default_font_size - 1);
     // Output Rect
     $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
     // Rect prend une longueur en 3eme param et 4eme param
     if (empty($hidetop)) {
         $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
         // line prend une position y en 2eme param et 4eme param
         $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
         $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
     }
     if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
         $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
         if (empty($hidetop)) {
             //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
             //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
         }
     }
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
         if (empty($hidetop)) {
             $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
             $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
         }
     }
     $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
     if (empty($hidetop)) {
         $pdf->SetXY($this->posxup - 1, $tab_top + 1);
         $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
     }
     $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
     if (empty($hidetop)) {
         $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
         if ($conf->global->PRODUCT_USE_UNITS) {
             $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
         } else {
             $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
         }
     }
     if ($conf->global->PRODUCT_USE_UNITS) {
         $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
         if (empty($hidetop)) {
             $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
             $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
         }
     }
     $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
     if (empty($hidetop)) {
         if ($this->atleastonediscount) {
             $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
             $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
         }
     }
     if ($this->atleastonediscount) {
         $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
     }
     if (empty($hidetop)) {
         $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
         $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
     }
 }
示例#30
-1
 function savepdfcertificate()
 {
     $datac = JRequest::get('post', JREQUEST_ALLOWRAW);
     include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
     $background_color = "";
     $op = JRequest::getVar("op", "");
     if ($op == 9) {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = JRequest::getVar('cn', '', 'get');
         $authorname = JRequest::getVar('an', '', 'get');
         $certificateid = JRequest::getVar('id', '', 'get');
         $completiondate = JRequest::getVar('cd', '', 'get');
         $course_id = JRequest::getVar('ci', '', 'get');
         $sitename = $config->get('sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = @guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         // final quiz --------------------------------------------------
         $sql = "SELECT id, score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc = $scores_avg_quizzes . '%';
             }
         }
         // final quiz --------------------------------------------------
         // regular ----------------------------------------------
         $s = 0;
         $sql = "select mr.`media_id` from #__guru_mediarel mr, #__guru_days d where mr.`type`='dtask' and mr.`type_id`=d.`id` and d.`pid`=" . intval($course_id);
         $db->setQuery($sql);
         $db->query();
         $lessons = $db->loadColumn();
         if (!isset($lessons) || count($lessons) == 0) {
             $lessons = array("0");
         }
         $sql = "select mr.`media_id` from #__guru_mediarel mr where mr.`layout`='12' and mr.`type`='scr_m' and mr.`type_id` in (" . implode(", ", $lessons) . ")";
         $db->setQuery($sql);
         $db->query();
         $all_quizzes = $db->loadColumn();
         if (isset($all_quizzes) && count($all_quizzes) > 0) {
             foreach ($all_quizzes as $key_quiz => $quiz_id) {
                 $sql = "SELECT score_quiz FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($quiz_id) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
                 $db->setQuery($sql);
                 $db->query();
                 $result_q = $db->loadColumn();
                 $res = @$result_q["0"];
                 $s += $res;
             }
             $avg_certc1 = "N/A";
             if ($s > 0) {
                 $avg_certc1 = $s / count($all_quizzes) . "%";
             }
         }
         // regular ----------------------------------------------
         /*$sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=".intval($user_id)." and quiz_id=".intval($result)." and pid=".intval($course_id )." ORDER BY id DESC LIMIT 0,1";
         			$db->setQuery($sql);
         			$result_q = $db->loadObject();
         	
         			$first= explode("|", @$result_q->score_quiz);
         	
         			@$res = intval(($first[0]/$first[1])*100);
         	
         			if($resulthasq == 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && $scores_avg_quizzes == ""){
         				$avg_certc1 = "N/A";
         			}
         			elseif($resulthasq != 0 && isset($scores_avg_quizzes)){
         				if($scores_avg_quizzes >= intval($avg_quizzes_cert)){
         					$avg_certc1 =  $scores_avg_quizzes.'%'; 
         				}
         				else{
         					$avg_certc1 = $scores_avg_quizzes.'%';
         				}
         			}*/
         /*if($result !=0 && $res !="" ){
         			if( $res >= $result_maxs){
         				$avg_certc = $res.'%';
         			}
         			elseif($res < $result_maxs){
         				$avg_certc = $res.'%';
         			}
         		}
         		elseif(($result !=0 && $result !="")){
         			$avg_certc = "N/A";
         		}
         		elseif($result ==0 || $result ==""){
         			$avg_certc = "N/A";
         		}*/
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         @($background_color[1] = str_replace("#", "", $background_color[1]));
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require_once JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $pdf = new mPDF('utf-8', 'A4-L', 0, strtolower($imagename[0]["font_certificate"]));
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     } else {
         $db = JFactory::getDBO();
         $user = JFactory::getUser();
         $config = JFactory::getConfig();
         $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
         $db->setQuery($imagename);
         $db->query();
         $imagename = $db->loadAssocList();
         if ($imagename[0]["design_background"] != "") {
             $image_theme = explode("/", $imagename[0]["design_background"]);
             if (trim($image_theme[4]) == 'thumbs') {
                 $image_theme = $image_theme[5];
             } else {
                 $image_theme = $image_theme[4];
             }
         } else {
             $background_color = "background-color:" . "#" . $imagename[0]["design_background_color"];
         }
         $site_url = JURI::root();
         $coursename = $datac['cn'];
         $authorname = $datac['an'];
         $certificateid = $datac['id'];
         $completiondate = $datac['cd'];
         $course_id = $datac['ci'];
         $sitename = $config->get('config.sitename');
         $user_id = $user->id;
         $scores_avg_quizzes = guruModelguruTask::getAvgScoresQ($user_id, $course_id);
         $avg_quizzes_cert = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($avg_quizzes_cert);
         $db->query();
         $avg_quizzes_cert = $db->loadResult();
         $sql = "SELECT id_final_exam FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $result = $db->loadResult();
         $sql = "SELECT hasquiz from #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($sql);
         $resulthasq = $db->loadResult();
         $sql = "SELECT max_score FROM #__guru_quiz WHERE id=" . intval($result);
         $db->setQuery($sql);
         $result_maxs = $db->loadResult();
         $sql = "SELECT id, score_quiz, time_quiz_taken_per_user  FROM #__guru_quiz_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($result) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1";
         $db->setQuery($sql);
         $result_q = $db->loadObject();
         $first = explode("|", @$result_q->score_quiz);
         @($res = intval($first[0] / $first[1] * 100));
         if ($resulthasq == 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && $scores_avg_quizzes == "") {
             $avg_certc1 = "N/A";
         } elseif ($resulthasq != 0 && isset($scores_avg_quizzes)) {
             if ($scores_avg_quizzes >= intval($avg_quizzes_cert)) {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             } else {
                 $avg_certc1 = $scores_avg_quizzes . '%';
             }
         }
         if ($result != 0 && $res != "") {
             if ($res >= $result_maxs) {
                 $avg_certc = $res . '%';
             } elseif ($res < $result_maxs) {
                 $avg_certc = $res . '%';
             }
         } elseif ($result != 0 && $result != "") {
             $avg_certc = "N/A";
         } elseif ($result == 0 || $result == "") {
             $avg_certc = "N/A";
         }
         $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
         $db->setQuery($firstnamelastname);
         $db->query();
         $firstnamelastname = $db->loadAssocList();
         $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
         $db->setQuery($coursemsg);
         $db->query();
         $coursemsg = $db->loadResult();
         $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid;
         $certificate_url = str_replace(" ", "%20", $certificate_url);
         $imagename[0]["templates1"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc1, $imagename[0]["templates1"]);
         $imagename[0]["templates1"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates1"]);
         while (ob_get_level()) {
             ob_end_clean();
         }
         header("Content-Encoding: None", true);
         if (strlen($imagename[0]["design_text_color"]) == 3) {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 1) . substr($imagename[0]["design_text_color"], 0, 1));
             $g = hexdec(substr($imagename[0]["design_text_color"], 1, 1) . substr($imagename[0]["design_text_color"], 1, 1));
             $b = hexdec(substr($imagename[0]["design_text_color"], 2, 1) . substr($imagename[0]["design_text_color"], 2, 1));
         } else {
             $r = hexdec(substr($imagename[0]["design_text_color"], 0, 2));
             $g = hexdec(substr($imagename[0]["design_text_color"], 2, 2));
             $b = hexdec(substr($imagename[0]["design_text_color"], 4, 2));
         }
         $background_color = explode(":", $background_color);
         $background_color[1] = str_replace("#", "", $background_color[1]);
         if (strlen($background_color[1]) == 3) {
             $rg = hexdec(substr($background_color[1], 0, 1) . substr($background_color[1], 0, 1));
             $gg = hexdec(substr($background_color[1], 1, 1) . substr($background_color, 1, 1));
             $bg = hexdec(substr($background_color[1], 2, 1) . substr($background_color[1], 2, 1));
         } else {
             $rg = hexdec(substr($background_color[1], 0, 2));
             $gg = hexdec(substr($background_color[1], 2, 2));
             $bg = hexdec(substr($background_color[1], 4, 2));
         }
         if ($imagename[0]["library_pdf"] == 0) {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "fpdf.php";
             $pdf = new PDF('L', 'mm', 'A5');
             $pdf->SetFont($imagename[0]["font_certificate"], '', 12);
             $pdf->SetTextColor($r, $g, $b);
             //set up a page
             $pdf->AddPage();
             if ($image_theme != "") {
                 $pdf->Image(JUri::base() . "images/stories/guru/certificates/" . $image_theme, -4, -1, 210, 150);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             $pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->WriteHTML(iconv('UTF-8', 'ISO-8859-1', $imagename[0]["templates1"]), true);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
         } else {
             require JPATH_SITE . DS . "components" . DS . "com_guru" . DS . "helpers" . DS . "MPDF" . DS . "mpdf.php";
             $pdf = new mPDF('utf-8', 'A4-L');
             $imagename[0]["templates1"] = '<style> body { font-family:"' . strtolower($imagename[0]["font_certificate"]) . '" ; color: rgb(' . $r . ', ' . $g . ', ' . $b . '); }</style>' . $imagename[0]["templates1"];
             //set up a page
             $pdf->AddPage('L');
             if ($image_theme != "") {
                 $pdf->Image(JPATH_BASE . "/images/stories/guru/certificates/" . $image_theme, 0, 0, 298, 210, 'jpg', '', true, false);
                 //$pdf->Cell(0,75,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C');
             } else {
                 $pdf->SetFillColor($rg, $gg, $bg);
                 //$pdf->Cell(0,115,JText::_("GURU_CERTIFICATE_OF_COMPLETION"),0,1,'C',true);
             }
             //$pdf->Ln(20);
             $pdf->SetXY(100, 50);
             $pdf->SetDisplayMode('fullpage');
             $pdf->WriteHTML($imagename[0]["templates1"]);
             $pdf->Output('certificate' . $certificateid . '.pdf', 'D');
             exit;
         }
     }
 }