]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-393] draft amo to yii
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 27 Mar 2025 14:05:06 +0000 (17:05 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 27 Mar 2025 14:05:06 +0000 (17:05 +0300)
erp24/actions/orders/DeliveryAction.php [new file with mode: 0644]
erp24/controllers/OrdersController.php
erp24/views/orders/delivery.php

diff --git a/erp24/actions/orders/DeliveryAction.php b/erp24/actions/orders/DeliveryAction.php
new file mode 100644 (file)
index 0000000..07192bc
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+
+namespace yii_app\actions\orders;
+
+use Yii;
+use yii\base\Action;
+use yii\helpers\ArrayHelper;
+use yii_app\records\Admin;
+use yii_app\records\Balances;
+use yii_app\records\CityStore;
+use yii_app\records\CreateChecks;
+use yii_app\records\ExportImportTable;
+use yii_app\records\OrdersStatus;
+use yii_app\records\Products1c;
+use yii_app\records\Sales;
+
+class DeliveryAction extends Action
+{
+    public function run() {
+
+        $action = Yii::$app->request->get('action');
+        if ($action == 'amoUpdateDate') { $TODO = 2; return "TODO 2"; }
+
+        if (Yii::$app->request->get('umoup')) { $TODO = 1; }
+
+        $createChecks = CreateChecks::find()->where(['>=', 'date', date('Y-m-d H:i:s', strtotime('-17 days', time()))])
+                            ->andWhere(['status' => 0])->andWhere(['!=', 'check_id', ''])->all();
+        $yesses = [];
+        foreach ($createChecks as $createCheck) {
+            /* @var CreateChecks $createCheck */
+            $yess = Sales::find()->select(['id'])->where(['id' => $createCheck->id, 'operation' => $createCheck->type])->one();
+            if (!$yess) {
+                $yesses []= $yess->id;
+                CreateChecks::updateAll(['status' => 1], ['check_id' => $createCheck->check_id]);
+            }
+        }
+
+//        $products=array(); $payment_types=array();
+
+        $usersArr = ArrayHelper::map(Products1c::find()->where(['tip' => 'admin'])->all(), 'id', 'name');
+        $orderStatuses = OrdersStatus::find()->select(['status_id', 'color', 'name'])->where(['pipeline_id' => 4021495])->all();
+        $status_ar = [];
+        foreach($orderStatuses as $orderStatus) {
+            /* @var $orderStatus OrdersStatus */
+            if ($orderStatus->status_id == 142) { $orderStatus->name = "Успешно"; }
+            if ($orderStatus->status_id == 143) { $orderStatus->name = "Отказ"; }
+            //$status_ar[$row["status_id"]]="<span class=\"tag\" style=\"background:".$row["color"]."\">".$row["name"]."</span>";
+        }
+
+        $lid_id = (int)(Yii::$app->request->post("lid_id") ?? 0);
+        $amo_id = (int)(Yii::$app->request->post("amo_id") ?? 0);
+        $delivery_date = htmlentities(Yii::$app->request->post("delivery_date") ?? date("Y-m-d"));
+
+        $status_ar2 = $status_ar;
+        unset($status_ar2[38369449]);
+        unset($status_ar2[38207068]);
+        unset($status_ar2[38207074]);
+        unset($status_ar2[38207077]);
+        unset($status_ar2[38207182]);
+
+        $balances = Balances::find()->select(['store_id', 'product_id', 'quantity'])->all();
+        $balancesAll = [];
+        foreach($balances as $balance) {
+            /* @var $balance Balances */
+            $balancesAll[$balance->store_id][$balance->product_id] = $balance->quantity;
+        }
+
+        $products1cs = Products1c::find()->alias('p1c')->select(['p1c.id'])
+            ->rightJoin('products_class pc', 'p1c.parent_id = pc.category_id and pc.tip="services"')->all();
+
+        $services = [];
+        foreach($products1cs as $products1c) {
+            $services[$products1c->id] = $products1c->id;
+        }
+
+        $eits = ExportImportTable::find()->select(['entity_id', 'export_val'])->where(['entity' => 'city_store', 'export_id' => 1])
+            ->andWhere(['>', 'entity_id', 0])->all();
+        $exportStore = [];
+        foreach($eits as $eit) {
+            $exportStore[$eit->entity_id] = $eit->export_val;
+        }
+
+        $users_arr_group_3_plus = ArrayHelper::map(Admin::find()->select(['id', 'name'])->where(['>', 'group_id', 3])->all(), 'id', 'name');
+
+        $stores_arr = ArrayHelper::map(Products1c::find()->select(['id', 'name'])->where(['tip' => 'city_store'])->all(), 'id', 'name');
+
+        $cityStores = CityStore::find()->select(['id', 'name', 'access_amo'])->all();
+        $storesNameArr = [];
+        foreach($cityStores as $cityStore) {
+            $store_arr[$cityStore->id] = $cityStore->name;
+            $storesNameArr[$cityStore->adress_amo] = $cityStore->id;
+        }
+
+
+
+        return $this->controller->render('delivery', compact('yesses', 'lid_id', 'delivery_date', 'status_ar2'));
+    }
+}
index 72785bd0a82c3a3597c10b697bf19c780ea45353..9d84703addad473f3120c5d498b927474df56497 100644 (file)
@@ -18,7 +18,8 @@ class OrdersController extends Controller
     public function actions()
     {
         return ArrayHelper::merge(parent::actions(), [
-            'fill-phone' => \yii_app\actions\orders\FillPhoneAction::class
+            'fill-phone' => \yii_app\actions\orders\FillPhoneAction::class,
+            'delivery' => \yii_app\actions\orders\DeliveryAction::class,
         ]);
     }
 
@@ -30,9 +31,9 @@ class OrdersController extends Controller
         return $this->render('amobaza');
     }
 
-    public function actionDelivery() {
-        return $this->render('delivery');
-    }
+//    public function actionDelivery() {
+//        return $this->render('delivery');
+//    }
 
     public function actionAmo_checks() {
         return $this->render('amo_checks');
index dc4c317e4e26d6e6f301245680f102d1f814c2ee..7efe1cf682e160637c853c782aeb45d7107bda71 100644 (file)
@@ -1,5 +1,66 @@
 <?php
 
-chdir(__DIR__ . '/../../');
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
 
-include 'modul/orders/delivery.php';
+/* @var $yesses array */
+/* @var $lid_id int */
+/* @var $delivery_date string */
+/* @var $status_ar2 array */
+
+?>
+
+<div class="ordersDelivery m-5">
+
+    <?php foreach ($yesses as $yess): ?>
+        <div class="row">
+            <div class="col-12">
+                ++++ <?= $yess ?> +++ есть чек в 1с
+            </div>
+        </div>
+    <?php endforeach; ?>
+
+    <h1>Заказы из amo и чеки в магазинах</h1>
+    <?php $form = ActiveForm::begin([
+        "action" => "/orders/delivery",
+        "method" => "GET",
+        "target" => "_blank",
+    ]) ?>
+    <?= Html::hiddenInput('action', 'amoUpdateDate') ?>
+    <?= Html::textInput('date', date('Y-m-d'), ['required' => true, 'type' => 'date']) ?>
+    <?= Html::submitButton('импортировать заказы с amo на выбранную дату', ['class' => 'btn btn-info']) ?>
+    <?php ActiveForm::end() ?>
+    <div style="color: red; font-size: 1rem; ">После импортирования заказов из АМО<br> нужно перезагрузить страницу с заказами</div>
+
+    <?php $form = ActiveForm::begin() ?>
+    <table class='mt-5'>
+        <tr>
+            <td>
+                <?= Html::textInput("lid_id", $lid_id, ['placeholder' => 'ID заказа', 'class' => 'form-control', 'style' => 'width:100px;']) ?>
+            </td>
+            <td>
+                <?= Html::textInput("amo_id", "", ['placeholder' => 'amo ID', 'class' => 'form-control', 'style' => 'width:100px;']) ?>
+            </td>
+            <td class='px-5'>дата доставки:
+                <span class='d-inline-block'>
+                    <?= Html::textInput("delivery_date", $delivery_date, ['type' => 'date', 'class' => 'form-control']) ?>
+                </span>
+            </td>
+        </tr>
+    </table>
+
+    <?php $cnt = 0; ?>
+    <?php foreach($status_ar2 as $id =>$name): ?>
+        <?php $cnt ++; ?>
+        <?php if ($cnt == 7): ?><br><?php endif;?>
+        <label for="st__<?= $id ?>" class="m-1">
+            <?= Html::checkbox('statuses[' . $id . ']', null, ['id' => 'st__' . $id]) ?>
+            <?= $name ?>
+        </label>";
+    <?php endforeach; ?>
+    <br>
+    <?= Html::button('вывод', ['class' => 'btn btn-success'])?>
+
+    <?php ActiveForm::end() ?>
+
+</div>