From 55db6cb17879bc273ecddfe202df1cfca83edfad Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 21 May 2024 21:12:31 +0300 Subject: [PATCH] fix part 014 --- erp24/modul/shipment/ajaxUpdateStoreZakup.php | 5 +--- erp24/modul/shipment/fields/quantity_fact.php | 5 ++-- erp24/modul/shipment/functionsShipment.php | 26 ++++++++++++------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/erp24/modul/shipment/ajaxUpdateStoreZakup.php b/erp24/modul/shipment/ajaxUpdateStoreZakup.php index 9ff94017..a5469347 100644 --- a/erp24/modul/shipment/ajaxUpdateStoreZakup.php +++ b/erp24/modul/shipment/ajaxUpdateStoreZakup.php @@ -276,14 +276,11 @@ try { if (empty($data_up)) echo "пусто"; echo " "; - } else { - echo " !!нет файла $f"; - } - echo ""; } + echo ""; } catch (Exception $ex) { echo $ex->getFile(). ' ' . $ex->getLine() . ' ' . $ex->getTraceAsString() . ' ' . $ex->getMessage(); die; diff --git a/erp24/modul/shipment/fields/quantity_fact.php b/erp24/modul/shipment/fields/quantity_fact.php index 5b8bafbd..7e0c3057 100644 --- a/erp24/modul/shipment/fields/quantity_fact.php +++ b/erp24/modul/shipment/fields/quantity_fact.php @@ -5,11 +5,12 @@ global $orderStoresArrayRelation_in, $whereInProductsId, $data_up; $date_id=$db::getValue("SELECT date_id FROM store_products_fact order by date_id DESC LIMIT 1"); if ($whereInProductsId != " in ()") { - $store_products_fact = $db::getRows("SELECT product_id,quantity, store_id,color FROM store_products_fact WHERE quantity>0 + $sql = "SELECT product_id,quantity, store_id,color FROM store_products_fact WHERE quantity>0 AND date_id=? AND store_id $orderStoresArrayRelation_in -AND product_id $whereInProductsId", [$date_id]); +AND product_id $whereInProductsId"; + $store_products_fact = $db::getRows($sql, [$date_id]); foreach ($store_products_fact as $row) { $data_up[$row["product_id"]][$row["store_id"]][$row["color"]] = ($data_up[$row["product_id"]][$row["store_id"]][$row["color"]] ?? 0) + $row["quantity"]; $data_up[$row["product_id"]][0][$row["color"]] = ($data_up[$row["product_id"]][0][$row["color"]] ?? 0) + $row["quantity"]; diff --git a/erp24/modul/shipment/functionsShipment.php b/erp24/modul/shipment/functionsShipment.php index 1c65b2be..f5839738 100644 --- a/erp24/modul/shipment/functionsShipment.php +++ b/erp24/modul/shipment/functionsShipment.php @@ -433,20 +433,21 @@ $status_store=""; if(!empty($store_id)) { if(!empty($_GET["status"]) and !empty($store_id) and !empty($orderId)) { - $db::sql("INSERT INTO store_order_status (order_id, store_id, status_id, status, date, admin_id) - VALUES ('$orderId', $status_order_id, 1, NOW(), " . $_SESSION["admin_id"] . ") - ON CONFLICT (id) DO UPDATE SET + $status_order_id = (int)$_GET["status"]; + $sql = "INSERT INTO store_order_status (order_id, store_id, status_id, status, date, admin_id) + VALUES ('$orderId', '$store_id', $status_order_id, 1, NOW(), " . $_SESSION["admin_id"] . ") + ON CONFLICT (order_id,store_id,status_id) DO UPDATE SET order_id = '$orderId', - store_id = ' . $store_id . ', + store_id = '$store_id', status_id = $status_order_id, status = 1, date = NOW(), - admin_id = " . $_SESSION["admin_id"]); -} + admin_id = " . $_SESSION["admin_id"]; + $db::sql($sql); +} $store_order_status_value=$db::getValue("SELECT status FROM store_order_status WHERE order_id=? AND store_id=? AND status_id=?",[$orderId,$store_id,$status_order_id]); - $status_store=" ".$storesArray[$store_id].":"; if(!empty($store_order_status_value)) $status_store .="внесено"; @@ -762,9 +763,14 @@ foreach($massivSQL as $productId =>$array) { - if($Insert) $db::sql("INSERT INTO store_orders_fields_data (product_id, order_id, store_id, field_name, field_id, value, value_text, color,hand,date_update, title) - VALUES (?,?,?,?,?,?,?,?,'-1',NOW(),?) ON CONFLICT (order_id, product_id, store_id, field_id, field_name, color) DO UPDATE SET value=?, hand=0, value_text=?, date_update=NOW(), title=?", - [$productId, $orderId, $storeId, $field_name, $field_id, $value, $value_text, $color, $title, $value, $value_text , $title]); + if($Insert) { + $sql = "INSERT INTO store_orders_fields_data (product_id, order_id, store_id, field_name, field_id, value, value_text, color,hand,date_update, title) + VALUES (?,?,?,?,?,?,?,?,'-1',NOW(),?) ON CONFLICT (order_id, product_id, store_id, field_id, field_name, color) DO UPDATE SET value=?, hand=0, value_text=?, date_update=NOW(), title=?"; + $sql2 = "INSERT INTO store_orders_fields_data (product_id, order_id, store_id, field_name, field_id, value, value_text, color,hand,date_update, title) + VALUES ('$productId','$orderId','$storeId','$field_name','$field_id','$value','$value_text','$color','-1',NOW(),'$title') ON CONFLICT (order_id, product_id, store_id, field_id, field_name, color) DO UPDATE SET value='$value', hand=0, value_text='$value_text', date_update=NOW(), title='$title'"; + // var_dump($sql2); die; + $db::sql($sql, [$productId, $orderId, $storeId, $field_name, $field_id, $value, $value_text, $color, $title, $value, $value_text , $title]); + } } -- 2.39.5