Skip to content

Commit 80aa4df

Browse files
authored
Merge pull request #214 from Oneami/master
#14. Catalog products: wrapper size for laptops
2 parents 512d9ce + dc118a8 commit 80aa4df

File tree

4 files changed

+90
-17
lines changed

4 files changed

+90
-17
lines changed

src/app/Admin/Controllers/Analytics/OrderSourceController.php

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Admin\Controllers\Analytics;
44

5-
use App\Enums\Order\UtmEnum;
65
use App\Models\Orders\Order;
6+
use App\Models\User\User;
77
use Encore\Admin\Grid;
88

99
class OrderSourceController extends AbstractCustomerAnalyticController
@@ -28,18 +28,7 @@ protected function getInstanceColumnTitle(): string
2828
*/
2929
protected function getInstanceNameColumn(): string
3030
{
31-
return 'CONCAT(utm_source, \'-\', utm_campaign)';
32-
}
33-
34-
/**
35-
* Generates additional grid columns for the given grid.
36-
*
37-
* @param $grid The grid object to generate columns for.
38-
*/
39-
protected function additionalGridColumns($grid): void
40-
{
41-
$grid->column('channel_name', 'Канал')->display(fn () => UtmEnum::tryFrom($this->instance_name)?->channelName());
42-
$grid->column('company_name', 'Компания')->display(fn () => UtmEnum::tryFrom($this->instance_name)?->companyName());
31+
return 'CONCAT(orders.utm_source, \'-\', orders.utm_campaign)';
4332
}
4433

4534
/**
@@ -49,12 +38,58 @@ protected function getPreparedGrid(): Grid
4938
{
5039
$grid = new Grid(new Order());
5140

52-
$grid->model()->selectRaw($this->getSelectSql())
53-
->withExpression('LastUserOrders', $this->getLastUserOrdersQuery())
41+
// // $qq = User::selectRaw($this->getSelectSql())
42+
// // ->leftJoin('orders', 'users.id', '=', 'orders.user_id')
43+
// // // ->leftJoin('order_items', 'orders.id', '=', 'order_items.order_id')
44+
// // ->groupBy('instance_name', 'users.id');
45+
46+
// // print_r($qq->toSql());
47+
// // exit();
48+
49+
// // users.id AS user_id,
50+
// // orders.created_at AS created_at,
51+
52+
// $orderCreatedAtStart = request()->input('order_created_at_start');
53+
// $orderCreatedAtEnd = request()->input('order_created_at_end');
54+
55+
// $subQuery = <<<SQL
56+
// (SELECT {$this->getInstanceNameColumn()} AS instance_name,
57+
// users.id AS user_id,
58+
// SUM(CASE WHEN orders.status_key IN ({$this->statuses['accepted']}) THEN DISTINCT() ELSE 0 END) AS accepted_count,
59+
// SUM(CASE WHEN orders.status_key IN ({$this->statuses['in_progress']}) THEN 1 ELSE 0 END) AS in_progress_count,
60+
// SUM(CASE WHEN orders.status_key IN ({$this->statuses['purchased']}) THEN 1 ELSE 0 END) AS purchased_count,
61+
// SUM(CASE WHEN orders.status_key IN ({$this->statuses['canceled']}) THEN 1 ELSE 0 END) AS canceled_count,
62+
// SUM(CASE WHEN orders.status_key IN ({$this->statuses['returned']}) THEN 1 ELSE 0 END) AS returned_count,
63+
// SUM(1) AS total_count
64+
// FROM orders LEFT JOIN users ON users.id = orders.user_id
65+
// GROUP BY instance_name) AS userOrders
66+
// SQL;
67+
68+
// // dd(\DB::statement($subQuery));
69+
70+
// $grid->model()
71+
// ->select('instance_name', 'accepted_count', 'in_progress_count', 'purchased_count', 'canceled_count', 'returned_count', 'total_count')
72+
// ->leftJoin(
73+
// \DB::raw($subQuery),
74+
// function ($join) {
75+
// $join->on('users.id', '=', 'userOrders.user_id');
76+
// }
77+
// );
78+
79+
$sub = \DB::table('orders')
80+
->selectRaw($this->getSelectSql())
5481
->leftJoin('users', 'users.id', '=', 'orders.user_id')
5582
->leftJoin('order_items', 'orders.id', '=', 'order_items.order_id')
83+
->where('orders.created_at', '>=', '2024-01-04 00:00:00')
5684
->groupBy('instance_name');
5785

86+
$grid->model()
87+
->select('qq.instance_name', 'qq.total_purchased_price', 'qq.total_lost_price')
88+
->from($sub, 'qq');
89+
// ->leftJoin('users', 'users.id', '=', 'orders.user_id')
90+
// ->leftJoin('order_items', 'orders.id', '=', 'order_items.order_id')
91+
// ->groupBy('instance_name');
92+
5893
return $grid;
5994
}
6095
}

src/app/Admin/Controllers/OrdersDistribution/Form/LogGrid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function index()
2020
$grid->column('created_at', 'Дата и время')->display(fn () => date('d.m.Y H:i:s', strtotime($this->created_at)));
2121
$grid->column('order_id', '№ заказа');
2222
$grid->column('action', 'Комментарий');
23-
$grid->column('admin.username', 'Менеджер')->display(fn () => $this->admin->getShortNameAttribute());
23+
$grid->column('admin.username', 'Менеджер')->display(fn () => $this->admin ? $this->admin->getShortNameAttribute() : null);
2424

2525
$grid->disableCreateButton();
2626
$grid->disableFilter();

src/resources/js/scripts.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,23 @@ $(function () {
9595
let childsCount = imageBlocks.length;
9696
let width = $(this).width();
9797
let curIndex = 0;
98+
const pagination = document.createElement("div");
99+
pagination.classList.add('product-item-images-pagination');
100+
for (let i = 0; i < childsCount; i++) {
101+
let paginationItem = document.createElement("span");
102+
paginationItem.setAttribute('data-index', i);
103+
pagination.appendChild(paginationItem);
104+
}
105+
$(this).append(pagination);
106+
98107
$(this).mousemove(function (getCurrentPos) {
99108
let percentPart = (getCurrentPos.offsetX * 100) / width;
100109
let index = Math.abs(Math.floor(percentPart / (100 / childsCount)));
101110
if (index < childsCount && index !== curIndex) {
102111
imageBlocks.css({ 'display': 'none' });
103112
$(imageBlocks[index]).css({ 'display': 'block' });
113+
pagination.children[curIndex].classList.remove('active');
114+
pagination.children[index].classList.add('active');
104115
curIndex = index;
105116
}
106117
});
@@ -109,6 +120,7 @@ $(function () {
109120
$(document).on('mouseleave', '.js-productItemImages', function () {
110121
$(this).find('.js-productItemImagesContainer').css({ 'display': 'none' });
111122
$(this).find('.js-productItemImagesContainer').first().css({ 'display': 'block' });
123+
$(this).find('.product-item-images-pagination').remove();
112124
});
113125
});
114126

src/resources/sass/_styles.scss

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ body {
2121

2222
.wrapper {
2323
@include media-breakpoint-up(lg) {
24+
margin: 0 20px;
25+
}
26+
}
27+
28+
.wrapper {
29+
@include media-breakpoint-up(xl) {
2430
margin: 0 100px;
2531
}
2632
}
@@ -322,6 +328,26 @@ button.scroll-top-btn {
322328
}
323329
}
324330

331+
.product-item-images-pagination {
332+
position: absolute;
333+
display: flex;
334+
top: 0;
335+
left: 0;
336+
width: 100%;
337+
gap: 2px;
338+
339+
span {
340+
background-color: rgba(0, 0, 0, 0.25);
341+
display: inline-flex;
342+
height: 3px;
343+
flex: 1;
344+
345+
&.active {
346+
background-color: rgba(0, 0, 0, 0.7);
347+
}
348+
}
349+
}
350+
325351
.product-item .image {
326352
.product-first-image {
327353
display: block;
@@ -551,7 +577,7 @@ span {
551577

552578
.product-labels {
553579
position: absolute;
554-
top: 0;
580+
top: 5px;
555581
right: 0;
556582
z-index: 20;
557583
display: flex;

0 commit comments

Comments
 (0)