Example #1
0
 public static function getRecords($date, $specialist_id)
 {
     $month = date('m', $date);
     $year = date('Y', $date);
     $day = date('j', $date);
     $start = $year . '-' . $month . '-' . $day;
     $sql = 'SELECT * FROM `records` WHERE DATE(`start_time`) = "' . $start . '" AND `specialist_id` = "' . $specialist_id . '" ';
     $sql .= 'AND `reserved` = false ORDER BY `start_time`';
     $result = Records::findBySql($sql)->all();
     return $result;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Records::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['specialist_id' => SORT_DESC, 'start_time' => SORT_ASC]]]);
     //        $dataProvider->setSort([
     //            'attributes' => [
     //                'start_time',
     //                'occupationName',
     //            ]
     //        ]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         //             $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('specialist.doctor');
     $query->joinWith('specialist.occupation');
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'cabinet_id' => $this->cabinet_id, 'reserved' => $this->reserved, 'visited' => $this->visited, 'sum' => $this->sum, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'records.start_time', $this->start_time])->AndFilterWhere(['like', 'doctors.name', $this->specialist_id])->AndFilterWhere(['like', 'occupations.name', $this->occupationName])->andFilterWhere(['like', 'records.name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Example #3
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\modules\doctors\models\Doctors;
use frontend\models\Records;
use frontend\models\Specialists;
/* @var $this yii\web\View */
/* @var $model frontend\models\records */
/* @var $form ActiveForm */
$record = Records::findOne($id);
$spec = Specialists::findOne($record->specialist_id);
$doctor = Doctors::findOne($spec->doctor_id);
$date = strtotime($record->start_time);
$specialist_id = $record->specialist_id;
$this->title = 'Регистрация заявки';
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Выбор времени приёма'), 'url' => ['list', 'date' => $date, 'id' => $specialist_id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="register">
    <div class="jumbotron">

    <?php 
echo '<h2>' . Html::label($doctor->name) . '</h2>';
echo '<h3>' . Html::label($doctor->description) . '</h3>';
echo '</div>';
$form = ActiveForm::begin();
echo $form->field($model, 'name')->input('text', ['value' => '']);
echo $form->field($model, 'phone')->input('text', ['value' => '']);
echo '<p />';
echo '<h3>' . Html::label('Время приёма:', 'lblTime', ['class' => "control-label"]) . '   ';
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTestRecords()
 {
     return $this->hasMany(Records::className(), ['test_id' => 'id']);
 }
Example #5
0
$this->title = 'Выбор времени приёма';
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Выбор даты'), 'url' => ['specialists/viewss', 'id' => $spec->occupation_id]];
$this->params['breadcrumbs'][] = $this->title;
echo Html::beginTag('div');
echo Html::beginTag('div', ['class' => "page-header"]);
echo Html::tag('h3', Html::encode($this->title));
echo Html::tag('h2', $doctor->name);
echo Html::tag('h4', $doctor->description);
$month = Records::$monthsFull[(int) date('m', $date) - 1];
echo '<h4><strong>' . date("d", $date) . ' ' . $month . ' ' . date('Y', $date) . '</strong></h4>';
echo Html::endTag('div');
?>
<div class="records-list">
    
    <?php 
$records = Records::getRecords($date, $id);
//        $count = 0;
$hour = 0;
echo Html::beginTag('div', ['class' => '']);
echo Html::beginTag('p');
for ($i = 0; $i < count($records); $i++) {
    echo Html::beginTag('div');
    $data = strtotime($records[$i]->start_time);
    if ($i == 0) {
        $hour = date("H", $data);
    }
    if (Yii::$app->user->isGuest) {
        $url = Url::to(['requests/create', 'id' => $records[$i]->id]);
    } else {
        $url = Url::to(['records/update', 'id' => $records[$i]->id]);
    }
Example #6
0
 public function actionDeleteRecord($items)
 {
     $items = explode(",", $items);
     Yii::$app->session->setFlash('success', $items);
     foreach ($items as $item) {
         $model = Records::findOne($item)->delete();
     }
     $searchModel = new RecordsSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 public function actionGetD($id)
 {
     $sql = 'SELECT `dc`.`start_time`, `dc`.`end_time` FROM `specialists` as `sp`, `doctors` as `dc` WHERE `sp`.`id` = "' . $id . '" AND `sp`.`doctor_id` =  `dc`.`id`';
     $result = Records::findBySql($sql)->one();
     echo Json::encode($result);
 }
 public function actionCheck()
 {
     $result = [];
     $request = Yii::$app->request;
     $test_id = $request->post('test_id');
     $word_id = $request->post('word_id');
     $answer_id = $request->post('answer_id');
     $language = $request->post('language');
     $username = $request->post('username');
     $user = User::findByUsername($username);
     $test = Test::findOne($test_id);
     $dictionaries = Dictionary::findAll([$language . '_id' => $word_id]);
     if (!$user || !$test) {
         return ['error' => true, 'message' => 'Either the user or test not found'];
     }
     foreach ($dictionaries as $dictionary) {
         $error = $language == 'ru' ? $dictionary->en_id != $answer_id : $dictionary->ru_id != $answer_id;
         if ($error) {
             continue;
         } else {
             break;
         }
     }
     if ($error) {
         $result['error'] = $error;
     }
     if (Records::hasMaxErrors($test_id)) {
         $result['maxErrors'] = true;
         return $result;
     }
     $lang_record = Languages::findOne(['lang' => $language]);
     $testRecord = new Records();
     $testRecord->attributes = ['test_id' => $test_id, 'dictionary_id' => $dictionary->id, 'language' => $lang_record->id, 'is_error' => (int) $error, 'wrong_answer_id' => $error ? $answer_id : null];
     $testRecord->save();
     // Check once again for max errors after the save
     if (Records::hasMaxErrors($test_id)) {
         $result['maxErrors'] = true;
         return $result;
     }
     if (!$error) {
         // Increase the score by 1
         $test->scoreUp();
     }
     return $result;
 }