public function actionLampiran()
 {
     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'];
         //            $lampiran_id = $_POST['id'];
         $start = 1;
         $file_name = 'Lampiran';
         $worksheet_name = 'Lampiran';
         $objPHPExcel = new PHPExcel();
         $this->header($objPHPExcel, $start, $worksheet_name, "LAMPIRAN DONASI NON TUNAI");
         $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}", "No.")->setCellValue("B{$start}", "Tgl Transaksi")->setCellValue("C{$start}", "Nama Donatur")->setCellValue("D{$start}", "Keterangan")->setCellValue("E{$start}", "Satuan")->setCellValue("F{$start}", "Jumlah")->getStyle("A{$start}:F{$start}")->getFont()->setBold(true);
         $start++;
         //            $rows = Pah::get_beban_anak($start_date, $end_date, $lampiran_id);
         $criteria = new CDbCriteria();
         $criteria->addBetweenCondition('trans_date', $start_date, $end_date);
         $rows = PahLampiran::model()->findAll($criteria);
         $no = 0;
         foreach ($rows as $row) {
             $no++;
             $total_beban = $format == 'excel' ? $row['qty'] : number_format($row['qty']);
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$start}", $no)->setCellValue("B{$start}", sql2date($row['trans_date']))->setCellValue("C{$start}", $row['nama'])->setCellValue("D{$start}", $row['keterangan'])->setCellValue("E{$start}", $row['satuan'])->setCellValue("F{$start}", $total_beban);
             $start++;
         }
         $end_body = $start - 1;
         $styleArray = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
         $objPHPExcel->setActiveSheetIndex(0)->getStyle("A{$start_body}:F{$end_body}")->applyFromArray($styleArray);
         $start_row = $start_body + 1;
         if ($format == 'excel') {
             $objPHPExcel->setActiveSheetIndex(0)->getStyle("F{$start_row}:F{$end_body}")->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_ACCOUNTING);
         } else {
             $objPHPExcel->setActiveSheetIndex(0)->getStyle("F{$start_body}:F{$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);
         $this->footer($objPHPExcel, $start, $file_name, $format, "Lampiran Donasi Non Tunai");
         Yii::app()->end();
     }
 }
 public function actionIndex()
 {
     if (isset($_POST['limit'])) {
         $limit = $_POST['limit'];
     } else {
         $limit = 20;
     }
     if (isset($_POST['start'])) {
         $start = $_POST['start'];
     } else {
         $start = 0;
     }
     $param = array();
     $criteria = new CDbCriteria();
     if (isset($_POST['nama'])) {
         $criteria->addCondition("nama like :nama");
         $param[':nama'] = "%" . $_POST['nama'] . "%";
     }
     if (isset($_POST['keterangan'])) {
         $criteria->addCondition("keterangan like :keterangan");
         $param[':keterangan'] = "%" . $_POST['keterangan'] . "%";
     }
     if (isset($_POST['satuan'])) {
         $criteria->addCondition("satuan like :satuan");
         $param[':satuan'] = "%" . $_POST['satuan'] . "%";
     }
     if (isset($_POST['qty'])) {
         $criteria->addCondition("qty = :qty");
         $param[':qty'] = $_POST['qty'];
     }
     if (isset($_POST['trans_date'])) {
         $criteria->addCondition("trans_date = :trans_date");
         $param[':trans_date'] = substr($_POST['trans_date'], 0, 10);
     }
     $criteria->limit = $limit;
     $criteria->offset = $start;
     $criteria->params = $param;
     $model = PahLampiran::model()->findAll($criteria);
     $total = PahLampiran::model()->count($criteria);
     $this->renderJson($model, $total);
 }