protected function footer($objPHPExcel, $start, $file_name, $format, $html_title)
 {
     $start++;
     $jemaat = get_jemaat_from_user_id(Yii::app()->user->getId());
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Dicetak oleh: " . $jemaat->real_name);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Pada tanggal " . get_date_today('dd/MM/yyyy') . " jam " . get_time_now());
     ob_end_clean();
     ob_start();
     if ($format == 'excel') {
         header('Content-Type: application/vnd.ms-excel');
         header("Content-Disposition: attachment;filename={$file_name}.xls");
         header('Cache-Control: max-age=0');
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
         $objWriter->save('php://output');
     } else {
         $objPHPExcel->getActiveSheet()->setShowGridlines(false);
         $mPDF1 = Yii::app()->ePdf->mpdf();
         $mPDF1 = Yii::app()->ePdf->mpdf('', 'A4');
         $objWriter = new PHPExcel_Writer_HTML($objPHPExcel);
         $header = $objWriter->generateHTMLHeader(true);
         $header = str_replace("<body>", "<body onload='window.print();'>", $header);
         $header = str_replace("Untitled Spreadsheet", $html_title, $header);
         $html = $header . $objWriter->generateStyles(true) . $objWriter->generateSheetData() . $objWriter->generateHTMLFooter();
         if ($format == 'pdf') {
             $mPDF1->WriteHTML($html);
             $mPDF1->Output('MutasiKasDitangan.pdf', 'D');
         } else {
             echo $html;
         }
     }
 }
 public function view()
 {
     $objWriter = new PHPExcel_Writer_HTML($this->getPHPExcelObj());
     $html['header'] = $objWriter->generateHTMLHeader();
     $html['style'] = $objWriter->generateStyles(true);
     // do not write <style> and </style>
     $html['body'] = $objWriter->generateSheetData();
     $html['footer'] = $objWriter->generateHTMLFooter();
     return $html;
 }
 public function actionMutasiKasDiTangan()
 {
     if (Yii::app()->request->isAjaxRequest) {
         return;
     }
     if (isset($_POST) && !empty($_POST)) {
         $format = $_POST['format'];
         $start_date = $_POST['trans_date_mulai'];
         $end_date = $_POST['trans_date_sampai'];
         $start = 1;
         $file_name = 'MutasiKas';
         $worksheet_name = 'Mutasi Kas';
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
         $objPHPExcel->setActiveSheetIndex(0)->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
         $objPHPExcel->setActiveSheetIndex(0)->getPageMargins()->setLeft(0.1 / 2.54);
         $objPHPExcel->setActiveSheetIndex(0)->getPageMargins()->setRight(0.1 / 2.54);
         $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "MUTASI KAS DI TANGAN")->getStyle("A{$start}")->getFont()->setSize(18)->setBold(true);
         $start++;
         $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PONDOK ASUH HARAPAN")->getStyle("A{$start}")->getFont()->setSize(14)->setBold(true);
         $start++;
         $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PERIODE: " . sql2long_date($start_date) . " - " . sql2long_date($end_date))->getStyle("A{$start}")->getFont()->setSize(12)->setBold(true);
         $objPHPExcel->getActiveSheet()->setTitle($worksheet_name);
         $start++;
         $start++;
         $start_body = $start;
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Doc. Ref")->setCellValue("B{$start}", "Tanggal")->setCellValue("C{$start}", "Payee/Payor")->setCellValue("D{$start}", "Nama Rekening")->setCellValue("E{$start}", "Kas Masuk")->setCellValue("F{$start}", "Kas Keluar")->setCellValue("G{$start}", "Saldo Kas")->getStyle("A{$start}:G{$start}")->getFont()->setBold(true);
         $start++;
         $rows = Pah::get_mutasi_kas_ditangan($start_date, $end_date);
         $nomer = 1;
         $saldo = 0;
         foreach ($rows as $row) {
             $saldo += $row['saldo'];
             //                $kas_masuk = $row['kas_masuk'] == 0 ? '' : ($format == 'excel' ? $row['kas_masuk'] : number_format($row['kas_masuk']));
             //                $kas_keluar = $row['kas_keluar'] == 0 ? '' : ($format == 'excel' ? -$row['kas_keluar'] : number_format(-$row['kas_keluar']));
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $nomer)->setCellValue("B{$start}", sql2date($row['trans_date']))->setCellValue("C{$start}", Pah::get_payee_payoor($row['type'], $row['trans_no']))->setCellValue("D{$start}", $row['nama_rekening'])->setCellValue("E{$start}", $kas_masuk)->setCellValue("F{$start}", $kas_keluar)->setCellValue("G{$start}", $format == 'excel' ? $saldo : number_format($saldo));
             $nomer++;
             $start++;
         }
         $end_body = $start - 1;
         $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
         $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:G{$end_body}")->applyFromArray($styleArray);
         $start_row = $start_body + 1;
         if ($format == 'excel') {
             $objPHPExcel->setActiveSheetIndex(0)->getStyle("E{$start_row}:G{$end_body}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING);
         } else {
             $objPHPExcel->setActiveSheetIndex(0)->getStyle("E{$start_body}:G{$end_body}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         }
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("A")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("B")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("C")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("D")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("E")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("F")->setAutoSize(true);
         $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension("G")->setAutoSize(true);
         $start++;
         $jemaat = get_jemaat_from_user_id(Yii::app()->user->getId());
         $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Dicetak oleh: " . $jemaat->real_name);
         $start++;
         $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Pada tanggal " . get_date_today('dd/MM/yyyy') . " jam " . get_time_now());
         ob_end_clean();
         ob_start();
         if ($format == 'excel') {
             header('Content-Type: application/vnd.ms-excel');
             header("Content-Disposition: attachment;filename={$file_name}.xls");
             header('Cache-Control: max-age=0');
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
             $objWriter->save('php://output');
         } else {
             $objPHPExcel->getActiveSheet()->setShowGridlines(false);
             $mPDF1 = Yii::app()->ePdf->mpdf();
             $mPDF1 = Yii::app()->ePdf->mpdf('', 'A4');
             $objWriter = new PHPExcel_Writer_HTML($objPHPExcel);
             $header = $objWriter->generateHTMLHeader(true);
             $header = str_replace("<body>", "<body onload='window.print();'>", $header);
             $header = str_replace("Untitled Spreadsheet", "Mutasi Kas di Tangan", $header);
             $html = $header . $objWriter->generateStyles(true) . $objWriter->generateSheetData() . $objWriter->generateHTMLFooter();
             if ($format == 'pdf') {
                 $mPDF1->WriteHTML($html);
                 $mPDF1->Output('MutasiKasDitangan.pdf', 'D');
             } else {
                 echo $html;
             }
             //                header('Content-Type: application/pdf');
             //                header("Content-Disposition: attachment;filename='$file_name.pdf'");
             //                header('Cache-Control: max-age=0');
             //                $objPHPExcel->getActiveSheet()->setShowGridlines(false);
             //                $rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
             //                $rendererLibraryPath = Yii::app()->basePath . '/vendors/mpdf';
             //                if (!PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) {
             //                    die(
             //                        'Please set the $rendererName and $rendererLibraryPath values' .
             //                            PHP_EOL .
             //                            ' as appropriate for your directory structure'
             //                    );
             //                }
             //
             //                $objWriter = new PHPExcel_Writer_PDF($objPHPExcel);
             //                $objWriter->save('php://output');
         }
         Yii::app()->end();
     }
 }
 public function actionPrint($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         return;
     }
     //        if (isset($_POST) && !empty($_POST)) {
     $pinjam = $this->loadModel($id, 'MtKembaliKendaraan');
     //        $pinjam = new MtKembaliKendaraan;
     $image = dirname(Yii::app()->getBasePath()) . '/images/mahkotrans.png';
     $start = 1;
     $file_name = 'KembaliKendaraan' . $pinjam->doc_ref_kembali;
     $worksheet_name = 'Kembali Kendaraan ' . $pinjam->doc_ref_kembali;
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(9);
     $objPHPExcel->setActiveSheetIndex(0)->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
     $objDrawing = new PHPExcel_Worksheet_Drawing();
     $objDrawing->setName('Logo');
     $objDrawing->setDescription('Logo');
     $objDrawing->setPath($image);
     $objDrawing->setHeight(30);
     $objDrawing1 = clone $objDrawing;
     $start_body = $start;
     $objPHPExcel->setActiveSheetIndex(0);
     $objDrawing1->setWorksheet($objPHPExcel->getActiveSheet());
     $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
     $objDrawing1->setCoordinates("A{$start}");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "MAHKOTRANS")->getStyle("A{$start}")->getFont()->setSize(14);
     $start++;
     $objPHPExcel->getActiveSheet()->setTitle($worksheet_name);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Villa Seturan Indah Blok D-10 Depok Sleman Yogyakarta 55281")->getStyle("A{$start}")->getFont()->setSize(6);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Telp. (0274) 7439982, 085292750055, 087838488822")->getStyle("A{$start}")->getFont()->setSize(6);
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PENGEMBALIAN KENDARAAN")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nomor Sewa / Kembali")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->doc_ref . " / " . $pinjam->doc_ref_kembali)->setCellValue("D{$start}", "Tanggal")->setCellValue("E{$start}", ": " . $pinjam->trans_date);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nama Konsumen")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->idPelanggan->nama)->setCellValue("D{$start}", "Kelompok Konsumen")->setCellValue("E{$start}", ": " . $pinjam->idPinjam->idKelompok->nama);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Tanda Pengenal")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->tanda_pengenal)->setCellValue("D{$start}", "No. Identitas")->setCellValue("E{$start}", ": " . $pinjam->idPinjam->no_identitas);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Jaminan")->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->jaminan . ", " . $pinjam->idPinjam->jaminan_desc);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Rencana Kembali")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->tgl_rencana_kembali)->setCellValue("D{$start}", "Kembali")->setCellValue("E{$start}", ": " . $pinjam->tgl_kembali);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nopol / Jenis Mobil")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->idMobil->nopol . " / " . $pinjam->idPinjam->idMobil->jenis)->setCellValue("D{$start}", "Season")->setCellValue("E{$start}", $pinjam->idPinjam->season == 0 ? ": Low" : ": High");
     $start++;
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_DASHED)));
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PERHITUNGAN ONGKOS SEWA")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $start_body = $start;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nama Item")->setCellValue("C{$start}", "Jumlah")->setCellValue("D{$start}", "Tarif")->setCellValue("G{$start}", "Total")->getStyle("B{$start}:G{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Mobil")->setCellValue("B{$start}", "Extend Per Bulan")->setCellValue("C{$start}", $pinjam->extend_bln)->setCellValue("D{$start}", $pinjam->idPinjam->trf_bulan)->setCellValue("G{$start}", $pinjam->extend_bln * $pinjam->idPinjam->trf_bulan);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $pinjam->extend_hari)->setCellValue("B{$start}", "Extend Per Hari")->setCellValue("D{$start}", $pinjam->idPinjam->trf_hari)->setCellValue("G{$start}", $pinjam->extend_hari * $pinjam->idPinjam->trf_hari);
     $start++;
     $extend_jam = $pinjam->extend_jam > 0 ? 1 : 0;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $extend_jam)->setCellValue("B{$start}", "Extend Per 12 Jam")->setCellValue("D{$start}", $pinjam->idPinjam->trf_jam)->setCellValue("G{$start}", $extend_jam * $pinjam->idPinjam->trf_jam);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $pinjam->overtime_jam)->setCellValue("B{$start}", "Overtime Per Jam")->setCellValue("D{$start}", $pinjam->idPinjam->trf_over_persen)->setCellValue("G{$start}", $pinjam->overtime_jam * $pinjam->idPinjam->trf_over_persen);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->setCellValue("A{$start}", "Lembar 1 : Untuk Konsumen")->setCellValue("C{$start}", "Total Extend")->setCellValue("G{$start}", $pinjam->ongkos_extend);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Total Sewa")->setCellValue("G{$start}", $pinjam->ongkos_sewa);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Driver")->setCellValue("G{$start}", $pinjam->ongkos_driver);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Bensin")->setCellValue("G{$start}", $pinjam->ongkos_bbm);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Total")->setCellValue("G{$start}", $pinjam->total_ongkos);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Diskon")->setCellValue("G{$start}", $pinjam->disc);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("C{$start}:F{$start}")->setCellValue("C{$start}", "DP " . $pinjam->trans_via . " / No. Bukti : " . $pinjam->no_bukti_bayar)->setCellValue("G{$start}", $pinjam->idPinjam->dp);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Pelunasan")->setCellValue("G{$start}", $pinjam->pelunasan);
     //        $start++;
     //        $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A$start:G$start")->
     //                setCellValue("A$start", "  ");
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->setCellValue("A{$start}", "Penyewa,")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Managemen Mahkotrans,")->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->getStyle("A{$start}")->applyFromArray($styleArray);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->getStyle("D{$start}")->applyFromArray($styleArray);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("C{$start_body}:G{$start}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING);
     //=================================================================================================================
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objDrawing->setCoordinates("A{$start}");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "MAHKOTRANS")->getStyle("A{$start}")->getFont()->setSize(14);
     $start++;
     $objPHPExcel->getActiveSheet()->setTitle($worksheet_name);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Villa Seturan Indah Blok D-10 Depok Sleman Yogyakarta 55281")->getStyle("A{$start}")->getFont()->setSize(6);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Telp. (0274) 7439982, 085292750055, 087838488822")->getStyle("A{$start}")->getFont()->setSize(6);
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PENGEMBALIAN KENDARAAN")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nomor Sewa / Kembali")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->doc_ref . " / " . $pinjam->doc_ref_kembali)->setCellValue("D{$start}", "Tanggal")->setCellValue("E{$start}", ": " . $pinjam->trans_date);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nama Konsumen")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->idPelanggan->nama)->setCellValue("D{$start}", "Kelompok Konsumen")->setCellValue("E{$start}", ": " . $pinjam->idPinjam->idKelompok->nama);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Tanda Pengenal")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->tanda_pengenal)->setCellValue("D{$start}", "No. Identitas")->setCellValue("E{$start}", ": " . $pinjam->idPinjam->no_identitas);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Jaminan")->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->jaminan . ", " . $pinjam->idPinjam->jaminan_desc);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Rencana Kembali")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->tgl_rencana_kembali)->setCellValue("D{$start}", "Kembali")->setCellValue("E{$start}", ": " . $pinjam->tgl_kembali);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nopol / Jenis Mobil")->setCellValue("B{$start}", ": " . $pinjam->idPinjam->idMobil->nopol . " / " . $pinjam->idPinjam->idMobil->jenis)->setCellValue("D{$start}", "Season")->setCellValue("E{$start}", $pinjam->idPinjam->season == 0 ? ": Low" : ": High");
     $start++;
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_DASHED)));
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PERHITUNGAN ONGKOS SEWA")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $start_body = $start;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Nama Item")->setCellValue("C{$start}", "Jumlah")->setCellValue("D{$start}", "Tarif")->setCellValue("G{$start}", "Total")->getStyle("B{$start}:G{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Mobil")->setCellValue("B{$start}", "Extend Per Bulan")->setCellValue("C{$start}", $pinjam->extend_bln)->setCellValue("D{$start}", $pinjam->idPinjam->trf_bulan)->setCellValue("G{$start}", $pinjam->extend_bln * $pinjam->idPinjam->trf_bulan);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $pinjam->extend_hari)->setCellValue("B{$start}", "Extend Per Hari")->setCellValue("D{$start}", $pinjam->idPinjam->trf_hari)->setCellValue("G{$start}", $pinjam->extend_hari * $pinjam->idPinjam->trf_hari);
     $start++;
     $extend_jam = $pinjam->extend_jam > 0 ? 1 : 0;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $extend_jam)->setCellValue("B{$start}", "Extend Per 12 Jam")->setCellValue("D{$start}", $pinjam->idPinjam->trf_jam)->setCellValue("G{$start}", $extend_jam * $pinjam->idPinjam->trf_jam);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", $pinjam->overtime_jam)->setCellValue("B{$start}", "Overtime Per Jam")->setCellValue("D{$start}", $pinjam->idPinjam->trf_over_persen)->setCellValue("G{$start}", $pinjam->overtime_jam * $pinjam->idPinjam->trf_over_persen);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->setCellValue("A{$start}", "Lembar 2 : Untuk Arsip")->setCellValue("C{$start}", "Total Extend")->setCellValue("G{$start}", $pinjam->ongkos_extend);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Total Sewa")->setCellValue("G{$start}", $pinjam->ongkos_sewa);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Driver")->setCellValue("G{$start}", $pinjam->ongkos_driver);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Bensin")->setCellValue("G{$start}", $pinjam->ongkos_bbm);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Total")->setCellValue("G{$start}", $pinjam->total_ongkos);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Diskon")->setCellValue("G{$start}", $pinjam->disc);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("C{$start}:F{$start}")->setCellValue("C{$start}", "DP " . $pinjam->trans_via . " / No. Bukti : " . $pinjam->no_bukti_bayar)->setCellValue("G{$start}", $pinjam->idPinjam->dp);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C{$start}", "Pelunasan")->setCellValue("G{$start}", $pinjam->pelunasan);
     //        $start++;
     //        $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A$start:G$start")->
     //                setCellValue("A$start", "  ");
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->setCellValue("A{$start}", "Penyewa,")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Managemen Mahkotrans,")->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:B{$start}")->getStyle("A{$start}")->applyFromArray($styleArray);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->getStyle("D{$start}")->applyFromArray($styleArray);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("C{$start_body}:G{$start}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING);
     ob_end_clean();
     ob_start();
     $objPHPExcel->getActiveSheet()->setShowGridlines(false);
     $mPDF1 = Yii::app()->ePdf->mpdf('', 'A4', 0, '', 5, 5, 6, 0, 0, 0, 'P');
     $objWriter = new PHPExcel_Writer_HTML($objPHPExcel);
     $html = $objWriter->generateStyles(true) . $objWriter->generateSheetData();
     $html = str_replace('.' . $image, app()->getBaseUrl(true) . '/images/mahkotrans.png', $html);
     $mPDF1->WriteHTML($html);
     $mPDF1->Output($file_name, 'D');
     Yii::app()->end();
 }
 public function actionPrint($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         return;
     }
     //        if (isset($_POST) && !empty($_POST)) {
     $kas_masuk = $this->loadModel($id, 'MtKasMasuk');
     //        $pinjam = new MtPinjamKendaraan;
     $image = dirname(Yii::app()->getBasePath()) . '/images/mahkotrans.png';
     $start = 1;
     $file_name = 'KasMasuk' . $kas_masuk->doc_ref;
     $worksheet_name = 'Kas Masuk ' . $kas_masuk->doc_ref;
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(9);
     $objPHPExcel->setActiveSheetIndex(0)->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
     $objDrawing = new PHPExcel_Worksheet_Drawing();
     $objDrawing->setName('Logo');
     $objDrawing->setDescription('Logo');
     $objDrawing->setPath($image);
     $objDrawing->setHeight(30);
     $objDrawing1 = clone $objDrawing;
     $start_body = $start;
     $objPHPExcel->setActiveSheetIndex(0);
     $objDrawing1->setWorksheet($objPHPExcel->getActiveSheet());
     $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
     $objDrawing1->setCoordinates("A{$start}");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "MAHKOTRANS")->getStyle("A{$start}")->getFont()->setSize(14);
     $start++;
     $objPHPExcel->getActiveSheet()->setTitle($worksheet_name);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Villa Seturan Indah Blok D-10 Depok Sleman Yogyakarta 55281")->getStyle("A{$start}")->getFont()->setSize(6);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Telp. (0274) 7439982, 085292750055, 087838488822")->getStyle("A{$start}")->getFont()->setSize(6);
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "KUITANSI")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "No : " . $kas_masuk->doc_ref)->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", "                                                                                          ")->getStyle("B{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Telah terima dari");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': ' . $kas_masuk->dari);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Sebagai pembayaran");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': ' . $kas_masuk->note);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Uang sejumlah");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': Rp ' . number_format($kas_masuk->amount, 2));
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Yogyakarta, " . get_date_today('dd MMMM yyyy'))->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Staf Mahkotrans")->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     //=================================================================================================================
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objDrawing->setCoordinates("A{$start}");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "MAHKOTRANS")->getStyle("A{$start}")->getFont()->setSize(14);
     $start++;
     $objPHPExcel->getActiveSheet()->setTitle($worksheet_name);
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Villa Seturan Indah Blok D-10 Depok Sleman Yogyakarta 55281")->getStyle("A{$start}")->getFont()->setSize(6);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Telp. (0274) 7439982, 085292750055, 087838488822")->getStyle("A{$start}")->getFont()->setSize(6);
     $styleArray = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:G{$start}")->applyFromArray($styleArray);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "KUITANSI")->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start}")->getFont()->setSize(12);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "No : " . $kas_masuk->doc_ref)->getStyle("A{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", "                                                                                          ")->getStyle("B{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Telah terima dari");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': ' . $kas_masuk->dari);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Sebagai pembayaran");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': ' . $kas_masuk->note);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", "Uang sejumlah");
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("B{$start}:G{$start}")->setCellValue("B{$start}", ': Rp ' . number_format($kas_masuk->amount, 2));
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Yogyakarta, " . get_date_today('dd MMMM yyyy'))->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "  ")->getStyle("A{$start}")->getFont()->setSize(16)->setBold(true);
     $start++;
     $objPHPExcel->setActiveSheetIndex(0)->mergeCells("D{$start}:G{$start}")->setCellValue("D{$start}", "Staf Mahkotrans")->getStyle("D{$start}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     ob_end_clean();
     ob_start();
     $objPHPExcel->getActiveSheet()->setShowGridlines(false);
     $mPDF1 = Yii::app()->ePdf->mpdf('', 'A4', 0, '', 10, 10, 5, 0, 0, 0, 'P');
     $objWriter = new PHPExcel_Writer_HTML($objPHPExcel);
     $html = $objWriter->generateStyles(true) . $objWriter->generateSheetData();
     $html = str_replace('.' . $image, app()->getBaseUrl(true) . '/images/mahkotrans.png', $html);
     $mPDF1->WriteHTML($html);
     $mPDF1->Output($file_name, 'D');
     Yii::app()->end();
 }