示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ShopOrder::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'order_sn', $this->order_sn]);
     return $dataProvider;
 }
示例#2
0
	<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');
示例#3
0
 public function actionMyOrderDelete($id)
 {
     $model = ShopOrder::findOne($id);
     if (!$model) {
         throw new NotFoundHttpException('您请求的页面不存在!');
     }
     $model->delete();
     return $this->redirect(['my-order']);
 }
示例#4
0
文件: view.php 项目: buuug7/game4039
$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 
}
示例#5
0
文件: index.php 项目: buuug7/game4039
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>
示例#6
0
 /**
  * Finds the ShopOrder model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ShopOrder the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ShopOrder::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrder()
 {
     return $this->hasOne(ShopOrder::className(), ['id' => 'order_id']);
 }