Ejemplo n.º 1
0
 public function search($order_id)
 {
     $query = OrdersProducts::find()->where(['order_id' => $order_id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionUpdate($order_id)
 {
     $model = $this->findModel($order_id);
     $searchModel = new OrdersAdminSearch();
     $searchModelProducts = new OrdersProductsAdminSearch();
     $dataProvider = $searchModelProducts->search($order_id);
     $query = OrdersProducts::find()->where(['order_id' => $order_id]);
     $total = $query->sum('quantity');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'order_id' => $model->order_id]);
     } else {
         return $this->render('update', ['model' => $model, 'dataProvider' => $dataProvider, 'total' => $total]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($id)
 {
     $query = OrdersProducts::find()->where(['order_id' => $id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // $query->andFilterWhere([
     //     'id' => $this->id,
     //     'id_parent' => $this->id_parent,
     //     'expanded' => $this->expanded,
     //     'root' => $this->root,
     //     'lft' => $this->lft,
     //     'rgt' => $this->rgt,
     //     'level' => $this->level,
     // ]);
     // $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
echo $model->address;
?>
</p>
<p>Комментарий: <?php 
echo $model->comment;
?>
</p>

</br>

<?
$order_id = $model->order_id;
$searchModel = new OrdersProductsSearch();
$dataProvider = $searchModel->search($order_id);

$query = OrdersProducts::find()->where(['order_id' => $order_id]);
$total = $query->sum('quantity');

echo GridView::widget([
    'dataProvider' => $dataProvider,
    'tableOptions' => ['class'=>'table table-bordered'],
    'layout' => "{items}",
    'showFooter'=>true,
    'columns' => [

//        [
//            'label'=>'<i class="fa fa-picture-o"></i>',
//            'encodeLabel'=>false,
//            'format'=>'raw',
//            'value'=>function ($model) {
//                $product = Products::findOne($model->product_id);
Ejemplo n.º 5
0
 public function getProducts()
 {
     return $this->hasMany(OrdersProducts::className(), ['order_id' => 'order_id']);
 }