public function validateDoubleDoctor($attribute, $params)
 {
     $validatequery = Trreservation::findOne(['Date' => $this->Date, 'DoctorID' => $this->DoctorID]);
     if ($validatequery && $validatequery->ReservationID != $this->ReservationID) {
         $this->addError($attribute, 'The Doctor has another booking in this time.');
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Trreservation::find();
     $query->joinWith(['room', 'patient', 'doctor']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['room'] = ['asc' => ['msroom.RoomName' => SORT_ASC], 'desc' => ['msroom.RoomName' => SORT_DESC]];
     $dataProvider->sort->attributes['patient'] = ['asc' => ['mspatient.FirstName' => SORT_ASC], 'desc' => ['mspatient.FirstName' => SORT_DESC]];
     $dataProvider->sort->attributes['doctor'] = ['asc' => ['msdoctor.FirstName' => SORT_ASC], 'desc' => ['msdoctor.FirstName' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         $query->orderBy(['Date' => SORT_DESC]);
         return $dataProvider;
     }
     $query->andFilterWhere(['ReservationID' => $this->ReservationID])->andFilterWhere(['like', 'Date', $this->Date])->andFilterWhere(['like', 'msroom.RoomName', $this->room])->andFilterWhere(['like', 'mspatient.FirstName', $this->patient])->andFilterWhere(['like', 'msdoctor.FirstName', $this->doctor])->orderBy(['Date' => SORT_DESC]);
     return $dataProvider;
 }
 /**
  * Finds the Trreservation model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Trreservation the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Trreservation::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
<?php

use yii\helpers\Html;
use app\models\Trreservation;
$events = array();
$kalender = Trreservation::findOne(26);
//Testing
$Event = new \yii2fullcalendar\models\Event();
$Event->id = 1;
$Event->title = 'Booked Schedule';
$Event->start = date('Y-m-d\\TH:m:s\\Z');
$events[] = $Event;
$Event = new \yii2fullcalendar\models\Event();
$Event->id = 2;
$Event->title = 'Booked Schedule';
$Event->start = date('Y-m-d\\TH:m:s\\Z', strtotime('tomorrow 6am'));
$events[] = $Event;
foreach ($querytest as $hasil) {
    $Event = new \yii2fullcalendar\models\Event();
    $Event->id = $hasil->ReservationID;
    $Event->title = 'Booked Schedule';
    $Event->start = $hasil->Date;
    $events[] = $Event;
}
?>

  <p><?php 
echo Html::encode($kalender->Date);
?>
</p>
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTrreservations()
 {
     return $this->hasMany(Trreservation::className(), ['RoomID' => 'RoomID']);
 }