public function actionOrder($id, $hallid) { $res = Hall::find()->select('hall_seat')->where(['id' => $hallid])->asArray()->one(); $res = $res['hall_seat']; $res2 = Order::find()->select('seats')->where(['session_id' => $id])->asArray()->one(); $res2 = $res2['seats']; $res2 = explode(",", $res2); return $this->render('seats', ['id' => $id, 'res' => $res, 'res2' => $res2]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Hall::find(); $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; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'hall_name', $this->hall_name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getHall() { return $this->hasOne(Hall::className(), ['id' => 'hall_id']); }
use yii\widgets\Pjax; /* @var $this yii\web\View */ /* @var $model common\models\Session */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="session-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'hall_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Hall::find()->all(), 'id', 'hall_name'), ['prompt' => 'Select Hall']); ?> <?php echo $form->field($model, 'start_time')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Time::find()->where(['6' => '0'])->all(), 'time_id', 'time_list'), ['prompt' => 'Select time', "disabled" => "disabled"]); ?> <?php echo $form->field($model, 'movie_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Movie::find()->all(), 'id', 'name'), ['prompt' => 'Select Movie', "disabled" => "disabled"]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
use yii\helpers\Html; use yii\widgets\DetailView; use common\models\Hall; /* @var $this yii\web\View */ /* @var $model common\models\Session */ $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => 'Sessions', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="session-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Hall', 'value' => common\models\Hall::findOne(['id' => $model->hall_id])->hall_name], ['label' => 'Movie', 'value' => common\models\Movie::findOne(['id' => $model->movie_id])->name], 'start_time']]); ?> </div>
use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel common\models\SessionSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Sessions'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="session-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'Hall', 'format' => 'raw', 'value' => function ($row) { return \common\models\Hall::findOne(['id' => $row->hall_id])->hall_name; }], ['label' => 'Movie', 'format' => 'raw', 'value' => function ($row) { return \common\models\Movie::findOne(['id' => $row->movie_id])->name; }], 'start_time', ['class' => 'yii\\grid\\ActionColumn', 'template' => ' {link}', 'buttons' => ['update' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-screenshot"></span>', $url); }, 'link' => function ($url, $model, $key) { return Html::a('Order tikcet', ['order', 'id' => $model->id, 'hallid' => $model->hall_id]); }]]]]); ?> </div>
/** * Finds the Hall model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Hall the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Hall::findOne($id); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }