public function actionIndex() { $countOrders = Orders::find()->count(); $countCatalogs = Catalogs::find()->where(['not', ['name' => 'ROOT']])->count(); $countProducts = Products::find()->count(); return $this->render('index', ['countOrders' => $countOrders, 'countCatalogs' => $countCatalogs, 'countProducts' => $countProducts]); }
/** * Updates an existing CatalogsAdmin model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($catalog_id) { $model = $this->findModel($catalog_id); if ($model->load(Yii::$app->request->post())) { $id_parent = Yii::$app->request->post('CatalogsAdmin')['id_parent']; $parent = Catalogs::find()->where(['catalog_id' => $id_parent])->one(); $model->prependTo($parent); if ($model->save()) { return $this->redirect(['view', 'catalog_id' => $model->catalog_id]); } } else { return $this->render('update', ['model' => $model]); } }
</div> <div class="box-body"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'summary' => '', 'tableOptions' => ['class' => 'table table-bordered table-hover'], 'columns' => [['label' => 'Код', 'contentOptions' => ['style' => 'max-width: 30px;'], 'value' => function ($model) { return $model->catalog_id; }], ['label' => '<i class="fa fa-picture-o"></i>', 'encodeLabel' => false, 'format' => 'raw', 'contentOptions' => ['style' => 'max-width: 30px;'], 'value' => function ($model) { if ($model->getBehavior('coverBehavior')->hasImage()) { // return Html::img($model->getBehavior('coverBehavior')->getUrl('original'),['class'=>'img-responsive','style'=>'max-width:50px;']); // $mainPhoto = $model->MainPhoto; return Html::a(Html::img($model->getBehavior('coverBehavior')->getUrl('original'), ['class' => 'img-responsive', 'style' => '']), ['products/view', 'catalog_id' => $model->catalog_id], ['style' => 'display:block;']); } else { return ' '; } }], 'name', ['label' => 'Родитель', 'filter' => Html::activeDropDownList($searchModel, 'id_parent', ArrayHelper::map(Catalogs::find()->where(['not', ['catalog_id' => $model->catalog_id]])->andWhere(['not', ['name' => 'ROOT']])->all(), 'catalog_id', 'name'), ['class' => 'form-control', 'prompt' => '']), 'value' => function ($model) { $parent = $model->parents(1)->one(); if ($parent->name == 'ROOT') { return ''; } else { return $parent->name; } }], ['class' => 'yii\\grid\\ActionColumn', 'urlCreator' => function ($action, $model, $key, $index) { return [$action, 'catalog_id' => $model->catalog_id]; }]]]); ?> </div> </div>
</ul> <div id="my-tab-content" class="tab-content"> <div class="tab-pane active" id="decription" style="padding-top:15px;min-height:300px;"> <?php echo $form->field($model, 'popular', ['template' => "<div class='col-sm-offset-2 col-sm-10'>{input}</div>", 'inputOptions' => ['class' => 'form-control']])->checkbox(); ?> <?php echo $form->field($model, 'product_id', ['template' => "{label}\n<div class='col-sm-10'>{input}\n{hint}\n{error}</div>", 'labelOptions' => ['class' => 'control-label col-sm-2'], 'inputOptions' => ['class' => 'form-control', 'disabled' => true]])->textInput(); ?> <? $catalogList = ArrayHelper::map(Catalogs::find() ->where(['not',['name'=>'ROOT']]) ->all(), 'catalog_id', 'name'); echo $form->field( $model, 'catalog_id', [ 'template' => "{label}\n<div class='col-sm-10'>{input}\n{hint}\n{error}</div>", 'labelOptions' => [ 'class' => 'control-label col-sm-2' ], 'inputOptions' => [ 'class' => 'form-control' ], ] )->dropDownList($catalogList, [ 'prompt' => 'Выберите каталог ...' ]); ?>