]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Таблица просмотра
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 3 Feb 2025 06:58:16 +0000 (09:58 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 3 Feb 2025 06:58:16 +0000 (09:58 +0300)
erp24/controllers/Products1cNomenclatureController.php [new file with mode: 0644]
erp24/records/Products1cNomenclature.php
erp24/views/products1c-nomenclature/index.php [new file with mode: 0644]
erp24/views/products1c-nomenclature/view.php [new file with mode: 0644]

diff --git a/erp24/controllers/Products1cNomenclatureController.php b/erp24/controllers/Products1cNomenclatureController.php
new file mode 100644 (file)
index 0000000..abfff6d
--- /dev/null
@@ -0,0 +1,144 @@
+<?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.');
+    }
+}
index 0549cc9b7b33899f72a4f8ead9cbbaa5e5c1519c..2e60e155a6afcdd8c924dc19405c79d0cb74c76e 100644 (file)
@@ -49,10 +49,10 @@ class Products1cNomenclature extends \yii\db\ActiveRecord
     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' => 'Вид',
diff --git a/erp24/views/products1c-nomenclature/index.php b/erp24/views/products1c-nomenclature/index.php
new file mode 100644 (file)
index 0000000..1c53592
--- /dev/null
@@ -0,0 +1,47 @@
+<?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>
diff --git a/erp24/views/products1c-nomenclature/view.php b/erp24/views/products1c-nomenclature/view.php
new file mode 100644 (file)
index 0000000..e2717e4
--- /dev/null
@@ -0,0 +1,35 @@
+<?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>