Server IP : 103.233.192.212 / Your IP : 3.15.145.122 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 : |
<?php class AdminController extends Controller { public $layout = '_layout-backend-admin'; public $pageTitle = 'Administrator'; // Detect Ajax Request protected function performAjaxValidation($model) { if(Yii::app()->getRequest()->getIsAjaxRequest()) { echo CActiveForm::validate($model); Yii::app()->end(); } } // หน้าหลัก Backend function actionMainBackend() { $this->render('mainBackend'); } function actionDownload() { $this->render('download/admin'); } /* * Method: Picture etc * - รูปภาพอื่นๆ ภายในระบบ */ function actionPictureEtc() { $model = new tbPictureEtc(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 10), 'criteria' => $criteria, )); $this->render('pictureEtcMain', array( 'dataProvider' => $dataprovider, )); } function actionPictureEtcAdd() { $model = new tbPictureEtc(); if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances($model, 'path_pic'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('picture_etc') . $pics_rename); $modelPic = new tbPictureEtc(); $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->status = 'Active'; $modelPic->save(); } $this->redirect(array('PictureEtc')); } $this->render('pictureEtcAdd', array( 'model' => $model, )); } function actionPictureEtcDelete($delete) { if(!empty($_GET)) { $model = new tbPictureEtc(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('picture_etc') . $model->path_pic); $model->deleteByPk($delete); } } /* * Method: Vision * - วิสัยทัศน์และพันธกิจ */ function actionVisionMain() { $model = new tbVision(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('visionMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionVisionEdit($id) { $model = new tbVision(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbVision']; if ($model->save()) { $this->redirect(array('VisionMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('visionEdit', array( 'model' => $model, )); } } // END tb_vision /* * Method: Village * - จำนวนหมู่บ้านประชากร */ function actionVillageMain() { $model = new tbVillage(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('villageMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionVillageAdd() { $model = new tbVillage(); if (!empty($_POST)) { $model->attributes = $_POST['tbVillage']; $criteria = new CDbCriteria(); $criteria->compare('config_name', 'date_village_update'); $modelConfig = tbConfig::model()->find($criteria); $modelConfig->config_value = $_POST['tbConfig']['config_name']; $modelConfig->save(); if ($model->save()) { $this->redirect(array('VillageMain')); } } $this->render('villageAdd', array( 'model' => $model, )); } function actionVillageEdit($id) { $model = new tbVillage(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbVillage']; $criteria = new CDbCriteria(); $criteria->compare('config_name', 'date_village_update'); $modelConfig = tbConfig::model()->find($criteria); $modelConfig->config_value = $_POST['tbConfig']['config_name']; $modelConfig->save(); if ($model->save()) { $this->redirect(array('VillageMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('villageEdit', array( 'model' => $model, )); } } function actionVillageDelete($id) { $model = new tbVillage(); $model->deleteByPk($id); $this->redirect(array('VillageMain')); } // END tb_village /* * Method: ข้อมูลอื่นๆ * - ประวัติความเป็นมา */ function actionHistoryMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'history'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('historyMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionHistoryEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('HistoryMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('historyEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : history]; /* * Method: ข้อมูลอื่นๆ * - สภาพทั่วไป ลักษณะภูมิประเทศ */ function actionClimateMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'climate'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('climateMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionClimateEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('ClimateMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('climateEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : climate]; /* * Method: ข้อมูลอื่นๆ * - การเมืองการปกครอง */ function actionDominionMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'dominion'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('dominionMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionDominionEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('DominionMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('dominionEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : dominion]; /* * Method: ข้อมูลอื่นๆ * - สภาพทางเศรษฐกิจ และ สังคม */ function actionSocialMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'social'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('socialMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionSocialEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('SocialMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('socialEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : social]; /* * Method: ข้อมูลอื่นๆ * - สภาพทางการศึกษา ศาสนา วัฒนธรรม */ function actionEducationMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'education'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('educationMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionEducationEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('EducationMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('educationEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : education]; /* * Method: ข้อมูลอื่นๆ * - การบริการพื้นที่ และ ทรัพยากรธรรมชาติ */ function actionResourceMain() { $model = new tbAboutEtc(); $criteria = new CDbCriteria(); $criteria->compare('type', 'resource'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('resourceMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionResourceEdit($id) { $model = new tbAboutEtc(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutEtc']; if ($model->save()) { $this->redirect(array('ResourceMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('resourceEdit', array( 'model' => $model, )); } } // END tb_about_etc [type : resource]; /* * Method: Agency * - สำนักปลัด */ function actionAgencyDeputyMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'deputy'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyDeputyMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyDeputyEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyDeputyMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyDeputyEdit', array( 'model' => $model, )); } } // END tb_agency [type : deputy]; /* * Method: Agency * - ส่วนการคลัง-กองคลัง */ function actionAgencyFinanceMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'finance'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyFinanceMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyFinanceEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyFinanceMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyFinanceEdit', array( 'model' => $model, )); } } // END tb_agency [type : finance]; /* * Method: Agency * - ส่วนโยธา-กองช่าง */ function actionAgencyCivilMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'civil'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyCivilMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyCivilEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyCivilMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyCivilEdit', array( 'model' => $model, )); } } // END tb_agency [type : civil]; /* * Method: Agency * - ส่วนการศึกษา-กองการศึกษา */ function actionAgencyEducationMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'education'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyEducationMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyEducationEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyEducationMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyEducationEdit', array( 'model' => $model, )); } } // END tb_agency [type : education]; /* * Method: Agency * - ส่วนสาธารณสุข-กองสาธารณสุข */ function actionAgencyHealthMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'health'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyHealthMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyHealthEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyHealthMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyHealthEdit', array( 'model' => $model, )); } } // END tb_agency [type : health]; /* * Method: Agency * - ส่วนสวัสดิการและสังคม-กองสวัสดิการ */ function actionAgencySocialMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'social'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencySocialMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencySocialEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencySocialMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencySocialEdit', array( 'model' => $model, )); } } // END tb_agency [type : social]; /* * Method: Agency * - ส่วนป้องกันและบรรเทาฯ-การป้องกันฯ */ function actionAgencyProtectMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'protect'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyProtectMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyProtectEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyProtectMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyProtectEdit', array( 'model' => $model, )); } } // END tb_agency [type : protect]; /* * Method: Agency * - กองวิชาการเเละแผนงาน */ function actionAgencyEducationplanMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'educationplan'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyEducationplanMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyEducationplanEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyEducationplanMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyEducationplanEdit', array( 'model' => $model, )); } } // END tb_agency [type : educationplan]; /* * Method: Agency * - กองการประปา */ function actionAgencyWaterMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'water'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyWaterMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyWaterEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyWaterMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyWaterEdit', array( 'model' => $model, )); } } // END tb_agency [type : water]; /* * Method: Agency * - กองการประปา */ function actionAgencyPawnshopMain() { $model = new tbAgency(); $criteria = new CDbCriteria(); $criteria->compare('type', 'pawnshop'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('agencyPawnshopMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAgencyPawnshopEdit($id) { $model = new tbAgency(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAgency']; if ($model->save()) { $this->redirect(array('AgencyPawnshopMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('agencyPawnshopEdit', array( 'model' => $model, )); } } // END tb_agency [type : pawnshop]; /* * Method: Policy * - นโยบายผู้บริหาร */ function actionPolicyMain() { $model = new tbPolicy(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('policyMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPolicyEdit($id) { $model = new tbPolicy(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPolicy']; if ($model->save()) { $this->redirect(array('PolicyMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('policyEdit', array( 'model' => $model, )); } } // END tb_policy /* * Method: Stragegy * - แผนยุทธศาสตร์การพัฒนาท้องถิ่น */ function actionStragegyMain() { $model = new tbStragegy(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('stragegyMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionStragegyAdd() { $model = new tbStragegy(); if (!empty($_POST)) { $model->attributes = $_POST['tbStragegy']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('StragegyEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('stragegyAdd', array( 'model' => $model, )); } function actionStragegyEdit($id) { $model = new tbStragegy(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbStragegy']; if ($model->save()) { $this->redirect(array('StragegyMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('stragegyEdit', array( 'model' => $model, )); } } function actionStragegyMainFile($id) { $model = new tbStragegyFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_stragegy_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('stragegyMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionStragegyAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbStragegyFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('stragegy') . $files_rename); $modelFile = new tbStragegyFile(); $modelFile->tb_stragegy_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('StragegyMainFile', 'id'=>$id)); } function actionStragegyDeleteFile($delete) { if(!empty($_GET)) { $model = new tbStragegyFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('stragegy') . $model->path_file); $model->deleteByPk($delete); } } function actionStragegyDelete($id) { // delete file $modelFile = new tbStragegyFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_stragegy_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('stragegy') . $valueFile->path_file); $modelFile = new tbStragegyFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbStragegy(); $model->deleteByPk($id); $this->redirect(array('StragegyMain')); } // END tb_stragegy /* * Method: Planthree * - แผนพัฒนาเทศบาลสามปี */ function actionPlanthreeMain() { $model = new tbPlanthree(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planthreeMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanthreeAdd() { $model = new tbPlanthree(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlanthree']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanthreeEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planthreeAdd', array( 'model' => $model, )); } function actionPlanthreeEdit($id) { $model = new tbPlanthree(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlanthree']; if ($model->save()) { $this->redirect(array('PlanthreeMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planthreeEdit', array( 'model' => $model, )); } } function actionPlanthreeMainFile($id) { $model = new tbPlanthreeFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_planthree_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planthreeMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanthreeAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanthreeFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planthree') . $files_rename); $modelFile = new tbPlanthreeFile(); $modelFile->tb_planthree_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanthreeMainFile', 'id'=>$id)); } function actionPlanthreeDeleteFile($delete) { if(!empty($_GET)) { $model = new tbPlanthreeFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planthree') . $model->path_file); $model->deleteByPk($delete); } } function actionPlanthreeDelete($id) { // delete file $modelFile = new tbPlanthreeFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_planthree_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planthree') . $valueFile->path_file); $modelFile = new tbPlanthreeFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbPlanthree(); $model->deleteByPk($id); $this->redirect(array('PlanthreeMain')); } // END tb_stragegy /* * Method: Planfour * - แผนพัฒนาเทศบาลสี่ปี */ function actionPlanfourMain() { $model = new tbPlanfour(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planfourMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanfourAdd() { $model = new tbPlanfour(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlanfour']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanfourEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planfourAdd', array( 'model' => $model, )); } function actionPlanfourEdit($id) { $model = new tbPlanfour(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlanfour']; if ($model->save()) { $this->redirect(array('PlanfourMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planfourEdit', array( 'model' => $model, )); } } function actionPlanfourMainFile($id) { $model = new tbPlanfourFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_planfour_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planfourMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanfourAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanfourFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planfour') . $files_rename); $modelFile = new tbPlanfourFile(); $modelFile->tb_planfour_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanfourMainFile', 'id'=>$id)); } function actionPlanfourDeleteFile($delete) { if(!empty($_GET)) { $model = new tbPlanfourFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planfour') . $model->path_file); $model->deleteByPk($delete); } } function actionPlanfourDelete($id) { // delete file $modelFile = new tbPlanfourFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_planfour_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('planfour') . $valueFile->path_file); $modelFile = new tbPlanfourFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbPlanfour(); $model->deleteByPk($id); $this->redirect(array('PlanfourMain')); } // END tb_planfour /* * Method: Plan * - นโยบายและแผน * Type: pplan(แผนอัตรากำลัง), budget(ข้อบัญญัติ/เทศบัญญัติงบประมาณ), laws(ข้อบัญญัติ/เทศบัญญัติกฏหมาย), plan(แผนการดำเนินการ), result(ผลการดำเนินการ), report(รายงาน ติดตามผล/การประชุม), * * ** function Main: PlanPPlanMain, PlanBudgetMain, PlanLawsMain, PlanMain, PlanResultMain, PlanReportMain, * ** function Add: PlanPPlanAdd, PlanBudgetAdd, PlanLawsAdd, PlanAdd, PlanResultAdd, PlanReportAdd, * ** function Edit: PlanPPlanEdit, PlanBudgetEdit, PlanLawsEdit, PlanEdit, PlanResultEdit, PlanReportEdit, * ** function MainFile: PlanPPlanMainFile, PlanBudgetMainFile, PlanLawsMainFile, PlanMainFile, PlanResultMainFile, PlanReportMainFile, * ** function AddFile: PlanPPlanAddFile, PlanBudgetAddFile, PlanLawsAddFile, PlanAddFile, PlanResultAddFile, PlanReportAddFile, * * Method: ที่ใช้งานร่วมกันภายในตาราง tb_plan, tb_plan_file * - function: PlanDeleteFile * - function: PlanDelete */ // แผนการดำเนินการ function actionPlanMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'plan'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'plan'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planAdd', array( 'model' => $model, )); } function actionPlanEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planEdit', array( 'model' => $model, )); } } function actionPlanMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanMainFile', 'id'=>$id)); } // END แผนการดำเนินการ // ผลการดำเนินการ function actionPlanResultMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'result'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planResultMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanResultAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'result'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanResultEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planResultAdd', array( 'model' => $model, )); } function actionPlanResultEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanResultMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planResultEdit', array( 'model' => $model, )); } } function actionPlanResultMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planResultMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanResultAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanResultMainFile', 'id'=>$id)); } // END ผลการดำเนินการ // รายงานติดตาม ผลการดำเนินการ function actionPlanResultReportMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'result_report'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planResultReportMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanResultReportAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'result_report'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanResultReportEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planResultReportAdd', array( 'model' => $model, )); } function actionPlanResultReportEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanResultReportMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planResultReportEdit', array( 'model' => $model, )); } } function actionPlanResultReportMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planResultReportMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanResultReportAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanResultReportMainFile', 'id'=>$id)); } // END รายงานติดตาม ผลการดำเนินการ // แผนอัตรากำลัง function actionPlanPPlanMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'pplan'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planPPlanMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanPPlanAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'pplan'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanPPlanEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planPPlanAdd', array( 'model' => $model, )); } function actionPlanPPlanEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanPPlanMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planPPlanEdit', array( 'model' => $model, )); } } function actionPlanPPlanMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planPPlanMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanPPlanAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanPPlanMainFile', 'id'=>$id)); } // END แผนอัตรากำลัง // รายงานการประชุม function actionPlanReportMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'report'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planReportMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanReportAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'report'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanReportEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planReportAdd', array( 'model' => $model, )); } function actionPlanReportEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanReportMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planReportEdit', array( 'model' => $model, )); } } function actionPlanReportMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planReportMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanReportAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanReportMainFile', 'id'=>$id)); } // END รายงานการประชุม // งบประมาณ function actionPlanBudgetMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'budget'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planBudgetMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanBudgetAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'budget'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanBudgetEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planBudgetAdd', array( 'model' => $model, )); } function actionPlanBudgetEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanBudgetMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planBudgetEdit', array( 'model' => $model, )); } } function actionPlanBudgetMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planBudgetMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanBudgetAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanBudgetMainFile', 'id'=>$id)); } // END งบประมาณ // กฏหมาย function actionPlanLawsMain() { $model = new tbPlan(); $criteria = new CDbCriteria(); $criteria->compare('plan_type', 'laws'); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('planLawsMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlanLawsAdd() { $model = new tbPlan(); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; $model->plan_type = 'laws'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlanLawsEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('planLawsAdd', array( 'model' => $model, )); } function actionPlanLawsEdit($id) { $model = new tbPlan(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbPlan']; if ($model->save()) { $this->redirect(array('PlanLawsMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('planLawsEdit', array( 'model' => $model, )); } } function actionPlanLawsMainFile($id) { $model = new tbPlanFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plan_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('planLawsMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlanLawsAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlanFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $files_rename); $modelFile = new tbPlanFile(); $modelFile->tb_plan_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlanLawsMainFile', 'id'=>$id)); } // END กฏหมาย function actionPlanDeleteFile($delete) { if(!empty($_GET)) { $model = new tbPlanFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $model->path_file); $model->deleteByPk($delete); } } function actionPlanDelete($id) { // delete file $modelFile = new tbPlanFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_plan_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plan') . $valueFile->path_file); $modelFile = new tbPlanFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbPlan(); $model->deleteByPk($id); $this->redirect(array('PlanMain')); } // END tb_plan, tb_plan_file /* * Method: News * - ข่าวประชาสัมพันธ์, ข่าวภาษี, ข่าวกิจกรรม * Type: news(ข่าวประชาสัมพันธ์), tax(ข่าวภาษี), activity(ข่าวกิจกรรม), pass_activity(ข่าวย้อนหลัง), hfund(ข่าวสาร สปสช.), newsotop(ข่าว Otop) * * ** Main: NewsMain, NewsTaxMain, NewsActivityMain, * ** Add: NewsAdd, NewsTaxAdd, NewsActivityAdd, * ** Edit: NewsEdit, NewsTaxEdit, NewsActivityEdit, * * Method: ที่ใช้งานร่วมกันภายในตาราง tb_news, tb_news_pic, tb_news_file * - function: NewsDeletePicture * - function: NewsDeletePictureTrue * - function: NewsDeleteFile * - function: NewsDeleteFileTrue * - function: NewsDelete */ // ข่าวประชาสัมพันธ์ function actionNewsMain() { $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->order = 't.news_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsAdd() { $model = new tbNews(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('newsAdd', array( 'model' => $model, )); } function actionNewsEdit($id) { $model = new tbNews(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; if($model->save()) { $this->redirect(array('NewsMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsEdit', array( 'model' => $model, )); } } function actionNewsMainFile($id) { $modelPic = new tbNewsPic(); $modelFile = new tbNewsFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_news_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('newsMainFile', array( 'modelPic' => $modelPic, 'modelFile' => $modelFile, 'primaryID' => $id, )); } function actionNewsAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $files_rename); $modelFile = new tbNewsFile(); $modelFile->tb_news_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsMainFile', 'id'=>$id)); } function actionNewsAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbNewsPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $modelPic = new tbNewsPic(); $modelPic->tb_news_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('NewsMainFile', 'id'=>$id)); } // END ข่าวประชาสัมพันธ์ // ข่าวภาษี function actionNewsTaxMain() { $model = new tbNews(); $criteria = new CDbCriteria(); $criteria->compare('news_type', 'tax'); $criteria->order = 't.news_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsTaxMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsTaxAdd() { $model = new tbNews(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'tax'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsTaxEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('newsTaxAdd', array( 'model' => $model, )); } function actionNewsTaxEdit($id) { $model = new tbNews(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'tax'; if($model->save()) { $this->redirect(array('NewsTaxMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsTaxEdit', array( 'model' => $model, )); } } function actionNewsTaxMainFile($id) { $modelFile = new tbNewsFile(); $modelPic = new tbNewsPic(); $criteria = new CDbCriteria(); $criteria->compare('tb_news_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('newsTaxMainFile', array( 'modelFile' => $modelFile, 'modelPic' => $modelPic, 'primaryID' => $id, )); } function actionNewsTaxAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $files_rename); $modelFile = new tbNewsFile(); $modelFile->tb_news_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsTaxMainFile', 'id'=>$id)); } function actionNewsTaxAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbNewsPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $modelPic = new tbNewsPic(); $modelPic->tb_news_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('NewsTaxMainFile', 'id'=>$id)); } // END ข่าวภาษี // ข่าวกิจกรรม function actionNewsActivityMain() { $model = new tbNews(); $criteria = new CDbCriteria(); $criteria->compare('news_type', 'activity'); $criteria->order = 't.news_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsActivityMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsActivityAdd() { $model = new tbNews(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'activity'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsActivityEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('newsActivityAdd', array( 'model' => $model, )); } function actionNewsActivityEdit($id) { $model = new tbNews(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'activity'; if ($model->save()) { $this->redirect(array('NewsActivityMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsActivityEdit', array( 'model' => $model, )); } } function actionNewsActivityMainFile($id) { $modelFile = new tbNewsFile(); $modelPic = new tbNewsPic(); $criteria = new CDbCriteria(); $criteria->compare('tb_news_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('newsActivityMainFile', array( 'modelFile' => $modelFile, 'modelPic' => $modelPic, 'primaryID' => $id, )); } function actionNewsActivityAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $files_rename); $modelFile = new tbNewsFile(); $modelFile->tb_news_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsActivityMainFile', 'id'=>$id)); } function actionNewsActivityAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbNewsPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $modelPic = new tbNewsPic(); $modelPic->tb_news_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('NewsActivityMainFile', 'id'=>$id)); } // END ข่าวกิจกรรม function actionNewsDeleteFile($delete) { if(!empty($_GET)) { $model = new tbNewsFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $model->path_file); $model->deleteByPk($delete); } } function actionNewsDeletePic($delete) { if(!empty($_GET)) { $model = new tbNewsPic(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $model->path_pic); $model->deleteByPk($delete); } } function actionNewsDelete($id) { // delete picture $modelPic = new tbNewsPic(); $modelPic = $modelPic->findAllByAttributes(array('tb_news_id' => $id)); foreach($modelPic as $valuePic) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $valuePic->path_pic); $modelPic = new tbNewsPic(); $modelPic->deleteByPk($valuePic->id); } // delete file $modelFile = new tbNewsFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_news_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $valueFile->path_file); $modelFile = new tbNewsFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbNews(); $model->deleteByPk($id); $this->redirect(array('NewsMain')); } // END tb_news, tb_news_pic, tb_news_file /* * Method: Tender * - ข่าวจัดชื้อ/จัดจ้าง และ พัสดุ * Type: tender(ข่าวจัดชื้อ/จัดจ้าง), object(ข่าวพัสดุ) * */ function actionTenderMain() { $model = new tbTender(); $criteria = new CDbCriteria(); $criteria->order = 't.tender_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('tenderMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionTenderAdd() { $model = new tbTender(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbTender']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('TenderEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('tenderAdd', array( 'model' => $model, )); } function actionTenderEdit($id) { $model = new tbTender(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbTender']; if($model->save()) { $this->redirect(array('TenderMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('tenderEdit', array( 'model' => $model, )); } } function actionTenderMainFile($id) { $model = new tbTenderFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_tender_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('tenderMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionTenderAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbTenderFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tender') . $files_rename); $modelFile = new tbTenderFile(); $modelFile->tb_tender_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('TenderMainFile', 'id'=>$id)); } function actionTenderDeleteFile($delete) { if(!empty($_GET)) { $model = new tbTenderFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tender') . $model->path_file); $model->deleteByPk($delete); } } function actionTenderDelete($id) { // delete file $modelFile = new tbTenderFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_tender_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tender') . $valueFile->path_file); $modelFile = new tbTenderFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbTender(); $model->deleteByPk($id); $this->redirect(array('TenderMain')); } // END tb_tender, tb_tender_file /* * Method: Tender * - แผนการจัดซื้อจัดจ้าง * * */ function actionPlantenderMain() { $model = new tbPlantender(); $criteria = new CDbCriteria(); $criteria->order = 't.plantender_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('plantenderMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPlantenderAdd() { $model = new tbPlantender(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPlantender']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PlantenderEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('plantenderAdd', array( 'model' => $model, )); } function actionPlantenderEdit($id) { $model = new tbPlantender(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPlantender']; if($model->save()) { $this->redirect(array('PlantenderMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('plantenderEdit', array( 'model' => $model, )); } } function actionPlantenderMainFile($id) { $model = new tbPlantenderFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_plantender_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('plantenderMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPlantenderAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPlantenderFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plantender') . $files_rename); $modelFile = new tbPlantenderFile(); $modelFile->tb_plantender_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PlantenderMainFile', 'id'=>$id)); } function actionPlantenderDeleteFile($delete) { if(!empty($_GET)) { $model = new tbPlantenderFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plantender') . $model->path_file); $model->deleteByPk($delete); } } function actionPlantenderDelete($id) { // delete file $modelFile = new tbPlantenderFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_plantender_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('plantender') . $valueFile->path_file); $modelFile = new tbPlantenderFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbPlantender(); $model->deleteByPk($id); $this->redirect(array('PlantenderMain')); } // END tb_plantender, tb_plantender_file /* * Method: Finance * - ข่าวการเงิน * Type: statistic(สถิติการเงิน), incomes(งบรายรับ-รายจ่าย), debtor(งบลูกหนี้-เจ้าหนี้), asset(งบทรัพย์สิน), trial(งบทดลอง), position(งบแสดงฐานะการเงิน) * */ function actionFinanceMain() { $model = new tbFinance(); $criteria = new CDbCriteria(); $criteria->order = 't.finance_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('financeMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionFinanceAdd() { $model = new tbFinance(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbFinance']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('FinanceEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('financeAdd', array( 'model' => $model, )); } function actionFinanceEdit($id) { $model = new tbFinance(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbFinance']; if ($model->save()) { $this->redirect(array('FinanceMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('financeEdit', array( 'model' => $model, )); } } function actionFinanceMainFile($id) { $model = new tbFinanceFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_finance_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('financeMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionFinanceAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbFinanceFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('finance') . $files_rename); $modelFile = new tbFinanceFile(); $modelFile->tb_finance_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('FinanceMainFile', 'id'=>$id)); } function actionFinanceDeleteFile($delete) { if(!empty($_GET)) { $model = new tbFinanceFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('finance') . $model->path_file); $model->deleteByPk($delete); } } function actionFinanceDelete($id) { // delete file $modelFile = new tbFinanceFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_finance_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('finance') . $valueFile->path_file); $modelFile = new tbFinanceFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbFinance(); $model->deleteByPk($id); $this->redirect(array('FinanceMain')); } // END tb_finance, tb_finance_file /* * Method: Otop and Travel * - สถานที่สำคัญและสินค้า OTOP * Type: otop(แบบ OTOP), travel(ท่องเที่ยว) * */ function actionOtopMain() { $model = new tbOtop(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('otopMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionOtopAdd() { $model = new tbOtop(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbOtop']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('OtopEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('otopAdd', array( 'model' => $model, )); } function actionOtopEdit($id) { $model = new tbOtop(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbOtop']; if ($model->save()) { $this->redirect(array('OtopMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('otopEdit', array( 'model' => $model, )); } } function actionOtopMainFile($id) { $model = new tbOtopPic(); $criteria = new CDbCriteria(); $criteria->compare('tb_otop_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('otopMainFile', array( 'modelPic' => $model, 'primaryID' => $id, )); } function actionOtopAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbOtopPic::model(), 'path_pic'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('otop') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('otop') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('otop') . $pics_rename); $modelPic = new tbOtopPic(); $modelPic->tb_otop_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('OtopMainFile', 'id'=>$id)); } function actionOtopDeletePic($delete) { if(!empty($_GET)) { $model = new tbOtopPic(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('otop') . $model->path_pic); $model->deleteByPk($delete); } } function actionOtopDelete($id) { // delete picture $modelPic = new tbOtopPic(); $modelPic = $modelPic->findAllByAttributes(array('tb_otop_id' => $id)); foreach($modelPic as $valuePic) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('otop') . $valuePic->path_pic); $modelPic = new tbOtopPic(); $modelPic->deleteByPk($valuePic->id); } $model = new tbOtop(); $model->deleteByPk($id); $this->redirect(array('OtopMain')); } // END tb_otop, tb_otop_pic /* * Method: Helping * - รับเรื่องร้องเรียน * */ function actionHelpingMain() { $model = new tbHelping(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('helpingMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionHelpingView($id) { $model = new tbHelping(); $model = $model->findByPk($id); if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { // update view $model->status_view = '1'; $model->save(); $this->render('helpingView', array( 'model' => $model, )); } } function actionHelpingConfirm($id, $status) { $model = new tbHelping(); $model = $model->findByPk($id); if(empty($model)) throw new CHttpException(null); if($status == '0'): $model->status_confirm = '0'; $model->save(); elseif($status == '1'): $model->status_confirm = '1'; $model->save(); endif; $this->redirect(array('HelpingView', 'id'=>$id)); } function actionHelpingDelete($id) { $model = new tbHelping(); $model = $model->findByPk($id); if (!empty($model->path_file)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('helping') . $model->path_file); } $model->deleteByPk($id); $this->redirect(array('HelpingMain')); } // END tb_helping /* * Method: Poll * - การสำรวจแสดงความคิดเห็น * */ function actionPollMain() { $model = new tbPoll(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('pollMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPollAdd() { $model = new tbPoll(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPoll']; if($model->save()) { $this->redirect(array('PollMain')); } } $this->render('pollAdd', array( 'model' => $model, )); } function actionPollEdit($id) { $model = new tbPoll(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPoll']; if($model->save()) { $this->redirect(array('PollMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('pollEdit', array( 'model' => $model, )); } } function actionPollDelete($id) { $model = new tbPoll(); $model->deleteByPk($id); $this->redirect(array('PollMain')); } // tb_poll, tb_poll_log /* * Method: Events News * - ปฏิทินกิจกรรม * */ function actionEventnewsMain() { $model = new tbEventnews(); $criteria = new CDbCriteria(); $criteria->order = 't.event_date_show desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('eventnewsMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionEventnewsAdd() { $model = new tbEventnews(); $this->performAjaxValidation($model); if(!empty($_POST)) { $model->attributes = $_POST['tbEventnews']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('EventnewsEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('eventnewsAdd', array( 'model' => $model, )); } function actionEventnewsEdit($id) { $model = new tbEventnews(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbEventnews']; if($model->save()) { $this->redirect(array('EventnewsMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('eventnewsEdit', array( 'model' => $model, )); } } function actionEventnewsMainFile($id) { $model = new tbEventnewsFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_eventnews_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('eventnewsMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionEventnewsAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbEventnewsFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('eventnews') . $files_rename); $modelFile = new tbEventnewsFile(); $modelFile->tb_eventnews_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('EventnewsMainFile', 'id'=>$id)); } function actionEventnewsDeleteFile($delete) { if(!empty($_GET)) { $model = new tbEventnewsFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('eventnews') . $model->path_file); $model->deleteByPk($delete); } } function actionEventnewsDelete($id) { // delete file $modelFile = new tbEventnewsFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_eventnews_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('eventnews') . $valueFile->path_file); $modelFile = new tbEventnewsFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbEventnews(); $model->deleteByPk($id); $this->redirect(array('EventnewsMain')); } // END tb_eventnews, tb_eventnews_file /* * Method: Journal * - e-Book วารสารหน่วยงาน * */ function actionJournalMain() { $model = new tbJournal(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('journalMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionJournalAdd() { $model = new tbJournal(); if(!empty($_POST)) { $model->attributes = $_POST['tbJournal']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('JournalEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('journalAdd', array( 'model' => $model, )); } function actionJournalEdit($id) { $model = new tbJournal(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbJournal']; if ($model->save()) { $this->redirect(array('JournalMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('journalEdit', array( 'model' => $model, )); } } function actionJournalMainFile($id) { $model = new tbJournalFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_journal_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('journalMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionJournalAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbJournalFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('journal') . $files_rename); $modelFile = new tbJournalFile(); $modelFile->tb_journal_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('JournalMainFile', 'id'=>$id)); } function actionJournalDeleteFile($delete) { if(!empty($_GET)) { $model = new tbJournalFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('journal') . $model->path_file); $model->deleteByPk($delete); } } function actionJournalDelete($id) { // delete file $modelFile = new tbJournalFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_journal_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('journal') . $valueFile->path_file); $modelFile = new tbJournalFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbJournal(); $model->deleteByPk($id); $this->redirect(array('JournalMain')); } // END tb_journal, tb_journal_file /* * Method: Weblink * - เชื่อมโยง Link * Type: county(ท้องถิ่น), assoc(องค์กร), website(เว็บไซต์ทั่วไป) * */ function actionWeblinkMain() { $model = new tbWebLink(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('weblinkMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionWeblinkAdd() { $model = new tbWebLink(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbWebLink']; // type : picture $picture = CUploadedFile::getInstance($model, 'weblink_path_pic'); $files_rename = OtherFunction::renameFile () . '.' . $picture->extensionName; if(!empty($picture)) { $model->weblink_path_pic = $files_rename; } else { $model->weblink_path_pic = ''; } if($model->save()) { if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $files_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $files_rename); $image->resize(175, 40, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $files_rename); } $this->redirect(array('WeblinkMain')); } } $this->render('weblinkAdd', array( 'model' => $model, )); } function actionWeblinkEdit($id) { $model = new tbWebLink(); $model = $model->findByPk($id); $this->performAjaxValidation($model); // ไฟล์เดิมใช้ในการลบข้อมูล $picOld = $model->weblink_path_pic; if(!empty($_POST)) { $model->attributes = $_POST['tbWebLink']; // type : picture $picture = CUploadedFile::getInstance($model, 'weblink_path_pic'); if(!empty($picture)) { $model->weblink_path_pic = $picture->name; } else { $model->weblink_path_pic = $picOld; } if($model->save()) { // if ถ้าแก้ไข แล้วรูปในการ upload ไม่เท่ากับค่าว่าง จริง! ให้เข้า และ ชื่อไฟล์ใน database เดิม ไม่ใช่ค่าว่างให้ทำการลบ ไฟล์ออก if(!empty($picture)) { if($picOld != '') { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $picOld); } } if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $picture->name); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $picture->name); $image->resize(175, 40, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $picture->name); } $this->redirect(array('WeblinkMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('weblinkEdit', array( 'model' => $model, )); } } function actionWeblinkDeletePicture($id) { $model = new tbWebLink(); $model = $model->findByPk($id); if (!empty($model->weblink_path_pic)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $model->weblink_path_pic); } $model->weblink_path_pic = ''; $model->save(); $this->redirect(Yii::app()->request->urlReferrer); } function actionWeblinkDelete($id) { $model = new tbWebLink(); $model = $model->findByPk($id); if (!empty($model->weblink_path_pic)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('weblink') . $model->weblink_path_pic); } $model->deleteByPk($id); $this->redirect(array('WeblinkMain')); } // END tb_weblink /* * Method: CheckInside * - งานตรวจสอบภายใน * */ function actionCheckInsideMain() { $model = new tbCheckinside(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('checkInsideMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionCheckinsideAdd() { $model = new tbCheckinside(); $this->performAjaxValidation($model); if(!empty($_POST)) { $model->attributes = $_POST['tbCheckinside']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('CheckinsideEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('checkInsideAdd', array( 'model' => $model, )); } function actionCheckinsideEdit($id) { $model = new tbCheckinside(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbCheckinside']; if ($model->save()) { $this->redirect(array('CheckInsideMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('checkInsideEdit', array( 'model' => $model, )); } } function actionCheckinsideMainFile($id) { $model = new tbCheckinsideFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_checkinside_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('checkInsideMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionCheckinsideAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbCheckinsideFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('checkinside') . $files_rename); $modelFile = new tbCheckinsideFile(); $modelFile->tb_checkinside_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('CheckinsideMainFile', 'id'=>$id)); } function actionCheckinsideDeleteFile($delete) { if(!empty($_GET)) { $model = new tbCheckinsideFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('checkinside') . $model->path_file); $model->deleteByPk($delete); } } function actionCheckinsideDelete($id) { // delete file $modelFile = new tbCheckinsideFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_checkinside_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('checkinside') . $valueFile->path_file); $modelFile = new tbCheckinsideFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbCheckinside(); $model->deleteByPk($id); $this->redirect(array('CheckInsideMain')); } // END tb_checkinside, tb_checkinside_file /* * Method: แผนผัง * - ข้อมูลหน่วยงาน และ ภาพแผนผัง * */ function actionChartGroupMain() { $model = new tbChartGroup(); $criteria = new CDbCriteria(); $criteria->order = 't.nums asc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('chartGroupMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionChartGroupAdd() { $model = new tbChartGroup(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbChartGroup']; // type : picture $picture = CUploadedFile::getInstance($model, 'pic_chart'); if(!empty($picture)) { $picture_rename = OtherFunction::renameFile () . '.' . $picture->extensionName; $model->pic_chart = $picture_rename; } else { $model->pic_chart = ''; } if($model->save()) { if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picture_rename); } $this->redirect(array('ChartGroupMain')); } } $this->render('chartGroupAdd', array( 'model' => $model, )); } function actionChartGroupEdit($id) { $model = new tbChartGroup(); $model = $model->findByPk($id); $this->performAjaxValidation($model); // ไฟล์เดิมใช้ในการลบข้อมูล $picOld = $model->pic_chart; if(!empty($_POST)) { $model->attributes = $_POST['tbChartGroup']; // type : picture $picture = CUploadedFile::getInstance($model, 'pic_chart'); if(!empty($picture)) { $picture_rename = OtherFunction::renameFile () . '.' . $picture->extensionName; $model->pic_chart = $picture_rename; } else { $model->pic_chart = $picOld; } if($model->save()) { // if ถ้าแก้ไข แล้วรูปในการ upload ไม่เท่ากับค่าว่าง จริง! ให้เข้า และ ชื่อไฟล์ใน database เดิม ไม่ใช่ค่าว่างให้ทำการลบ ไฟล์ออก if(!empty($picture)) { if($picOld != '') { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picOld); } } if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picture_rename); } $this->redirect(array('ChartGroupMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('chartGroupEdit', array( 'model' => $model, )); } } function actionChartGroupDeletePicture($id) { $model = new tbChartGroup(); $model = $model->findByPk($id); if (!empty($model->pic_chart)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $model->pic_chart); } $model->pic_chart = ''; $model->save(); $this->redirect(Yii::app()->request->urlReferrer); } function actionChartGroupDelete($id) { // delete file $modelList = new tbChartPosition(); $modelList = $modelList->findAllByAttributes(array('tb_chart_group_id' => $id)); foreach($modelList as $valueList) { $modelList = new tbChartPosition(); $modelList->deleteByPk($valueList->id); } $model = new tbChartGroup(); $model = $model->findByPk($id); if (!empty($model->pic_chart)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $model->pic_chart); } $model->deleteByPk($id); $this->redirect(array('ChartGroupMain')); } // END tb_chart_group /* * Method: ตำแหน่งบุคล่ากร * - ข้อมูลตำแหน่งบุคลากร * */ function actionChartPositionMain() { $model = new tbChartPosition(); $criteria = new CDbCriteria(); $criteria->order = 't.nums desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('chartPositionMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionChartPositionAdd() { $model = new tbChartPosition(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbChartPosition']; if($model->save()) { $this->redirect(array('ChartPositionMain')); } } $this->render('chartPositionAdd', array( 'model' => $model, )); } function actionChartPositionEdit($id) { $model = new tbChartPosition(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbChartPosition']; if($model->save()) { $this->redirect(array('ChartPositionMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('chartPositionEdit', array( 'model' => $model, )); } } function actionChartPositionDelete($id) { // delete file $modelFile = new tbChartProfile(); $modelFile = $modelFile->findAllByAttributes(array('tb_chart_position_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $valueFile->picture); $modelFile = new tbChartProfile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbChartPosition(); $model->deleteByPk($id); $this->redirect(array('ChartPositionMain')); } // END tb_chart_position /* * Method: ข้อมูลบุคลากร * - ข้อมูลบุคลากร * */ function actionChartProfileMain() { $model = new tbChartProfile(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('chartProfileMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionChartProfileGetPosition() { $group_id = $_POST['id']; if(!empty($group_id)) { $criteria = new CDbCriteria(); $criteria->compare('tb_chart_group_id', $group_id); $dataChartPosition = CHtml::listData(tbChartPosition::model()->findAll($criteria), 'id', 'position_name'); echo '<select class="span8" name="tbChartProfile[tb_chart_position_id]" id="tbChartProfile_tb_chart_position_id">'; foreach ($dataChartPosition as $key => $value): echo '<option value="'.$key.'">'.$value.'</option>'; endforeach; echo '</select>'; } else { echo 'null'; } } function actionChartProfileAdd() { $model = new tbChartProfile(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbChartProfile']; // type : picture $picture = CUploadedFile::getInstance($model, 'picture'); if(!empty($picture)) { $picture_rename = OtherFunction::renameFile () . '.' . $picture->extensionName; $model->picture = $picture_rename; } else { $model->picture = ''; } if($model->save()) { if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picture_rename); } $this->redirect(array('ChartProfileMain')); } } $this->render('chartProfileAdd', array( 'model' => $model, )); } function actionChartProfileEdit($id) { $model = new tbChartProfile(); $model = $model->findByPk($id); $this->performAjaxValidation($model); // ไฟล์เดิมใช้ในการลบข้อมูล $picOld = $model->picture; if(!empty($_POST)) { $model->attributes = $_POST['tbChartProfile']; // type : picture $picture = CUploadedFile::getInstance($model, 'picture'); if(!empty($picture)) { $picture_rename = OtherFunction::renameFile () . '.' . $picture->extensionName; $model->picture = $picture_rename; } else { $model->picture = $picOld; } if($model->save()) { // if ถ้าแก้ไข แล้วรูปในการ upload ไม่เท่ากับค่าว่าง จริง! ให้เข้า และ ชื่อไฟล์ใน database เดิม ไม่ใช่ค่าว่างให้ทำการลบ ไฟล์ออก if(!empty($picture)) { if($picOld != '') { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picOld); } } if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $picture_rename); } $this->redirect(array('ChartProfileMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('chartProfileEdit', array( 'model' => $model, )); } } function actionChartProfileDeletePicture($id) { $model = new tbChartProfile(); $model = $model->findByPk($id); if (!empty($model->picture)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $model->picture); } $model->picture = ''; $model->save(); $this->redirect(Yii::app()->request->urlReferrer); } function actionChartProfileDelete($id) { $model = new tbChartProfile(); $model = $model->findByPk($id); if (!empty($model->picture)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('chart') . $model->picture); } $model->deleteByPk($id); $this->redirect(array('ChartProfileMain')); } // END tb_chart_profile /* * Method: VDO * - วีดีโอ * */ function actionVdoMain() { $model = new tbVdo(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('vdoMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionVdoAdd() { $model = new tbVdo(); if (!empty($_POST)) { $model->attributes = $_POST['tbVdo']; if ($model->save()) { $this->redirect(array('VdoMain')); } } $this->render('vdoAdd', array( 'model' => $model, )); } function actionVdoEdit($id) { $model = new tbVdo(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbVdo']; if ($model->save()) { $this->redirect(array('VdoMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('vdoEdit', array( 'model' => $model, )); } } function actionVdoDelete($id) { $model = new tbVdo(); $model->deleteByPk($id); $this->redirect(array('VdoMain')); } // END tb_vdo /* * Method: Newsbook Member * - ข้อมูลหน่วยงาน หนังสือเวียน * */ function actionNewsbookMemberMain() { $model = new tbNewsbookMember(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsbookMemberMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsbookMemberAdd() { $model = new tbNewsbookMember(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsbookMember']; if ($model->save()) { $this->redirect(array('NewsbookMemberMain')); } } $this->render('newsbookMemberAdd', array( 'model' => $model, )); } function actionNewsbookMemberEdit($id) { $model = new tbNewsbookMember(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsbookMember']; if ($model->save()) { $this->redirect(array('NewsbookMemberMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsbookMemberEdit', array( 'model' => $model, )); } } function actionNewsbookMemberDelete($id) { $model = new tbNewsbookMember(); $model->deleteByPk($id); $this->redirect(array('NewsbookMemberMain')); } // END tb_newsbook_member /* * Method: Newsbook * - ข้อมูลหนังสือเวียน * */ function actionNewsbookMain() { $model = new tbNewsbook(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsbookMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsbookAdd() { $model = new tbNewsbook(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsbook']; if ($model->save()) { $tbNewsbook_lastID = Yii::app()->db->getLastInsertID(); // loop group $group = $_POST['tbNewsbookGroup']['tb_newsbook_member_id']; for ($i = 0; $i <= sizeOf($group); $i++) { if ($group[$i] != '') { $modelGroup = new tbNewsbookGroup(); $modelGroup->tb_newsbook_id = $tbNewsbook_lastID; $modelGroup->tb_newsbook_member_id = $_POST['tbNewsbookGroup']['tb_newsbook_member_id'][$i]; $modelGroup->save(); } } Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsbookEdit', 'id'=>$tbNewsbook_lastID)); } } $this->render('newsbookAdd', array( 'model' => $model, )); } function actionNewsbookEdit($id) { $model = new tbNewsbook(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsbook']; if ($model->save()) { // claer tb_newsbook_group data $modelGroupDelete = new tbNewsbookGroup(); $modelGroupDelete->deleteAllByAttributes(array('tb_newsbook_id' => $id)); // loop group $group = $_POST['tbNewsbookGroup']['tb_newsbook_member_id']; for ($i = 0; $i <= sizeOf($group); $i++) { if ($group[$i] != '') { $modelGroup = new tbNewsbookGroup(); $modelGroup->tb_newsbook_id = $model->id; $modelGroup->tb_newsbook_member_id = $_POST['tbNewsbookGroup']['tb_newsbook_member_id'][$i]; $modelGroup->save(); } } $this->redirect(array('NewsbookMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsbookEdit', array( 'model' => $model, )); } } function actionNewsbookMainFile($id) { $model = new tbNewsbookFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_newsbook_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('newsbookMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionNewsbookAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsbookFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('newsbook') . $files_rename); $modelFile = new tbNewsbookFile(); $modelFile->tb_newsbook_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsbookMainFile', 'id'=>$id)); } function actionNewsbookDeleteFile($delete) { if(!empty($_GET)) { $model = new tbNewsbookFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('newsbook') . $model->path_file); $model->deleteByPk($delete); } } function actionNewsbookDelete($id) { // delete file $modelFile = new tbNewsbookFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_newsbook_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('newsbook') . $valueFile->path_file); $modelFile = new tbNewsbookFile(); $modelFile->deleteByPk($valueFile->id); } $modelGroup = new tbNewsbookGroup(); $modelGroup->deleteAllByAttributes(array('tb_newsbook_id' => $id)); $model = new tbNewsbook(); $model->deleteByPk($id); $this->redirect(array('NewsbookMain')); } // END tb_newsbook, tb_newsbook_file, tb_newsbook_group /* * Method: Personal Group * - หน่วยงานบุคลการ * */ function actionPersonalGroupMain() { $model = new tbPersonalGroup(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('personalGroupMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPersonalGroupAdd() { $model = new tbPersonalGroup(); if(!empty($_POST)) { $model->attributes = $_POST['tbPersonalGroup']; if($model->save()) { $this->redirect(array('PersonalGroupMain')); } } $this->render('personalGroupAdd', array( 'model' => $model, )); } function actionPersonalGroupEdit($id) { $model = new tbPersonalGroup(); $model = $model->findByPk($id); if(!empty($_POST)) { $model->attributes = $_POST['tbPersonalGroup']; if($model->save()) { $this->redirect(array('PersonalGroupMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('personalGroupEdit', array( 'model' => $model, )); } } function actionPersonalGroupDelete($id) { // delete file $modelList = new tbPersonalPosition(); $modelList = $modelList->findAllByAttributes(array('tb_personal_group_id' => $id)); foreach($modelList as $valueList) { $modelList = new tbPersonalPosition(); $modelList->deleteByPk($valueList->id); } $model = new tbPersonalGroup(); $model->deleteByPk($id); $this->redirect(array('PersonalGroupMain')); } // END tb_personal_group /* * Method: Personal Position * - ตำแหน่งบุคลากร * */ function actionPersonalPositionMain() { $model = new tbPersonalPosition(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('personalPositionMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPersonalPositionAdd() { $model = new tbPersonalPosition(); $this->performAjaxValidation($model); if(!empty($_POST)) { $model->attributes = $_POST['tbPersonalPosition']; if($model->save()) { $this->redirect(array('PersonalPositionMain')); } } $this->render('personalPositionAdd', array( 'model' => $model, )); } function actionPersonalPositionEdit($id) { $model = new tbPersonalPosition(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if(!empty($_POST)) { $model->attributes = $_POST['tbPersonalPosition']; if($model->save()) { $this->redirect(array('PersonalPositionMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('personalPositionEdit', array( 'model' => $model, )); } } function actionPersonalPositionDelete($id) { $model = new tbPersonalPosition(); $model->deleteByPk($id); $this->redirect(array('PersonalPositionMain')); } // END tb_personal_position /* * Method: Personal * - จัดการบุคลการ * */ function actionPersonalMain() { $model = new tbPersonal(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('personalMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPersonalPrint() { Yii::import('ext.yexcel.Classes.PHPExcel'); $model = new tbPersonal(); $model = $model->findAll(); $objPHPExcel = new PHPExcel(); // merge column $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'ลำดับ')->mergeCells('A1:A2') ->setCellValue('B1', 'ข้อมูลบุคคล')->mergeCells('B1:F1') ->setCellValue('G1', 'การศึกษา')->mergeCells('G1:I1') ->setCellValue('J1', 'ปฏิบัติราชการ')->mergeCells('J1:N1') ->setCellValue('O1', 'โทษทางวินัย')->mergeCells('O1:P1') ->setCellValue('Q1', 'เครื่องราชฯ')->mergeCells('Q1:R1'); // header column $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('B2', 'คำนำหน้า') ->setCellValue('C2', 'ชื่อ') ->setCellValue('D2', 'นามสกุล') ->setCellValue('E2', 'เลขประจำตัวประชาชน') ->setCellValue('F2', 'วันเดือนปีเกิด') ->setCellValue('G2', 'วุฒิการศึกษา') ->setCellValue('H2', 'สาขา') ->setCellValue('I2', 'จากสถาบัน') ->setCellValue('J2', 'ตำแหน่งปัจจุบัน') ->setCellValue('K2', 'วันเดือนปี ที่ดำรงตำแหน่ง') ->setCellValue('L2', 'ระดับ') ->setCellValue('M2', 'วันเดือนปี ที่เข้ารับราชการ') ->setCellValue('N2', 'วันเดือนปี ที่เกษียณ') ->setCellValue('O2', 'ร้ายแรง/ไม่ร้ายแรง/ไม่มี') ->setCellValue('P2', 'วันเดือนปี ที่ถูกลงโทษ') ->setCellValue('Q2', 'รับขั้นสู่งสุด') ->setCellValue('R2', 'รับเมื่อ (ราชกิจจา)'); $i = 3; foreach ($model as $value) { $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $i-2); // ลำดับ $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, OtherFunction::getPrintPrefix($value->prefix)); // คำนำหน้า $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $value->name); // ชื่อ $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $value->surname); // สกุล $objPHPExcel->getActiveSheet()->setCellValueExplicit('E' . $i, $value->personal_id); // เลขประจำตัวประชาชน $objPHPExcel->getActiveSheet()->setCellValue('F' . $i, OtherFunction::DateforPrint($value->birthday)); // วันเดือนปีเกิด $objPHPExcel->getActiveSheet()->setCellValue('G' . $i, OtherFunction::getPrintEduLevel($value->edu_level)); // วุฒิการศึกษา $objPHPExcel->getActiveSheet()->setCellValue('H' . $i, $value->major_name); // สาขา $objPHPExcel->getActiveSheet()->setCellValue('I' . $i, $value->institute_name); // จากสถาบัน $objPHPExcel->getActiveSheet()->setCellValue('J' . $i, OtherFunction::getPrintPersonalPos($value->tb_personal_position_id)); // ตำแหน่งปัจจุบัน $objPHPExcel->getActiveSheet()->setCellValue('K' . $i, OtherFunction::DateforPrint($value->pos_date_in)); // วันเดือนปีที่ดำรงตำแหน่ง $objPHPExcel->getActiveSheet()->setCellValue('L' . $i, $value->pos_level); // ระดับ $objPHPExcel->getActiveSheet()->setCellValue('M' . $i, OtherFunction::DateforPrint($value->date_officer_in)); // วันเดือนปีที่เข้ารับราชการ $objPHPExcel->getActiveSheet()->setCellValue('N' . $i, $value->date_officer_retire); // ปีเกษียณ $objPHPExcel->getActiveSheet()->setCellValue('O' . $i, OtherFunction::getPrintAccuseChoice($value->accuse_choice)); // ร้ายแรง-ไม่ร้ายแรง $objPHPExcel->getActiveSheet()->setCellValue('P' . $i, OtherFunction::DateforPrint($value->accuse_date)); // วันเดือนปีที่ถูกลงโทษ $objPHPExcel->getActiveSheet()->setCellValue('Q' . $i, $value->royal_level); // รับขั้นสูงสุด $objPHPExcel->getActiveSheet()->setCellValue('R' . $i, OtherFunction::DateforPrint($value->royal_date)); // รับเมื่อ (ราชกิจจา) $i++; } $filename = mt_rand(1,100000).'.xlsx'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); Yii::app()->end(); } function actionPersonalGetPosition() { $group_id = $_POST['id']; if(!empty($group_id)) { $criteria = new CDbCriteria(); $criteria->compare('tb_personal_group_id', $group_id); $dataChartPosition = CHtml::listData(tbPersonalPosition::model()->findAll($criteria), 'id', 'position_name'); echo '<select class="span8" name="tbPersonal[tb_personal_position_id]" id="tbPersonal_tb_personal_position_id">'; foreach ($dataChartPosition as $key => $value): echo '<option value="'.$key.'">'.$value.'</option>'; endforeach; echo '</select>'; } else { echo 'null'; } } function actionPersonalAdd() { $model = new tbPersonal(); $this->performAjaxValidation($model); if(!empty($_POST)) { $model->attributes = $_POST['tbPersonal']; // type : picture $picture = CUploadedFile::getInstance($model, 'personal_pic'); if(!empty($picture)) { $model->personal_pic = $picture->name; } else { $model->personal_pic = ''; } // date to mysql $model->birthday = OtherFunction::thaiToMySQLDate($_POST['day_birthday'].'/'.$_POST['month_birthday'].'/'.$_POST['year_birthday']); if(!empty($_POST['year_posDateIn'])): $model->pos_date_in = OtherFunction::thaiToMySQLDate($_POST['day_posDateIn'].'/'.$_POST['month_posDateIn'].'/'.$_POST['year_posDateIn']); endif; if(!empty($_POST['year_dateOfficerIn'])): $model->date_officer_in = OtherFunction::thaiToMySQLDate($_POST['day_dateOfficerIn'].'/'.$_POST['month_dateOfficerIn'].'/'.$_POST['year_dateOfficerIn']); endif; if(!empty($_POST['year_accuseDate'])): $model->accuse_date = OtherFunction::thaiToMySQLDate($_POST['day_accuseDate'].'/'.$_POST['month_accuseDate'].'/'.$_POST['year_accuseDate']); endif; if(!empty($_POST['year_royalDate'])): $model->royal_date = OtherFunction::thaiToMySQLDate($_POST['day_royalDate'].'/'.$_POST['month_royalDate'].'/'.$_POST['year_royalDate']); endif; if($model->save()) { if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); $image->resize(100, 120, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); } $this->redirect(array('PersonalMain')); } } $this->render('personalAdd', array( 'model' => $model, )); } function actionPersonalEdit($id) { $model = new tbPersonal(); $model = $model->findByPk($id); $this->performAjaxValidation($model); // ไฟล์เดิมใช้ในการลบข้อมูล if(isset($model->personal_pic)): $picOld = $model->personal_pic; endif; if(!empty($_POST)) { $model->attributes = $_POST['tbPersonal']; // type : picture $picture = CUploadedFile::getInstance($model, 'personal_pic'); if(!empty($picture)) { $model->personal_pic = $picture->name; } else { $model->personal_pic = $picOld; } // date to mysql $model->birthday = OtherFunction::thaiToMySQLDate($_POST['day_birthday'].'/'.$_POST['month_birthday'].'/'.$_POST['year_birthday']); if(!empty($_POST['year_posDateIn'])): $model->pos_date_in = OtherFunction::thaiToMySQLDate($_POST['day_posDateIn'].'/'.$_POST['month_posDateIn'].'/'.$_POST['year_posDateIn']); endif; if(!empty($_POST['year_dateOfficerIn'])): $model->date_officer_in = OtherFunction::thaiToMySQLDate($_POST['day_dateOfficerIn'].'/'.$_POST['month_dateOfficerIn'].'/'.$_POST['year_dateOfficerIn']); endif; if(!empty($_POST['year_accuseDate'])): $model->accuse_date = OtherFunction::thaiToMySQLDate($_POST['day_accuseDate'].'/'.$_POST['month_accuseDate'].'/'.$_POST['year_accuseDate']); endif; if(!empty($_POST['year_royalDate'])): $model->royal_date = OtherFunction::thaiToMySQLDate($_POST['day_royalDate'].'/'.$_POST['month_royalDate'].'/'.$_POST['year_royalDate']); endif; if($model->save()) { // if ถ้าแก้ไข แล้วรูปในการ upload ไม่เท่ากับค่าว่าง จริง! ให้เข้า และ ชื่อไฟล์ใน database เดิม ไม่ใช่ค่าว่างให้ทำการลบ ไฟล์ออก if(!empty($picture)) { if($picOld != '') { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picOld); } } if(!empty($picture)) { $picture->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); $image->resize(100, 120, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $picture->name); } $this->redirect(array('PersonalMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('personalEdit', array( 'model' => $model, )); } } function actionPersonalDeletePicture($id) { $model = new tbPersonal(); $model = $model->findByPk($id); if (!empty($model->personal_pic)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $model->personal_pic); } $model->personal_pic = ''; $model->save(); $this->redirect(Yii::app()->request->urlReferrer); } function actionPersonalDelete($id) { $model = new tbPersonal(); $model = $model->findByPk($id); if (!empty($model->personal_pic)) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('personal_pic') . $model->personal_pic); } $model->deleteByPk($id); $this->redirect(array('PersonalMain')); } // END tb_personal // ข่าวสาร สปสช. function actionNewsHfundMain() { $model = new tbNews(); $criteria = new CDbCriteria(); $criteria->compare('news_type', 'hfund'); $criteria->order = 't.news_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newsHfundMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsHfundAdd() { $model = new tbNews(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'hfund'; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsHfundEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('newsHfundAdd', array( 'model' => $model, )); } function actionNewsHfundEdit($id) { $model = new tbNews(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNews']; $model->news_type = 'hfund'; if ($model->save()) { $this->redirect(array('NewsHfundMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newsHfundEdit', array( 'model' => $model, )); } } function actionNewsHfundMainFile($id) { $modelFile = new tbNewsFile(); $modelPic = new tbNewsPic(); $criteria = new CDbCriteria(); $criteria->compare('tb_news_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('newsHfundMainFile', array( 'modelFile' => $modelFile, 'modelPic' => $modelPic, 'primaryID' => $id, )); } function actionNewsHfundAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_file') . $files_rename); $modelFile = new tbNewsFile(); $modelFile->tb_news_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsHfundMainFile', 'id'=>$id)); } function actionNewsHfundAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbNewsPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_image') . $pics_rename); $modelPic = new tbNewsPic(); $modelPic->tb_news_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('NewsHfundMainFile', 'id'=>$id)); } // END ข่าวสาร สปสช. /* * Method: Welfare * - รายชื่อผู้รับเบี้ย * Type: cripple(คนพิการ), elder(ผู้สูงอายุ), aids(เอดส์) * */ function actionWelfareMain() { $model = new tbWelfare(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('welfareMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionWelfareAdd() { $model = new tbWelfare(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbWelfare']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('WelfareEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('welfareAdd', array( 'model' => $model, )); } function actionWelfareEdit($id) { $model = new tbWelfare(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbWelfare']; if ($model->save()) { $this->redirect(array('WelfareMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('welfareEdit', array( 'model' => $model, )); } } function actionWelfareMainFile($id) { $model = new tbWelfareFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_welfare_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('welfareMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionWelfareAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbWelfareFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('welfare') . $files_rename); $modelFile = new tbWelfareFile(); $modelFile->tb_welfare_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('WelfareMainFile', 'id'=>$id)); } function actionWelfareDeleteFile($delete) { if(!empty($_GET)) { $model = new tbWelfareFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('welfare') . $model->path_file); $model->deleteByPk($delete); } } function actionWelfareDelete($id) { // delete file $modelFile = new tbWelfareFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_welfare_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('welfare') . $valueFile->path_file); $modelFile = new tbWelfareFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbWelfare(); $model->deleteByPk($id); $this->redirect(array('WelfareMain')); } // END tb_welfare, tb_welfare_file // public function actionPrintTotalPdf() { $this->render('printtotalpdf'); } function actionPrintPdf($id) { $model = new tbPersonal(); $model_group = new tbPersonalGroup(); $model_position = new tbPersonalPosition(); $personal = $model->findByPk($id); $personal_group = $model_group->findByPk($personal['tb_personal_group_id']); $personal_position = $model_position->findByPk($personal['tb_personal_position_id']); unset($personal_position['id']); unset($personal_group['id']); $personal['personal_pic'] = OtherFunction::pathFile('personal_pic').$personal['personal_pic'] ; $personal['birthday'] = OtherFunction::DateThai($personal['birthday']); $personal['accuse_date'] = OtherFunction::DateThai($personal['accuse_date']); $personal['accuse_choice'] = OtherFunction::getPrintAccuseChoice($personal['accuse_choice']); $personal['date_officer_retire'] = OtherFunction::DateThai($personal['date_officer_retire']); $personal['date_officer_in'] = OtherFunction::DateThai($personal['date_officer_in']); $personal['royal_date'] = OtherFunction::DateThai($personal['royal_date']); $personal['edu_level'] = OtherFunction::getPrintEduLevel($personal['edu_level']); //print_r($this->DateThai($personal['date_officer_in'])); //print_r($personal_position);die(); if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('printpdf', array( 'personal' => $personal, 'personal_group' => $personal_group, 'personal_position' => $personal_position, )); } } public function actionViewDownload($id) { $this->render('viewDownload',array( 'model'=>$this->loadModel($id), )); } public function actionAdminDownload() { $model=new TbDownload('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['TbDownload'])) $model->attributes=$_GET['TbDownload']; $this->render('adminDownload',array( 'model'=>$model, )); } public function actionCreateDownload() { $model=new TbDownload; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['TbDownload'])) { $model->attributes=$_POST['TbDownload']; $model->path=CUploadedFile::getInstance($model,'path'); if($model->save()) { $imageName =$_FILES["TbDownload"]["name"]["path"]; $model->path->saveAs(Yii::getPathOfAlias('webroot').'/images/file/'.$imageName); // redirect to success page $this->redirect(array('admin/adminDownload')); } else { $this->render('createDownload',array( 'model'=>$model, )); } } else { $this->render('createDownload',array( 'model'=>$model, )); } } public function actionDeleteDownload($id) { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModelDownload($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); } public function loadModelDownload($id) { $model=TbDownload::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } // /*manual*/ function actionManualMain() { $model = new tbManual(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('manualMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionManualAdd() { $model = new tbManual(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbManual']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('ManualEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('manualAdd', array( 'model' => $model, )); } function actionManualEdit($id) { $model = new tbManual(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbManual']; if($model->save()) { $this->redirect(array('ManualMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('manualEdit', array( 'model' => $model, )); } } function actionManualMainFile($id) { $model = new tbManualFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_manual_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('manualMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionManualAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbManualFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('manual') . $files_rename); $modelFile = new tbManualFile(); $modelFile->tb_manual_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('ManualMainFile', 'id'=>$id)); } function actionManualDeleteFile($delete) { if(!empty($_GET)) { $model = new tbManualFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('manual') . $model->path_file); $model->deleteByPk($delete); } } function actionManualDelete($id) { // delete file $modelFile = new tbManualFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_manual_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('manual') . $valueFile->path_file); $modelFile = new tbManualFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbManual(); $model->deleteByPk($id); $this->redirect(array('ManualMain')); } // END tb_manual // Prb tb_prb public function actionViewPrb($id) { $this->render('viewPrb',array( 'model'=>$this->loadModel($id), )); } public function actionAdminPrb() { $model=new TbPrb('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['TbPrb'])) $model->attributes=$_GET['TbPrb']; $this->render('adminPrb',array( 'model'=>$model, )); } public function actionCreatePrb() { $model=new TbPrb; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['TbPrb'])) { $model->attributes=$_POST['TbPrb']; $model->path=CUploadedFile::getInstance($model,'path'); if($model->save()) { $imageName =$_FILES["TbPrb"]["name"]["path"]; $model->path->saveAs(Yii::getPathOfAlias('webroot').'/images/prb/'.$imageName); // redirect to success page $this->redirect(array('admin/adminPrb')); } else { $this->render('createPrb',array( 'model'=>$model, )); } } else { $this->render('createPrb',array( 'model'=>$model, )); } } public function actionDeletePrb($id) { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModelPrb($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); } public function loadModelPrb($id) { $model=TbPrb::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } // /* * Method: pricemid * การเผยเเพร่ราคากลางตามเเบบ ปปช * * */ function actionPricemidMain() { $model = new tbPricemid(); $criteria = new CDbCriteria(); $criteria->order = 't.pricemid_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('pricemidMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionPricemidAdd() { $model = new tbPricemid(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPricemid']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('PricemidEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('pricemidAdd', array( 'model' => $model, )); } function actionPricemidEdit($id) { $model = new tbPricemid(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbPricemid']; if($model->save()) { $this->redirect(array('PricemidMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('pricemidEdit', array( 'model' => $model, )); } } function actionPricemidMainFile($id) { $model = new tbPricemidFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_pricemid_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('pricemidMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionPricemidAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbPricemidFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('pricemid') . $files_rename); $modelFile = new tbPricemidFile(); $modelFile->tb_pricemid_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('PricemidMainFile', 'id'=>$id)); } function actionPricemidDeleteFile($delete) { if(!empty($_GET)) { $model = new tbPricemidFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('pricemid') . $model->path_file); $model->deleteByPk($delete); } } function actionPricemidDelete($id) { // delete file $modelFile = new tbPricemidFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_pricemid_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('pricemid') . $valueFile->path_file); $modelFile = new tbPricemidFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbPricemid(); $model->deleteByPk($id); $this->redirect(array('PricemidMain')); } // END tb_pricemid, tb_pricemid_file /* * Method: pricemid *ผลการจัดซื้อจัดจ้าง * * */ function actionTenderResultMain() { $model = new tbTenderresult(); $criteria = new CDbCriteria(); $criteria->order = 't.tenderresult_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('tenderresultMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionTenderResultAdd() { $model = new tbTenderresult(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbTenderresult']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('TenderResultEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('tenderresultAdd', array( 'model' => $model, )); } function actionTenderResultEdit($id) { $model = new tbTenderresult(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbTenderresult']; if($model->save()) { $this->redirect(array('TenderResultMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('tenderresultEdit', array( 'model' => $model, )); } } function actionTenderResultMainFile($id) { $model = new tbTenderresultFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_tenderresult_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('tenderresultMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionTenderResultAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbTenderresultFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tenderresult') . $files_rename); $modelFile = new tbTenderresultFile(); $modelFile->tb_tenderresult_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('TenderResultMainFile', 'id'=>$id)); } function actionTenderResultDeleteFile($delete) { if(!empty($_GET)) { $model = new tbTenderresultFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tenderresult') . $model->path_file); $model->deleteByPk($delete); } } function actionTenderResultDelete($id) { // delete file $modelFile = new tbTenderresultFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_tenderresult_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('tenderresult') . $valueFile->path_file); $modelFile = new tbTenderresultFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbTenderresult(); $model->deleteByPk($id); $this->redirect(array('TenderResultMain')); } // END tb_tenderresult, tb_tenderresult_file /* * Method: information * - ศูนย์ข้อมูลข่าวสาร */ function actionInformationMain() { $model = new tbInformation(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('informationMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionInformationAdd() { $model = new tbInformation(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbInformation']; if ($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('InformationEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('informationAdd', array( 'model' => $model, )); } function actionInformationEdit($id) { $model = new tbInformation(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbInformation']; if ($model->save()) { $this->redirect(array('InformationMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('informationEdit', array( 'model' => $model, )); } } function actionInformationMainFile($id) { $model = new tbInformationFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_information_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('informationMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionInformationAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbInformationFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('information') . $files_rename); $modelFile = new tbInformationFile(); $modelFile->tb_information_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('InformationMainFile', 'id'=>$id)); } function actionInformationDeleteFile($delete) { if(!empty($_GET)) { $model = new tbInformationFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('information') . $model->path_file); $model->deleteByPk($delete); } } function actionInformationDelete($id) { // delete file $modelFile = new tbInformationFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_information_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('information') . $valueFile->path_file); $modelFile = new tbInformationFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbInformation(); $model->deleteByPk($id); $this->redirect(array('InformationMain')); } // END tb_information // กองทุนหลักประกันสุขภาพ function actionFundMain() { $model = new tbFund(); $criteria = new CDbCriteria(); $criteria->compare('fund_type', 'fund_work', false, 'OR'); $criteria->compare('fund_type', 'fund_elder', false, 'OR'); $criteria->order = 't.fund_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('fundMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionFundAdd() { $model = new tbFund(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbFund']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('FundEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('fundAdd', array( 'model' => $model, )); } function actionFundEdit($id) { $model = new tbFund(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbFund']; if($model->save()) { $this->redirect(array('FundMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('fundEdit', array( 'model' => $model, )); } } function actionFundMainFile($id) { $modelPic = new tbFundPic(); $modelFile = new tbFundFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_fund_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('fundMainFile', array( 'modelPic' => $modelPic, 'modelFile' => $modelFile, 'primaryID' => $id, )); } function actionFundAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbFundFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_file') . $files_rename); $modelFile = new tbFundFile(); $modelFile->tb_fund_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('FundMainFile', 'id'=>$id)); } function actionFundAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbFundPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_image') . $pics_rename); $modelPic = new tbFundPic(); $modelPic->tb_fund_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('FundMainFile', 'id'=>$id)); } function actionFundDeleteFile($delete) { if(!empty($_GET)) { $model = new tbFundFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_file') . $model->path_file); $model->deleteByPk($delete); } } function actionFundDeletePic($delete) { if(!empty($_GET)) { $model = new tbFundPic(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_image') . $model->path_pic); $model->deleteByPk($delete); } } function actionFundDelete($id) { // delete picture $modelPic = new tbFundPic(); $modelPic = $modelPic->findAllByAttributes(array('tb_fund_id' => $id)); foreach($modelPic as $valuePic) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_image') . $valuePic->path_pic); $modelPic = new tbFundPic(); $modelPic->deleteByPk($valuePic->id); } // delete file $modelFile = new tbFundFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_fund_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('fund_file') . $valueFile->path_file); $modelFile = new tbFundFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbFund(); $model->deleteByPk($id); $this->redirect(array('FundMain')); } // กองทุนหลักประกันสุขภาพ // ศูนย์ช่วยเหลือประชาชน function actionAboutHelpMain() { $model = new tbAboutHelp(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 1), 'criteria' => $criteria, )); $this->render('abouthelpMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionAboutHelpEdit($id) { $model = new tbAboutHelp(); $model = $model->findByPk($id); if (!empty($_POST)) { $model->attributes = $_POST['tbAboutHelp']; if ($model->save()) { $this->redirect(array('AboutHelpMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('abouthelpEdit', array( 'model' => $model, )); } } // END tb_about_help ; // help_download ; public function actionHelpPersonViewDownload($id) { $this->render('helppersonviewDownload',array( 'model'=>$this->loadModel($id), )); } public function actionHelpPersonAdminDownload() { $model=new tbHelpPersonDownload('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['tbHelpPersonDownload'])) $model->attributes=$_GET['tbHelpPersonDownload']; $this->render('helppersonadminDownload',array( 'model'=>$model, )); } public function actionHelpPersonCreateDownload() { $model=new tbHelpPersonDownload; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['tbHelpPersonDownload'])) { $model->attributes=$_POST['tbHelpPersonDownload']; $model->path=CUploadedFile::getInstance($model,'path'); if($model->save()) { $imageName =$_FILES["tbHelpPersonDownload"]["name"]["path"]; $model->path->saveAs(Yii::getPathOfAlias('webroot').'/images/file/'.$imageName); // redirect to success page $this->redirect(array('admin/helppersonadminDownload')); } else { $this->render('helppersoncreateDownload',array( 'model'=>$model, )); } } else { $this->render('helppersoncreateDownload',array( 'model'=>$model, )); } } public function actionHelpPersonDeleteDownload($id) { if(Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $this->loadModelHelpPersonDownload($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } else throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); } public function loadModelHelpPersonDownload($id) { $model=tbHelpPersonDownload::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } // // ข่่าวสารศูนย์ช่วยเหลือประชาชน function actionNewsHelpPersonMain() { $model = new tbNewsHelpPerson(); $criteria = new CDbCriteria(); $criteria->order = 't.news_helpperson_date_true desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('newshelppersonMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionNewsHelpPersonAdd() { $model = new tbNewsHelpPerson(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsHelpPerson']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('NewsHelpPersonEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('newshelppersonAdd', array( 'model' => $model, )); } function actionNewsHelpPersonEdit($id) { $model = new tbNewsHelpPerson(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbNewsHelpPerson']; if($model->save()) { $this->redirect(array('NewsHelpPersonMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('newshelppersonEdit', array( 'model' => $model, )); } } function actionNewsHelpPersonMainFile($id) { $modelPic = new tbNewsHelpPersonPic(); $modelFile = new tbNewsHelpPersonFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_news_helpperson_id', $id); $criteria->order = 't.id desc'; $modelFile = $modelFile->findAll($criteria); $modelPic = $modelPic->findAll($criteria); $this->render('newshelppersonMainFile', array( 'modelPic' => $modelPic, 'modelFile' => $modelFile, 'primaryID' => $id, )); } function actionNewsHelpPersonAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbNewsHelpPersonFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_file') . $files_rename); $modelFile = new tbNewsHelpPersonFile(); $modelFile->tb_news_helpperson_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('NewsHelpPersonMainFile', 'id'=>$id)); } function actionNewsHelpPersonAddPic($id) { if(!empty($_POST)) { // type picture $pic_array = CUploadedFile::getInstances(tbNewsHelpPersonPic::model(), 'path_file'); foreach ($pic_array as $pics) { $pics_rename = OtherFunction::renameFile () . '.' . $pics->extensionName; $pics->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_image') . $pics_rename); $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_image') . $pics_rename); $image->resize(600, null, Image::NONE)->quality(100); $image->save(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_image') . $pics_rename); $modelPic = new tbNewsHelpPersonPic(); $modelPic->tb_news_helpperson_id = $id; $modelPic->file_name = $pics->name; $modelPic->path_pic = $pics_rename; $modelPic->save(); } } $this->redirect(array('NewsHelpPersonMainFile', 'id'=>$id)); } function actionNewsHelpPersonDeleteFile($delete) { if(!empty($_GET)) { $model = new tbNewsHelpPersonFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_file') . $model->path_file); $model->deleteByPk($delete); } } function actionNewsHelpPersonDeletePic($delete) { if(!empty($_GET)) { $model = new tbNewsHelpPersonPic(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_image') . $model->path_pic); $model->deleteByPk($delete); } } function actionNewsHelpPersonDelete($id) { // delete picture $modelPic = new tbNewsHelpPersonPic(); $modelPic = $modelPic->findAllByAttributes(array('tb_news_helpperson_id' => $id)); foreach($modelPic as $valuePic) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_image') . $valuePic->path_pic); $modelPic = new tbNewsHelpPersonPic(); $modelPic->deleteByPk($valuePic->id); } // delete file $modelFile = new tbNewsHelpPersonFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_news_helpperson_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('news_helpperson_file') . $valueFile->path_file); $modelFile = new tbNewsHelpPersonFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbNewsHelpPerson(); $model->deleteByPk($id); $this->redirect(array('NewsHelpPersonMain')); } // ข่่าวสารศูนย์ช่วยเหลือประชาชน /* * Method: OPT * การประเมินคุณธรรมเเละความโปร่งใสในการดำเนินของอปท. * * */ function actionOPTMain() { $model = new tbOPT(); $criteria = new CDbCriteria(); $criteria->order = 't.id desc'; $dataprovider = new CActiveDataProvider($model, array( 'pagination' => array('pageSize' => 25), 'criteria' => $criteria, )); $this->render('optMain', array( 'dataprovider' => $dataprovider, 'model' => $model, )); } function actionOPTAdd() { $model = new tbOPT(); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbOPT']; if($model->save()) { Yii::app()->user->setFlash('success', 'ทำการเพิ่มข้อมูลเรียบร้อยแล้ว'); $this->redirect(array('OPTEdit', 'id'=>Yii::app()->db->getLastInsertID())); } } $this->render('optAdd', array( 'model' => $model, )); } function actionOPTEdit($id) { $model = new tbOPT(); $model = $model->findByPk($id); $this->performAjaxValidation($model); if (!empty($_POST)) { $model->attributes = $_POST['tbOPT']; if($model->save()) { $this->redirect(array('OPTMain')); } } if (empty($model)) { $this->redirect(Yii::app()->homeUrl); } else { $this->render('optEdit', array( 'model' => $model, )); } } function actionOPTMainFile($id) { $model = new tbOPTFile(); $criteria = new CDbCriteria(); $criteria->compare('tb_opt_id', $id); $criteria->order = 't.id desc'; $model = $model->findAll($criteria); $this->render('optMainFile', array( 'model' => $model, 'primaryID' => $id, )); } function actionOPTAddFile($id) { if(!empty($_POST)) { // type file $file_array = CUploadedFile::getInstances(tbOPTFile::model(), 'path_file'); foreach ($file_array as $files) { $files_rename = OtherFunction::renameFile () . '.' . $files->extensionName; $files->saveAs(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('opt') . $files_rename); $modelFile = new tbOPTFile(); $modelFile->tb_opt_id = $id; $modelFile->file_name = $files->name; $modelFile->path_file = $files_rename; $modelFile->save(); } } $this->redirect(array('OPTMainFile', 'id'=>$id)); } function actionOPTDeleteFile($delete) { if(!empty($_GET)) { $model = new tbOPTFile(); $model = $model->findByPk($delete); @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('opt') . $model->path_file); $model->deleteByPk($delete); } } function actionOPTDelete($id) { // delete file $modelFile = new tbOPTFile(); $modelFile = $modelFile->findAllByAttributes(array('tb_opt_id' => $id)); foreach($modelFile as $valueFile) { @unlink(Yii::getPathOfAlias('webroot') . OtherFunction::pathFile('opt') . $valueFile->path_file); $modelFile = new tbOPTFile(); $modelFile->deleteByPk($valueFile->id); } $model = new tbOPT(); $model->deleteByPk($id); $this->redirect(array('OPTMain')); } // END tb_opt, tb_opt_file } ?>