public function actionPengeluaranPerKodeRekeningDetil()
 {
     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'];
         $kode = $_POST['account_code'];
         $daftar_code = Pah::get_arr_kode_rekening_pengeluaran($kode);
         $index = 0;
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getDefaultStyle()->getFont()->setSize(10);
         $file_name = 'PengeluaranPerKodeRekeningDetil';
         foreach ($daftar_code as $key => $codename) {
             $start = 1;
             $worksheet_name = "{$key} - {$codename}";
             if ($index > 0) {
                 $objPHPExcel->createSheet($index);
             }
             $objPHPExcel->setActiveSheetIndex($index);
             $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
             $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft(0.1 / 2.54);
             $objPHPExcel->getActiveSheet()->getPageMargins()->setRight(0.1 / 2.54);
             $objPHPExcel->getActiveSheet()->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "LAPORAN DETIL PENGELUARAN " . strtoupper($codename))->getStyle("A{$start}")->getFont()->setSize(18)->setBold(true);
             $start++;
             $objPHPExcel->getActiveSheet()->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "PONDOK ASUH HARAPAN")->getStyle("A{$start}")->getFont()->setSize(14)->setBold(true);
             $start++;
             $objPHPExcel->getActiveSheet()->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->getActiveSheet()->setCellValue("A{$start}", "Tgl")->setCellValue("B{$start}", "Keterangan")->setCellValue("C{$start}", "Debit")->setCellValue("D{$start}", "Kredit")->getStyle("A{$start}:D{$start}")->getFont()->setBold(true);
             $start++;
             $rows = Pah::get_pengeluaran_detil_kode_rekening($start_date, $end_date, $key);
             $total = Pah::get_total_pengeluaran($start_date, $end_date, $key);
             $total_persen = 0;
             foreach ($rows as $row) {
                 //                    $total_persen += $row['total_beban'] / $total;
                 //                    $total_beban = $row['total_beban'];
                 //                    $persen = $row['total_beban'] / $total;
                 $objPHPExcel->getActiveSheet()->setCellValue("A{$start}", $row['tran_date'])->setCellValue("B{$start}", $row['memo_'])->setCellValue("C{$start}", $row['debit'])->setCellValue("D{$start}", $row['kredit']);
                 $start++;
             }
             //$total_format = $format == 'excel' ? $total : acc_format($total);
             $objPHPExcel->getActiveSheet()->setCellValue("A{$start}", 'Total')->setCellValue($total > 0 ? "C{$start}" : "D{$start}", $total);
             //                    ->setCellValue("C$start", $format == 'excel' ? $total_persen : percent_format($total_persen, 2));
             $start++;
             $end_body = $start - 1;
             $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
             $objPHPExcel->getActiveSheet()->getStyle("A{$start_body}:D{$end_body}")->applyFromArray($styleArray);
             $start_row = $start_body + 1;
             $objPHPExcel->getActiveSheet()->getStyle("C{$start_row}:D{$end_body}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING);
             //                $objPHPExcel->getActiveSheet()->getStyle("C$start_row:C$end_body")->getNumberFormat()
             //                    ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
             $objPHPExcel->getActiveSheet()->getColumnDimension("A")->setAutoSize(true);
             $objPHPExcel->getActiveSheet()->getColumnDimension("B")->setAutoSize(true);
             $objPHPExcel->getActiveSheet()->getColumnDimension("C")->setAutoSize(true);
             $objPHPExcel->getActiveSheet()->getColumnDimension("D")->setAutoSize(true);
             $objPHPExcel->getActiveSheet()->getColumnDimension("E")->setAutoSize(true);
             $start++;
             $jemaat = get_jemaat_from_user_id(Yii::app()->user->getId());
             $objPHPExcel->getActiveSheet()->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Dicetak oleh: " . $jemaat->real_name);
             $start++;
             $objPHPExcel->getActiveSheet()->mergeCells("A{$start}:G{$start}")->setCellValue("A{$start}", "Pada tanggal " . get_date_today('dd/MM/yyyy') . " jam " . get_time_now());
             $index++;
         }
         ob_end_clean();
         ob_start();
         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');
         Yii::app()->end();
     }
 }