/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = \frontend\modules\doctors\models\Doctors::find()->orderBy('name'); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'number' => $this->number, 'price_initial' => $this->price_initial, 'price_secondary' => $this->price_secondary, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
$color = 'black'; } $month = date("n", $tm); $month = Records::$months[$month - 1]; echo '<td style="color: ' . $color . ';">' . Records::$days[$dt] . '<br />' . date("j ", $tm) . $month . '</td>'; $tm += 60 * 60 * 24; $numberOfDay = date("w", $tm); $dt = date("w", $tm); } echo '</tr>'; for ($i = 0; $i < count($models); $i++) { $dt = time(); // сегодняшняя дата echo '<tr>'; $url = ''; $doctor = Doctors::findOne(['id' => $models[$i]->doctor_id]); $text = '<strong>' . $doctor->name . '</strong><br />'; $text .= $doctor->description; echo '<td style="border-bottom: 1px solid red; text-align: justify;">' . $text . '</td>'; for ($j = 0; $j < 7; $j++) { $count = $models[$i]->getCountRecords($dt); $href = Url::to(['records/list', 'date' => $dt, 'id' => $models[$i]->id]); // $href= 'records/list?id='.$models[$i]->id; if ($count != 0) { $type = ''; $class = 'btn-primary btn-lg'; $text = '9:00-14:00<br/ >приёмов:<br />' . $count; } else { $type = 'disabled'; //$class = 'btn-success'; //$class = 'btn-primary';
<?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"]) . ' ';
/** * Проверка на наличие совпадающих записей * @param type $name ФИО доктора * @return boolean */ public function actionIsDouble($name) { $result = false; $model = Doctors::findOne(['name' => $name]); if ($model) { $result = true; } return $result; }
/** * @return \yii\db\ActiveQuery */ public function getDoctor() { return $this->hasOne(\frontend\modules\doctors\models\Doctors::className(), ['id' => 'doctor_id']); }
use frontend\modules\doctors\models\Doctors; use frontend\modules\occupations\models\Occupations; use kartik\select2\Select2; /* @var $this yii\web\View */ /* @var $model frontend\models\Specialists */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="specialists-form"> <?php $form = ActiveForm::begin(); ?> <?php $list = ArrayHelper::map(Doctors::find()->orderBy('name')->all(), 'id', 'name'); echo $form->field($model, 'doctor_id')->widget(Select2::classname(), ['data' => $list, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите врача ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php $list = ArrayHelper::map(Occupations::find()->orderBy('name')->all(), 'id', 'name'); echo $form->field($model, 'occupation_id')->widget(Select2::classname(), ['data' => $list, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите специальность ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Добавить') : Yii::t('app', 'Изменить'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php
<p> <?php echo Html::a('Добавить врача', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model) { $url = '/doctors/default/view?id=' . $model->id; $result = Html::a($model->name, $url, []); return $result; }], 'number', 'description:ntext', 'phone', ['attribute' => 'start_time', 'format' => 'raw', 'value' => function ($model) { if (is_numeric($model->start_time) && $model->start_time > 0) { $result = Doctors::timeToString($model->start_time); } else { $result = '<span class="text-danger">Не задано</span>'; } return $result; }], ['attribute' => 'end_time', 'format' => 'raw', 'value' => function ($model) { if (is_numeric($model->end_time) && $model->end_time > 0) { $result = Doctors::timeToString($model->end_time); } else { $result = '<span class="text-danger">Не задано</span>'; } return $result; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
public function actionGetName($id) { $result = Specialists::findOne($id); $result = Doctors::findOne($result->doctor_id); return $result->name; }