From 22202805540a5abe7661e7d9d953c9bda199068e Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 27 Mar 2025 17:05:06 +0300 Subject: [PATCH] [ERP-393] draft amo to yii --- erp24/actions/orders/DeliveryAction.php | 98 +++++++++++++++++++++++++ erp24/controllers/OrdersController.php | 9 ++- erp24/views/orders/delivery.php | 65 +++++++++++++++- 3 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 erp24/actions/orders/DeliveryAction.php diff --git a/erp24/actions/orders/DeliveryAction.php b/erp24/actions/orders/DeliveryAction.php new file mode 100644 index 00000000..07192bc7 --- /dev/null +++ b/erp24/actions/orders/DeliveryAction.php @@ -0,0 +1,98 @@ +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"]]="".$row["name"].""; + } + + $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')); + } +} diff --git a/erp24/controllers/OrdersController.php b/erp24/controllers/OrdersController.php index 72785bd0..9d84703a 100644 --- a/erp24/controllers/OrdersController.php +++ b/erp24/controllers/OrdersController.php @@ -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'); diff --git a/erp24/views/orders/delivery.php b/erp24/views/orders/delivery.php index dc4c317e..7efe1cf6 100644 --- a/erp24/views/orders/delivery.php +++ b/erp24/views/orders/delivery.php @@ -1,5 +1,66 @@ + +
+ + +
+
+ ++++ +++ есть чек в 1с +
+
+ + +

Заказы из amo и чеки в магазинах

+ "/orders/delivery", + "method" => "GET", + "target" => "_blank", + ]) ?> + + true, 'type' => 'date']) ?> + 'btn btn-info']) ?> + +
После импортирования заказов из АМО
нужно перезагрузить страницу с заказами
+ + + + + + + + +
+ 'ID заказа', 'class' => 'form-control', 'style' => 'width:100px;']) ?> + + 'amo ID', 'class' => 'form-control', 'style' => 'width:100px;']) ?> + дата доставки: + + 'date', 'class' => 'form-control']) ?> + +
+ + + $name): ?> + +
+ "; + +
+ 'btn btn-success'])?> + + + +
-- 2.39.5