--- /dev/null
+<?php
+
+namespace app\controllers;
+
+use yii_app\records\Products1cNomenclature;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * Products1cNomenclatureController implements the CRUD actions for Products1cNomenclature model.
+ */
+class Products1cNomenclatureController extends Controller
+{
+ /**
+ * @inheritDoc
+ */
+ public function behaviors()
+ {
+ return array_merge(
+ parent::behaviors(),
+ [
+ 'verbs' => [
+ 'class' => VerbFilter::class,
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Lists all Products1cNomenclature models.
+ *
+ * @return string
+ */
+ public function actionIndex()
+ {
+ $dataProvider = new ActiveDataProvider([
+ 'query' => Products1cNomenclature::find(),
+ /*
+ 'pagination' => [
+ 'pageSize' => 50
+ ],
+ 'sort' => [
+ 'defaultOrder' => [
+ 'id' => SORT_DESC,
+ ]
+ ],
+ */
+ ]);
+
+ return $this->render('index', [
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single Products1cNomenclature model.
+ * @param string $id GUID - уникальный номер номенклатуры в 1С
+ * @return string
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new Products1cNomenclature model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return string|\yii\web\Response
+ */
+ public function actionCreate()
+ {
+ $model = new Products1cNomenclature();
+
+ if ($this->request->isPost) {
+ if ($model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+ } else {
+ $model->loadDefaultValues();
+ }
+
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Updates an existing Products1cNomenclature model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param string $id GUID - уникальный номер номенклатуры в 1С
+ * @return string|\yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id]);
+ }
+
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+
+ /**
+ * Deletes an existing Products1cNomenclature model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param string $id GUID - уникальный номер номенклатуры в 1С
+ * @return \yii\web\Response
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the Products1cNomenclature model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param string $id GUID - уникальный номер номенклатуры в 1С
+ * @return Products1cNomenclature the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = Products1cNomenclature::findOne(['id' => $id])) !== null) {
+ return $model;
+ }
+
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+}
public function attributeLabels()
{
return [
- 'id' => 'GUID - уникальный номер номенклатуры в 1С',
- 'location' => 'расположение номенклатуры в системе 1С, т.е. путь до папки где храниться номенклатура',
- 'name' => 'имÑ\8f номенклаÑ\82Ñ\83Ñ\80Ñ\8b',
- 'type_num' => 'Название вида номенклатуры из логического условия, без квадратных скобок.',
+ 'id' => 'GUID',
+ 'location' => 'Расположение номенклатуры в системе 1С',
+ 'name' => 'Ð\98мÑ\8f',
+ 'type_num' => 'Название вида номенклатуры',
'category' => 'Категория',
'subcategory' => 'Подкатегория',
'species' => 'Вид',
--- /dev/null
+<?php
+
+use yii_app\records\Products1cNomenclature;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+use yii\grid\GridView;
+
+/** @var yii\web\View $this */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Товары с категориями';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="products1c-nomenclature-index p-4">
+
+ <h1><?= Html::encode($this->title) ?></h1>
+
+
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'id',
+ 'location',
+ 'name',
+ 'type_num',
+ 'category',
+ 'subcategory',
+ 'species',
+ 'sort',
+ 'size',
+ 'measure',
+ 'color',
+ [
+ 'class' => ActionColumn::class,
+ 'template' => '{view}',
+ 'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) {
+ return Url::toRoute([$action, 'id' => $model->id]);
+ }
+ ],
+ ],
+ ]); ?>
+
+
+</div>
--- /dev/null
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\Products1cNomenclature $model */
+
+$this->title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Products1c Nomenclatures', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+<div class="products1c-nomenclature-view p-4">
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary mb-3']) ?>
+ <h1><?= Html::encode($this->title) ?></h1>
+
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'location',
+ 'name',
+ 'type_num',
+ 'category',
+ 'subcategory',
+ 'species',
+ 'sort',
+ 'size',
+ 'measure',
+ 'color',
+ ],
+ ]) ?>
+
+</div>