| Cikkszám | +Mennyiség | +Terméknév | +
|---|
+ + +
diff --git a/css/custom_panel.css b/css/custom_panel.css index b12d767..d9e44a7 100644 --- a/css/custom_panel.css +++ b/css/custom_panel.css @@ -193,6 +193,7 @@ button { border-radius: 5px; padding: 30px; display: none; + border: 1px solid #dddddd; } .cat-tab.form-section.active { diff --git a/dashboard/acquire.php b/dashboard/acquire.php new file mode 100644 index 0000000..68bf1f2 --- /dev/null +++ b/dashboard/acquire.php @@ -0,0 +1,314 @@ +query($query)) { + while ($c_climair = $result->fetch_assoc()) { + $c_item_id = $c_climair['item_id']; + + $annual_query = mysqli_query($conn, "SELECT AVG(total_consumption) AS avg_total_consumption FROM statistics_annual WHERE item_id = '$c_item_id' AND year >= YEAR(CURDATE()) - 2"); + $annual_data = mysqli_fetch_assoc($annual_query); + + $avg_total_consumption = 0; + $is_new = false; + if ($annual_data != null && $annual_data['avg_total_consumption'] != null) { + $avg_total_consumption = $annual_data['avg_total_consumption']; + } else { + $is_new = true; + } + + if ($avg_total_consumption == 0) { + $c_car_type = $c_climair['car_type']; + $c_car_brand = $c_climair['car_brand']; + $stmt = $conn->prepare("SELECT AVG(total_consumption) AS avg_total_consumption + FROM statistics_annual sa + WHERE sa.item_id IN ( + SELECT item_id + FROM pr_parameters + WHERE category = 'ClimAir' + AND data_status = 1 + AND car_type = ? + AND car_brand = ? + ) + AND sa.year >= YEAR(CURDATE()) - 2"); + + $stmt->bind_param("ss", $c_car_type, $c_car_brand); + $stmt->execute(); + $annual_data_type = $stmt->get_result(); + while ($row = $annual_data_type->fetch_assoc()) { + $avg_total_consumption = $row['avg_total_consumption']; + } + + } + + $month_4_consumption = ($avg_total_consumption / 365) * (4 + 2) * 30; // Napi fogyás * 4 hónapos tervezés + 2 hónap beérkezési idő + + $daily_query = mysqli_query($conn, "SELECT under_sales FROM statistics_daily WHERE item_id = '$c_item_id'"); + $daily_data = mysqli_fetch_assoc($daily_query); + + if ($daily_data != null) { + $month_4_consumption += $daily_data['under_sales']; + } + + $set_items = splitSetitem_id($c_item_id); + if ($set_items != null) { + $return_list[] = [ + "item_id" => $set_items['item1'], + "amount" => ceil($month_4_consumption), + "name_in_db" => $c_climair['name_in_db'], + "is_new" => $is_new + ]; + $return_list[] = [ + "item_id" => $set_items['item2'], + "amount" => ceil($month_4_consumption), + "name_in_db" => $c_climair['name_in_db'], + "is_new" => $is_new + ]; + } else { + $return_list[] = [ + "item_id" => $c_item_id, + "amount" => ceil($month_4_consumption), + "name_in_db" => $c_climair['name_in_db'], + "is_new" => $is_new + ]; + } + } + } + + /* Return előkészítése */ + $return_list = array_reduce($return_list, function($carry, $item) { + $id = $item['item_id']; + if (isset($carry[$id])) { + $carry[$id]['amount'] += $item['amount']; + } else { + $carry[$id] = $item; + } + return $carry; + }, []); + $return_list = array_values($return_list); + usort($return_list, function($a, $b) { + if ($a['is_new'] != $b['is_new']) { + return $b['is_new'] - $a['is_new']; + } + return $a['amount'] <=> $b['amount']; + }); + echo json_encode(['result' => 'ok', 'return_list' => $return_list]); + } + + exit(); +} + +?> + + +
+ + + +
| Cikkszám | +Mennyiség | +Terméknév | +
|---|
Terméklista
'; } + $menuhtml .= ' + '; + } + if (UserHasPerm('statistics_menu')) { if (!$isProduct) { $isProduct = true; $menuhtml .= 'Terméklista
'; } $menuhtml .= '