NG1NDEX
Server IP : 103.233.192.212  /  Your IP : 18.118.162.243
Web Server : Apache/2
System : Linux sv1.inde.co.th 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64
User : sumpatuan ( 1058)
PHP Version : 5.5.38
Disable Function : symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,putenv,passthru,escapeshellarg,escapeshellcmd,pcntl_exec,proc_get_status,proc_nice,proc_terminate,pclose,ini_alter,virtual,openlog,ini_restore
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/sumpatuan/public_html/backup/protected/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/sumpatuan/public_html/backup/protected/controllers/MainController.php
<?php

class MainController extends Controller {
    
    // หน้าแรก สำหรับเข้าเว็บ
    function actionMain() {
        $this->layout = 'main';
        $this->pageTitle = Yii::app()->name.'ยินดีต้อนรับ';
 	$this->render('main');

    

    }
    
    // หน้ารอง หลังจากเข้ามา ภายในเว็บ
    function actionMainHomepage() {
        $this->layout = 'main-home';
        $this->pageTitle = Yii::app()->name.'ยินดีต้อนรับ';
        $this->render('mainHomepage');
    }
    
    // หน้าแสดงสถานะผิดพลาด ของระบบ
    function actionError() {
        $this->layout = '_layout-state';
        $this->pageTitle = 'เกิดข้อผิดพลาด';
        
        $this->render('_state-error');
    }
    
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    
    /*
     * หน้า Login Administrator
     * 
     */
    
    // เข้าสู่ระบบ สำหรับผู้ดูแล
    function actionLoginAdmin() {
        $this->layout = '_layout-state';
        $this->pageTiTle = Yii::app()->name.'Administrator';
        
        $model = new tbAdmin();
        
        if (!empty($_POST)) {

            $user = $_POST['tbAdmin']['admin_user'];
            $pass = $_POST['tbAdmin']['admin_pass'];

            if(($user && $pass) != "") {
                $result = $model->findByAttributes(array("admin_user" => $user, "admin_pass" => $pass));

                if (!empty($result)) {
                    
                    Yii::app()->session['sess_id'] = Yii::app()->session->sessionID;
                    Yii::app()->session['admin_id'] = $result['id'];
                    $this->redirect(array("Admin/MainBackend"));
                    
                } else {

                    Yii::app()->user->setFlash('warning', 'Username หรือ Password ไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง!');
                    $this->redirect(array("Main/LoginAdmin"));
                }
            } else {
                Yii::app()->user->setFlash('warning', 'กรุณากรอกข้อมูลให้ครบถ้วน');
                $this->redirect(array("Main/LoginAdmin"));
            }
        }
        
        $this->render('_state-admin-login', array(
            'model' => $model,
        ));
    }
    
    // ออกจากระบบ Backoffice
    function actionLogoutAdmin() {
        unset(Yii::app()->session['admin_id']);
        $this->redirect(Yii::app()->homeUrl);
    }
    
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    
    /*
     * หน้า Login หนังสือเวียน
     * 
     */
    
    // เข้าสู่ระบบ หนังสือเวียน
    function actionLoginNewsbook() {
        $this->layout = '_layout-state';
        $this->pageTiTle = Yii::app()->name.'Newsbook';
        
        $model = new tbNewsbookMember();
        
        if (!empty($_POST)) {

            $user = $_POST['tbNewsbookMember']['mb_user'];
            $pass = $_POST['tbNewsbookMember']['mb_pass'];

            if(($user && $pass) != "") {
                $result = $model->findByAttributes(array("mb_user" => $user, "mb_pass" => $pass));

                if (!empty($result)) {
                    
                    Yii::app()->session['sess_id'] = Yii::app()->session->sessionID;
                    Yii::app()->session['newsbook_member_id'] = $result['id'];
                    $this->redirect(array("Main/MainNewsbook"));
                    
                } else {

                    Yii::app()->user->setFlash('warning', 'Username หรือ Password ไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง!');
                    $this->redirect(array("Main/LoginNewsbook"));
                }
            } else {
                Yii::app()->user->setFlash('warning', 'กรุณากรอกข้อมูลให้ครบถ้วน');
                $this->redirect(array("Main/LoginNewsbook"));
            }
        }
        
        $this->render('_state-admin-newsbook-login', array(
            'model' => $model,
        ));
    }
    
    // หน้าหลัก หนังสือเวียน
    function actionMainNewsbook() {
        $this->layout = '_layout-backend-newsbook';
        $this->pageTitle = 'ข้อมูลหนังสือเวียน';
        
        $model = new tbNewsbook();
        $model->unsetAttributes();
        
        if (isset($_GET['tbNewsbook'])) {
            $model->attributes = $_GET['tbNewsbook'];
        }
        
        $this->render('etc/newsbookMain', array(
            'model' => $model,
        ));
    }
    
    // แสดงข้อมูล หนังสือเวียน
    function actionViewNewsbook($id) {
        $this->layout = '_layout-backend-newsbook';
        $this->pageTitle = 'ข้อมูลหนังสือเวียน';
        
        $model = new tbNewsbook();
        
        if (!empty($id)) {
            $model = $model->findByPk($id);
        } else {
            $this->render(Yii::app()->homeUrl);
        }
        
        // array decode
        $array_decode = CJSON::decode($model->nb_tag_view);
        $newsbook_id = Yii::app()->session['newsbook_member_id'];
        
        // check value in json
        if(sizeOf($array_decode) == 0):
            
            $array_encode[] = $newsbook_id;
        
        elseif(sizeOf($array_decode) != 0):
            
            $array_plus[] = $newsbook_id;
            $array_merge = array_merge($array_decode, $array_plus);
            $array_encode = array_unique($array_merge);
            
        endif;
        
        $model->nb_tag_view = CJSON::encode($array_encode);
        $model->save();
        
        $this->render('etc/viewNewsbook', array(
            'model' => $model,
        ));
    }
    
    // ออกจากระบบ หนังสือเวียน
    function actionLogoutNewsbook() {
        unset(Yii::app()->session['newsbook_member_id']);
        $this->redirect(Yii::app()->homeUrl);
    }
    
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    
    /*
     * ข้อมูล องค์การบริหารส้วนตำบล
     * 
     */
    
    // Main-menu
    // ข้อมูล อบต.
    function actionAboutAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อมูล อบต.';
        
        $this->render('aboutAll');
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * หน่วยงานและอำนาจหน้าที่
     * 
     */
    
    // Main-menu
    // ข้อมูลหน่วยงานและอำนาจหน้าที่
    function actionAgencyAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อมูล หน่วยงานและอำนาจหน้าที่.';
        
        $this->render('agencyAll');
    }
    
    
    ############################################################################
    ############################################################################
    
    /*
     * ลดขั้นตอนการปฏิบัติงาน
     * 
     */
    
    // Main-menu
    // ลดขั้นตอนการปฏิบัติงาน
    function actionReduction() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ลดขั้นตอนการปฏิบัติงาน';
        
        $this->render('reduction');
    }
    
    
    ############################################################################
    ############################################################################
    
    /*
     * บุคลากร
     * 
     */
    
    // ข้อมูลบุคลากร
    function actionPersonalAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนผังบุคลากร';
        
        $this->render('personalAll');
    }
    
    // Fancybox แผนผัง
    function actionPersonalPosView($id) {
        $this->layout = '_layout-fancybox';
        $this->render('personalPosView', array(
            'posId' => $id,
        ));
    }

	
	
	
    ############################################################################
    ############################################################################
    
    /*
     * นโยบายและแผน
     * 
     */
    
    // Main-menu
    // เมนู นโยบายผู้บริหาร
    function actionPlanAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'นโยบายและแผน';
        
        $this->render('planAll');
    }
    
    // เมนู แผนยุทธศาสตร์ และ การพัฒนาท้องถิ่น
    function actionPlanStragegy() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนยุทธศาสตร์ และ การพัฒนาท้องถิ่น';
        
        $model = new tbStragegy();

        $criteria = new CDbCriteria();
        $criteria->compare('stragegy_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/stragegyAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู แผนการดำเนินการ
    function actionPlantypeplan() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนการดำเนินการ';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'plan');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู ผลการดำเนินการ
    function actionPlantyperesult() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ผลการดำเนินการ';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'result');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planResultAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู รายงานติดตามผลการดำเนินการ
    function actionPlantyperesultreport() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'รายงานติดตามผลการดำเนินการ';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'result_report');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planResultReportAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู แผนอัตรากำลัง
    function actionPlantypepplan() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนอัตรากำลัง';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'pplan');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/pPlanAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู รายงานการประชุม
    function actionPlantypereport() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'รายงานการประชุม';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'report');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planReportAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
	
	 // เมนู แผนพัฒนาเทศบาลสามปี
    function actionPlanthree() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนพัฒนาเทศบาลสามปี';
        
        $model = new tbPlanthree();

        $criteria = new CDbCriteria();
        $criteria->compare('planthree_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planthreeAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
	
	 // เมนู แผนพัฒนาท้องถิ่นลี่ปี
    function actionPlanfour() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนพัฒนาท้องถิ่นสี่ปี';
        
        $model = new tbPlanfour();

        $criteria = new CDbCriteria();
        $criteria->compare('planfour_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planfourAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
	
	
		
	
	
	
    /*
     * ข้อบัญญัติ/เทศบัญญัติ
     * 
     */
    
    // Main-menu
    // เมนู ข้อบัญญัติ/เทศบัญญัติ งบประมาณ
    function actionPlantypebudget() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อบัญญัติ งบประมาณ';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'budget');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planBudgetAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู ข้อบัญญัติ/เทศบัญญัติ กฏหมาย
    function actionPlantypelaws() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อบัญญัติ กฏหมาย';
        
        $model = new tbPlan();
        
        $criteria = new CDbCriteria();
        $criteria->compare('plan_type', 'laws');
        $criteria->compare('plan_status', 'Active');
        $criteria->order = 't.id DESC';
        
        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('plan/planLawsAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * ข่าวสารและประกาศ
     * - ข่าวประชาสัมพันธ์: news, pass_activity, newsotop
     * - ข่าวภาษี: tax
     * - ข่าวกิจกรรม: activity
     * - ข่าวจัดชื้อ/จัดจ้าง และ พัสดุ: tb_tender
     * - ข่าวการเงิน: tb_finance
     */
    
    // Main-menu
    // เมนู ข่าวประชาสัมพันธ์, ข่าวภาษี, ข่าวกิจกรรม
    function actionNews() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข่าวประชาสัมพันธ์ ข่าวภาษี ข่าวกิจกรรม';
        
        $model = new tbNews();
        
        $criteria = new CDbCriteria();
        $criteria->compare('news_type', 'news', false, 'OR');
        $criteria->compare('news_type', 'pass_activity', false, 'OR');
        $criteria->compare('news_type', 'newsotop', false, 'OR');
        $criteria->compare('news_status', 'Active');
        $criteria->order = 't.news_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 5),
            'criteria' => $criteria,
        ));
        
        $this->render('news/newsAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionNewsPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbNews();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->news_views = $model->news_views + 1;
        $model->save();
        
        $this->pageTitle = $model->news_title;
        $this->render('news/viewNews', array(
            'model' => $model,
        ));
    }
    
    // เมนู ข่าวภาษี
    function actionNewstypetext() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข่าวภาษี';
        
        $model = new tbNews();
        
        $criteria = new CDbCriteria();
        $criteria->compare('news_type', 'tax');
        $criteria->compare('news_status', 'Active');
        $criteria->order = 't.news_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));

        $this->render('news/newsTaxAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู ข่าวกิจกรรม
    function actionNewstypeactivity() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข่าวกิจกรรม';
        
        $model = new tbNews();
        
        $criteria = new CDbCriteria();
        $criteria->compare('news_type', 'activity');
        $criteria->compare('news_status', 'Active');
        $criteria->order = 't.news_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));

        $this->render('news/newsActivityAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // เมนู ข่าวจัดชื้อ-จัดจ้าง และ พัสดุ
    function actionNewsTender() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข่าวจัดชื้อ-จัดจ้าง และ พัสดุ';
        
        $model = new tbTender();

        $criteria = new CDbCriteria();
        $criteria->compare('tender_status', 'Active');
        $criteria->order = 't.tender_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/tenderAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionNewsTenderPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbTender();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->tender_views = $model->tender_views + 1;
        $model->save();
        
        $this->pageTitle = $model->tender_title;
        $this->render('news/viewTender', array(
            'model' => $model,
        ));
    }
    
	  function actionLinkAll() {
		  $this->layout = 'main-home-sub';
		   $this->render('linkAll');
	  }
    // เมนู ข่าวการเงิน
    function actionNewsFinance() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข่าวการเงิน';
        
        $model = new tbFinance();
     
        $criteria = new CDbCriteria();
        $criteria->compare('finance_status', 'Active');
        $criteria->order = 't.finance_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/financeAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionNewsFinancePreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbFinance();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        $this->pageTitle = $model->finance_title;
        $this->render('news/viewFinance', array(
            'model' => $model,
        ));
    }
    
    
    ############################################################################
    ############################################################################
    
    /*
     * WEBBOARD
     * 
     */
    
    // เรียกข้อมูล Webboard เข้ามายัง Website
    function actionWebboardInclude() {
        $this->layout = '_layout-fancybox';
        $this->render('webboardAll');
    }
    
    
    ############################################################################
    ############################################################################
    
    /*
     * CONTACT
     * 
     */
    
    // ที่อยู่ติดต่อ GOOGLE MAP
    function actionContact() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อมูลการติดต่อ';
        
        $this->render('contact');
    }
    
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
    
    /*
     * ปฏิทินกิจกรรม (หน้าหลัก)
     * 
     */

    // เมนู ปฏิทินกิจกรรม    
    function actionEventnewsPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbEventnews();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->event_views = $model->event_views + 1;
        $model->save();
        
        $this->pageTitle = $model->event_title;
        $this->render('etc/viewEventnews', array(
            'model' => $model,
        ));
    }    
    
    ############################################################################
    ############################################################################
    ###############################  เมนูย่อย  ###################################
    ############################################################################
    ############################################################################
    
    // เมนู E-book วารสารหน่วยงาน
    function actionJournalAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'วารสารหน่วยงาน';
        
        $model = new tbJournal();

        $criteria = new CDbCriteria();
        $criteria->compare('journal_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('journalAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    // เมนู สปสช. สำนักหลักประกันสุขภาพ
    function actionNewsHfundAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'สปสช. สำนักหลักประกันสุขภาพ';
        
        $model = new tbNews();

        $criteria = new CDbCriteria();
        $criteria->compare('news_type', 'hfund');
        $criteria->compare('news_status', 'Active');
        $criteria->order = 't.news_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('newsHfundAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * สถานที่สำคัญ และ สินค้า OTOP
     * 
     */
    
    // Main-menu
    // เมนู OTOP
    function actionOtopAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อมูล OTOP';
        
        $model = new tbOtop();
        $criteria = new CDbCriteria();
        $criteria->compare('otop_status', 'Active');
        $criteria->compare('otop_type', 'otop');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('etc/otopAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionPlaceotopPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbOtop();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->otop_views = $model->otop_views + 1;
        $model->save();
        
        $this->pageTitle = $model->otop_name;
        $this->render('etc/viewPlaceOtop', array(
            'model' => $model,
        ));
    }
    
    // เมนู สถานที่สำคัญ และ สินค้า OTOP
    function actionTravelAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ข้อมูล OTOP';
        
        $model = new tbOtop();

        $criteria = new CDbCriteria();
        $criteria->compare('otop_status', 'Active');
        $criteria->compare('otop_type', 'travel');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('etc/travelAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * รายชื่อผู้รับเบี้ยเลี้ยงยังชีพ
     * 
     */
    
    // Main-menu
    // เมนู รายชื่อผู้รับเบี้ยเลี้ยงยังชีพ
    function actionWelfareAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'รายชื่อผู้รับเบี้ยเลี้ยงยังชีพ';
        
        $model = new tbWelfare();

        $criteria = new CDbCriteria();
        $criteria->compare('welfare_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('welfareAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionWelfarePreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbWelfare();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->welfare_views = $model->welfare_views + 1;
        $model->save();
        
        $this->pageTitle = $model->welfare_title;
        $this->render('etc/viewWelfare', array(
            'model' => $model,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * การสำรวจแสดงความคิดเห็น
     * 
     */
    
    // Main-menu
    // การสำรวจแสดงความคิดเห็น
    function actionPollAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'การสำรวจแสดงความคิดเห็น';
        
        $model = new tbPoll();

        $criteria = new CDbCriteria();
        $criteria->compare('topic_status', 'Active');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('pollAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    // ตอบคำถาม การสำรวจแสดงความคิดเห็น
    function actionPollAdd($id) {
        $this->layout = '_layout-fancybox';
        
        $model = new tbPoll();
        $model = $model->findByPk($id);
        
        if(!empty($_POST)) {
            
            // call tbPollLog
            $modelLog = new tbPollLog();
            
            $modelLog->tb_poll_id = $id;
            $modelLog->op_num = $_POST['pollValue'];
            $modelLog->log_ip = OtherFunction::getIp();
            
            if($modelLog->save()) {
                Yii::app()->user->setFlash('success', 'ขอบคุณที่ร่วมแสดงความคิดเห็น');
                $this->redirect(array('PollAll'));
            }
            
        }
        
        $this->render('etc/viewPollAdd', array(
            'model' => $model,
        ));
    }
    
    // สรุปผล การสำรวจแสดงความคิดเห็น
    function actionPollTotal($id) {
        $this->layout = '_layout-fancybox';
        
        $model = new tbPoll();
        $model = $model->findByPk($id);
        
        // check poll_id num ALL
        $criteria = new CDbCriteria();
        $criteria->compare('tb_poll_id', $id);
        $resultCount = tbPollLog::model()->count($criteria);
        
        // group and count
        $criteria = new CDbCriteria();
        $criteria->select = 'op_num, COUNT(op_num) AS op_num_count';
        $criteria->compare('tb_poll_id', $id);
        $criteria->group = 't.op_num';
        $criteria->order = 't.op_num ASC';
        $resultPercent = tbPollLog::model()->findAll($criteria);
        
        // op_id All value
        $opName = array(
            "1" => $model->op1,
            "2" => $model->op2,
            "3" => $model->op3,
            "4" => $model->op4,
            "5" => $model->op5
        );
        
        // cal percent
        foreach($resultPercent as $value) {
            $percect[$value->op_num] = round(($value->op_num_count/$resultCount)*100, 2);
        }
        
        // add merge to array
        for($i = 0; $i <= sizeof($opName); $i++) {
            if($percect[$i] != '') {
                $resultValue[] = array($opName[$i] => $percect[$i]);
            }
        }
        
        $this->render('etc/viewPollTotal', array(
            'model' => $model,
            'dataPie' => $resultValue,
        ));
    }
    
    ############################################################################
    ############################################################################
    
    /*
     * การสำรวจแสดงความคิดเห็น
     * 
     */

    // ตรวจสอบข้อมูลแบบ Ajax
    protected function performAjaxValidation($model) {
        if(Yii::app()->getRequest()->getIsAjaxRequest()) {
            $model->scenario = 'resetPasswordWithCaptcha';
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }
    }
    
    // Main-menu
    // รับเรื่องร้องเรียน
    function actionHelpingAdd() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'รับเรื่องร้องเรียน';
        
        $model = new tbHelping();
        $this->performAjaxValidation($model);
            
        if(!empty($_POST)) {
            $model->attributes = $_POST['tbHelping'];

            // type : picture
            $picture = CUploadedFile::getInstance($model, 'path_file');
            if(!empty($picture)) {
                $picture_rename = OtherFunction::renameFile () . '.' . $picture->extensionName;
                $model->path_file = $picture_rename;
            } else {
                $model->path_file = '';
            }
            
            if($model->save()) {
                if(!empty($picture)) {
                    $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('helping') . $picture_rename);
                    $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('helping') . $picture_rename);
                    $image->resize(500, 300, Image::NONE)->quality(100);
                    $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('helping') . $picture_rename);
                }

                Yii::app()->user->setFlash('success', 'รับเรื่องร้องเรียน เรียบร้อยแล้ว');
                $this->redirect(array('Main/HelpingAdd'));
            }
        }
        
        $this->render('helpingAdd', array(
            'model' => $model,
        ));
    }
    
 	// เมนู download	
   function actionDownload() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ดาวน์โหลดแบบฟอร์มราชการ';
        $this->render('download');
    }
	
	// เมนู คู่มือประชาชน
    function actionManual() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'คู่มือประชาชน';
        
        $model = new tbManual();

        $criteria = new CDbCriteria();
        $criteria->compare('status', 'Active');
        $criteria->order = 't.id desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/manualAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionManualPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbManual();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
      
        
        $this->pageTitle = $model->title;
        $this->render('news/viewManual', array(
            'model' => $model,
        ));
    }
	 
	// เมนู พ.ร.บ.คอมพิวเตอร์
	function actionPrb() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'พ.ร.บ.คอมพิวเตอร์';
        $this->render('prb');
    }
	
	// เมนู แผนจัดชื้อ-จัดจ้าง 
    function actionPlantender() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนจัดชื้อจัดจ้าง';
        
        $model = new tbPlantender();

        $criteria = new CDbCriteria();
        $criteria->compare('plantender_status', 'Active');
        $criteria->order = 't.plantender_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/plantenderAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionPlantenderPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbPlantender();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->plantender_views = $model->plantender_views + 1;
        $model->save();
        
        $this->pageTitle = $model->plantender_title;
        $this->render('news/viewPlantender', array(
            'model' => $model,
        ));
    }
	//
	// เมนู แผนจัดชื้อ-จัดจ้าง 
    function actionPricemid() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนจัดชื้อจัดจ้าง';
        
        $model = new tbPricemid();

        $criteria = new CDbCriteria();
        $criteria->compare('pricemid_status', 'Active');
        $criteria->order = 't.pricemid_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/pricemidAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionPricemidPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbPricemid();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->pricemid_views = $model->pricemid_views + 1;
        $model->save();
        
        $this->pageTitle = $model->pricemid_title;
        $this->render('news/viewPricemid', array(
            'model' => $model,
        ));
    }
	//
	 // เมนู แผนจัดชื้อ-จัดจ้าง 
    function actionTenderResult() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'แผนจัดชื้อจัดจ้าง';
        
        $model = new tbTenderresult();

        $criteria = new CDbCriteria();
        $criteria->compare('tenderresult_status', 'Active');
        $criteria->order = 't.tenderresult_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/tenderresultAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionTenderResultPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbTenderresult();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->tenderresult_views = $model->tenderresult_views + 1;
        $model->save();
        
        $this->pageTitle = $model->tenderresult_title;
        $this->render('news/viewTenderresult', array(
            'model' => $model,
        ));
    }
  	
	
	// เมนู บุคลากร
    function actionPersonalTest() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'บุคลากร';
        
        $model = new tbChartGroup();

        $criteria = new CDbCriteria();
      

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 20),
            'criteria' => $criteria,
        ));
        
        $this->render('news/personalAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionPersonalPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbChartPosition();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        
        
        $this->pageTitle = 'บุคลากร';
        $this->render('news/viewPersonal', array(
            'model' => $model,
        ));
    }
	
	// Main-menu
    // เมนู ศูนย์ข้อมูลข่าวสาร
    function actionInformationSevenAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ศูนย์ข้อมูลข่าวสาร';
        
        $model = new tbInformation();
        $criteria = new CDbCriteria();
        $criteria->compare('information_status', 'Active');
        $criteria->compare('information_type', 'seven');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('etc/informationsevenAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionInformationPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbInformation();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        
        
        $this->pageTitle = $model->information_name;
        $this->render('etc/viewInformation', array(
            'model' => $model,
        ));
    }
    
   
    function actionInformationNineAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ศูนย์ข้อมูลข่าวสาร';
        
        $model = new tbInformation();

        $criteria = new CDbCriteria();
        $criteria->compare('information_status', 'Active');
        $criteria->compare('information_type', 'nine');
        $criteria->order = 't.id DESC';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => Yii::app()->params['pageSizeGrid']),
            'criteria' => $criteria,
        ));
        
        $this->render('etc/informationnineAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
	
	// เมนู กองทุนหลักประกันสุขภาพ
    function actionFundwork() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'กองทุนหลักประกันสุขภาพ';
        
        $model = new tbFund();
        
        $criteria = new CDbCriteria();
        $criteria->compare('fund_type', 'fund_work');
        $criteria->compare('fund_status', 'Active');
        $criteria->order = 't.fund_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));

        $this->render('news/fundworkAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
	
	 function actionFundElder() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'กองทุนหลักประกันสุขภาพ';
        
        $model = new tbFund();
        
        $criteria = new CDbCriteria();
        $criteria->compare('fund_type', 'fund_elder');
        $criteria->compare('fund_status', 'Active');
        $criteria->order = 't.fund_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));

        $this->render('news/fundelderAll', array(
            'dataProvider' => $dataProvider,
        ));
    }
    
    function actionFundPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbFund();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        
        $model->save();
        
        $this->pageTitle = $model->fund_title;
        $this->render('news/viewFund', array(
            'model' => $model,
        ));
    }
	
	//ศูนย์ช่วยเหลือประชาชน
	 function actionAboutHelp() {
        $this->layout = 'main-home-sub';
         $this->pageTitle = 'ศูนย์ช่วยเหลือประชาชน';
        
        $this->render('aboutHelp');
    }
	
	// เมนูเเบบลงทะเบียนขอรับความช่วยเหลือ
	function actionHelpPersonnDownload() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ศูนย์ช่วยเหลือประชาชน';
        $this->render('helppersonDownload');
    }
	
	
	// เมนู ศูนย์ช่วยเหลือประชาชน
    function actionNewsHelpPerson() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ศูนย์ช่วยเหลือประชาชน';
        
        $model = new tbNewsHelpPerson();
        
        $criteria = new CDbCriteria();
  
        $criteria->order = 't.news_helpperson_date_true desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));

        $this->render('news/newsHelpPerson', array(
            'dataProvider' => $dataProvider,
        ));
    }
	
	 function actionNewsHelpPersonPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbNewsHelpPerson();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        
        $model->save();
        
        $this->pageTitle = $model->news_helpperson_title;
        $this->render('news/viewnewsHelpPerson', array(
            'model' => $model,
        ));
    }
	
	// egp
    function actionEGPAll() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ประกาศจัดซื้อจัดจ้าง เชื่อมโยงฐานข้อมูลของกรมบัญชีกลาง.';
        $this->render('egpAll');
    }
	
	// เมนู การประเมินคุณธรรมเเละความโปร่งใสในการดำเนินของอปท.
    function actionOPT1() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = ' มาตรการป้องกันการทุจริต ';
        
        $model = new tbOPT();

        $criteria = new CDbCriteria();
		$criteria->compare('opt_type', 'opt1');
        $criteria->compare('opt_status', 'Active');
        $criteria->order = 't.id desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/opt1All', array(
            'dataProvider' => $dataProvider,
        ));
    }
	function actionOPT2() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'คู่มือการดำเนินงาน';
        
        $model = new tbOPT();

        $criteria = new CDbCriteria();
		$criteria->compare('opt_type', 'opt2');
        $criteria->compare('opt_status', 'Active');
        $criteria->order = 't.id desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/opt2All', array(
            'dataProvider' => $dataProvider,
        ));
    }
	function actionOPT3() {
        $this->layout = 'main-home-sub';
        $this->pageTitle = 'ประกาศ/คำสั่ง';
        
        $model = new tbOPT();

        $criteria = new CDbCriteria();
		$criteria->compare('opt_type', 'opt3');
        $criteria->compare('opt_status', 'Active');
        $criteria->order = 't.id desc';

        $dataProvider = new CActiveDataProvider($model, array(
            'pagination' => array('pageSize' => 10),
            'criteria' => $criteria,
        ));
        
        $this->render('news/opt3All', array(
            'dataProvider' => $dataProvider,
        ));
    }
	function actionOPTPreview($id) {
        $this->layout = 'main-home-sub';
        
        $model = new tbOPT();
        $model = $model->findByPk($id);
        
        if($model === null)
                throw new CHttpException(null);
        
        // plus views
        $model->opt_views = $model->opt_views + 1;
        $model->save();
        
        $this->pageTitle = $model->opt_title;
        $this->render('news/viewOPT', array(
            'model' => $model,
        ));
    }
	
	function actionPrivacy() {
		$this->layout = 'main-home-sub';
        $this->render('privacy');
}
	
    ############################################################################
    ############################################################################
}
?>

Anon7 - 2022
AnonSec Team