From df24da8915c7a033f27f82d147bee7870b9b586b Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Sun, 15 Feb 2026 15:03:24 +0100 Subject: [PATCH] ver. 0.274 - ShopClients Domain+DI migration --- .../shop-clients/clients-details.php | 53 +--- admin/templates/shop-clients/view-list.php | 84 +----- admin/templates/site/main-layout.php | 2 +- autoload/Domain/Client/ClientRepository.php | 250 ++++++++++++++++++ .../Controllers/ShopClientsController.php | 222 ++++++++++++++++ autoload/admin/class.Site.php | 7 + autoload/admin/controls/class.ShopClients.php | 28 -- autoload/admin/factory/class.ShopClients.php | 17 -- docs/CHANGELOG.md | 10 +- docs/DATABASE_STRUCTURE.md | 22 ++ docs/PROJECT_STRUCTURE.md | 7 + docs/REFACTORING_PLAN.md | 7 +- docs/TESTING.md | 9 + .../Domain/Client/ClientRepositoryTest.php | 134 ++++++++++ .../Controllers/ShopClientsControllerTest.php | 56 ++++ updates/0.20/ver_0.274.zip | Bin 0 -> 13351 bytes updates/0.20/ver_0.274_files.txt | 2 + updates/changelog.php | 8 + updates/versions.php | 2 +- 19 files changed, 740 insertions(+), 180 deletions(-) create mode 100644 autoload/Domain/Client/ClientRepository.php create mode 100644 autoload/admin/Controllers/ShopClientsController.php delete mode 100644 autoload/admin/controls/class.ShopClients.php delete mode 100644 autoload/admin/factory/class.ShopClients.php create mode 100644 tests/Unit/Domain/Client/ClientRepositoryTest.php create mode 100644 tests/Unit/admin/Controllers/ShopClientsControllerTest.php create mode 100644 updates/0.20/ver_0.274.zip create mode 100644 updates/0.20/ver_0.274_files.txt diff --git a/admin/templates/shop-clients/clients-details.php b/admin/templates/shop-clients/clients-details.php index 8c0edb7..6028434 100644 --- a/admin/templates/shop-clients/clients-details.php +++ b/admin/templates/shop-clients/clients-details.php @@ -1,48 +1,9 @@ -
name . ' ' . $this->surname; ?>
-
Łączne zakupy w wysokości: total_spent; ?> zł
+
name . ' ' . $this->surname, ENT_QUOTES, 'UTF-8'); ?>
+
+ Łączne zakupy: total_spent, 2, '.', ' '); ?> zl, + liczba zamówień: total_orders; ?> +
-
+
- gdb_opt = $gdb; - -$grid->src = $this->orders_info; - -$grid -> debug = true; -$grid -> order = [ 'column' => 'date_order', 'type' => 'DESC' ]; -$grid -> search = []; -$grid -> columns_view = [ - [ - 'name' => 'Lp.', - 'th' => [ 'class' => 'g-lp' ], - 'td' => [ 'class' => 'g-center' ], - 'autoincrement' => true - ], [ - 'name' => 'Data zamówienia', - 'db' => 'date_order', - 'td' => [ 'class' => 'g-center' ], - 'th' => [ 'class' => 'g-center', 'style' => 'width: 175px;' ], - ], [ - 'name' => 'Wartość', - 'db' => 'summary', - 'td' => [ 'class' => 'g-right' ], - 'th' => [ 'class' => 'g-right', 'style' => 'width: 150px;' ], - 'php' => 'echo number_format( "[summary]", 2, ".", " " ) . " zł";', - ], [ - 'name' => 'Typ płatności', - 'db' => 'payment_method', - 'th' => [ 'style' => 'width: 350px;' ], - ], [ - 'name' => 'Rodzaj transportu', - 'db' => 'transport', - 'th' => [ 'style' => 'width: 350px;' ], - ], [ - 'name' => 'Wiadomość', - 'db' => 'message', - ], -]; - -echo $grid -> draw(); -?> \ No newline at end of file + $this->ordersTable]); ?> \ No newline at end of file diff --git a/admin/templates/shop-clients/view-list.php b/admin/templates/shop-clients/view-list.php index 85800c6..e5f9b0c 100644 --- a/admin/templates/shop-clients/view-list.php +++ b/admin/templates/shop-clients/view-list.php @@ -1,84 +1,2 @@
Lista klientów
- gdb_opt = $gdb; - -$grid->sql = " - SELECT - MAX( client_id ) AS client_id, client_name, client_surname, client_email, MAX( client_phone ) AS client_phone, MAX( client_city ) AS client_city, COUNT(*) AS total_orders, SUM(summary) AS total_spent, - CASE - WHEN MAX(client_id) IS NOT NULL - THEN 'Zarejestrowany' - ELSE - 'Gość' - END AS client_type - FROM pp_shop_orders - WHERE client_name IS NOT NULL AND client_surname IS NOT NULL AND client_email IS NOT NULL - GROUP BY client_name, client_surname, client_email - ORDER BY - CASE - WHEN MAX(client_id) IS NOT NULL THEN 1 - ELSE 2 - END, - client_name ASC"; -$grid -> sql_count = " - SELECT COUNT(*) - FROM ( SELECT client_name, client_surname, client_email - FROM pp_shop_orders - WHERE client_name IS NOT NULL AND client_surname IS NOT NULL AND client_email IS NOT NULL - GROUP BY client_name, client_surname, client_email - ) AS unique_clients"; - -$grid -> order = [ 'column' => 'date_order', 'type' => 'DESC' ]; -$grid -> search = []; -$grid -> columns_view = [ - [ - 'name' => 'Lp.', - 'th' => [ 'class' => 'g-lp' ], - 'td' => [ 'class' => 'g-center' ], - 'autoincrement' => true - ], [ - 'name' => 'Typ klienta', - 'db' => 'client_type', - 'td' => [ 'class' => 'g-center' ], - 'th' => [ 'class' => 'g-center', 'style' => 'width: 100px;' ], - ], [ - 'name' => 'Nazwisko, imię', - 'th' => [ 'style' => 'width: 225px;' ], - 'php' => 'echo "[client_surname]" . " " . "[client_name]";', - ], [ - 'name' => 'Email', - 'db' => 'client_email', - 'th' => [ 'style' => 'width: 150px;' ], - ], - [ - 'name' => 'Telefon', - 'db' => 'client_phone', - 'th' => [ 'style' => 'width: 150px;' ], - ], [ - 'name' => 'Miasto', - 'db' => 'client_city', - 'th' => [ 'style' => 'width: 150px;' ], - ], [ - 'name' => 'Wartość zamówień', - 'db' => 'total_spent', - 'td' => [ 'class' => 'g-right' ], - 'th' => [ 'class' => 'g-right', 'style' => 'width: 150px;' ], - 'php' => 'echo number_format( "[total_spent]", 2, ".", " " ) . " zł";', - ], [ - 'name' => 'Ilosc zamówień', - 'db' => 'total_orders', - 'td' => [ 'class' => 'g-center' ], - 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ], - 'php' => 'echo "[total_orders]";' - ], [ - 'name' => 'Akcje', - 'th' => [ 'class' => 'g-center', 'style' => 'width: 100px;' ], - 'td' => [ 'class' => 'g-center' ], - 'php' => 'echo "zobacz zamówienia";', - ] -]; - -echo $grid -> draw(); \ No newline at end of file + $this->viewModel]); ?> \ No newline at end of file diff --git a/admin/templates/site/main-layout.php b/admin/templates/site/main-layout.php index ef7f00f..c8f92f0 100644 --- a/admin/templates/site/main-layout.php +++ b/admin/templates/site/main-layout.php @@ -55,7 +55,7 @@