private function create_ex_coupon($vendor_id)
 {
     $pdf = new PDF_Code128();
     // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
     $pdf->AddFont('angsana', '', 'angsa.php');
     // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
     $pdf->AddFont('angsana', 'B', 'angsab.php');
     $pdf->AddFont('angsana', 'I', 'angsai.php');
     $pdf->AddFont('angsana', 'BI', 'angsaz.php');
     //สร้างหน้าเอกสาร
     $pdf->AddPage();
     $sql = "\tSELECT sc.deal_start,\n\t\t\t\t\t\t\t\t\tsc.deal_expile,\n\t\t\t\t\t\t\t\t\tsc.round_start,\n\t\t\t\t\t\t\t\t\tsc.round_end,\n\t\t\t\t\t\t\t\t\tsc.deal_name,\n\t\t\t\t\t\t\t\t\tp.product_name,\n\t\t\t\t\t\t\t\t\tp.product_detail,\n\t\t\t\t\t\t\t\t\tv.vendor_id,\n\t\t\t\t\t\t\t\t\tv.vendor_name,\n\t\t\t\t\t\t\t\t\tv.vendor_contact_fname,\n\t\t\t\t\t\t\t\t\tv.vendor_contact_sname,\n\t\t\t\t\t\t\t\t\tv.vendor_email,\n\t\t\t\t\t\t\t\t\tv.vendor_address,\n\t\t\t\t\t\t\t\t\tv.vendor_website,\n\t\t\t\t\t\t\t\t\tv.vendor_logo,\n\t\t\t\t\t\t\t\t\tv.vendor_map,\n\t\t\t\t\t\t\t\t\tv.vendor_about_us,\n\t\t\t\t\t\t\t\t\tv.vendor_pay_type,\n\t\t\t\t\t\t\t\t\td.deal_main_detail,\n\t\t\t\t\t\t\t\t\td.deal_main_condition\n\t\t\t\t\t\tFROM view_sell_coupon sc\n\t\t\t\t\t\tLEFT JOIN tbl_vendor_profile v ON sc.vendor_id\t=\tv.vendor_id\n\t\t\t\t\t\tLEFT JOIN tbl_deal_product p ON p.deal_id = sc.deal_id\n\t\t\t\t\t\tLEFT JOIN tbl_deal_main d ON sc.deal_id = d.deal_id\n\t\t\t\t\t\tWHERE v.vendor_id = '" . $vendor_id . "'\n\t\t\t\t\t\tORDER BY sc.round_id DESC\n\t\t\t\t\t\tLIMIT 0,1";
     $query = $this->db->query($sql);
     $data = $query->row_array();
     $year = date("Y", time()) + 543;
     $year = substr($year, 2);
     $deal_name = $data["deal_name"];
     $vendor_logo = $data["vendor_logo"];
     $location = $data["vendor_address"];
     $fine_print = $data["deal_main_detail"];
     $deal_main_condition = $data["deal_main_condition"];
     $vendor_email = $data["vendor_email"];
     $vendor_website = $data["vendor_website"];
     $mem_name = "คุณ xxxxxxxxxxx xxxxxxxxxxxxx";
     $member_id = $year . "0000xx";
     $coupon = "1";
     $coupon_c = "0000" . rand("1000", "9999");
     $coupon_price = "00" . rand("1000", "9999") . "00";
     $barcode = $coupon_c . $coupon_price;
     $voucher_number = $vendor_id . "-0000xx";
     $order_id = $year . date("m", time()) . "0000xx";
     $redemption_code = rand("1111", "9999");
     $product_name = $data["product_name"];
     $product_detail = $data["product_detail"];
     $coupon_can_use = $data["deal_start"];
     $coupon_expire = $data["deal_expile"];
     $coupon_can_use_full = $this->thai_date(strtotime(date_format(date_create($coupon_can_use), "Y-m-d")));
     $coupon_expire_full = $this->thai_date(strtotime(date_format(date_create($coupon_expire), "Y-m-d")));
     unset($coupon_data);
     $image1 = " ../../assets/images/company_logo.png";
     $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 30);
     $Line_V = " ../../assets/images/Line_Vertical.png";
     $pdf->Image($Line_V, 100, 0, 1.6);
     $Line_H = " ../../assets/images/Line_H.png";
     $pdf->Image($Line_H, 0, 105, 180);
     // กำหนดฟอนต์
     $pdf->SetFont('angsana', '', 11);
     // พิมพ์ข้อความลงเอกสาร
     $pdf->setXY(10, 33);
     //$pdf->MultiCell( 70  , 4 , iconv( 'UTF-8','cp874' , $product_detail),0,'L' );
     $pdf->SetFont('angsana', '', 9);
     $pdf->Ln(3);
     $pdf->MultiCell(70, 4, iconv('UTF-8', 'cp874', $deal_name . "   # " . $product_name));
     $pdf->setXY(10, 59);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'PURCHASED BY:'));
     $pdf->setXY(10, 69);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'VOUCHER NUMBER:'));
     $pdf->setXY(40, 69);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'ORDER ID:'));
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(10, 81);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'CUSTOMER ID:'));
     $pdf->setXY(40, 81);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'REDEMPTION CODE:'));
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(10, 63);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $mem_name));
     $pdf->SetFont('angsana', '', 15);
     $pdf->setXY(10, 73);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $voucher_number));
     $pdf->setXY(40, 73);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $order_id));
     $pdf->SetFont('angsana', '', 13);
     $pdf->setXY(10, 85);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $member_id));
     $pdf->setXY(40, 85);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $redemption_code));
     // วาดรูปกรอกสี่เหลี่ยม
     $pdf->SetDrawColor(195, 195, 195);
     $pdf->SetLineWidth(0.2835);
     $pdf->Rect(107, 19, 70, 23, 'D');
     if (!empty($barcode)) {
         $pdf->Code128(116, 22, $barcode, 52, 11);
         $pdf->SetFont('angsana', '', 10);
         $pdf->setXY(156, 35);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'BARCODE'));
         $pdf->setXY(148, 38);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $barcode));
     }
     $pdf->SetFont('angsana', '', 10);
     $pdf->setXY(110, 48);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'สงวนสิทธิ์ไม่คืนเงินสำหรับคูปองที่ไม่ได้ใช้งานในระยะเวลา'));
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(110, 55);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'VALID FROM:'));
     $pdf->SetFont('angsana', '', 20);
     $pdf->SetTextColor(255, 0, 0);
     $pdf->setXY(109, 60);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $coupon_can_use_full . ' to ' . $coupon_expire_full));
     // วาดรูปกรอกสี่เหลี่ยม
     $pdf->SetDrawColor(195, 195, 195);
     $pdf->SetLineWidth(0.2835);
     $pdf->Rect(107, 68, 70, 31, 'D');
     $pdf->SetFont('angsana', '', 14);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->setXY(130, 71);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Need Assistance?'));
     $pdf->SetFont('angsana', '', 9);
     $pdf->setXY(116, 76);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Call Thebestdeal1 : 02 938 4399 | Email : info@thebestdeal1.com'));
     $image2 = " ../../assets/images/thebestdeal1.png";
     $pdf->Image($image2, 123, 79, 15);
     $image3 = " ../../assets/images/facebook.png";
     $pdf->Image($image3, 147, 79, 15);
     $pdf->SetFont('angsana', '', 10);
     $pdf->setXY(121, 95);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Thebestdeal1.com'));
     $pdf->SetFont('angsana', '', 10);
     $pdf->setXY(149, 95);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Facebook'));
     /*	
     				 	$pdf->SetFont('angsana','',10);
     					$pdf->setXY( 10, 100  );
     					$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , '--------------------------------------------------------------------------------------------------------------------------------------------') ); 
     */
     $pdf->SetFont('angsana', 'B', 14);
     $pdf->setXY(8, 110);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Fine Print:'));
     $pdf->SetFont('angsana', 'B', 14);
     $pdf->setXY(105, 110);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Location:'));
     $pdf->SetFont('angsana', '', 12);
     $pdf->setXY(105, 140);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Email :'));
     $pdf->SetFont('angsana', '', 12);
     $pdf->setXY(115, 140);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $vendor_email));
     $pdf->SetFont('angsana', '', 12);
     $pdf->setXY(105, 145);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Website :'));
     $pdf->SetFont('angsana', '', 12);
     $pdf->setXY(118, 145);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $vendor_website));
     $fine_print = $this->clear_text_editor($fine_print);
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(8, 115);
     $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874//TRANSLIT//IGNORE', $fine_print), 0, 'L');
     $location = $this->clear_text_editor($location);
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(105, 113);
     $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874//TRANSLIT//IGNORE', $location), 0, 'L');
     $pdf->SetFont('angsana', 'B', 14);
     $pdf->setXY(105, 161);
     $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Other:'));
     $deal_main_condition = $this->clear_text_editor($deal_main_condition);
     $pdf->SetFont('angsana', '', 11);
     $pdf->setXY(105, 165);
     $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874//TRANSLIT//IGNORE', $deal_main_condition), 0, 'L');
     unlink($_SERVER["DOCUMENT_ROOT"] . "/assets/media/vendor_pdf/" . $vendor_id . ".pdf");
     $pdf->Output($_SERVER["DOCUMENT_ROOT"] . "/assets/media/vendor_pdf/" . $vendor_id . ".pdf", "F");
     chmod($_SERVER["DOCUMENT_ROOT"] . "/assets/media/vendor_pdf/" . $vendor_id . ".pdf", 0777);
 }
 /**
  * @return void
  * @param integer $linha
  */
 private function _gerarLinha()
 {
     $yRec = 1.6;
     $xRec = 1.6;
     $yImagem = $yRec + 0.3;
     $xImagem = $xRec + 0.3;
     $yHeader = $yRec + 0.5;
     $xHeader = $xRec + 1.8;
     $yTexto = $yRec + 1.5;
     $xTexto = $xRec + 0.3;
     $hRec = 6;
     // Linhas para interessados, cada caracter ocupa em média 1.51cm
     // A etiqueta possui 11.4cm para escrita na horizontal, que seria igual a 75 caracteres.
     $listLinhasInteressados = array();
     $llinhaInteressados = 0;
     $lchar = 75;
     $lstop = false;
     $this->_txInteressado = "Interessados: " . $this->_txInteressado;
     if (strlen($this->_txInteressado) > $lchar) {
         if ($llinhaInteressados == count($listLinhasInteressados)) {
             $lchar = 75;
             $lstop = true;
         }
         $listInteressados = explode(",", $this->_txInteressado);
         $txInteressadoLinha = "";
         foreach ($listInteressados as $key => $txInteressado) {
             $txInteressadoLinha .= $txInteressado;
             $endValue = end($listInteressados);
             if (strlen($txInteressadoLinha) < $lchar) {
                 if ($lstop && $endValue != $txInteressado) {
                     $txInteressadoLinha .= " e outros";
                 }
                 $listLinhasInteressados[] = $txInteressadoLinha;
                 $txInteressadoLinha = "";
             } else {
                 if (!$lstop && $endValue != $txInteressado) {
                     $txInteressadoLinha .= ", ";
                 } else {
                     $listWordsInteressado = explode(' ', $txInteressadoLinha);
                     $txLinhaDoInteressadoLen = "";
                     $txLinhaDoInteressadoTex = "";
                     foreach ($listWordsInteressado as $key => $word) {
                         $txLinhaDoInteressadoLen .= $word . " ";
                         if (strlen($txLinhaDoInteressadoLen) < $lchar) {
                             $txLinhaDoInteressadoTex .= $word . " ";
                             if ($listWordsInteressado[$key] == end($listWordsInteressado)) {
                                 $txLinhaDoInteressadoTex = rtrim($txLinhaDoInteressadoTex);
                                 $listLinhasInteressados[] = $txLinhaDoInteressadoTex;
                                 $txLinhaDoInteressadoTex = "";
                                 $txLinhaDoInteressadoLen = "";
                             }
                         } else {
                             $listLinhasInteressados[] = $txLinhaDoInteressadoTex;
                             $txLinhaDoInteressadoTex = "";
                             $txLinhaDoInteressadoLen = "";
                         }
                     }
                 }
             }
             if ($lstop) {
                 break;
             }
         }
     } else {
         $listLinhasInteressados[] = $this->_txInteressado;
     }
     // linhas para assunto complementar
     $listLinhasAssuntoCompl = array();
     $llinhaAssunto = 1;
     $lchar = 75;
     $lstop = false;
     $txAssuntoComplLabel = "Assunto Complementar: ";
     if (strlen($this->_txAssuntoComplementar) > 0) {
         $this->_txAssuntoComplementar = mb_strtoupper($this->_txAssuntoComplementar, 'UTF-8');
         $this->_txAssuntoComplementar = preg_replace('/\\s+/', " ", $this->_txAssuntoComplementar);
         $this->_txAssuntoComplementar = $txAssuntoComplLabel . $this->_txAssuntoComplementar;
     }
     if (strlen($this->_txAssuntoComplementar) > $lchar) {
         $listWords = explode(" ", $this->_txAssuntoComplementar);
         $totalWords = count($listWords) - 1;
         $linhaAssunto = "";
         foreach ($listWords as $key => $word) {
             $lenlinha = strlen($linhaAssunto);
             $lenword = strlen($word);
             $endvalue = end($listWords);
             $lcharC = $lchar;
             if ($key == 0) {
                 $lcharC = $lchar - strlen($txAssuntoComplLabel);
             }
             if ($lenlinha + $lenword <= $lcharC) {
                 $linhaAssunto .= " " . $word;
             } else {
                 $listLinhasAssuntoCompl[] = utf8_decode($linhaAssunto);
                 $linhaAssunto = " " . $word;
             }
             if ($key == $totalWords && $endvalue == $word) {
                 $listLinhasAssuntoCompl[] = utf8_decode($linhaAssunto);
             }
         }
     } else {
         if (strlen($this->_txAssuntoComplementar) > 0) {
             $listLinhasAssuntoCompl[] = utf8_decode($this->_txAssuntoComplementar);
         }
     }
     // POSICIONAMENTO DO QUADRO
     $totYTex = $yTexto + 0.35 * (12 + count($listLinhasInteressados) + count($listLinhasAssuntoCompl));
     $diffHRec = ($totYTex - ($hRec + $yRec)) / 2;
     $yHeader -= ($totYTex - ($hRec + $yRec)) / 2;
     $yRec -= $diffHRec + 0.15;
     $xImagem -= ($totYTex - ($hRec + $yRec)) / 2 - 0.2;
     $yTexto = $yHeader + count($this->_listTxHeader) * 0.35;
     $this->_pdf->Image($this->_flLogo, $yImagem, $xImagem, 1);
     foreach ($this->_listTxHeader as $txHeader) {
         $this->_pdf->SetFont('Arial', 'B', 8);
         $this->_pdf->Text($xHeader, $yHeader, utf8_decode($txHeader));
         $yHeader += 0.35;
     }
     if (!is_null($this->getCoAmbitoProcesso()) && $this->getCoAmbitoProcesso() != 'F') {
         $nuEtiqueta = $this->_nuArtefato;
     } else {
         $nuEtiqueta = $this->_maskNumber->filter($this->_nuArtefato);
     }
     $this->_pdf->SetFont("Arial", "B", 8);
     $yTexto += 0.5;
     $labelNrProcesso = utf8_decode("Número do Processo: ");
     $this->_pdf->Text($xTexto, $yTexto, $labelNrProcesso . $nuEtiqueta);
     $yTexto += 0.35;
     $this->_pdf->Text($xTexto, $yTexto, utf8_decode("Autuação: ") . $this->_dtAutuacao);
     foreach ($listLinhasInteressados as $key => $txLinhaInteressado) {
         if ($txLinhaInteressado != end($listLinhasInteressados)) {
             $txLinhaInteressado .= " ";
         } else {
             $txLinhaInteressado .= ".";
         }
         $yTexto += 0.35;
         $this->_pdf->Text($xTexto, $yTexto, utf8_decode($txLinhaInteressado));
     }
     $yTexto += 0.35;
     $this->_pdf->Text($xTexto, $yTexto, "Assunto: " . utf8_decode($this->_txAssunto));
     $this->_pdf->SetFont("Arial", "B", 7);
     if (count($listLinhasAssuntoCompl)) {
         foreach ($listLinhasAssuntoCompl as $txLinhaAssuntoCompl) {
             $yTexto += 0.35;
             $this->_pdf->Text($xTexto, $yTexto, trim($txLinhaAssuntoCompl));
         }
     }
     // Dados da Digital
     $this->_pdf->SetFont("Arial", "B", 8);
     $yTexto += 0.35;
     $digital = $this->getDocumentoAutuado();
     if ($digital instanceof \Sgdoce\Model\Entity\Artefato) {
         $nuDigital = $digital->getNuDigital()->getNuEtiqueta();
         if (strlen($nuDigital) <= 7) {
             $nuDigital = str_pad($nuDigital, 7, "0", STR_PAD_LEFT);
         }
         $nuDigitalLinha = "Digital: " . $nuDigital;
         $tipoDocumentoLinha = " Tipo: " . $digital->getSqTipoDocumento()->getNoTipoDocumento();
         $nuArtefatoLinha = "Número: " . $digital->getNuArtefato();
         if (strlen($nuDigitalLinha . $tipoDocumentoLinha . $nuArtefatoLinha) > 68) {
             $text = $nuDigitalLinha . $tipoDocumentoLinha;
             $text = utf8_decode($text);
             $this->_pdf->Text($xTexto, $yTexto, $text);
             $yTexto += 0.35;
             $text = $nuArtefatoLinha;
             $text = utf8_decode($text);
             $this->_pdf->Text($xTexto, $yTexto, $text);
         } else {
             $text = $nuDigitalLinha . $tipoDocumentoLinha . " - " . $nuArtefatoLinha;
             $text = utf8_decode($text);
             $this->_pdf->Text($xTexto, $yTexto, $text);
         }
     }
     $yTexto += 0.2;
     $this->_pdf->Code128($xTexto + 1.8, $yTexto, $this->_nuArtefato, 7.9, 0.9);
     $yTexto += 1.25;
     $this->_pdf->SetFont("Arial", "", 9);
     $this->_pdf->Text($xTexto + 3.8, $yTexto, $nuEtiqueta);
     $this->_pdf->Rect($xRec, $yRec, 11.8, $hRec + $diffHRec * 0.6);
 }
 /**
  * @return TPDocumento
  * @param array $content
  */
 public function generatePDF($content)
 {
     define('FPDF_FONTPATH', 'bibliotecas/fpdf/font/');
     include 'bibliotecas/fpdf/fpdf.php';
     include 'bibliotecas/barcode/code128.php';
     $this->filename = $filename = sprintf('%s/TMP/%s.pdf', __CAM_UPLOAD__, CFUtils::random());
     $this->newname = sprintf('%s/0%s', $this->generateRepositoryForDigital($content['DIGITAL']), CFUtils::random());
     $pdf = new PDF_Code128();
     $pdf->SetFont('times', '', 12);
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $pdf->ln(2);
     $pdf->SetFont('Arial', '', 9);
     $pdf->Text(170, 12, __ETIQUETA__);
     $pdf->Code128(165, 14, $content['DIGITAL'], 30, 9);
     $pdf->Text(173, 27, $content['DIGITAL']);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->Cell(180, 5, '', 0, 0, 'R');
     $pdf->Cell(5, 5, '', 0, 1, 'L');
     $pdf->Image("imagens/" . __LOGO_JPG__, 95, 8, 20, 20);
     $pdf->Ln(20);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(22, 5, "Digital: ", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(100, 5, $content['DIGITAL'], 0, 0, 'L');
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(18, 5, "Data do Documento:  ", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(40, 5, CFUtils::formatDate($content['DT_DOCUMENTO']), 0, 1, 'R');
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(22, 5, "Origem:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(100, 5, utf8_decode($content['ORIGEM']), 0, 0, 'L');
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(18, 5, utf8_decode("Número Solicitação:  "), 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(40, 5, utf8_decode($content['NUMERO']), 0, 1, 'R');
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(22, 5, "Interessado:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(100, 5, utf8_decode($content['INTERESSADO']), 0, 0, 'L');
     $pdf->Ln();
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->Cell(22, 5, "Assunto:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->MultiCell(165, 5, utf8_decode($content['ASSUNTO']), 0, 1);
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->Cell(35, 5, "Assunto Complementar:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->MultiCell(165, 5, utf8_decode($content['ASSUNTO_COMPLEMENTAR']), 0, 1);
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->Cell(22, 5, "Prioridade:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->MultiCell(165, 5, utf8_decode($content['NM_PRIORIDADE']), 0, 1);
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(5, 5, '', 0, 0, 'C');
     $pdf->Cell(22, 5, "Data do Prazo:", 0, 0, 'L');
     $pdf->SetFont("Arial", '', 8);
     $pdf->MultiCell(165, 5, CFUtils::formatDate($content['DT_PRAZO']), 0, 1);
     $pdf->Ln();
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(195, 5, utf8_decode("Informações do Documento"), 0, 1, 'C');
     $pdf->Ln();
     $pdf->Cell(8, 5, '', 0, 0, 'C');
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(40, 5, 'Ao ' . utf8_decode($content['DESTINO']), 0, 1, 'L');
     $pdf->Ln();
     $pdf->SetFont("Arial", '', 8);
     $pdf->Cell(8, 5, '', 0, 0, 'L');
     $pdf->Write(5, utf8_decode($content['SOLICITACAO']));
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetFont("Arial", "B", 8);
     $pdf->Cell(8, 5, '', 0, 0, 'L');
     $pdf->Write(5, utf8_decode($content['NOME']));
     $pdf->Output($filename, 'F');
     return $this;
 }
Exemple #4
0
<?php

require 'code128.php';
$pdf = new PDF_Code128();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 10);
//A set
$code = 'CODE 128';
$pdf->Code128(50, 20, $code, 80, 20);
$pdf->SetXY(50, 45);
$pdf->Write(5, 'A set: "' . $code . '"');
//B set
$code = 'Code 128';
$pdf->Code128(50, 70, $code, 80, 20);
$pdf->SetXY(50, 95);
$pdf->Write(5, 'B set: "' . $code . '"');
//C set
$code = '12345678901234567890';
$pdf->Code128(50, 120, $code, 110, 20);
$pdf->SetXY(50, 145);
$pdf->Write(5, 'C set: "' . $code . '"');
//A,C,B sets
$code = 'ABCDEFG1234567890AbCdEf';
$pdf->Code128(50, 170, $code, 125, 20);
$pdf->SetXY(50, 195);
$pdf->Write(5, 'ABC sets combined: "' . $code . '"');
$pdf->Output();
Exemple #5
0
$y_pos = 0;
$pdf->SetMargins(0, 0, 0, 0);
foreach ($data as $key) {
    if ($x_pos == 0 && $y_pos == 0) {
        $pdf->AddPage();
    }
    $pdf->Line(70 + $x_pos, 5 + $y_pos, 5 + $x_pos, 5 + $y_pos);
    // garis hor atas
    $pdf->Line(70 + $x_pos, 35 + $y_pos, 5 + $x_pos, 35 + $y_pos);
    // garis hor bawah
    $pdf->Line(5 + $x_pos, 35 + $y_pos, 5 + $x_pos, 5 + $y_pos);
    // garis ver kiri
    $pdf->Line(70 + $x_pos, 5 + $y_pos, 70 + $x_pos, 35 + $y_pos);
    // garis ver kanan
    $pdf->SetFont('Arial', 'B', 13);
    $pdf->Text(7 + $x_pos, 10 + $y_pos, "Kartu Anggota Ojek");
    $pdf->SetFont('Arial', '', 8);
    $pdf->Text(7 + $x_pos, 15 + $y_pos, 'Nama Lengkap : ' . $key->namalengkap . " " . $key->id);
    $pdf->Text(7 + $x_pos, 20 + $y_pos, 'No. HP : ' . $key->nohp);
    $pdf->Text(7 + $x_pos, 25 + $y_pos, 'Jenis Kelaimin : ' . $key->kelamin);
    $pdf->Code128(7 + $x_pos, 28 + $y_pos, $key->nohp, 40, 5);
    $x_pos = $x_pos + 70;
    if ($x_pos >= 150) {
        $x_pos = 0;
        $y_pos = $y_pos + 35;
        if ($y_pos >= 340) {
            $y_pos = 0;
        }
    }
}
$pdf->Output();
Exemple #6
0
 /**
  * @return void
  * @param integer $linha
  */
 private function _gerarLinhasComNUP($linha)
 {
     switch ($linha) {
         case 1:
             $yImagem = 1.8;
             $yTexto = $yImagem - 0.1;
             break;
         case 2:
             $yImagem = 3.8;
             $yTexto = $yImagem - 0.1;
             break;
         case 3:
             $yImagem = 6.0;
             $yTexto = $yImagem - 0.1;
             break;
         case 4:
             $yImagem = 8.1;
             $yTexto = $yImagem - 0.1;
             break;
         case 5:
             $yImagem = 10.3;
             $yTexto = $yImagem - 0.1;
             break;
         case 6:
             $yImagem = 12.3;
             $yTexto = $yImagem - 0.1;
             break;
         case 7:
             $yImagem = 14.5;
             $yTexto = $yImagem - 0.1;
             break;
         case 8:
             $yImagem = 16.5;
             $yTexto = $yImagem - 0.1;
             break;
         case 9:
             $yImagem = 18.7;
             $yTexto = $yImagem - 0.1;
             break;
         case 10:
             $yImagem = 20.8;
             $yTexto = $yImagem - 0.1;
             break;
         case 11:
             $yImagem = 22.9;
             $yTexto = $yImagem - 0.1;
             break;
         case 12:
             $yImagem = 25.0;
             $yTexto = $yImagem - 0.1;
             break;
         case 13:
             $yImagem = 27.2;
             $yTexto = $yImagem - 0.1;
             break;
     }
     $xImagemNup = 0.9;
     $xImagemEtiqueta = 1.9;
     $xTextoNup = 0.8;
     $xTextoEtiqueta = 2.35;
     $xTextoRotated = 0.65;
     $widthBarcodeDigital = 2;
     $widthBarcodeNup = 3;
     $heigthBarcode = 0.4;
     for ($ws = 1; $ws <= 5; $ws++) {
         if (isset($this->_digitais[$this->_count])) {
             $nuEtiqueta = $this->_digitais[$this->_count]['nuEtiqueta'];
             $nuNUP = $this->_digitais[$this->_count]['nuNupSiorg'];
             $nuNUPMask = $this->_maskNumber->filter($nuNUP);
             if ($ws != 5) {
                 $this->_rotatedText($xTextoRotated, $yTexto + 1.2, $this->_textoEtiqueta, 90);
                 $this->_pdf->Text($xTextoNup, $yTexto, $nuNUPMask);
                 $this->_pdf->Code128($xImagemNup, $yImagem, $nuNUP, $widthBarcodeNup, $heigthBarcode);
                 $this->_pdf->Code128($xImagemEtiqueta, $yImagem + 0.5, $nuEtiqueta, $widthBarcodeDigital, $heigthBarcode);
                 $this->_pdf->Text($xTextoEtiqueta, $yTexto + 1.2, $nuEtiqueta);
                 $this->_count++;
                 if ($ws != 4) {
                     if ($ws == 1) {
                         $xImagemNup = $xImagemNup + 4.1;
                         $xImagemEtiqueta = $xImagemEtiqueta + 4.1;
                         $xTextoNup = $xTextoNup + 4.1;
                         $xTextoEtiqueta = $xTextoEtiqueta + 4.1;
                         $xTextoRotated = $xTextoRotated + 4.1;
                     } else {
                         if ($ws != 2) {
                             $xImagemNup = $xImagemNup + 4.1;
                             $xImagemEtiqueta = $xImagemEtiqueta + 4.1;
                             $xTextoNup = $xTextoNup + 4.1;
                             $xTextoEtiqueta = $xTextoEtiqueta + 4.1;
                             $xTextoRotated = $xTextoRotated + 4.1;
                         } else {
                             //3º Coluna de etiqueta
                             $xImagemNup = $xImagemNup + 4.1;
                             $xImagemEtiqueta = $xImagemEtiqueta + 4.1;
                             $xTextoNup = $xTextoNup + 4.1;
                             $xTextoEtiqueta = $xTextoEtiqueta + 4.1;
                             $xTextoRotated = $xTextoRotated + 4.1;
                         }
                     }
                 }
             } else {
                 $xImagemNup = $xImagemNup + 4.1;
                 $xImagemEtiqueta = $xImagemEtiqueta + 4.1;
                 $xTextoNup = $xTextoNup + 4.1;
                 $xTextoEtiqueta = $xTextoEtiqueta + 4.1;
                 $xTextoRotated = $xTextoRotated + 4.1;
                 $yImagem = $yImagem;
                 $this->_rotatedText($xTextoRotated, $yTexto + 1.2, $this->_textoEtiqueta, 90);
                 $this->_pdf->Text($xTextoNup, $yTexto, $nuNUPMask);
                 $this->_pdf->Code128($xImagemNup, $yImagem, $nuNUP, $widthBarcodeNup, $heigthBarcode);
                 $this->_pdf->Code128($xImagemEtiqueta, $yImagem + 0.5, $nuEtiqueta, $widthBarcodeDigital, $heigthBarcode);
                 $this->_pdf->Text($xTextoEtiqueta, $yTexto + 1.2, $nuEtiqueta);
                 $this->_count++;
             }
         }
     }
 }
                      b.harga LIKE "%'.$b_harga.'%" and
                      b.sumber LIKE "%'.$b_sumber.'%" and
                      b.kondisi LIKE "%'.$b_kondisi.'%" and
                      b.status LIKE "%'.$b_status.'%" and
                      b.keterangan LIKE "%'.$b_keterangan.'%"';  

                  $e = mysql_query($s) or die(mysql_error());
                  $n = mysql_num_rows($e);
      $pdf = new FPDF('L','mm','A4');
      $pdf=new PDF_Code128();
      $pdf->AddPage();
      $pdf->SetFont('Arial','',6);
      $pdf->Ln();

              $barkode = $r['barkode'];
$pdf->Code128(50,20,$code,80,20);
          //         $out.=' <table border="1" width="50%">';
          //         // $nox = 1;
          //         if($n==0){
          //           $out.=' <tr>
          //                     <td colspan="2">-</td>
          //                   </tr>';
          //         }else{
          //           $kolom = 2;
          //           $counter = 1;
          //           while ($r=mysql_fetch_assoc($e)) {
          //             if (($counter-1) % $kolom == 0){
          //               $out.="<tr>";
          //             } 
          //             // $x = bar128(stripcslashes($r['barkode']));
          //             $out.="<td align='center' cellspacing='5' style='padding: 20px' width='20%'>";
 function printPDF($member_id = "", $deal_id = "", $coupon_id = "")
 {
     $pdf = new PDF_Code128();
     // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
     $pdf->AddFont('angsana', '', 'angsa.php');
     // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
     $pdf->AddFont('angsana', 'B', 'angsab.php');
     $pdf->AddFont('angsana', 'I', 'angsai.php');
     $pdf->AddFont('angsana', 'BI', 'angsaz.php');
     //สร้างหน้าเอกสาร
     $pdf->AddPage();
     if ($coupon_id != "") {
         $coupon_data = $this->coupon_main->get_coupon($member_id, $deal_id, $coupon_id);
         $deal_name = $coupon_data["deal_main"]["deal_name"];
         $vendor_logo = $coupon_data["deal_main"]["vendor_logo"];
         $location = $coupon_data["deal_main"]["location"];
         $fine_print = $coupon_data["deal_main"]["deal_main_detail"];
         $deal_main_condition = $coupon_data["deal_main"]["deal_main_condition"];
         $mem_name = $coupon_data["member"]["member_name"] . "   " . $coupon_data["member"]["member_sname"];
         $member_id = $coupon_data["member"]["member_id"];
         $coupon = $coupon_data["coupon"]["coupon_id"];
         $barcode = $coupon_data["coupon"]["barcode"];
         $voucher_number = $coupon_data["coupon"]["voucher_number"];
         $order_id = $coupon_data["coupon"]["order_id"];
         $redemption_code = $coupon_data["coupon"]["redemption_code"];
         $product_name = $coupon_data["coupon"]["product_name"];
         $product_detail = $coupon_data["coupon"]["product_detail"];
         $coupon_can_use = $coupon_data["coupon"]["coupon_can_use"];
         $coupon_expire = $coupon_data["coupon"]["coupon_expire"];
         $coupon_can_use_full = $this->thai_date(strtotime(date_format(date_create($coupon_can_use), "Y-m-d")));
         $coupon_expire_full = $this->thai_date(strtotime(date_format(date_create($coupon_expire), "Y-m-d")));
         unset($coupon_data);
         $image1 = " ../../assets/images/company_logo.png";
         $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 30);
         $Line_V = " ../../assets/images/Line_Vertical.png";
         $pdf->Image($Line_V, 100, 0, 1.6);
         $Line_H = " ../../assets/images/Line_H.png";
         $pdf->Image($Line_H, 0, 105, 180);
         // กำหนดฟอนต์
         $pdf->SetFont('angsana', '', 11);
         // พิมพ์ข้อความลงเอกสาร
         $pdf->setXY(10, 33);
         $pdf->MultiCell(90, 4, iconv('UTF-8', 'cp874', $product_detail), 0, 'L');
         $pdf->SetFont('angsana', '', 9);
         $pdf->Ln(2);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $product_name));
         $pdf->setXY(10, 51);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'PURCHASED BY:'));
         $pdf->setXY(10, 61);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'VOUCHER NUMBER:'));
         $pdf->setXY(40, 61);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'ORDER ID:'));
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(10, 73);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'CUSTOMER ID:'));
         $pdf->setXY(40, 73);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'REDEMPTION CODE:'));
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(10, 55);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $mem_name));
         $pdf->SetFont('angsana', '', 15);
         $pdf->setXY(10, 65);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $voucher_number));
         $pdf->setXY(40, 65);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $order_id));
         $pdf->SetFont('angsana', '', 13);
         $pdf->setXY(10, 77);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $member_id));
         $pdf->setXY(40, 77);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $redemption_code));
         // วาดรูปกรอกสี่เหลี่ยม
         $pdf->SetDrawColor(195, 195, 195);
         $pdf->SetLineWidth(0.2835);
         $pdf->Rect(107, 19, 70, 23, 'D');
         if (!empty($barcode)) {
             $pdf->Code128(116, 22, $barcode, 52, 11);
             $pdf->SetFont('angsana', '', 10);
             $pdf->setXY(156, 35);
             $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'BARCODE'));
             $pdf->setXY(148, 38);
             $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $barcode));
         }
         $pdf->SetFont('angsana', '', 10);
         $pdf->setXY(110, 48);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'สงวนสิทธิ์ไม่คืนเงินสำหรับคูปองที่ไม่ได้ใช้งานในระยะเวลา'));
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(110, 55);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'VALID FROM:'));
         $pdf->SetFont('angsana', '', 20);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->setXY(109, 60);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', $coupon_can_use_full . ' to ' . $coupon_expire_full));
         // วาดรูปกรอกสี่เหลี่ยม
         $pdf->SetDrawColor(195, 195, 195);
         $pdf->SetLineWidth(0.2835);
         $pdf->Rect(107, 68, 70, 31, 'D');
         $pdf->SetFont('angsana', '', 14);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->setXY(130, 71);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Need Assistance?'));
         $pdf->SetFont('angsana', '', 9);
         $pdf->setXY(116, 76);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Call Thebestdeal1 : 02 938 4399 | Email : info@thebestdeal1.com'));
         $image2 = " ../../assets/images/thebestdeal1.png";
         $pdf->Image($image2, 123, 79, 15);
         $image3 = " ../../assets/images/facebook.png";
         $pdf->Image($image3, 147, 79, 15);
         $pdf->SetFont('angsana', '', 10);
         $pdf->setXY(121, 95);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Thebestdeal1.com'));
         $pdf->SetFont('angsana', '', 10);
         $pdf->setXY(149, 95);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Facebook'));
         /*	$pdf->SetFont('angsana','',10);
         			$pdf->setXY( 10, 100  );
         			$pdf->MultiCell( 0  , 0 , iconv( 'UTF-8','cp874' , '--------------------------------------------------------------------------------------------------------------------------------------------') ); */
         $pdf->SetFont('angsana', 'B', 14);
         $pdf->setXY(8, 110);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Fine Print:'));
         $pdf->SetFont('angsana', 'B', 14);
         $pdf->setXY(105, 110);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Location:'));
         $fine_print = str_replace('&nbsp;', ' ', $fine_print);
         $fine_print = str_replace('&bull;', ' ', $fine_print);
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(8, 115);
         $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874//TRANSLIT//IGNORE', strip_tags($fine_print)), 0, 'L');
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(105, 113);
         $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874', strip_tags($location)), 0, 'L');
         $pdf->SetFont('angsana', 'B', 14);
         $pdf->setXY(105, 161);
         $pdf->MultiCell(0, 0, iconv('UTF-8', 'cp874', 'Other:'));
         $pdf->SetFont('angsana', '', 11);
         $pdf->setXY(105, 165);
         $pdf->MultiCell(90, 5, iconv('UTF-8', 'cp874', strip_tags($deal_main_condition)), 0, 'L');
         $pdf->Output();
     }
 }