public function download($id) { $book = Book::with(array('chapter' => function ($query) { $query->orderBy('order', 'asc'); }, 'chapter.element' => function ($query) { $query->orderBy('order', 'asc'); }))->where("id", "=", $id)->get(); $view = View::make('pdf/result', array("book" => $book)); $pdf = new TCPDF(); $pdf->AddPage(); $pdf->writeHTML($view, true, false, true, false, ''); $filename = public_path() . '/pdf/test.pdf'; $pdf->output($filename, 'F'); return Response::download($filename); }
public function postAdicionar() { $pdf = new TCPDF(); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('GestBiblio - Sistema de Gestão de Bibliotecas'); $pdf->SetTitle('Comprovante de Imprestimo'); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->AddPage(); $html = ''; $pdf->Text(90, 140, 'This is a test'); $filename = storage_path() . '/test.pdf'; $pdf->output($filename, 'F'); return Response::view($filename); }
/** * [พิมพ์ post] * @param [type] $id [description] * @return [type] [description] */ public function printPost($id) { if (Session::get('c3') == 1) { $sql = ' select c.*, concat(n.pname,n.fname," ",n.lname) as fullname from c_blog_posts c left join n_datageneral n on n.cid=c.created_by'; $sql .= ' where postID =' . e($id) . ' '; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // set header and footer fonts $pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(15, 15, 15); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->AddPage(); $pdf->SetFont('angsanaupc', 'B', 16, '', true); $pdf->SetXY(15, 15); $pdf->MultiCell(180, 0, 'ใบประสานงานขอรถ', 0, 'C', 0, 1, '', '', true); $data = DB::select($sql); $pdf->SetFont('angsanaupc', '', 14, '', true); $tbl = '<br /><br /><table style="width: 100%; padding:2px;" cellspacing="0">'; foreach ($data as $key => $value) { $tbl = $tbl . '<tr> <td style="border: 0px solid #000000; text-align:left"> เรื่อง ' . $value->postTitle . '</td> </tr>'; $tbl = $tbl . '<tr> <td style="border: 0px solid #000000; text-align:left"> สร้างโดย ' . $value->fullname . ' วันที่ ' . date("d-m", strtotime($value->postDate)) . '-' . (date("Y", strtotime($value->postDate)) + 543) . ' เวลา ' . date("H:i:s", strtotime($value->postDate)) . '</td> </tr>'; $tbl = $tbl . '<tr> <td style="border: 0px solid #000000; text-align:left"> ' . $value->postDesc . '</td> </tr>'; } $tbl = $tbl . '</table>'; $pdf->writeHTML($tbl, true, false, false, false, ''); $filename = storage_path() . '/report_post.pdf'; $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); } else { return Redirect::to('contact'); } }
public function salary_sso_pdf_export() { $m = Input::get('m_sso_1'); $y = Input::get('y_sso_1'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); // set header and footer fonts $pdf->setHeaderFont(array('freeserif', 'B', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('freeserif', 'B', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(10, 15, 10); $pdf->SetHeaderMargin(15); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetFont('freeserif', '', 14, '', true); $n = DB::select('select * from s_general_data'); foreach ($n as $k) { $name = $k->name; } $sql = ' select s.cid, concat(n.pname,"",n.fname," ",n.lname) as name, (s.salary+s.salary_other) as salary, s.salary_sso '; $sql .= ' from s_salary_detail s'; $sql .= ' left join n_datageneral n on n.cid=s.cid'; $sql .= ' where year(order_date)=' . $y . ' and month(order_date)=' . $m . ' '; $data = DB::Select($sql); $j = 0; $row = 0; $sum1 = 0; $sum2 = 0; foreach ($data as $k) { $row++; if ($j == 30) { $j = 0; } if ($j == 0) { $pdf->AddPage('', 'A4'); //header $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(5); $pdf->SetX(160); $pdf->MultiCell(40, 5, 'สปส.1-10 (ส่วนที่ 2)', 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 14, '', true); $pdf->MultiCell(190, 5, 'แบบรายงานการแสดงการส่งเงินสมทบ ', 0, 'C', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(18); $pdf->MultiCell(190, 5, 'การนำส่งเงินสมทบสำหรับค่าจ้างเดิอน ' . $this->get_monthyearThai($m, $y), 0, 'C', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(30); $pdf->SetX(10); $pdf->MultiCell(40, 5, 'ชื่อสถานประกอบการ ', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(30); $pdf->SetX(50); $pdf->MultiCell(70, 5, $name, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(30); $pdf->SetX(140); $pdf->MultiCell(22, 5, 'เลขที่บัญชี', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(30); $pdf->SetX(163); $pdf->MultiCell(25, 5, '1090000219', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(36); $pdf->SetX(140); $pdf->MultiCell(22, 5, 'สาขา', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(36); $pdf->SetX(163); $pdf->MultiCell(25, 5, '300311', 0, 'L', 0, 1, '', '', true); $linever = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(200, 43, 10, 43, $linever); $pdf->Line(200, 50, 10, 50, $linever); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(43); $pdf->SetX(10); $pdf->MultiCell(20, 7, 'ลำดับที่', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(30); $pdf->MultiCell(40, 7, 'เลขประจำตัวประชาชน', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(70); $pdf->MultiCell(70, 7, 'ชื่อ-สกุล', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(140); $pdf->MultiCell(30, 7, 'ค่าจ้าง', 0, 'R', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(170); $pdf->MultiCell(30, 7, 'เงินสมทบ', 0, 'R', 0, 1, '', '', true); } //end add header //detail $pdf->SetY(50 + $j * 7.5); $pdf->SetX(10); $pdf->MultiCell(20, 7, $row, 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(30); $pdf->MultiCell(40, 7, $k->cid, 0, 'C', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(70, 7, $k->name, 0, 'L', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(140); $pdf->MultiCell(30, 7, number_format($k->salary, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(170); $pdf->MultiCell(30, 7, number_format($k->salary_sso, 2), 0, 'R', 0, 1, '', '', true); //end detail $sum1 = $sum1 + $k->salary; $sum2 = $sum2 + $k->salary_sso; $j++; } // end data //sum all $pdf->Line(200, 50 + $j * 7.5, 10, 50 + $j * 7.5, $linever); $pdf->Line(200, 56 + $j * 7.5, 10, 57 + $j * 7.5, $linever); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(70, 7, 'ยอดรวม', 0, 'C', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(140); $pdf->MultiCell(30, 7, number_format($sum1, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(170); $pdf->MultiCell(30, 7, number_format($sum2, 2), 0, 'R', 0, 1, '', '', true); //end sum all // $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(62 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(90, 5, 'ลงชื่อ.............................................................', 0, 'R', 0, 1, '', '', true); $pdf->SetY(62 + $j * 7.5); $pdf->SetX(160); $pdf->MultiCell(43, 5, 'นายจ้าง/ผู้รับมอบอำนาจ', 0, 'R', 0, 1, '', '', true); $pdf->SetY(70 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(90, 5, '(.............................................................)', 0, 'R', 0, 1, '', '', true); $pdf->SetY(82 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(120, 5, 'ยื่นแบบวันที่.............เดือน..............................พ.ศ..............', 0, 'C', 0, 1, '', '', true); $filename = storage_path() . '/salary_sso_pdf_export.pdf'; // Response::download($filename); $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); }
/** * Save PHPExcel to file * * @param string $pFilename Filename for the saved file * @throws Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file {$pFilename} for writing."); } // Set PDF $this->_isPdf = true; // Build CSS $this->buildCSS(true); // Generate HTML $html = ''; //$html .= $this->generateHTMLHeader(false); $html .= $this->generateSheetData(); //$html .= $this->generateHTMLFooter(); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } // Override Page Orientation if (!is_null($this->_orientation)) { $orientation = $this->_orientation == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; } // Override Paper Size if (!is_null($this->_paperSize)) { $printPaperSize = $this->_paperSize; } if (isset(self::$_paperSizes[$printPaperSize])) { $paperSize = self::$_paperSizes[$printPaperSize]; } // Create PDF $pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf->setFontSubsetting(false); // Set margins, converting inches to points (using 72 dpi) $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72); $pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72); // $pdf->setHeaderMargin($printMargins->getHeader() * 72); // $pdf->setFooterMargin($printMargins->getFooter() * 72); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); // Set the appropriate font $pdf->SetFont($this->_font); $pdf->writeHTML($html); // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); // Close file fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); }
/** * Save PHPExcel to file * * @param string $pFilename Name of the file to save as * @throws PHPExcel_Writer_Exception */ public function save($pFilename = NULL) { $fileHandle = parent::prepareForSave($pFilename); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; } // Override Paper Size if (!is_null($this->getPaperSize())) { $printPaperSize = $this->getPaperSize(); } if (isset(self::$_paperSizes[$printPaperSize])) { $paperSize = self::$_paperSizes[$printPaperSize]; } // Create PDF $pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf->setFontSubsetting(FALSE); // Set margins, converting inches to points (using 72 dpi) $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72); $pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72); $pdf->setPrintHeader(FALSE); $pdf->setPrintFooter(FALSE); $pdf->AddPage(); // Set the appropriate font $pdf->SetFont($this->getFont()); $pdf->writeHTML($this->generateHTMLHeader(FALSE) . $this->generateSheetData() . $this->generateHTMLFooter()); // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); parent::restoreStateAfterSave($fileHandle); }
/** * Send the document to a given destination: string, local file or browser. * In the last case, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced.<br /> * The method first calls Close() if necessary to terminate the document. * @param $name (string) The name of the file when saved. Note that special characters are removed and blanks characters are replaced with the underscore character. * @param $dest (string) Destination where to send the document. It can take one of the following values:<ul><li>I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.</li><li>D: send to the browser and force a file download with the name given by name.</li><li>F: save to a local server file with the name given by name.</li><li>S: return the document as a string (name is ignored).</li><li>FI: equivalent to F + I option</li><li>FD: equivalent to F + D option</li><li>E: return the document as base64 mime multi-part email attachment (RFC 2045)</li></ul> * @public * @since Moodle 1.0 * @see Close() */ public function Output($name = 'doc.pdf', $dest = 'I') { $olddebug = error_reporting(0); $result = parent::output($name, $dest); error_reporting($olddebug); return $result; }
/** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null) { $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file {$pFilename} for writing."); } // Build CSS $this->buildCSS(true); // Generate HTML $html = ''; //$html .= $this->generateHTMLHeader(false); $html .= $this->generateSheetData(); //$html .= $this->generateHTMLFooter(); // Default PDF paper size $paperSize = 'A4'; $orientation = 'P'; // Check for overrides if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == 'landscape' ? 'L' : 'P'; } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == 'landscape' ? 'L' : 'P'; } // Create PDF $pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf->AddPage(); $pdf->writeHTML($html); // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); // Close file fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); }
public function tax_continuous_type4($id = null, $year = null) { if (Session::get('level') != '') { $y = Input::get('y3'); if ($y != '') { $year = $y; $id = 'all'; } $pdf = new TCPDF(); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $n = DB::select('select * from s_general_data'); foreach ($n as $k) { $name = $k->name; $address = $k->address; $address2 = $k->address2; $tax_id2 = $k->tax_id2; $director = $k->director; } $sql = ' select concat(n.pname,"",n.fname," ",n.lname) as name, s.cid, s.tax_id,sum(s.salary+s.r_other) as salary, sum(s.r_c) as r_c, sum(s.special_m+s.pts+s.pts2) as special, sum(s.tax) as tax ,sum(s.kbk) as kbk from s_salary_ocsc_detail s left join n_datageneral n on n.cid=s.cid left join n_position_salary p on p.cid=n.cid where s.cid=5350400051484 and year(s.order_date)=' . $year . ' group by s.cid order by n.datainfoID asc '; $result = DB::select($sql); foreach ($result as $key) { $pdf->AddPage('P', 'A4'); $pdf->SetFont('freeserif', 'B', 11, '', true); $pdf->MultiCell(185, 5, 'เลขที่ งป. ........................./ ' . ($year == 'null' ? $this->yearThai() : $year + 543), 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 16, '', true); $pdf->SetY(25); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'หนังสือรับรองการหักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true); $pdf->SetY(34); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'ตามมาตรา 50 ทวิ แห่งประมวลรัษฎากร', 0, 'C', 0, 1, '', '', true); //===== แนวตั้ง =====// $linever1 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 190, 18, 50, $linever1); $linever2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 190, 80, 50, $linever2); $linever3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(110, 190, 110, 50, $linever3); $linever4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(135, 190, 135, 50, $linever4); $linever5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(165, 190, 165, 50, $linever5); $linever6 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(195, 190, 195, 50, $linever6); //===== แนวนอน =====// $linetop = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 50, 195, 50, $linetop); $linetop2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 63, 195, 63, $linetop2); $linetop3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 120, 80, 120, $linetop3); $linetop4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 180, 195, 180, $linetop4); $linetop5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 190, 195, 190, $linetop5); //======= text in box 1 ========// $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(52); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้มีหน้าที่หักภาษี ณ ที่จ่าย บุคคลคณะบุคคล นิติบุคคล ส่วนราชการ องค์การ รัฐวิสาหกิจ ฯลฯ ', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(82); $pdf->SetX(19); $pdf->MultiCell(62, 5, $address2, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(105); $pdf->SetX(19); $pdf->MultiCell(40, 5, $tax_id2, 0, 'L', 0, 1, '', '', true); //======= text in box 2 ========// $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(122); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetY(137); $pdf->SetX(21); $pdf->MultiCell(59, 5, $key->name, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(145); $pdf->SetX(19); $pdf->MultiCell(62, 5, $address, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(165); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'เลขประจำตัวผู้เสียภาษีของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(178); $pdf->SetX(22); $pdf->MultiCell(62, 5, $key->cid, 0, 'L', 0, 1, '', '', true); //======= text in box 3 header content ========// $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(83); $pdf->MultiCell(32, 5, 'เงินได้ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(111); $pdf->MultiCell(32, 5, 'ปีภาษีที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(138); $pdf->MultiCell(32, 5, 'จำนวนเงิน', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(167); $pdf->MultiCell(32, 5, 'ภาษีที่หักไว้', 0, 'L', 0, 1, '', '', true); //============= text in content ================// $pdf->SetFont('freeserif', '', 12, '', true); //-----col 1 $pdf->SetY(70); $pdf->SetX(80); $pdf->MultiCell(30, 5, 'เงินเดือน ค่าจ้าง บำนาญ เบี้ยเลี้ยง โบนัส ตามมาตรา 40(1)', 0, 'L', 0, 1, '', '', true); $pdf->SetY(95); $pdf->SetX(80); $pdf->MultiCell(31, 5, 'เงินประจำตำแหน่ง', 0, 'L', 0, 1, '', '', true); $pdf->SetY(104); $pdf->SetX(80); $pdf->MultiCell(27, 5, 'เงินค่าตอบแทนพิเศษ พตส ค่าครองชีพ', 0, 'L', 0, 1, '', '', true); //-----col 2 $pdf->SetY(70); $pdf->SetX(116); $pdf->MultiCell(31, 5, $year == 'null' ? $this->yearThai() : $year + 543, 0, 'L', 0, 1, '', '', true); //-----col 3 $pdf->SetY(70); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->salary, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(95); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->r_c, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(104); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->special, 2), 0, 'R', 0, 1, '', '', true); //-----col 4 $pdf->SetY(70); $pdf->SetX(165); $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true); //============= text in box 4 footer sum ============// $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(182); $pdf->SetX(89); $pdf->MultiCell(32, 5, 'รวม', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(182); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->salary + $key->special + $key->r_c, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(182); $pdf->SetX(165); $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true); //============= text footer ================// $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(195); $pdf->SetX(22); $pdf->MultiCell(32, 5, 'ผู้จ่ายเงิน', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(39); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(44); $pdf->MultiCell(30, 5, '(1) หัก ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(73); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(78); $pdf->MultiCell(35, 5, '(2) ออกให้ตลอดไป', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(112); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(117); $pdf->MultiCell(35, 5, '(3) ออกให้ครั้งเดียว', 0, 'L', 0, 1, '', '', true); $pdf->SetY(205); $pdf->SetX(39); $pdf->MultiCell(5, 5, ' /', 1, 'L', 0, 1, '', '', true); $pdf->SetY(205); $pdf->SetX(44); $pdf->MultiCell(100, 5, '(4) เงินสบทบกองทุนประกันสังคม ' . ' ' . number_format($key->kbk, 2) . ' บาท', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetY(220); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'ข้าพเจ้าขอรับรองว่า ข้อความและตัวเลขดังกล่าวข้างต้นนี้ถูกต้องตามความเป็นจริงทุกประการ', 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(235); $pdf->SetX(32); $pdf->MultiCell(170, 5, 'ลงชื่อ...........................................................ผู้มีหน้าที่หักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true); $pdf->SetY(245); $pdf->SetX(32); $pdf->MultiCell(140, 5, $director, 0, 'C', 0, 1, '', '', true); $pdf->SetY(255); $pdf->SetX(32); $pdf->MultiCell(140, 5, 'ทันตแพทย์เชี่ยวชาญ ปฎิบัติราชการแทน', 0, 'C', 0, 1, '', '', true); $pdf->SetY(265); $pdf->SetX(32); $pdf->MultiCell(140, 5, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true); } $filename = storage_path() . '/report_tax_continuous_emp4.pdf'; // Response::download($filename); $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); } else { return View::make('login.index'); } }
public function view_reserve($id) { if (Session::get('level') == '1' || Session::get('level') == '3') { $sql = ' select * from c_reserve_cars '; $sql .= ' where reserve_id =' . $id . ' '; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // set header and footer fonts $pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(10, 10, 10); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetFont('angsanaupc', '', 14, '', true); $pdf->AddPage(); $pdf->SetXY(10, 10); $pdf->Image('images/krut.jpg', '', '', 20, 20, '', '', 'T', false, 300, '', false, false, 0, false, false, false); $pdf->SetFont('angsanaupc', 'B', 18, '', true); $pdf->SetXY(75, 20); $pdf->MultiCell(60, 0, 'บันทึกข้อความ', 0, 'C', 0, 1, '', '', true); $result = DB::select($sql); foreach ($result as $key) { $pdf->SetFont('angsanaupc', 'B', 14, '', true); $pdf->SetXY(10, 32); $pdf->MultiCell(25, 0, 'ส่วนราชการ', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(35, 32); $pdf->MultiCell(160, 0, 'ฝ่าย........................................................................................โรงพยาบาลโนนไทย อำเภอโนนไทย จังหวัดนครราชสีมา', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(44, 31); $pdf->MultiCell(65, 0, $key->department, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','B',14,'',true); $pdf->SetXY(10, 40); $pdf->MultiCell(10, 0, 'ที่', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','B',14,'',true); $pdf->SetXY(20, 40); $pdf->MultiCell(170, 0, 'นม 0032.301/...........................................วันที่.............................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(43, 39); $pdf->MultiCell(31, 0, $key->num_nm, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(83, 39); $pdf->MultiCell(44, 0, $key->date_nm == '0000-00-00' ? '' : $this->get_monthyearThai($key->date_nm), 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','B',14,'',true); $pdf->SetXY(10, 48); $pdf->MultiCell(10, 0, 'เรื่อง', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','B',14,'',true); $pdf->SetXY(20, 48); $pdf->MultiCell(60, 0, ' ขออนุมัติไปราชการ', 0, 'L', 0, 1, '', '', true); $style = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 5, 'color' => array(0, 0, 0)); $pdf->Line(10, 57, 195, 57, $style); //$pdf->SetFont('angsanaupc','B',14,'',true); $pdf->SetXY(10, 62); $pdf->MultiCell(70, 0, 'เรียน ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(20, 72); $pdf->MultiCell(176, 0, 'ด้วยข้าพเจ้า..........................................................................ตำแหน่ง...........................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(39, 71); $pdf->MultiCell(55, 0, $key->req_name, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(108, 71); $pdf->MultiCell(70, 0, $key->position, 0, 'L', 0, 1, '', '', true); $sql2 = ' select * from c_together where together_id=' . $key->together_id . ' '; $result2 = DB::select($sql2); $n = 0; $r = 0; $pdf->SetXY(10, 80); $pdf->MultiCell(20, 0, 'พร้อมด้วย', 0, 'L', 0, 1, '', '', true); if (count($result2) > 0) { foreach ($result2 as $key2) { $n++; $r = $r + 7; $pdf->SetXY(20, 84 + $r); $pdf->MultiCell(176, 0, $n . '.................................................................................ตำแหน่ง.....................................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(25, 83 + $r); $pdf->MultiCell(60, 0, $key2->req_name, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(100, 83 + $r); $pdf->MultiCell(90, 0, $key2->position, 0, 'L', 0, 1, '', '', true); } } else { $pdf->SetXY(10, 85); $pdf->MultiCell(20, 0, '-', 0, 'L', 0, 1, '', '', true); } $pdf->SetXY(10, 91 + $r); $pdf->MultiCell(186, 0, 'ขออนุมัติเดินทางไปราชการที่.............................................................................หน่วยงานผู้จัด...............................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(50, 90 + $r); $pdf->MultiCell(59, 0, $key->location, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(130, 90 + $r); $pdf->MultiCell(60, 0, $key->institution, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(10, 97 + $r); $pdf->MultiCell(186, 0, 'เรื่อง...........................................................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(20, 96 + $r); $pdf->MultiCell(175, 0, $key->title, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(10, 103 + $r); $pdf->MultiCell(187, 0, 'ตามหนังสือที่.........................................................................................................................ลงวันที่........................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(32, 102 + $r); $pdf->MultiCell(74, 0, $key->ref_book_number, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(136, 102 + $r); $pdf->MultiCell(50, 0, $key->ref_book_date == '0000-00-00' ? '' : $this->get_monthyearThai($key->ref_book_date), 0, 'L', 0, 1, '', '', true); $pdf->SetXY(10, 110 + $r); $pdf->MultiCell(186, 0, 'ทั้งนี้ตั้งแต่วันที่.........................................................................ถึงวันที่...........................................................................รวม............................วัน', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(34, 109 + $r); $pdf->MultiCell(55, 0, $key->startdate == '0000-00-00' ? '' : $this->get_monthyearThai($key->startdate), 0, 'L', 0, 1, '', '', true); $pdf->SetXY(100, 109 + $r); $pdf->MultiCell(53, 0, $key->enddate == '0000-00-00' ? '' : $this->get_monthyearThai($key->enddate), 0, 'L', 0, 1, '', '', true); $pdf->SetXY(167, 109 + $r); $pdf->MultiCell(20, 0, $key->allday, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(10, 116 + $r); $pdf->MultiCell(186, 0, 'สำหรับค่าใช้จ่ายในการเดินทางไปราชการขอเบิกจ่ายเงินบำรุงของโรงพยาบาล และขอใช้รถยนต์เดินทางไปราชการครั้งนี้', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(20, 125 + $r); $pdf->MultiCell(6, 0, $key->usecar1 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true); $pdf->SetXY(29, 125 + $r); $pdf->MultiCell(60, 0, 'ใช้รถยนต์ของทางโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(20, 135 + $r); $pdf->MultiCell(6, 0, $key->usecar2 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true); $pdf->SetXY(29, 135 + $r); $pdf->MultiCell(170, 0, 'ใช้รถยนต์ส่วนตัว หมายเลขทะเบียน.......................................................................ตามหลักเกณฑ์การเบิกค่า', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(84, 134 + $r); $pdf->MultiCell(40, 0, $key->usecar2_car_number, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(29, 141 + $r); $pdf->MultiCell(170, 0, 'ยานพาหนะส่วนตัวในการเดินทางไปราชการ กิโลเมตรละ 4 บาท เป็นเงิน................................................บาท', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(123, 140 + $r); $pdf->MultiCell(38, 0, $key->usecar2_km_money, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(20, 149 + $r); $pdf->MultiCell(6, 0, $key->usecar3 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true); $pdf->SetXY(29, 149 + $r); $pdf->MultiCell(170, 0, 'อื่น ๆ (ระบุ)......................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(50, 148 + $r); $pdf->MultiCell(140, 0, $key->usecar3_detail, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(29, 158 + $r); $pdf->MultiCell(140, 0, 'จึงเรียนมาเพื่อทราบ และโปรดพิจารณาอนุมัติด้วย จะเป็นพระคุณ', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(95, 168 + $r); $pdf->MultiCell(100, 0, '(ลงชื่อ)...............................................................ผู้ขอ', 0, 'R', 0, 1, '', '', true); $pdf->SetXY(122, 167 + $r); $pdf->MultiCell(64, 0, '', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(128, 175 + $r); $pdf->MultiCell(69, 0, '(............................................................)', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(129, 174 + $r); $pdf->MultiCell(64, 0, $key->regis_user_req, 0, 'C', 0, 1, '', '', true); $h_re = DB::Select('select * from n_department_header where departmentName="' . $key->department . '" '); foreach ($h_re as $k_h) { $header_name = $k_h->header_name; } if (!isset($header_name)) { $header_name = ''; } $pdf->SetXY(10, 186 + $r); $pdf->MultiCell(68, 0, 'เสนอ ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(11, 194 + $r); $pdf->MultiCell(69, 0, '...................................................', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(10, 204 + $r); $pdf->MultiCell(90, 0, '(ลงชื่อ).........................................................หัวหน้าฝ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(18, 212 + $r); $pdf->MultiCell(69, 0, '(.........................................................)', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(20, 211 + $r); $pdf->MultiCell(45, 0, $header_name, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(120, 194 + $r); $pdf->MultiCell(6, 0, $key->daytrue == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true); $pdf->SetXY(123, 194 + $r); $pdf->MultiCell(40, 0, 'ไม่เป็นวันทำการ', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(120, 204 + $r); $pdf->MultiCell(6, 0, $key->dayflase == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true); $pdf->SetXY(123, 204 + $r); $pdf->MultiCell(40, 0, 'เป็นวันทำการ', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(105, 219 + $r); $pdf->MultiCell(90, 0, '(ลงชื่อ)...........................................................ผู้อนุมัติ', 0, 'R', 0, 1, '', '', true); $pdf->SetXY(115, 227 + $r); $pdf->MultiCell(90, 0, '( นายบุญชัย ธนบัตรชัย )', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(115, 235 + $r); $pdf->MultiCell(90, 0, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true); } //end foreach $filename = storage_path() . '/report_reserve.pdf'; $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); } else { $data = DB::table('c_req_cars')->where('godate', '>=', date('Y-m-d'))->orderBy('godate', 'asc')->paginate(10); return View::make('home.index', array('data' => $data)); } }
public function view_reqcar($id) { if (Session::get('level') == '1' || Session::get('level') == '2' || Session::get('level') == '3') { $sql = ' select * from c_req_cars '; $sql .= ' where req_car_id =' . $id . ' '; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); // set header and footer fonts $pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(15, 15, 15); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->AddPage(); $pdf->SetFont('angsanaupc', 'B', 16, '', true); $pdf->SetXY(15, 15); $pdf->MultiCell(180, 0, 'ใบขออนุญาตใช้รถยนต์โรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true); $result = DB::select($sql); foreach ($result as $key) { $pdf->SetFont('angsanaupc', 'B', 14, '', true); $pdf->SetXY(115, 25); $pdf->MultiCell(80, 0, 'วันที่.................................................เวลา........................น.', 0, 'R', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(128, 24); $pdf->MultiCell(38, 0, $key->req_date == '0000-00-00' ? '' : $this->get_monthyearThai($key->req_date), 0, 'C', 0, 1, '', '', true); $pdf->SetXY(171, 24); $pdf->MultiCell(20, 0, $key->writetime, 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 35); $pdf->MultiCell(70, 0, 'เรียน ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(26, 47); $pdf->MultiCell(180, 0, 'ข้าพเจ้า.......................................................ตำแหน่ง......................................................................ฝ่าย..................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('angsanaupc', 'B', 13, '', true); $pdf->SetXY(37, 46); $pdf->MultiCell(45, 0, $key->req_name, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(92, 46); $pdf->MultiCell(57, 0, $key->position, 0, 'L', 0, 1, '', '', true); $pdf->SetXY(155, 46); $pdf->MultiCell(40, 0, $key->department, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('angsanaupc', 'B', 14, '', true); $pdf->SetXY(15, 56); $pdf->MultiCell(181, 0, 'ขออนุญาตใช้รถไป(ไปที่ไหน).........................................................................................................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(60, 55); $pdf->MultiCell(135, 0, $key->location, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 65); $pdf->MultiCell(181, 0, 'เพื่อ.....................................................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(24, 64); $pdf->MultiCell(170, 0, $key->detail, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 74); $pdf->MultiCell(181, 0, 'มีคนนั่ง..................................คน ในวันที่............................................................................................... เวลา...........................................น.', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(29, 73); $pdf->MultiCell(20, 0, $key->qty, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(74, 73); $pdf->MultiCell(70, 0, $key->godate == '0000-00-00' ? '' : $this->get_monthyearThai($key->godate), 0, 'C', 0, 1, '', '', true); $pdf->SetXY(158, 73); $pdf->MultiCell(30, 0, $key->gotime_start, 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 83); $pdf->MultiCell(181, 0, 'ถึงเวลา...................................น. โดยมี...................................................................................ผู้รับผิดชอบ', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(28, 82); $pdf->MultiCell(24, 0, $key->gotime_end, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(68, 82); $pdf->MultiCell(62, 0, $key->responsible, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(166, 82); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 93); $pdf->MultiCell(70, 0, 'ระบุสถานที่ขึ้นรถ', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(15, 100); $pdf->MultiCell(100, 0, '1.....................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(19, 99); $pdf->MultiCell(70, 0, $key->upcar1, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 108); $pdf->MultiCell(100, 0, '2.....................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(19, 107); $pdf->MultiCell(70, 0, $key->upcar2, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 116); $pdf->MultiCell(100, 0, '3.....................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(19, 115); $pdf->MultiCell(70, 0, $key->upcar3, 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(95, 130); $pdf->MultiCell(100, 0, '(ลงชื่อ)...............................................................ผู้ขออนุญาต', 0, 'R', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(110, 129); $pdf->MultiCell(65, 0, '', 0, 'C', 0, 1, '', '', true); //pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(118, 137); $pdf->MultiCell(69, 0, '(..............................................................)', 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(120, 136); $pdf->MultiCell(65, 0, $key->user_req, 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(95, 150); $pdf->MultiCell(100, 0, '(ลงชื่อ)...............................................................หัวหน้าฝ่าย', 0, 'R', 0, 1, '', '', true); $pdf->SetXY(118, 157); $pdf->MultiCell(69, 0, '(............................................................)', 0, 'C', 0, 1, '', '', true); $h_re = DB::Select('select * from n_department_header where departmentName="' . $key->department . '" '); foreach ($h_re as $k_h) { $header_name = $k_h->header_name; } if (!isset($header_name)) { $header_name = ''; } $pdf->SetXY(120, 156); $pdf->MultiCell(65, 0, $header_name, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 177); $pdf->MultiCell(180, 0, 'ความเห็นของผู้ควบคุมรถยนต์ เห็นควรอนุญาต โดยใช้รถยนต์หมายเลขทะเบียน.......................................................................................', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(140, 176); $pdf->MultiCell(45, 0, $key->car_number, 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(15, 185); $pdf->MultiCell(180, 0, 'และให้.....................................................................................................เป็นพนักงานขับรถยนต์ ระยะทาง.................................กิโลเมตร', 0, 'L', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(28, 184); $pdf->MultiCell(73, 0, $key->driver, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(153, 184); $pdf->MultiCell(24, 0, $key->km_driver, 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(95, 200); $pdf->MultiCell(100, 0, '(ลงชื่อ)...............................................................ผู้ควบคุม', 0, 'R', 0, 1, '', '', true); $pdf->SetXY(121, 208); $pdf->MultiCell(69, 0, '(................................................................)', 0, 'C', 0, 1, '', '', true); //$pdf->SetFont('angsanaupc','',14,'',true); $pdf->SetXY(114, 199); $pdf->MultiCell(65, 0, '', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(121, 207); $pdf->MultiCell(63, 0, $key->driver_control, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 220); $pdf->MultiCell(180, 0, 'ความเห็นของผู้มีอำนาจสั่งใช้รถยนต์...............................................................................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(15, 227); $pdf->MultiCell(180, 0, '..........................................................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true); $pdf->SetXY(15, 227); $pdf->MultiCell(165, 0, $key->comment, 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 245); $pdf->MultiCell(180, 0, '(ลงชื่อ).................................................................ผู้อนุมัติ', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 252); //$pdf->MultiCell(180, 0, '(นายบุญชัย ธนบัตรชัย)', 0, 'C', 0, 1, '', '', true); $pdf->MultiCell(180, 0, '(นายพิศิษฐ์ สมผดุง)', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 259); $pdf->MultiCell(180, 0, 'ทันตแพทย์เชี่ยวชาญ ปฎิบัติราชการแทน', 0, 'C', 0, 1, '', '', true); $pdf->SetXY(15, 267); $pdf->MultiCell(180, 0, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true); } $filename = storage_path() . '/report_reqcar.pdf'; $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); } else { $data = DB::table('c_req_cars')->where('godate', '>=', date('Y-m-d'))->orderBy('godate', 'asc')->paginate(10); return View::make('home.index', array('data' => $data)); } }
public function generarReporte() { //$this->AddPage(); parent::output($this->strUrlArchivo, 'F'); }
/** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null, $title = '') { // garbage collect $this->_phpExcel->garbageCollect(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); // Open file $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file {$pFilename} for writing."); } // Set PDF $this->_isPdf = true; // Build CSS $this->buildCSS(true); // Generate HTML $html = ''; //$html .= $this->generateHTMLHeader(false); if (!empty($title)) { $html .= '<h1 align="center">' . $title . '</h1>'; } $html .= $this->generateSheetData(); //$html .= $this->generateHTMLFooter(); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) // Check for paper size and page orientation if (is_null($this->getSheetIndex())) { $orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); } else { $orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); } // Override Page Orientation if (!is_null($this->_orientation)) { $orientation = $this->_orientation == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P'; } // Override Paper Size if (!is_null($this->_paperSize)) { $printPaperSize = $this->_paperSize; } if (isset(self::$_paperSizes[$printPaperSize])) { $paperSize = self::$_paperSizes[$printPaperSize]; } // Create PDF $pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); // Set the appropriate font require_once "../classes/Settings.php"; require_once "../classes/SettingsQuery.php"; $setQ = new SettingsQuery(); $setQ->connect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $setQ->execSelect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $set = $setQ->fetchRow(); $pdf->setFont($set->getFontNormal(), '', $set->getFontSize()); //$pdf->SetFont($this->_font); $pdf->writeHTML($html); // Document info $pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); // Write to file fwrite($fileHandle, $pdf->output($pFilename, 'S')); // Close file fclose($fileHandle); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); }
function output($html, $title = 'document', $pFilename = 'doc.pdf') { require_once '../classes/PHPExcel/Shared/PDF/tcpdf.php'; require_once "../classes/Settings.php"; require_once "../classes/SettingsQuery.php"; // Create PDF $pdf = new TCPDF('P', 'pt', 'A4'); $pdf->SetMargins(56.7, 56.7); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setTitle($title); $pdf->AddPage(); // Set the appropriate font $setQ = new SettingsQuery(); $setQ->connect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $setQ->execSelect(); if ($setQ->errorOccurred()) { $setQ->close(); displayErrorPage($setQ); } $set = $setQ->fetchRow(); $pdf->setFont($set->getFontNormal()); $pdf->writeHTML($html); $pdf->SetTitle($title); return $pdf->output($pFilename, 'S'); }