 ($_POST['topeminjaman'] as $key => $value) {
                    if ($value!= "0" ) {
                        $andValue.= " AND '".date("Y-m-d", strtotime( $value ) )."' ";
                    }
                }
            }

            if (isset($_POST['jatuh_tempo'])) {
            foreach ($_POST['jatuh_tempo'] as $key => $value) {
                if ($value!= "0" ) {
                    $andValue.= " OR DATE(sentitems.SendingDateTime) BETWEEN '".date("Y-m-d", strtotime( $value ) )."' ";
                    }
                }
            } 
            if (isset($_POST['tojatuh_tempo'])) {
                foreach ($_POST['tojatuh_tempo'] as $key => $value) {
                    if ($value!= "0" ) {
                        $andValue.= " AND '".date("Y-m-d", strtotime( $value ) )."' ";
                    }
                }
            }   
             
            if (isset($_POST['no_anggota'])) {
            foreach ($_POST['no_anggota'] as $key => $value) {
                if ($value!= "0" ) {
                    $andValue.= " AND members.ID = '".addslashes($value)."' ";
                    }
                }
            }  

            
            $sql = "SELECT ".$periode_format.", 
                    COUNT(sentitems.DestinationNumber) AS jum_anggota, 
                    COUNT(collections.ID) AS jumlah_koleksi, 
                    COUNT(IF(sentitems.Status!= 'SendingError',0,NULL)) sukses_send,
                    COUNT(IF(sentitems.Status = 'SendingError',0,NULL)) gagal_send
                    FROM 
                    sentitems
                    INNER JOIN members ON members.Phone = sentitems.DestinationNumber
                    INNER JOIN collections ON collections.BookingMemberID = members.MemberNo
                    WHERE DATE(sentitems.SendingDateTime) ";        
        
        $sql.= $sqlPeriode;
        $sql.= $andValue;
        if ($_POST['periode'] == "harian"){
                    $sql.= " GROUP BY DATE_FORMAT(sentitems.SendingDateTime,'%d-%m-%Y') ORDER BY DATE_FORMAT(sentitems.SendingDateTime,'%Y-%m-%d') DESC";
                } elseif ($_POST['periode'] == "bulanan") {
                    $sql.= " GROUP BY MONTH(sentitems.SendingDateTime) ORDER BY DATE_FORMAT(sentitems.SendingDateTime,'%Y-%m-%d') DESC";
                } else {
                    $sql.= " GROUP BY YEAR(sentitems.SendingDateTime) ORDER BY DATE_FORMAT(sentitems.SendingDateTime,'%Y-%m-%d') DESC";
                }

        $data = Yii::$app->db->createCommand($sql)->queryAll(); 

        $Berdasarkan = array();
        foreach ($_POST['kriterias'] as $key => $value) {
            $Berdasarkan[].= ''.yii::t('app',$this->getRealNameKriteria($value)).'';
        }
        $Berdasarkan = implode(yii::t('app',' dan '), $Berdasarkan);

        // if (count($_POST['kriterias']) == 1 && implode($_POST[implode($_POST['kriterias'])])!== "0") {
         
        //     $Berdasarkan.='('.implode($_POST[implode($_POST['kriterias'])]). ')';
        // }

        $content['LaporanKriteria'] = ""; 
        $content['LaporanSubJudulKriteriaVal'] = '$kriteriaVal'; 
        $content['TableLaporan'] = $data; 
        $content['LaporanPeriode'] = $periode;
        $content['LaporanPeriode2'] = $periode2;
        $content['sql'] = $sql; 
        $content['Berdasarkan'] = $Berdasarkan;
        $content['kop'] =  isset($_POST['kop']); 

        if ($content['kop']) {
            $header =  ['<img src="'.Yii::$app->urlManager->createUrl("../uploaded_files/aplikasi/kop.png").'" style="margin-top: -30px; height: 180; width: 100%;" >'];
            $set = 55;
        } else {
            $header =  [''];
            $set = 10;
        }

        $pdf = new Pdf([
           'mode' => Pdf::MODE_CORE, // leaner size using standard fonts
           'marginTop' => $set,
           'marginLeft' => 0,
           'marginRight' => 0,
            'content' => $this->renderPartial('pdf-view-laporan-periodik-frekuensi', $content),
            'options' => [
            'title' => 'Laporan Frekuensi',
           'subject' => 'Perpustakaan Nasional Republik Indonesia'],
           'methods' => [ 
                'SetHeader'=> $header,
                'SetFooter'=>['<div class="footer" style="margin-right:60px;">Page {PAGENO}</div>'],
            ],
            ]);
        return $pdf->render();

    }

public function actionExportExcel()
{
    // $model = Opaclogs::find()->All();

        $_POST =  $_SESSION['Array_POST_Filter'];
        $andValue = '';
        $sqlPeriode = '';
        $subjek = '';

          //Untuk Header Laporan berdasarkan Periode yng dipilih
        if (isset($_POST['periode'])) 
        {
            if ($_POST['periode'] == "harian") 
            {
                $periode_format = 'DATE_FORMAT(sentitems.SendingDateTime,"%d-%M-%Y") Periode';
                $periode = yii::t('app','Harian');
                $periode2= yii::t('app','Periode').' '.$_POST['from_date'].' s/d '.$_POST['to_date'];
                $sqlPeriode = "BETWEEN '".date("Y-m-d", strtotime($_POST['from_date']) )."' AND '".date("Y-m-d", strtotime($_POST['to_date']) )."' ";
            } 
            elseif ($_POST['periode'] == "bulanan") 
            {
                $periode_format = 'DATE_FORMAT(sentitems.SendingDateTime,"%M-%Y") Periode';
                $periode = yii::t('app','Bulanan');
                $periode2= yii::t('app','Periode').' '.date("M", mktime(0, 0, 0, $_POST['fromBulan'], 10)).'-'.$_POST['fromTahun'].' s/d '.date("M", mktime(0, 0, 0, $_POST['toBulan'], 10)).'-'.$_POST['toTahun'];
                $sqlPeriode = "BETWEEN '".date("Y-m-d", mktime(0,0,0,$_POST['fromBulan'],1,$_POST['fromTahun']))."' AND '".date("Y-m-t", mktime(0,0,0,$_POST['toBulan'],1,$_POST['toTahun']))."' ";
            } 
            elseif ($_POST['periode'] == "tahunan") 
            {
                $periode_format = 'DATE_FORMAT(sentitems.SendingDateTime,"%Y") Periode';
                $periode = yii::t('app','Tahunan');
                $periode2= yii::t('app','Periode').' '.$_POST['fromTahunan'].' s/d '.$_POST['toTahunan'];
                $sqlPeriode = "BETWEEN '".date("Y-m-d", mktime(0,0,0,1,1,$_POST['fromTahunan']))."' AND '".date("Y-m-d", mktime(0,0,0,12,31,$_POST['toTahunan']))."' ";
            }
            else 
            {
                $periode