%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
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/11585/cwd/html/ppaobm/frontend/modules/booking/controllers/ |
Upload File : |
<?php namespace frontend\modules\booking\controllers; use Yii; use frontend\modules\booking\models\BookingData; use frontend\modules\booking\models\BookingDataSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\filters\AccessControl; use yii\base\InvalidParamException; use yii\web\BadRequestHttpException; /** * 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 [ 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['POST'], ], ], ]; } /** * Lists all BookingData models. * @return mixed */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, ], ]; } 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, ]); } /** * 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), ]); } /** * 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->save(false); $idd = Yii::$app->db->getLastInsertID(); //ส่ง LINE Notify // $res = $model->Linebot($idd); // return $this->redirect(['/booking/bookingdata/index']); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } } else { return $this->render('create', [ 'model' => $model, ]); } } public function actionCancel() { $model = new BookingData(); if ($model->load(Yii::$app->request->post())) { if (($data = BookingData::find()->where(['pin' => $model->pin])->one()) !== null) { return $this->redirect(['cancelview', 'pin' => $model->pin]); } else { // $errors = 'ไม่มีเลขบัตรประชาชนที่ค้นหา'; Yii::$app->session->setFlash('message', "ไม่มีเลขบัตรประชาชนที่ค้นหา"); return $this->render('cancel', [ 'model' => $model, ]); } } else { return $this->render('cancel', [ 'model' => $model, ]); } } public function actionCancelview($pin) { if (($model = BookingData::find()->where(['pin' => $pin])->all()) !== null) { $searchModel = new BookingDataSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->query->where(['IN', 'pin', $model]); // $dataProvider->pagination = ['pageSize' => 50,]; $dataProvider->sort = [ 'defaultOrder' => [ 'status' => SORT_ASC, 'id' => SORT_DESC, ] ]; return $this->render('cancelview', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'pin' => $pin, ]); } // $model = BookingData::find()->where(['pin' => $pin])->all(); // // $searchModel = new BookingDataSearch(); // $dataProvider = $searchModel->search(Yii::$app->request->queryParams); // $dataProvider->query->where(['IN', 'pin', $model]); //// $dataProvider->pagination = ['pageSize' => 50,]; // $dataProvider->sort = [ // 'defaultOrder' => [ // 'status' => SORT_ASC, // 'id' => SORT_DESC, // ] // ]; // return $this->render('cancelview', [ // 'searchModel' => $searchModel, // 'dataProvider' => $dataProvider, // 'pin' => $pin, // ]); } // public function actionCanceldetail() { // // $model = new BookingData(); // // if ($model->load(Yii::$app->request->post())) { // return $this->redirect(['canceldetail', 'pin' => $model->pin]); // } else { // return $this->render('cancelview', [ // 'model' => $model, // ]); // } // } public function actionCanceldetail($id) { $model = $this->findModel($id); return $this->renderAjax('canceldetail', [ '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->save()) { return $this->redirect(['view', 'id' => $model->id]); } 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) { //----------delete files $model = $this->findModel($id); $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(['cancelview', 'pin' => $model->pin]); } /** * 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 */ protected function findModel($id) { if (($model = BookingData::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); } public function actionJsoncalendar($start = NULL, $end = NULL, $_ = NULL) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $times = BookingData::find()->where(['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; } }