From: Alexander Smirnov Date: Wed, 10 Jan 2024 16:43:26 +0000 (+0300) Subject: add /bonus/write_off during moving pure php to yii X-Git-Tag: 1.1~189^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ce03eb257ba2aa86acf143c3a882ce2b80538f27;p=erp24_rep%2Fyii-erp24%2F.git add /bonus/write_off during moving pure php to yii --- diff --git a/erp24/actions/shipment/WriteOffAction.php b/erp24/actions/shipment/WriteOffAction.php new file mode 100644 index 00000000..61e91cdb --- /dev/null +++ b/erp24/actions/shipment/WriteOffAction.php @@ -0,0 +1,12 @@ +controller->render('write_off'); + } +} \ No newline at end of file diff --git a/erp24/controllers/ShipmentController.php b/erp24/controllers/ShipmentController.php index d42c40ed..9ba01738 100755 --- a/erp24/controllers/ShipmentController.php +++ b/erp24/controllers/ShipmentController.php @@ -29,6 +29,7 @@ class ShipmentController extends \yii\web\Controller 'store-products-fact-edit' => \yii_app\actions\shipment\StoreProductsFactEditAction::class, 'polnogramm' => \yii_app\actions\shipment\PolnogrammAction::class, 'store-planogram-logi' => \yii_app\actions\shipment\StorePlanogramLogiAction::class, + 'write_off' => \yii_app\actions\shipment\WriteOffAction::class, ]; } diff --git a/erp24/views/shipment/write_off.php b/erp24/views/shipment/write_off.php new file mode 100644 index 00000000..111c7b91 --- /dev/null +++ b/erp24/views/shipment/write_off.php @@ -0,0 +1,90 @@ +='$date_14day'"; $get .="&date1=$date_14day"; } +if(!empty($_REQUEST["date2"])) {$date2=htmlentities($_REQUEST["date2"]); $where .=" AND date<='$date2'"; $get .="&date2=$date2";} + + +echo'
+ + + +
'; + + +$stores=$db::mapping("SELECT id, name FROM products_1c WHERE tip='city_store'"); + + +$data=$db::getRows("SELECT p.product_id, products.name, sum(p.quantity) as cnt, w.store_id, prices.price +FROM write_offs as w, write_offs_products as p , products_1c as products, prices +WHERE p.write_offs_id=w.id AND products.id=p.product_id AND products.id=prices.product_id AND w.type='Брак' AND w.date>=? AND w.date<=? group BY w.store_id, p.product_id order by p.product_id, cnt DESC",[$date_14day,$date2]); + +foreach($data as $row) { + $write[$row["product_id"]][$row["store_id"]] =$row["cnt"]; + $write_all[$row["store_id"]] +=$row["cnt"]; + $all +=$row["cnt"]; + + + $write_price_all[$row["store_id"]] +=$row["cnt"]*$row["price"]; + $all_price +=$row["cnt"]*$row["price"]; +} + + +echo" Данные из 1c c $date_14day по $date2 +

% списания от общего списания по магазинам

+ + Списнаия на сумму $all_price= + "; +foreach($stores as $storeId =>$store) { + + $percent_all=round(100*($write_all[$storeId]/($all + 0.0001))); + $percantArr[$storeId]=$percent_all; + $percentp_all=round(100*($write_price_all[$storeId]/($all_price + 0.0001))); + $percantArrPrice[$storeId]=$percentp_all; + +} + +arsort($percantArr); +foreach($percantArr as $storeId =>$percent_all) { + if($percent_all>0) echo""; + +} + +echo"
".$stores[$storeId]." $percent_all%".$write_price_all[$storeId]."".$percantArrPrice[$storeId]."%
"; + +$data=$db::getRows("SELECT p.product_id, products.name, sum(p.quantity) as cnt +FROM write_offs as w, write_offs_products as p , products_1c as products +WHERE p.write_offs_id=w.id AND products.id=p.product_id AND w.type='Брак' AND w.date>=? AND w.date<=? group BY p.product_id order by cnt DESC",[$date_14day,$date2]); +echo"

Списания по магазинам

"; +foreach($data as $row) { + + echo" "; + + foreach($write[$row["product_id"]] ?? [] as $storeId => $cnt) { + + + $percent=round( ($cnt/$row["cnt"])*100 ); + + echo""; + + + } + +} +echo"
+".$row["name"]."".$row["cnt"]."
$cnt $percent%".$stores[$storeId]."
"; + + + + + +include_once dirname(__DIR__, 2) . '/templates/bottom_light.php'; \ No newline at end of file