Ejemplo n.º 1
0
 public function actionLinkFilerRows($paramId, $parentParamId)
 {
     $paramsName = \app\models\GoodsParamsName::findOne($paramId);
     if ($parentParamId) {
         $paramsValues = \app\models\GoodsParams::find()->where('goods_params_name_id = :goods_params_name_id AND link_category = :link_category', [':goods_params_name_id' => $paramId, ':link_category' => $parentParamId])->all();
     } else {
         $paramsValues = \app\models\GoodsParams::find()->where('goods_params_name_id = :goods_params_name_id', [':goods_params_name_id' => $paramId])->all();
     }
     $data = \yii\helpers\ArrayHelper::map($paramsValues, 'id', 'value');
     $arRes = ['title' => $paramsName->name, 'name' => $paramsName->id, 'data' => ['' => ' - Все - '] + $data, 'parent_param' => $paramsName->parent_param, 'ch' => ''];
     header('Content-Type: utf-8');
     //        print $this->renderPartial('_row_filter', $arRes);
     $arRres = ['paramId' => $paramId, 'html' => $this->renderPartial('_row_filter', $arRes)];
     print json_encode($arRres);
 }
Ejemplo n.º 2
0
 /**
  * Deletes an existing GoodsParams model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $goodParam = $this->findModel($id);
     $goodParamName = \app\models\GoodsParamsName::findOne($goodParam->goods_params_name_id);
     $goods = \app\components\Goods::find($goodParamName->goods_type_type, $goodParam->goods_params_name_id . '=:id', [':id' => $goodParam->id])->all();
     foreach ($goods as $good) {
         \app\models\Goods::deleteAll('id=:goods_id', [':goods_id' => $good->goods_id]);
     }
     return $this->redirect(['index']);
 }
Ejemplo n.º 3
0
 /**
  * Finds the GoodsParamsName model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return GoodsParamsName the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GoodsParamsName::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
        <p>
            <?php 
    echo Html::a('Добавить наценку', ['create'], ['class' => 'btn btn-success']);
    ?>
        </p>

        <?php 
    echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'goods_type_type', 'label' => 'Тип товара', 'format' => 'html', 'value' => function ($model) {
        $oGT = \app\models\GoodsType::findOne($model->goods_type_type);
        return '[' . $oGT->type . '] <b>' . $oGT->name . '</b>';
    }], ['attribute' => 'test1', 'label' => 'Параметр', 'format' => 'html', 'value' => function ($model) {
        $arP = explode(';', $model->params);
        $arV = explode(';', $model->values);
        $arPP = [];
        foreach ($arP as $key => $paramId) {
            $oPar = \app\models\GoodsParamsName::findOne($paramId);
            $oVal = app\models\GoodsParams::findOne($arV[$key]);
            if ($oPar instanceof \app\models\GoodsParamsName && $oVal instanceof app\models\GoodsParams) {
                $arPP[] = $oPar->name . ': <b>' . $oVal->value . '</b>';
            }
        }
        return implode('; ', $arPP);
    }], ['attribute' => 'coef1', 'label' => 'Коэффициент', 'format' => 'html', 'value' => function ($model) {
        return $model->coef;
    }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
    ?>
        <?php 
}
?>

</div>