$this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Shop Order'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $model->order_sn; ?> <div class="shop-order-view"> <p> <?php echo Html::a(Yii::t('backend', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('backend', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('backend', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['order_sn', ['attribute' => 'user_id', 'value' => $model->user->username], 'created_at:datetime', 'updated_at:datetime', 'phone', 'address:ntext', 'email:email', 'notes:ntext', ['attribute' => 'status', 'value' => ArrayHelper::getValue(ShopOrder::getStatus(), $model->status)]]]); ?> <div class="col-lg-12"> <h4>该订单包含商品信息:</h4> <?php $orderItems = \common\models\ShopOrderItem::find()->where(['order_id' => $model->id])->all(); ?> <?php foreach ($orderItems as $k => $v) { ?> <?php echo DetailView::widget(['model' => $v, 'attributes' => ['title', 'price', 'product_id', 'quantity']]); ?> <?php }
<div class="container content"> <div class="headline"> <a href="<?php echo Url::toRoute(['product/my-order']); ?> "><h2>我的订单</h2></a> </div> <div class="row"> <div class="col-lg-12"> <?php echo \yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_sn', ['attribute' => '名称', 'value' => function ($model) { return \common\models\ShopOrderItem::findOne(['order_id' => $model->id])->title; }], ['attribute' => 'user_id', 'value' => function ($model) { return $model->user ? $model->user->username : null; }], 'phone', 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => ShopOrder::getStatus()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model, $key) { return Html::a('<span class="glyphicon glyphicon glyphicon-trash"></span>', ['/product/my-order-delete', 'id' => $model->id], ['title' => '删除', 'aria-labe' => '删除', 'data-confirm' => "您确定要删除此项吗?", 'data-method' => 'post']); }]]], 'layout' => "{items}\n{summary}\n{pager}"]); ?> </div> </div> </div> --> <?php $js = <<<JS //make user-nav active \$('.index-nav').removeClass('active'); \$('.shangcheng-nav').addClass('active');
use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii\grid\GridView; use common\models\ShopOrder; /* @var $this yii\web\View */ /* @var $searchModel backend\models\search\ShopOrderSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('common', 'Shop Order'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="shop-order-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Shop Order')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_sn', ['attribute' => 'user_id', 'value' => function ($model) { return $model->user ? $model->user->username : null; }], 'phone', 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => ShopOrder::getStatus()], ['class' => 'yii\\grid\\ActionColumn']], 'layout' => "{items}\n{summary}\n{pager}"]); ?> </div>