Your IP : 216.73.216.79


Current Path : /var/www/html/planmalaysiav2/common/components/
Upload File :
Current File : /var/www/html/planmalaysiav2/common/components/PortalModule.php

<?php 

namespace common\components;

use yii\BaseYii as Yii;
use common\components\LanguageSwitcher;
use yii\db\Expression;

class PortalModule {

    public $assetbundle;

    private $module = [
        'translate',
        'php',
        'helloworld',
        'slider',
        'statistik',
        'aktiviti',
        'didyaknow',
        'nextmonth',
        'contactus',
        'poll',
        'visitor',
        // 'announcement',
        'artikel',
        'artikelterkini',
        'langswitch',
        'currentdate',
        'breadcrumb',
        'langcode',
        'photogallery',
        'videogallery',
        'infographic',
        'flash',
        'faq',
        'quiz',
        'currentlang',
        'modalfooter',
		'waktusolat',
    ];

    private $trait = [
        'common\components\PortalModuleExtension',
    ];

    public function traitInit()
    {
        foreach ($this->trait as $class) {
            $ref = new \ReflectionClass($class);
            $obj = $ref->newInstanceArgs();
            $tag = $ref->getProperty('tag');
            $tagval = $tag->getValue($obj);
            $this->setTag($tagval);
        }
    }

    public function load($content)
    {  
        /* load trait */
        $this->traitInit();
        /* tags */
        $tags = implode("|", $this->module);
        
        return preg_replace_callback(
            "#\[((?:$tags)+?)\]([\s\S]*?|(?R))\[[^'-]*?\/((?:$tags)+?)\]#",
            function ($matches){
                // if (method_exists($this, $matches[1])) {
                    return $this->{$matches[1]}($matches[2]);
                // }
            },
            $content
        );
    }

    public function setTag($tag){

        foreach ($tag as $tags) {
            array_push($this->module, $tags); 
        }
    }

    public function __call($method,$argument)
    {
        foreach ($this->trait as $tval) {
            if (method_exists($tval, $method)) {
                $ref = new \ReflectionClass($tval);
                $obj = $ref->newInstanceArgs();
                return $obj->{$method}($argument);
            }
        }
    }

    private function translate($content)
    {
        return Yii::t("portal",$content);
    }

    public function php($content)
    {   
        $tmpfname = @tempnam(sys_get_temp_dir(), "tmp");
        $handle = fopen($tmpfname, "w+");
        fwrite($handle, $content);
        fclose($handle);
        include($tmpfname);
        $output = ob_get_contents(); // This contains the output of yourtemplate.php
        ob_end_clean();
        unlink($tmpfname);
        return $output;
    }
	
	public function waktusolat() {
		$curl = curl_init();

		curl_setopt_array($curl, array(
		  CURLOPT_URL => "https://www.e-solat.gov.my/index.php?r=esolatApi/TakwimSolat&period=year&zone=WLY01",
		  CURLOPT_RETURNTRANSFER => true,
		  CURLOPT_TIMEOUT => 30,
		  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		  CURLOPT_CUSTOMREQUEST => "GET",
		  CURLOPT_HTTPHEADER => array(
			"cache-control: no-cache"
		  ),
		));

		$response = curl_exec($curl);
		$err = curl_error($curl);

		curl_close($curl);
		// print_r(json_decode($response));

		/*foreach (json_decode($response) as $key => $value) {
			print_r($value[0]);
		}*/
		// print_r($todaywaktusolat);
		$html = "";
		$html .=
<<<HTML
        <p>hijaz hensem</p>
HTML;
        return  $html;
	}

    public function slider($content){
        $sliders  = \backend\models\BanciImageSlider::find()->where(['banci_image_slider_status' => '1'])->all();

        $html = '';
        foreach($sliders as $slider){
            $img = str_replace('#img','admin/uploads/'.$slider->banci_image_slider_image_url,$content);
            $desc = str_replace('#desc', $slider->banci_image_slider_description, $img);

            if(Yii::$app->language == "en"){
                $img = str_replace('#img','admin/uploads/'.$slider->banci_image_slider_image_url_en,$content);
                $desc = str_replace('#desc', $slider->banci_image_slider_description_en, $img);
            }

            $html .= $desc;
        }

        return $html;
    }

    public function statistik(){
        $stat = \backend\models\BanciStatistic::find()->orderBy(['banci_statistic_sort' => 'ASC'])->all();

        $html = '';
        foreach ($stat as $svalue) {
            $icon  = $svalue->banci_statistic_icon_image;
            $title = Yii::t('portal',$svalue->banci_statistic_title);
            $desc  = Yii::t('portal',$svalue->banci_statistic_description);
            $count = $svalue->banci_statistic_counter;
            $html .=
<<<HTML
                <!-- <div class="col-md-2 col-sm-4 col-xs-6 w3_footer_grid"> -->
                    <div class="mainstats">
                        <img src="admin/uploads/$icon" style="width:40%;margin-left: 30%;margin-right:30%;margin-top:10px;">

                        <h3 style="margin-bottom:0;text-align: center;background: none;color: #888;padding-top: 10px">$title</h3>
                        <h4 style="background: none;margin:0;padding:10px;text-align: center;font-weight: bold;position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;">$count</h4>
                    </div>
                <!-- </div> -->

HTML;
        }
        return  $html;   
    }

    public function aktiviti(){
        $aktivit = \backend\models\BanciActivitiesInformation::find()->all();
        $html = '';
        $count = 0;
        foreach ($aktivit as $avalue) {
            $count++;
            if (Yii::$app->language == 'my') {
                $title = $avalue->banci_activities_information_title;
                $subtitle = $avalue->banci_activities_information_subtitle;
                $description = $avalue->banci_activities_information_description;
            } else if (Yii::$app->language == 'en') {
                $title = $avalue->banci_activities_information_title_en;
                $subtitle = $avalue->banci_activities_information_subtitle_en;
                $description = $avalue->banci_activities_information_description_en;
            }
            
            $icon = $avalue->banci_activities_information_icon;
            $link = $avalue->banci_activities_information_url;

        $html .=
<<<HTML
            	<div class="col-md-3 col-sm-6 col-xs-6 w3ls-markets-grid text-center" onclick="appclick($count,'$link')">
                <!-- <a href="$link"> -->
					<div class="agileits-icon-grid" style="min-height:300px">
						<div class="icon-left">
							<i class="$icon" aria-hidden="true"></i>
						</div>
						<div class="icon-right">
							<h5>$title</h5>
							<p>$description</p>
						</div>
						<div class="clearfix"></div>
                    </div>
                <!-- </a> -->
				</div>

                <script>
                    function appclick(no,link) {
                        if (no==1) {
                            $('#eCensusModal').modal();
                        } else {
                            window.location.href = link;
                        }
                    }
                </script>
HTML;
        }
        return $html;
    }

    public function content($type){
        $content = \backend\models\BanciGeneralContent::find()->where(['banci_general_content_type'=>$type])->all();
        return $content;
    }

//    public function didyaknow(){
//        $content = \backend\models\BanciArticle::find()->where(['banci_article_category'=>'DK'])->AsArray()->one();
//        $lang = Yii::$app->language;
//        return $content['banci_article_content_'.$lang];
//    }



//     public function didyaknow(){
//         $content = $this->content('DK');
//         $html = ''; 
//         foreach ($content as $cvalue) {

//             if(Yii::$app->language == 'my'){
//                 $title = $cvalue->banci_general_content_title;
//                 $content = $cvalue->banci_general_content_content;
//             }else{
//                  $title = $cvalue->banci_general_content_title_en;
//                 $content = $cvalue->banci_general_content_content_en;

//             }
//             $html .=
// <<<HTML
//                 <div class="col-md-7  col-sm-8 col-xs-8 wthree-offers1-right" style="background: #372d6d;">
//                     <h3 style="color:#fff;margin-bottom:30px;font-weight: :bold;">$title</h3>
//                     $content
//                 </div>
// HTML;
//         }
//         return $html;
//     }

    public function didyaknow(){ // dynamic 21-May-2018 2:20 AM
        // $content = $this->content('DK');
        $content = \backend\models\BanciArticle::find()->where(['banci_article_category'=>'DK','banci_article_status'=>0])->orderBy(new Expression('rand()'))->one();
        $html = ''; 
        $didyaknowtitle = Yii::t("portal","Tahukah Anda?");
        // foreach ($content as $cvalue) {

            if(Yii::$app->language == 'my'){
                $title = $content->banci_article_title_my;
                $contentarticle = $content->banci_article_content_my;
                $img = $content->banci_article_image;
            }else{
                $title = $content->banci_article_title_en;
                $contentarticle = $content->banci_article_content_en;
                $img = $content->banci_article_image;
            }
            $html .=
<<<HTML
            <div class="col-md-7  col-sm-8 col-xs-8 wthree-offers1-right" style="background: #372d6d;min-height: 350px">
                <h3 style="color:#fff;margin-bottom:30px;font-weight: :bold;">$didyaknowtitle</h3>
                <h4 style="color:#fff;margin-bottom:10px;font-weight: :bold;">$title</h4>
                $contentarticle
            </div>
            <div class="col-md-5 col-sm-4  col-xs-4 wthree-offers1" style="padding:20px;">
                <img src="/banci/www/admin/uploads/$img" alt="" class="img-responsive" />
            </div>
HTML;
        // }
        return $html;
    }

    public function nextmonth(){
        // $nextmonth = \backend\models\BanciNextMonth::find()->all();
        $sql = "SELECT * FROM banci_next_month WHERE banci_next_month_date > NOW() ORDER BY banci_next_month_date LIMIT 2";
        $nextmonth = Yii::$app->db->createCommand($sql)->queryAll();
        $nextmonthtitle = Yii::t('portal','BULAN - BULAN SETERUSNYA');
        $nextmonthsubtitle = Yii::t('portal','Kalendar Banci Anda.');
        $html = '<div class="offers-left-heading">
					<h4>'.$nextmonthtitle.' </h4>
                    <h5>'.$nextmonthsubtitle.'</h5>
				</div>';

        foreach ($nextmonth as  $nvalue) {
            $date = $nvalue['banci_next_month_date'];
            $desc = $nvalue['banci_next_month_description'];
            $day  = date('d',strtotime($date));
            $datefull = date('d M Y', strtotime($date));
            $html .=
<<<HTML
            <div class="offers-left-grids" style="margin-top:10px;">
                <div class="offers-number">
                    <p>$day</p>
                </div>
                <div class="offers-text">
                    <h4>$datefull</h4>
                    <p><i class="fa fa-angle-right" aria-hidden="true"></i>&nbsp;$desc</p>
                </div>
                <div class="clearfix"></div>
            </div>
HTML;
        }

        return $html;
    }

    public function contactus(){
        $content = $this->content('CU');
        foreach($content as $cvalue){
            if(Yii::$app->language == "my"){
                $content = $cvalue->banci_general_content_content;
            }else{
                $content = $cvalue->banci_general_content_content_en;
            }
            break;
        }
        return $content;
    }

    public function poll(){
        $mpoll = \backend\models\BanciQuestionaire::find()->where(['questionaire_featured' => '1'])->asArray()->one();
        $send = Yii::t('portal','HANTAR');
        if (Yii::$app->language == 'my')
            $question = $mpoll['questionaire_question'];
        else
            $question = $mpoll['questionaire_question_en'];
        $id = $mpoll['questionaire_id'];
        $pollresult = Yii::t('portal','Keputusan Poll');
        $title = $mpoll['questionaire_title'];
        $publicpoll = Yii::t('portal','Public Poll');
        
        if($mpoll == NULL){
            return '';
        }

        $option1 = '';
        $option2 = '';
        $option3 = '';
        $option4 = '';
        $option5 = '';
        if(!empty($mpoll['questionaire_option_1'])){

            $myoption1 =  $mpoll['questionaire_option_1'];
            $option1 = '<span><input name="vote" style="display: inline-block;float: left;margin-right:10px;" type="radio" value="1" />'.$myoption1.' </span><br />';
        }

        if(!empty($mpoll['questionaire_option_2'])){

            $myoption2 =  $mpoll['questionaire_option_2'];
            $option2 = '<span><input name="vote" style="display: inline-block;float: left;margin-right:10px;" type="radio" value="2" />'.$myoption2.' </span><br />';
        }
        

        if(!empty($mpoll['questionaire_option_3'])){
            $myoption3 = $mpoll['questionaire_option_3'];
            $option3 = '<span><input name="vote" style="display: inline-block;float: left;margin-right:10px;" type="radio" value="3" />'.$myoption3.' </span><br />';
        }

        if(!empty($mpoll['questionaire_option_4'])){

            $myoption4 =  $mpoll['questionaire_option_4'];
            $option4 = '<span><input name="vote"  style="display: inline-block;float: left;margin-right:10px;" type="radio" value="4" />'.$myoption4.' </span><br />';
        }

        if(!empty($mpoll['questionaire_option_5'])){

            $myoption5 =  $mpoll['questionaire_option_5'];
            $option5 = '<span><input name="vote"  style="display: inline-block;float: left;margin-right:10px;" type="radio" value="5" />'.$myoption5.' </span><br />';
        }

        $csrftoken = Yii::$app->request->csrfToken;
        $csrfparam = Yii::$app->request->csrfParam;
        $form = 
<<<HTML

<style>
#formpoll span,#formpoll input{
    padding:5px 5px 5px 0;
    display:inline-block;
}
#sendhr{
    border-bottom:1px solid #baa5a5;
}
</style>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script>
$(document).ready(function(){
    
    var answer = getCookie('hasAnswer');

    if(answer){
        $('#formpoll').empty();
        $('#formpoll').append('<div class="alert alert-info">Terima Kasih Atas Maklumbalas anda!!</div>');
    }

    $('#sendpoll').click(function(){

        if($('input[name=vote]:checked').length > 0){
            $.ajax({
                    url:"index.php?r=/banci-questionaire/ajax-poll-save&id=$id",
                    method:'POST',
                    dataType:'html',
                    data: $('#form$id').serialize(),
                    success:function(result){
                            if(result == "ok!!"){
                                $('#pollmodal').modal('show');
                                $('#formpoll').empty();
                                $('#formpoll').append('<div class="alert alert-info">Terima Kasih Atas Maklumbalas anda!!</div>');
                                setCookie('hasAnswer','true',7);
                            }
                    }
                });
        }else{
            alert('Sila Buat Pilihan Terlebih dahulu');
        }   
    });

    $('#pollmodal').on('shown.bs.modal',function(){
        $.ajax({
           url:"index.php?r=banci-questionaire/get-poll&id=$id",
           method:'GET',
           dataType:'json',
           success:function(result){
               drawpoll(result);
           }
        });
    });
        function drawpoll(data){
            // Set up the chart
            var chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'pollresultcontainer',
                    type: 'column',
                    options3d: {
                        enabled: true,
                        alpha: 15,
                        beta: 15,
                        depth: 50,
                        viewDistance: 25
                    }
                },
                title: {
                    text: '$pollresult'
                },
                xAxis: {
                    categories:data.categories,
                    labels: {
                        skew3d: true,
                        style: {
                            fontSize: '16px'
                        }
                    }
                },
                subtitle: {
                    text: '$title'
                },
                plotOptions: {
                    column: {
                        depth: 25
                    }
                },
                series: [{
                    name:'$question',
                    data: data.polldata
                }]
            });
        }
    });
</script>

<div class="col-xs-12 col-sm-4" style="margin-top: 30px;" id="pollcontainer">
    <h2 class="fcolortajuk" style="font-family: 'Lato', sans-serif !important;margin-bottom:30px;">$publicpoll</h2>
    <div id="formpoll" style="font-family: 'Lato', sans-serif !important;">
    <p><b>$question</b></p>
        <form id="form$id" action="">
            <!-- option 1 -->
            $option1
            <!-- option 2 -->
            $option2
            <!-- option 3 -->
            $option3
            <!-- option 4 -->
            $option4
            <!-- option 5 -->
            $option5
            <input id="poll-form-token" type="hidden" name="$csrfparam" value="$csrftoken"/>
            <!--hr id="sendhr"-->
            <span><button style="padding:5px;margin-" class="btn btn-primary" id="sendpoll" type="button">$send</button></span>
        </form>
    </div>
</div>


<!-- Modal -->
<div class="modal fade" id="pollmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <!-- <h3 class="modal-title" id="myModalLabel">$pollresult</h3> -->
      </div>
      <div class="modal-body">
        <div id="pollresultcontainer"></div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->
      </div>
    </div>
  </div>
</div>

HTML;

return $form;
}
    
     public function visitor(){
        $content = $this->content('VS');
        foreach($content as $cvalue){
            if(Yii::$app->language == "my"){
                $content = $cvalue->banci_general_content_content;
            }else{
                $content = $cvalue->banci_general_content_content_en;
            }
            break;
        }
        return $content;
    }

    // public function announcement(){
    //     $content = \backend\models\BanciNextMonth::find()->where(['banci_announcement_status'=>1])->all();
    //     foreach($content as $cvalue){
    //         $content = $cvalue->banci_announcement_content;
    //         break;
    //     }
    //     return $content;
    // }

    public function artikel($code){
        
        $content  = \backend\models\BanciArticle::find()->where(['banci_article_category'=>$code,'banci_article_status' => '0'])->all();
        $contentdata = [];
        $subArr = [];

        $i = 0;
        foreach ($content as $ccat) {
            $sub = $ccat->banci_article_subcategory;
            $id = $ccat->banci_article_id;   
            $ref = \backend\models\Ref::find()->where(['cat' => 'STYPE','code' => $sub])->one();
            $descr = Yii::t('portal',$ref['descr']);
            $code = $ref['code'];
            $contentdata[$code][$id]['image'] = $ccat->banci_article_image;

            if(Yii::$app->language == "my"){
                $contentdata[$code][$id]['title'] = $ccat->banci_article_title_my;
                $contentdata[$code][$id]['string'] = $ccat->banci_article_content_my;
            }else{
                $contentdata[$code][$id]['title'] = $ccat->banci_article_title_en;
                $contentdata[$code][$id]['string'] = $ccat->banci_article_content_en;
            }
            $contentdata[$code][$id]['update'] = date('d-m-Y H:i:s', strtotime($ccat->updated_at));
        $i++;}

         /* tab bar */
        $html = ' <ul class="nav nav-tabs">';
        $c = 0;
        foreach($contentdata as $cont => $conval){
            $active = ($c == 0) ? 'active' : '';$c++;

            $html .=
<<<HTML
            <li class="artikel $active"><a href="#$cont" data-toggle="tab">$descr</a></li>
HTML;
        }
        $html .= '</ul>';
        $html .= '<div class="tab-content " style="padding-top:1em;">';
        
        $i = 0;
        foreach($contentdata as $cval => $carr){
        
        $active = ($i == 0) ? 'active' : '';$i++;
        
        $html .= '<div class="tab-pane '.$active.' " id="'.$cval.'">';

            foreach($carr as $crrval){

                $image = $crrval['image'];
                $title = $crrval['title'];
                $string = $crrval['string'];
                $update = $crrval['update'];
                $width = 10;

                if (strlen($string) > $width) 
                {
                    $string = wordwrap($string, $width);
                    $string = substr($string, 0, strpos($string, "\n"));
                }
                $html .= 
<<<HTML
      
                    <div class="row">
                        <div class="col-lg-4 agileits_services_grid">
                            <div class="w3_agile_services_grid1 animated fadeIn">
                                <img src="admin/uploads/$image" class="img-responsive animated fadeIn">
                                <div class="w3_blur"></div>
                            </div>
                        </div>
                        <div class="col-lg-8">
                            <h3 class="animated slideInUp">$title</h3>
                            <p class="animated slideInUp"><span>Kemaskini pada $update</span></p>
                            <p class="animated slideInUp">Mauris urna risus, tincidunt vel condimentum vel, maximus eu sem. Morbi fermentum, enim ac rhoncus sollicitudin, elit justo ornare mi, vitae iaculis diam risus id nisi.</p>
                            <div class="w3layouts_more2">
                                <a href="admin/uploads/$image" class="animated slideInUp">Selanjutnya</a>
                            </div>
                        </div>
                    </div>
                    <hr>
HTML;
            }
            $html .= '</div>';
        }
        $html .= '</div>';

        return $html;

    }

    public function artikelterkini($code){    
        $content  = \backend\models\BanciArticle::find()->where(['banci_article_category'=>$code,'banci_article_status' => '0'])->orderBy(['created_at' => 'DESC'])->all();
        $html = '<div class="col-lg-3">
			        <h3>Terkini</h3>
			            <hr>';
        foreach ($content as $ckey => $cval) {
        $image = $cval->banci_article_image;
        if(Yii::$app->language == "my"){
            $title = $cval->banci_article_title_my;
        }else{
            $title = $cval->banci_article_title_en;
        }
        $html .= 
<<<HTML
        <div class="agileits_services_grid">
            <div class="w3_agile_services_grid1 animated fadeIn">
                <img src="admin/uploads/$image" class="img-responsive animated fadeIn">
                <div class="w3_blur"></div>
            </div>
        </div>
        <a href="" class="animated slideInUp"><p style="padding-top:0.5em">$title <span class="badge badge-primary">Terkini</span></p></a>
        <hr>
HTML;
        }

        $html .= '</div>';

        return $html;
    }

    public function langswitch(){
        // $assetBundle = InspiniaAsset::register($this);
        return languageSwitcher::Widget(["bundleBase"=>$this->assetbundle->baseUrl]);
    }

    public function currentdate(){
        date_default_timezone_set('Asia/Kuala_Lumpur');
        if (Yii::$app->language == 'en'){ // ENGLISH
            return date("l d M Y");
        } else{ // MALAY
            $date = date("Y/m/d");
  
            // months in Malay
            $months = array(1 => "Januari",
                    2 => "Februari",
                    3 => "Mac",
                    4 => "April",
                    5 => "Mei",
                    6 => "Jun",
                    7 => "Julai",
                    8 => "Ogos",
                    9 => "September",
                    10=> "Oktober",
                    11=> "November",
                    12=> "Disember");
        
            $mj = date("n", strtotime($date));
        
            // days in Malay
            $days = array(1 => "Isnin",
                    2 => "Selasa",
                    3 => "Rabu",
                    4 => "Khamis",
                    5 => "Jumaat",
                    6 => "Sabtu",
                    7 => "Ahad");
        
            $dy = date("N", strtotime($date));
        
            $fullday = $days[$dy]; // For example Monday
            $month = $months[$mj]; // For example January
            $day = date("d", strtotime($date)); //For example 1
            $year = date("Y", strtotime($date));// For example 2018

            return $fullday.' '.$day.' '.$month.' '.$year;
        }
    }

    public function currentlang(){
        $lang = Yii::$app->language;
        return $lang;
    }

    public function breadcrumb(){
        $page_id = Yii::$app->request->get('page_id');

        $content = \backend\models\Breadcrumb::find()->where(['breadcrumb_page_id'=>$page_id])->one();

        $arrlink = explode(",",$content->breadcrumb_href_link);
        $arrtitle = explode(",",$content->breadcrumb_title);
        $html = "<label>";
        foreach ($arrtitle as $key => $value) {
            if ($key == 0) {
                $html .= '<a href="'.$arrlink[$key].'"><i class="fa fa-home"></i> '.strtoupper(Yii::t("portal",$value)).'</a>';  
            } else {
                $html .= '&nbsp;&raquo;&nbsp;';
                $html .= '<a href="'.$arrlink[$key].'">'.strtoupper(Yii::t("portal",$value)).'</a>';
            }
        }
        $html .= "</label>";
        return $html;
    }

    public function langcode(){
        return Yii::$app->language;
    }

    public function photogallery(){
        $aid = Yii::$app->request->get('aid');
        $content = \backend\models\BanciMediaGallery::find()->where(['media_gallery_id'=>$aid])->orderBy(['created_at' => 'ASC'])->one();
        $html = '';
        $imgurl = explode('#',$content['media_gallery_file_url']);
        foreach ($imgurl as $key) {
            $html .= '<a href="admin/'.$key.'" data-ngthumb="admin/'.$key.'"></a>';
        }
        return $html;
    }

    public function videogallery(){
        $content = \backend\models\BanciMediaGallery::find()->where(['media_gallery_file_type'=>2])->orderBy(['created_at' => 'ASC'])->all();
        $html = '';
        foreach ($content as $key) {
            $html .= '<a href="'.$key->media_gallery_file_url.'">'.$key->media_gallery_title.'</a>';
        }
        return $html;
    }

    public function infographic($code){
        $content = \backend\models\BanciArticle::find()->where(['banci_article_category'=>$code,'banci_article_status'=>0])->orderBy(['created_at' => 'ASC'])->all();
        $html = '';
        foreach ($content as $key) {
            $html .= '<a href="admin/uploads/'.$key->banci_article_image.'" data-ngthumb="admin/uploads/'.$key->banci_article_image.'"></a>';
        }
        return $html;
    }

    public function flash(){
        $aid = Yii::$app->request->get('aid');
        $html = '';

        if ($aid == 37){
            $html .= '<embed src="admin/uploads/visbanci/flashdosm2.swf" quality="high" bgcolor="#ffffff" width="100%" height="400" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        } else if ($aid == 48){
            $html .= '<embed src="admin/uploads/visbanci/Homo statiscus.swf" quality="high" bgcolor="#ffffff" width="100%" height="500" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        } else if ($aid == 96){
            $html .= '<embed src="admin/uploads/visbanci/Visualization new.swf" quality="high" bgcolor="#ffffff" width="100%" height="500" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        } else if ($aid == 192){
            $html .= '<embed src="admin/uploads/visbanci/Visualization new.swf" quality="high" bgcolor="#ffffff" width="100%" height="500" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        } else if ($aid == 193){
            $html .= '<embed src="admin/uploads/visbanci/Visualization 2.swf" quality="high" bgcolor="#ffffff" width="100%" height="500" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        } else if ($aid == 194){
            $html .= '<embed src="admin/uploads/visbanci/Visualization 3.swf" quality="high" bgcolor="#ffffff" width="100%" height="500" name="intro" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
        }

        return $html;
    }

    public function faq(){
        $content = \backend\models\BanciFaq::find()->where(['faq_status'=>1])->orderBy(['faq_no' => 'ASC'])->all();
        $html = '';

        foreach ($content as $key) {

            if (Yii::$app->language == 'my') {
                $question = $key->faq_question_my;
                $answer = $key->faq_answer_my;
            } else if (Yii::$app->language == 'en') {
                $question = $key->faq_question_en;
                $answer = $key->faq_answer_en;
            }
            $html .= '<button class="accordion">'.$question.'</button>';
            $html .= '<div class="panel">';
            $html .= '<p>'.$answer.'</p>';
            $html .= '</div>';
        }
        return $html;
    }

    public function modalfooter(){
        $html = '';
        $html .= 
<<<HTML
        <div class="modal-footer">
            <!--button type="button" class="btn btn-primary" data-dismiss="modal"  style="visibility:visible;">Close</button-->
            <p style="width:100%;text-align:center;"><small><a href="tel:+60388857000" style="color:#333333;"><i class="fa fa-phone" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;+603-88857000</a>,&nbsp;
            <a href="https://www.dosm.gov.my" style="color:#333333;"><i class="fa fa-globe" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;https://www.dosm.gov.my</a>,&nbsp;
            <a href="www.mycensus.gov.my" style="color:#333333;"><i class="fa fa-globe" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;www.mycensus.gov.my</a></small></p>
        </div>
HTML;
        return $html;
    }
}