%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 49.231.201.246  /  Your IP : 216.73.216.248
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : root ( 0)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/eoffice/frontend/modules/bookingdata/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/html/eoffice/frontend/modules/bookingdata/controllers/DefaultController.php
<?php

namespace frontend\modules\bookingdata\controllers;

use Yii;
use yii\web\Controller;
use backend\modules\bookingdata\models\BookingData;
use backend\modules\bookingdata\models\BookingRoom;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;
use backend\models\TeleBotBooking;

/**
 * Default controller for the `bookingdata` module
 */
class DefaultController extends Controller {

    /**
     * Renders the index view for the module
     * @return string
     */
    
    public function actionIndex() {
        $searchModel = new \backend\modules\bookingdata\models\BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 20,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'id' => SORT_DESC,
            ]
        ];

        $calendarid = Yii::$app->request->post('calendarid');
        if (Yii::$app->request->post('calendarid')) {
            $id = Yii::$app->request->post('calendarid');
        } else {
            $id = 0;
        }

        return $this->render('index', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'calendarid' => $id,
        ]);
    }

    public function actionForm() {
        $model = new BookingData();
        if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) {
                $model->status = 0;
                $model->save(false);
                $idd = Yii::$app->db->getLastInsertID();
//                //ส่ง LINE Notify
                // $res = $model->Linebotbooking($idd);
            	$res = $this->Telebotbooking($idd);
                // $this->sendTelegramMessage("📝 มีการจองห้องประชุมใหม่");
                return $this->render('view', [
                            'model' => $model,
                ]);
            } else {
                return $this->render('form', [
                            'model' => $model,
                ]);
            }
        } else {
            return $this->render('form', [
                        'model' => $model,
            ]);
        }
    }

    public function actionView($id) {
        return $this->render('view', [
                    'model' => $this->findModel($id),
        ]);
    }
    public function actionMobile() {
        $this->layout = '@app/theme/metronic/layouts/main_mobile.php';
        $searchModel = new \backend\modules\bookingdata\models\BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 20,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'id' => SORT_DESC,
            ]
        ];

        $calendarid = Yii::$app->request->post('calendarid');
        if (Yii::$app->request->post('calendarid')) {
            $id = Yii::$app->request->post('calendarid');
        } else {
            $id = 0;
        }
        return $this->render('mobile', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'calendarid' => $id,
        ]);
    }

    public function actionSet($id) {
        $this->layout = '@app/theme/metronic/layouts/main_mobile.php';
        return $this->render('set', [
                    'model' => $this->findModel($id),
        ]);
    }

    public function actionBookingset($id) {

        $model = $this->findModel($id);

        if (Yii::$app->request->post()) {
            $model->status = 1;
            $model->save(false);
            return $this->redirect(['/bookingdata/default/set', 'id' => $id]);
        }

        return $this->render('set', [
                    'model' => $model,
        ]);
    }

    public function actionBookingunset($id) {

        $model = $this->findModel($id);

        if (Yii::$app->request->post()) {
            $model->status = 0;
            $model->save(false);
            return $this->redirect(['/bookingdata/default/set', 'id' => $id]);
        }

        return $this->render('set', [
                    'model' => $model,
        ]);
    }

    public function actionDelete($id) {
        $this->findModel($id)->delete();

        return $this->redirect(['index']);
    }

    public function actionJsoncalendar($start = NULL, $end = NULL, $_ = NULL, $id = NULL) {

        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

        if ($id == 0) {
            $times = BookingData::find()->where(['status' => 1])->all();
        } else {
            $times = BookingData::find()->where(['booking_room_id' => $id])->andWhere(['status' => 1])->all();
        }

        $events = array();

        foreach ($times AS $time) {
            //Testing
            $room = \backend\modules\bookingdata\models\BookingRoom::find()->where(['id' => $time->booking_room_id])->one();
            $department_name = \backend\modules\departments\models\Departments::find()->where(['id' => $time->booking_department])->one();
            $Event = new \yii2fullcalendar\models\Event();
            $Event->id = $time->id;
            $Event->textColor = '#ffffff';
            $Event->color = $room->color;
            $Event->url = 'view?id=' . $time->id;
            if ($time->online == 1){
                $Event->dow = $department_name->abbreviation . ' ⭐️';
            }else{
                $Event->dow = $department_name->abbreviation;
            }
            
            $Event->online = $time->online;
            $Event->nonstandard = [
                'room' => $room->name,
                'start' => Yii::$app->formatter->asDateTime($time->booking_date_start, 'php:H:i'),
                'end' => Yii::$app->formatter->asDateTime($time->booking_date_end, 'php:H:i'),
            ];
//            $Event->title = $time->booking_department;
            $Event->title = '<b>' . $department_name->name . ' </b><br><small>' . $time->booking_subject . '<small>';
            $Event->start = date('Y-m-d\TH:i:s\Z', strtotime($time->booking_date_start));
            $Event->end = date('Y-m-d\TH:i:s\Z', strtotime($time->booking_date_end));
            $events[] = $Event;
        }

        return $events;
    }

    protected function findModel($id) {
        if (($model = \backend\modules\bookingdata\models\BookingData::findOne($id)) !== null) {
            return $model;
        }

        throw new NotFoundHttpException('The requested page does not exist.');
    }
public function Telebotbooking($id) {
        $data = BookingData::find()->where(['id' => $id])->one();
        $department_name = \backend\modules\departments\models\Departments::find()->where(['id' => $data->booking_department])->one();
        $room = BookingRoom::find()->where(['id' => $data->booking_room_id])->one();
//        $sum = $data->department_male + $data->department_female;
        $date1 = Yii::$app->thaiFormatter->asDateTime($data->booking_date_start, 'php:d F พ.ศ. Y');
        $date2 = Yii::$app->thaiFormatter->asDateTime($data->booking_date_end, 'php:d F พ.ศ. Y');
        $online = '';
        $link = 'https://office.ppao.go.th/bookingdata/default/set?id='.$data->id;
        if ($date1 == $date2){
            $datetext = Yii::$app->thaiFormatter->asDateTime($data->booking_date_start, 'php:d F พ.ศ. Y เวลา H:i - ').Yii::$app->thaiFormatter->asDateTime($data->booking_date_end, 'php:H:i');
        }else {
            $datetext = Yii::$app->thaiFormatter->asDateTime($data->booking_date_start, 'php:d F พ.ศ. Y เวลา H:i ถึง ').Yii::$app->thaiFormatter->asDateTime($data->booking_date_end, 'php:d F พ.ศ. Y เวลา H:i');
        }
        if ($data->online == 1){
            $online = '⭐️ระบบประชุมออนไลน์⭐️ ';
        }
        $message = $online . 'หน่วยงาน : ' . $department_name->name . ' ขอใช้ห้องประชุม : '. $room->name .'  วันที่ : ' . $datetext . ' เรื่อง : ' . $data->booking_subject . ' ผู้ขอใช้ : ' . $data->name . ' (' . $data->tel . ') คลิกที่ Link เพื่อยืนยันการขอใช้ --> '.$link;
        $model = new TeleBotBooking();
        $model->message = $message;
//        $model->save(false);

        $res = $this->sendTelegramMessage($message);
    }
function sendTelegramMessage($message)
{
    $botToken = '8159140724:AAGKqMc0QZS6DnDnsc5HYu3kBOYT49hc6zk';
    $chatId = '-4628774882';
    $url = "https://api.telegram.org/bot8159140724:AAGKqMc0QZS6DnDnsc5HYu3kBOYT49hc6zk/sendMessage";

    $postData = [
        'chat_id' => $chatId,
        'text' => $message,
        'parse_mode' => 'HTML' // หรือ 'Markdown' ก็ได้
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    $result = curl_exec($ch);
    curl_close($ch);

    return $result;
}

}

Anon7 - 2022
AnonSec Team