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); }
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(' ', ' ', $fine_print); $fine_print = str_replace('•', ' ', $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(); } }