From: Alexander Smirnov Date: Sat, 20 Apr 2024 14:04:43 +0000 (+0300) Subject: shipment store product fact p1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7c60f5f5cbf8cedcd9024e6461ba44bf011eb48b;p=yii-erp24%2F.git shipment store product fact p1 --- diff --git a/erp24/controllers/ShipmentController.php b/erp24/controllers/ShipmentController.php index 1b0fe7a..efc3e9c 100755 --- a/erp24/controllers/ShipmentController.php +++ b/erp24/controllers/ShipmentController.php @@ -20,4 +20,6 @@ class ShipmentController extends Controller public function actionDivisionStorePrint() { return $this->render('division-store-print'); } public function actionStoreOrderScore() { return $this->render('store-order-score'); } public function actionAjaxDivisionAutoHandStart() { return $this->renderPartial('ajax-division-auto-hand-start'); } + public function actionStoreProductsFact() { return $this->render('store-products-fact'); } + public function actionStoreProductsFactEdit() { return $this->renderPartial('store-products-fact-edit'); } } \ No newline at end of file diff --git a/erp24/modul/shipment/storeProductsFact.php b/erp24/modul/shipment/storeProductsFact.php index e086af3..e727097 100644 --- a/erp24/modul/shipment/storeProductsFact.php +++ b/erp24/modul/shipment/storeProductsFact.php @@ -1,10 +1,12 @@ -"Понедельник", "wednesday"=>"Среда" ]; +$dayLinkstArray=["monday"=>"Понедельник", "wednesday"=>"Среда"]; $typer=""; foreach($dayLinkstArray as $lnk => $name) { @@ -75,7 +77,8 @@ error_mess("Выберите дату $date_div"); exit(); } -$data=$db::getRows("SELECT id,name, providers_arr FROM `store_orders` WHERE date_start>NOW() - interval 25 day"); +$data=$db::getRows("SELECT id,name, providers_arr FROM store_orders WHERE date_start > NOW()::date - '25 day'::interval"); +$prov = []; foreach($data as $row) { $pr=explode(",",$row["providers_arr"]); foreach($pr as $prid) { if(!empty($prid)) $prov[$prid]=$prid;} @@ -158,16 +161,16 @@ foreach($data3 as $row2) $factAll[$row2["store_id"]][$row2["product_id"]]=$row2[ foreach($stores as $stId =>$nameStore) { //echo"
магазин ".$nameStore." "; $cnt=0; $all=0; -$arrays=$store_planogramAllStores[$stId]; +$arrays=$store_planogramAllStores[$stId] ?? []; if(!empty($stores[$stId])){ foreach($arrays as $productId =>$quantity) { - if($factAll[$stId][$productId]>0 and $quantity>0) { + if(($factAll[$stId][$productId] ?? 0)>0 and $quantity>0) { //echo"+ $productId = $quantity"; $cnt++; } $all++; } - $percent=round(100*($cnt/$all)); + $percent=$all > 0 ? round(100*($cnt/$all)) : 0; //echo" $cnt из $all =$percent %"; $storesFact[$stId]=$percent; //не заполнившие магазины @@ -182,7 +185,7 @@ if($percent<15) $storesFactNo[]=$stId; foreach($stores as $strid=>$namestore){ -echo""; if($storesFact[$strid]>20) echo"+".$storesFact[$strid]."%"; @@ -209,7 +212,7 @@ if(!empty($storesFactNo)) { $w=""; $providers=$db::mapping("SELECT id,name FROM shipment_providers "); $k=0; -foreach($in as $pid) { echo''.$providers[$pid].''; if($k!=0) $w .=" OR"; $w .=" o.provider_id='$pid'"; $k++; } +foreach($in ?? [] as $pid) { echo''.$providers[$pid].''; if($k!=0) $w .=" OR"; $w .=" o.provider_id='$pid'"; $k++; } if(!empty($_POST["quantity"])) { @@ -302,18 +305,25 @@ foreach($prov as $pid) { } $where .=")"; -$data=$db::getRows("SELECT p.id, p.name, o.provider_id, o.colors FROM products_1c_options as o, products_1c as p -WHERE o.provider_id>0 AND p.view='1' AND p.id=o.id $where order by o.provider_id ASC, p.name ASC"); +if ($where != ' AND o.provider_id in()') { + $sql = "SELECT p.id, p.name, o.provider_id, o.colors FROM products_1c_options as o, products_1c as p +WHERE o.provider_id>0 AND p.view='1' AND p.id=o.id $where order by o.provider_id ASC, p.name ASC"; + $data = $db::getRows($sql); +} else { + $data = []; +} $products_group=$db::mapping("SELECT id, name FROM products_1c WHERE tip='products_group'"); //foreach($data4 as $row4) $products_group[$row4["id"]]=$row4["name"]; -$data2=$db::getRows("SELECT p.id, p.name, p.parent_id, o.provider_id, o.colors, p.parent_id as category_id FROM +$sql = "SELECT p.id, p.name, p.parent_id, o.provider_id, o.colors, p.parent_id as category_id FROM products_class as cl LEFT JOIN products_1c as p ON (p.view='1' AND p.parent_id=cl.category_id ) LEFT JOIN products_1c_options as o ON (p.id=o.id) -WHERE cl.tip='related' group by p.id order by o.provider_id, p.parent_id, p.name ASC"); +WHERE cl.tip='related' group by p.id, o.provider_id, o.colors order by o.provider_id, p.parent_id, p.name ASC"; +//var_dump($sql); die; +$data2=$db::getRows($sql); //SELECT p.id, p.name, p.parent_id, provider_id FROM products_class as cl, products_1c as p WHERE p.parent_id=cl.category_id AND cl.tip='related' AND p.view='1' order by p.parent_id, p.name ASC $data = array_merge($data, $data2); @@ -322,6 +332,8 @@ $data = array_merge($data, $data2); $p=0; $p2=0; +$providersIn = []; +$category_idIn = []; foreach($data as $row) { @@ -360,8 +372,8 @@ if(!in_array($row["category_id"],$category_idIn) and !empty($products_group[$row // ".$providers[$row["provider_id"]]." // echo"".$row["name"].""; -if($store_planogram[$row["id"]]>0 or $_SESSION["show_planogram_0"]==1) { -$difference=$store_planogram[$row["id"]]-$values_in[$row["id"]]["quantity"]; +if(($store_planogram[$row["id"]] ?? 0)>0 or $_SESSION["show_planogram_0"]==1) { +$difference=($store_planogram[$row["id"]] ?? 0)-($values_in[$row["id"]]["quantity"] ?? 0); if(!empty($store_planogram[$row["id"]])) $difference_percent=100-round(100*$difference/$store_planogram[$row["id"]]); else $difference_percent=""; @@ -370,8 +382,8 @@ else $difference_percent=""; if($p>1 or $p2>1) echo"display:none;"; -if($store_planogram[$row["id"]]==0) echo"opacity:0.9;"; -if($difference_percent==0 and $store_planogram[$row["id"]]!=0) echo"background:#ffe391;"; +if(($store_planogram[$row["id"]] ?? 0)==0) echo"opacity:0.9;"; +if($difference_percent==0 and ($store_planogram[$row["id"]] ?? 0)!=0) echo"background:#ffe391;"; if($difference_percent>=100) echo"background:#9effd2;"; @@ -380,16 +392,16 @@ if($difference_percent>=100) echo"background:#9effd2;"; if(!empty($row["category_id"])) echo" category__".$row["category_id"]; -if($store_planogram[$row["id"]]==0) echo" bg-danger2"; +if(($store_planogram[$row["id"]] ?? -1) ==0) echo" bg-danger2"; echo"\">".$row["name"]." -".$balances[$row["id"]].""; +".($balances[$row["id"]] ?? '').""; foreach($massiver as $f =>$mass) { echo''; if($mass["type"]=="number") { - echo'-выбрать-"; foreach($mass["values_arr"] as $v => $name) { - echo""; } echo''; @@ -418,7 +430,7 @@ if($store_planogram[$row["id"]]==0) echo" bg-danger2"; } -echo''.$store_planogram[$row["id"]].' +echo''.($store_planogram[$row["id"]] ?? '').' .t tbody tr td{padding:0;} .t tbody tr td input.form-control{padding:0;margin:0 2px;text-align:center;font-weight:bold;} .table tbody tr td{padding:0;} @@ -602,19 +617,17 @@ table tbody td small{color:#787878; text-align:center; font-size:0.7rem; margin: '; +include_once dirname(__DIR__, 2) . '/templates/bottom_light.php'; } - -include"templates/bottom.php"; - - - diff --git a/erp24/modul/shipment/storeProductsFactEdit.php b/erp24/modul/shipment/storeProductsFactEdit.php index 5591634..72da4f7 100644 --- a/erp24/modul/shipment/storeProductsFactEdit.php +++ b/erp24/modul/shipment/storeProductsFactEdit.php @@ -1,6 +1,6 @@ -
++$color++$sql"; $db::sql($sql); diff --git a/erp24/views/shipment/store-products-fact-edit.php b/erp24/views/shipment/store-products-fact-edit.php new file mode 100644 index 0000000..51a023e --- /dev/null +++ b/erp24/views/shipment/store-products-fact-edit.php @@ -0,0 +1,5 @@ +