$getquery = str_replace("+", " ", $_GET[query]); $getquerykorporate = str_replace("+", " ", $_GET[query_korporate]); //instansiasi fpdf $pdf = new PDF_MC_Table('L', 'cm', 'A4'); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetMargins(0.7, 0.7, 0.7, 0.7); #tampilkan judul laporan $pdf->SetFont('Arial', 'B', '16'); $pdf->Cell(0, 0, "CIPAGANTI RENTAL CAR & TRAVEL", '0', 1, 'C'); $pdf->Cell(0, 2, "HASIL SEWA KENDARAAN", '0', 1, 'C'); $pdf->SetFont('Arial', 'B', '12'); $pdf->Cell(3, 3, "CABANG : " . $gudang, 0, 0, 'L'); $pdf->Cell(25.2, 3, "PERIODE : " . DateToIndo($mulai) . " - " . DateToIndo($akhir), 0, 0, 'R'); //membuat kop tabel $y = $pdf->GetY(); $pdf->SetY($y + 2.5); $pdf->SetFont('Arial', 'B', 11); $pdf->SetWidths(array(2.3, 2.5, 2.5, 2.5, 3.7, 2.2, 2.2, 2.6, 2.6, 2.6, 2.6)); $pdf->SetHeight(0.1); $pdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C')); $pdf->Row(array("CSO", "Berangkat", "No. Order", "No. Kendaraan", "Merk Kendaraan", "Periode Awal", "Periode Akhir", "Customer", "T.Sewa", "T.Bayar", "Piutang")); $pdf->SetFont('Arial', 'B', 9); $pdf->SetWidths(array(28.3)); $pdf->Row(array("SEWA KENDARAAN RETAIL")); //ISI TABEL $pdf->SetFont('Arial', '', 9); $pdf->SetWidths(array(2.3, 2.5, 2.5, 2.5, 3.7, 2.2, 2.2, 2.6, 2.6, 2.6, 2.6)); $pdf->SetHeight(0.1); $pdf->SetAligns(array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C')); $query_data = $getquery;
/** * Init function */ function __construct($json) { require 'mc_table.php'; parent::__construct($json); // Get Config $conf = isset($_SESSION['pluginsConfig']) && isset($_SESSION['pluginsConfig']['export']) && isset($_SESSION['pluginsConfig']['export']['PDF']) ? $_SESSION['pluginsConfig']['export'] : array('PDF' => array()); $defaultFont = isset($conf['PDF']['defaultFont']) ? $conf['PDF']['defaultFont'] : 'FreeSans'; $defaultFontSize = isset($conf['PDF']['defaultFontSize']) ? $conf['PDF']['defaultFontSize'] : 9; $headerFont = isset($conf['PDF']['headerFont']) ? $conf['PDF']['headerFont'] : $defaultFont; $headerFontSize = isset($conf['PDF']['headerFontSize']) ? $conf['PDF']['headerFontSize'] : $defaultFontSize; $headerFontStyle = isset($conf['PDF']['headerFontStyle']) ? $conf['PDF']['headerFontStyle'] : ''; $layerFont = isset($conf['PDF']['layerFont']) ? $conf['PDF']['layerFont'] : $defaultFont; $layerFontSize = isset($conf['PDF']['layerFontSize']) ? $conf['PDF']['layerFontSize'] : $defaultFontSize; $layerFontStyle = isset($conf['PDF']['layerFontStyle']) ? $conf['PDF']['layerFontStyle'] : ''; // Write to table $pdf = new PDF_MC_Table(); // only for tcpdf version >= 3 // - font not well defined --> errors // - header and footer printed = lines on top and bottom $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->Open(); $groups = (array) $this->jsonList[0]; foreach ($groups as $grp) { $ret = $this->prepareData4PDF($grp); $colsPerc = $ret[0]; $data = $ret[1]; $header = $data['header']; $records = $data['records']; $pdfW = 180; // orientation detection $orientation = 'P'; $colsum = $ret[2]; $maxSize = max($headerFontSize, $defaultFontSize); $widthTmp = $colsum * $maxSize / 4; if ($widthTmp > 1.5 * $pdfW) { $pdfW = 270; $orientation = 'L'; } $pdf->AddPage($orientation); $cols = array(); foreach ($colsPerc as $cp) { $cols[] = $cp * $pdfW; } // add group name: $pdf->SetFont($layerFont, $layerFontStyle, $layerFontSize); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->Cell(0, 0, $grp->description); $pdf->SetXY($x, $y + 9); // Calculate column widths $pdf->SetWidths($cols); // Add header $pdf->SetFont($headerFont, $headerFontStyle, $headerFontSize); $pdf->Row($header); // Add records $pdf->SetFont($defaultFont, '', $defaultFontSize); foreach ($records as $row) { $pdf->Row($row); } } $pdfFilePath = $this->tempFilePath . '.pdf'; $this->tempFileLocation .= '.pdf'; $pdf->Output($pdfFilePath, 'F'); }