]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-358 Сверстать интерфейс автопм
authormarina <m.zozirova@gmail.com>
Mon, 24 Mar 2025 06:12:53 +0000 (09:12 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 24 Mar 2025 06:12:53 +0000 (09:12 +0300)
erp24/actions/shipment/AutoPlanogrammaAction.php [new file with mode: 0644]
erp24/controllers/ShipmentController.php
erp24/views/shipment/auto-planogramma.php [new file with mode: 0644]
erp24/views/shipment/auto-polnogramma.php [deleted file]

diff --git a/erp24/actions/shipment/AutoPlanogrammaAction.php b/erp24/actions/shipment/AutoPlanogrammaAction.php
new file mode 100644 (file)
index 0000000..7479fee
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace yii_app\actions\shipment;
+
+use yii\base\Action;
+use yii\data\ArrayDataProvider;
+use yii\db\Expression;
+use yii\db\Query;
+use yii_app\records\Products1cNomenclature;
+
+
+class AutoPlanogrammaAction extends Action
+{
+    public function run()
+    {
+        $categories = Products1cNomenclature::find()
+            ->select([
+                'category',
+                new Expression("jsonb_object_agg(subcategory, products) AS subcategories")
+            ])
+            ->from(
+                (new Query())
+                    ->select([
+                        'category',
+                        'subcategory',
+                        new Expression('array_agg(name) AS products')
+                    ])
+                    ->from('products_1c_nomenclature')
+                    ->andWhere(['ilike', 'name', 'роз'])
+                    ->groupBy(['category', 'subcategory'])
+            )
+            ->groupBy('category')
+            ->asArray()
+            ->all();
+
+        $dataProvider = new ArrayDataProvider([
+
+        ]);
+
+        return $this->controller->render('auto-planogramma', [
+            'categories' => $categories
+        ]);
+    }
+}
index 9bc3b5845c8762d8809b88219483287e6fa9f68f..02f7e87b077234b54e013c48578562f363777a0c 100755 (executable)
@@ -11,6 +11,7 @@ class ShipmentController extends Controller
     public function actions() {
         return [
             'add' => \yii_app\actions\shipment\AddAction::class,
+            'auto-planogramma' => \yii_app\actions\shipment\AutoPlanogrammaAction::class,
         ];
     }
 
@@ -39,10 +40,4 @@ class ShipmentController extends Controller
     public function actionConfigSort() { return $this->render('config-sort'); }
     public function actionFields() { return $this->render('fields'); }
     public function actionStatusesEdit() { return $this->render('statuses-edit'); }
-    public function actionAutoPolnogramma() {
-
-        return $this->render('auto-polnogramma', [
-            'categories' => Products1cNomenclature::find()->select('type_num')->groupBy('type_num')->all()
-        ]);
-    }
 }
\ No newline at end of file
diff --git a/erp24/views/shipment/auto-planogramma.php b/erp24/views/shipment/auto-planogramma.php
new file mode 100644 (file)
index 0000000..7d289a3
--- /dev/null
@@ -0,0 +1,314 @@
+<?php
+
+use kartik\grid\GridView;
+use kartik\select2\Select2;
+use yii\helpers\ArrayHelper;
+use yii\helpers\Html;
+use yii_app\helpers\DateHelper;
+use yii_app\records\Admin;
+use yii_app\records\AdminGroup;
+use yii_app\records\StoreCityList;
+use yii_app\records\StoreDynamic;
+use yii_app\records\StoreType;
+use sjaakp\bandoneon\Bandoneon;
+
+/* @var $categories \yii_app\records\Products1cNomenclature */
+
+
+use yii\data\ArrayDataProvider;
+
+$data = [
+    ['Адрес' => '01 Ванеева 181', 'Значение' => 300],
+    ['Адрес' => '02 Плотникова 4', 'Значение' => 300],
+    ['Адрес' => '03 Гагарина 60', 'Значение' => 100],
+    ['Адрес' => '04 Московское шоссе 9а', 'Значение' => 50],
+    ['Адрес' => '05 Белинского 71', 'Значение' => 300],
+    ['Адрес' => '06 Коминтерна 168', 'Значение' => 160],
+    ['Адрес' => '07 Аэродромная', 'Значение' => 300],
+];
+$addresses = array_column($data, 'Адрес');
+$values = array_column($data, 'Значение');
+
+$row = array_combine($addresses, $values);
+$dataProvider = new ArrayDataProvider([
+    'allModels' => [$row],
+    'pagination' => false,
+]);
+
+$tooltipText = "Оффлайн: 50&#10;Флаумак (off-line): 20&#10;Флаумак (on-line): 10&#10;Флаумак (market): 10&#10;Изумительная (off-line): 30&#10;Списания: 20";
+
+$columns = [];
+foreach ($addresses as $address) {
+    $columns[] = [
+        'attribute' => $address,
+        'label' => $address,
+        'format' => 'raw',
+        'headerOptions' => ['style' => 'writing-mode: sideways-lr; text-align: center; white-space: nowrap; font-weight: bold; transform-origin: left bottom; padding-right: 7%;'],
+        'value' => function ($model, $key, $index) use ($address, $tooltipText) {
+            return '<span style="display: flex; flex-direction: column; gap: 10px;">
+                <span style="display: flex; align-items: center; gap: 5px;">
+                    ' . Html::input('text', '', $model[$address], [
+                    'class' => 'btn btn-primary',
+                    'data-bs-toggle' => 'tooltip',
+                    'data-bs-placement' => 'top',
+                    'title' => $tooltipText,
+                    'style' => 'background:#e73535;'
+                ]) . '
+                    <button style="border: none; background: transparent; cursor: pointer;">
+                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+                            <path d="M20 11v5a1 1 0 0 1-2 0v-4H7.414l1.293 1.293a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.416l3-3a1 1 0 0 1 1.414 1.416L7.414 10H19a1 1 0 0 1 1 1z" 
+                                  fill="grey" stroke="none"/>
+                        </svg>
+                    </button>
+                </span>
+
+                <span style="display: flex; align-items: center; gap: 5px;">
+                    ' . Html::input('text', '', $model[$address], [
+                    'class' => 'btn btn-primary',
+                    'data-bs-toggle' => 'tooltip',
+                    'data-bs-placement' => 'top',
+                    'title' => $tooltipText,
+                    'style' => 'background:yellowgreen;'
+                ]) . '
+                    <button style="border: none; background: transparent; cursor: pointer;">
+                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+                            <path d="M20 11v5a1 1 0 0 1-2 0v-4H7.414l1.293 1.293a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.416l3-3a1 1 0 0 1 1.414 1.416L7.414 10H19a1 1 0 0 1 1 1z" 
+                                  fill="red" stroke="none"/>
+                        </svg>
+                    </button>
+                </span>
+                                <span style="display: flex; align-items: center; gap: 5px;">
+                    ' . Html::input('text', '', $model[$address], [
+                    'class' => 'btn btn-primary',
+                    'data-bs-toggle' => 'tooltip',
+                    'data-bs-placement' => 'top',
+                    'title' => $tooltipText,
+                    'style' => 'background:#3280cd;'
+                ]) . '
+                    <button style="border: none; background: transparent; cursor: pointer;">
+                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+                            <path d="M20 11v5a1 1 0 0 1-2 0v-4H7.414l1.293 1.293a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.416l3-3a1 1 0 0 1 1.414 1.416L7.414 10H19a1 1 0 0 1 1 1z" 
+                                  fill="red" stroke="none"/>
+                        </svg>
+                    </button>
+                </span>
+                             <span style="display: flex; align-items: center; gap: 5px;">
+                    ' . Html::input('text', '', $model[$address], [
+                    'class' => 'btn btn-primary',
+                    'data-bs-toggle' => 'tooltip',
+                    'data-bs-placement' => 'top',
+                    'title' => $tooltipText,
+                    'style' => 'background:yellowgreen;'
+                ]) . '
+                    <button style="border: none; background: transparent; cursor: pointer;">
+                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+                            <path d="M20 11v5a1 1 0 0 1-2 0v-4H7.414l1.293 1.293a1 1 0 0 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.416l3-3a1 1 0 0 1 1.414 1.416L7.414 10H19a1 1 0 0 1 1 1z" 
+                                  fill="grey" stroke="none"/>
+                        </svg>
+                    </button>
+                </span>
+
+                
+            </span>';
+        },
+    ];
+}
+?>
+<h1 class="ms-3 mb-4"><?=Html::encode("Автопланограмма")?></h1>
+<div class="autopolnogramma p-3 px-4">
+    <div class="filters">
+        <div class="row">
+        </div>
+        <div class="collapse show" id="filter-container">
+            <div class="row">
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'year-filter',
+                        'data' => array_combine(range(date('Y') - 5, date('Y') + 5), range(date('Y') - 5, date('Y') + 5)),
+                        'options' => ['placeholder' => 'Год', 'id' => 'year'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'city-filter',
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
+                        'options' => ['placeholder' => 'Город', 'id' => 'city'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'store-type-filter',
+                        'data' => ArrayHelper::map(StoreType::find()->orderBy('sequence_number')->all(), 'id', 'name'),
+                        'options' => ['placeholder' => 'Тип магазина', 'id' => 'store-type', 'style' => 'width: 110%;'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'territorial-manager-filter',
+                        'data' => ArrayHelper::map(
+                            array_merge(
+                                Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]),
+                                Admin::findAll(['id' => StoreDynamic::find()->andWhere(['category' => 3, 'active' => 1])->select('value_int')->column()])
+                            ),
+                            'id',
+                            'name',
+                        ),
+                        'options' => ['placeholder' => 'Тер. управляющий', 'id' => 'territorial-manger'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'polnogramma-type-filter',
+                        'data' => ['min' => 'min', 'max' => 'max'],
+                        'options' => ['placeholder' => 'Тип п-ма', 'id' => 'polnogramma-type'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Html::submitButton('Применить', ['class' => 'btn btn-apply btn-primary', 'style' => 'width:100%']); ?>
+                </div>
+            </div>
+            <div class="row py-3">
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'week-filter',
+                        'data' => ['1' => '1', '2' => '2'],
+                        'options' => ['placeholder' => 'Неделя', 'id' => 'week'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'region-filter',
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'),
+                        'options' => ['placeholder' => 'Регион', 'id' => 'region'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex">
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'bush_chef_florist',
+                        'value' => null,
+                        'data' => ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name'),
+                        'options' => [
+                            'placeholder' => 'Кустовой шеф-флорист',
+                            'class' => 'form-select',
+                            'id' => 'bush_chef_florist',
+                        ],
+                        'pluginOptions' => [
+                            'allowClear' => true,
+                        ],
+                    ]); ?>
+                </div>
+                <div class="col-md d-flex">
+                </div>
+                <div class="col-md d-flex"></div>
+            </div>
+            <div class="row">
+                <div class="col-md d-flex">
+                    <?= Html::label('Месяца-месяцы') ?>
+                </div>
+                <div class="col-md d-flex">
+                    <?= Select2::widget([
+                        'name' => 'district-filter',
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'),
+                        'options' => ['placeholder' => 'Район', 'id' => 'district'],
+                        'pluginOptions' => ['allowClear' => true],
+                    ]) ?>
+                </div>
+                <div class="col-md d-flex"></div>
+                <div class="col-md d-flex"></div>
+                <div class="col-md d-flex"></div>
+                <div class="col-md d-flex">
+                    <?= Html::button('Сохранить', ['class' => 'btn btn-success btn-save', 'style' => 'width:100%']); ?>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="col-md-3 py-7">
+        <div class="row">
+
+            <div class="row" style="display: flex;align-items: flex-start; position: relative;">
+                <?= Html::label("год: 2025 неделя: 05") ?><br>
+                <?= Html::label("январь - февраль") ?><br>
+                <?= Html::label("Тип п-ма:") ?><br>
+                <?= Html::label("Город:") ?><br>
+                <?= Html::label("Регион:") ?><br>
+                <?= Html::label("Район:") ?><br>
+                <?= Html::label("Тип магазина:") ?><br>
+                <?= Html::label("Тер. Уп.:") ?><br>
+                <?= Html::label("КШФ:") ?><br>
+
+                <div style="display: flex; flex-direction: column; align-items: flex-end; gap: 5px;">
+                    <?= Html::a('Auto', '#', ['class' => 'btn btn-success', 'style' => 'width:25%']) ?>
+                    <?= Html::a('Corrected', '#', ['class' => 'btn btn-success', 'style' => 'width:25%']) ?>
+                </div>
+            </div>
+            <div class="row mt-3">
+                <div class="list-group">
+                    <?php Bandoneon::begin(); ?>
+
+                    <?php foreach ($categories as $category):
+                        $subcategories = is_string($category['subcategories'])
+                            ? json_decode($category['subcategories'], true)
+                            : $category['subcategories']; ?>
+
+                        <div class="list-group-item list-group-item-action fw-bold">
+                            <?= htmlspecialchars($category['category']) ?>
+                        </div>
+
+                        <?php if (!empty($subcategories)):
+                        Bandoneon::begin();
+                        foreach ($subcategories as $subcategory => $products): ?>
+
+                            <div class="list-group-item list-group-item-action ms-3 fw-semibold">
+                                <?= htmlspecialchars($subcategory) ?>
+                            </div>
+
+                            <?php if (!empty($products)): ?>
+                                <div class="ms-4">
+                                    <?php foreach ($products as $product): ?>
+                                        <div class="list-group-item list-group-item-action">
+                                            <?= htmlspecialchars($product) ?>
+                                        </div>
+                                    <?php endforeach; ?>
+                                </div>
+                            <?php endif; ?>
+
+                        <?php endforeach;
+                        Bandoneon::end();
+                    endif;
+                    endforeach; ?>
+
+                    <?php Bandoneon::end(); ?>
+                </div>
+            </div>
+
+        </div>
+    </div>
+
+    <div class="col-md-9 text-center">
+        <div class="d-flex justify-content-center">
+            <button class="btn btn-light" type="button" data-bs-toggle="collapse" data-bs-target="#filter-container"
+                    aria-expanded="true">
+                <span>▲</span>
+            </button>
+        </div>
+        <?= GridView::widget([
+            'dataProvider' => $dataProvider,
+            'layout' => '{items}', // Только таблица, без пагинации
+            'tableOptions' => ['class' => 'table table-bordered mt-2'],
+            'columns' => $columns,
+        ]);
+
+        ?>
+
+    </div>
+</div>
+</div>
diff --git a/erp24/views/shipment/auto-polnogramma.php b/erp24/views/shipment/auto-polnogramma.php
deleted file mode 100644 (file)
index aa536f0..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-use kartik\select2\Select2;
-use yii\helpers\ArrayHelper;
-use yii\helpers\Html;
-use yii_app\records\Admin;
-use yii_app\records\AdminGroup;
-use yii_app\records\StoreCityList;
-use yii_app\records\StoreDynamic;
-use yii_app\records\StoreType;
-use sjaakp\bandoneon\Bandoneon;
-
-?>
-<div class="autopolnogramma p-3">
-    <div class="filters">
-        <div class="row">
-            <?= Html::label('Автополнограмма') ?>
-        </div>
-        <div class="row">
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'year-filter',
-                    'data' => array_combine(range(date('Y') - 5, date('Y') + 5), range(date('Y') - 5, date('Y') + 5)),
-                    'options' => ['placeholder' => 'Год', 'id' => 'year'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'city-filter',
-                    'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
-                    'options' => ['placeholder' => 'Город', 'id' => 'city'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'store-type-filter',
-                    'data' => ArrayHelper::map(StoreType::find()->orderBy('sequence_number')->all(), 'id', 'name'),
-                    'options' => ['placeholder' => 'Тип магазина', 'id' => 'store-type', 'style' => 'width: 110%;'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'territorial-manager-filter',
-                    'data' => ArrayHelper::map(
-                        array_merge(
-                            Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]),
-                            Admin::findAll(['id' => StoreDynamic::find()->andWhere(['category' => 3, 'active' => 1])->select('value_int')->column()])
-                        ),
-                        'id',
-                        'name',
-                    ),
-                    'options' => ['placeholder' => 'Тер. управляющий', 'id' => 'territorial-manger'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'polnogramma-type-filter',
-                    'data' => ['min' => 'min', 'max' => 'max'],
-                    'options' => ['placeholder' => 'Тип п-ма', 'id' => 'polnogramma-type'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Html::submitButton('Применить', ['class' => 'btn btn-apply btn-primary', 'style' => 'width:100%']);?>
-            </div>
-        </div>
-        <div class="row py-3">
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'week-filter',
-                    'data' => ['1' => '1', '2' => '2'],
-                    'options' => ['placeholder' => 'Неделя', 'id' => 'week'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'region-filter',
-                    'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'),
-                    'options' => ['placeholder' => 'Регион', 'id' => 'region'],
-                    'pluginOptions' => ['allowClear' => true],
-                ]) ?>
-            </div>
-            <div class="col-md d-flex">
-<!--                ttr-->
-            </div>
-            <div class="col-md d-flex">
-                <?= Select2::widget([
-                    'name' => 'bush_chef_florist',
-                    'value' => null,
-                    'data' => ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name'),
-                    'options' => [
-                        'placeholder' => 'Кустовой шеф-флорист',
-                        'class' => 'form-select',
-                        'id' => 'bush_chef_florist',
-                    ],
-                    'pluginOptions' => [
-                        'allowClear' => true,
-                    ],
-                ]); ?>
-            </div>
-            <div class="col-md d-flex">
-                <!--                ttr-->
-            </div>
-            <div class="col-md d-flex">
-                <?= Html::button('Сохранить', ['class' => 'btn btn-apply btn-save', 'style' => 'width:100%']);?>
-            </div>
-        </div>
-    </div>
-    <div class="row">
-        <div class="col-md-5">
-            <?php Bandoneon::begin();
-            foreach ($categories as $category) {
-                echo "<h4>$category->type_num</h4>";
-                echo "<div class=\"group-{$category->id}\"></div>";
-            }
-            Bandoneon::end() ?>
-        </div>
-    </div>
-
-</div>
\ No newline at end of file