ver. 0.314: fix wyszukiwarki admin + title zamówienia
- Fix: globalna wyszukiwarka - Content-Type, Cache-Control, POST, FETCH_ASSOC, try/catch wrapper - New: document.title w szczegółach zamówienia = numer zamówienia Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ $orderId = (int)($this -> order['id'] ?? 0);
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="site-title">Szczegóły zamówienia: <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?></div>
|
<div class="site-title">Szczegóły zamówienia: <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?></div>
|
||||||
|
<script>document.title = 'Zamówienie <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?> - shopPro';</script>
|
||||||
|
|
||||||
<div class="od-actions mb15">
|
<div class="od-actions mb15">
|
||||||
<a href="/admin/shop_order/list/" class="btn btn-dark btn-sm">
|
<a href="/admin/shop_order/list/" class="btn btn-dark btn-sm">
|
||||||
|
|||||||
@@ -322,7 +322,7 @@
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/admin/settings/globalSearchAjax/',
|
url: '/admin/settings/globalSearchAjax/',
|
||||||
type: 'GET',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: { q: phrase },
|
data: { q: phrase },
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
@@ -333,8 +333,12 @@
|
|||||||
|
|
||||||
renderResults(response.items || []);
|
renderResults(response.items || []);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(xhr) {
|
||||||
$results.html('<div class="admin-global-search-empty">Błąd połączenia</div>').addClass('open');
|
var msg = 'Błąd połączenia';
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
msg = 'Błąd parsowania odpowiedzi';
|
||||||
|
}
|
||||||
|
$results.html('<div class="admin-global-search-empty">' + msg + '</div>').addClass('open');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,26 +73,45 @@ class SettingsController
|
|||||||
*/
|
*/
|
||||||
public function globalSearchAjax(): void
|
public function globalSearchAjax(): void
|
||||||
{
|
{
|
||||||
global $mdb;
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
header('Cache-Control: no-store');
|
||||||
|
|
||||||
$phrase = trim((string)\Shared\Helpers\Helpers::get('q'));
|
try {
|
||||||
if ($phrase === '' || mb_strlen($phrase) < 2) {
|
$this->executeGlobalSearch();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => 'ok',
|
'status' => 'error',
|
||||||
'items' => [],
|
'items' => [],
|
||||||
]);
|
]);
|
||||||
exit;
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function executeGlobalSearch(): void
|
||||||
|
{
|
||||||
|
global $mdb;
|
||||||
|
|
||||||
|
$phrase = isset($_REQUEST['q']) ? trim((string)$_REQUEST['q']) : '';
|
||||||
|
if ($phrase === '' || mb_strlen($phrase) < 2) {
|
||||||
|
echo json_encode(['status' => 'ok', 'items' => []]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$phrase = mb_substr($phrase, 0, 120);
|
$phrase = mb_substr($phrase, 0, 120);
|
||||||
$phraseNormalized = preg_replace('/\s+/', ' ', $phrase);
|
$phraseNormalized = trim((string)preg_replace('/\s+/', ' ', $phrase));
|
||||||
$phraseNormalized = trim((string)$phraseNormalized);
|
|
||||||
$like = '%' . $phrase . '%';
|
$like = '%' . $phrase . '%';
|
||||||
$likeNormalized = '%' . $phraseNormalized . '%';
|
$likeNormalized = '%' . $phraseNormalized . '%';
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
$defaultLang = (string)$this->languagesRepository->defaultLanguage();
|
|
||||||
|
|
||||||
|
$defaultLang = '1';
|
||||||
|
try {
|
||||||
|
$defaultLang = (string)$this->languagesRepository->defaultLanguage();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
// fallback to '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Produkty ---
|
||||||
try {
|
try {
|
||||||
$productStmt = $mdb->query(
|
$productStmt = $mdb->query(
|
||||||
'SELECT '
|
'SELECT '
|
||||||
@@ -115,7 +134,10 @@ class SettingsController
|
|||||||
$productStmt = false;
|
$productStmt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$productRows = $productStmt ? $productStmt->fetchAll() : [];
|
$productRows = ($productStmt && method_exists($productStmt, 'fetchAll'))
|
||||||
|
? $productStmt->fetchAll(\PDO::FETCH_ASSOC)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (is_array($productRows)) {
|
if (is_array($productRows)) {
|
||||||
foreach ($productRows as $row) {
|
foreach ($productRows as $row) {
|
||||||
$productId = (int)($row['id'] ?? 0);
|
$productId = (int)($row['id'] ?? 0);
|
||||||
@@ -147,6 +169,7 @@ class SettingsController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Zamowienia ---
|
||||||
try {
|
try {
|
||||||
$orderStmt = $mdb->query(
|
$orderStmt = $mdb->query(
|
||||||
'SELECT '
|
'SELECT '
|
||||||
@@ -178,7 +201,10 @@ class SettingsController
|
|||||||
$orderStmt = false;
|
$orderStmt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$orderRows = $orderStmt ? $orderStmt->fetchAll() : [];
|
$orderRows = ($orderStmt && method_exists($orderStmt, 'fetchAll'))
|
||||||
|
? $orderStmt->fetchAll(\PDO::FETCH_ASSOC)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (is_array($orderRows)) {
|
if (is_array($orderRows)) {
|
||||||
foreach ($orderRows as $row) {
|
foreach ($orderRows as $row) {
|
||||||
$orderId = (int)($row['id'] ?? 0);
|
$orderId = (int)($row['id'] ?? 0);
|
||||||
@@ -214,11 +240,12 @@ class SettingsController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode([
|
$json = json_encode(['status' => 'ok', 'items' => array_slice($items, 0, 20)]);
|
||||||
'status' => 'ok',
|
if ($json === false) {
|
||||||
'items' => array_slice($items, 0, 20),
|
echo json_encode(['status' => 'ok', 'items' => []], JSON_UNESCAPED_UNICODE);
|
||||||
]);
|
return;
|
||||||
exit;
|
}
|
||||||
|
echo $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ Logi zmian z migracji na Domain-Driven Architecture. Najnowsze na gorze.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## ver. 0.314 (2026-02-23) - Fix wyszukiwarki admin + title zamówienia
|
||||||
|
|
||||||
|
- **FIX**: Globalna wyszukiwarka w panelu admina przestała zwracać wyniki — dodano `Content-Type: application/json` i `Cache-Control: no-store` (zapobiega cache'owaniu przez proxy/CDN), zmiana AJAX z GET na POST, `fetchAll(PDO::FETCH_ASSOC)`, top-level try/catch z gwarantowaną odpowiedzią JSON
|
||||||
|
- **NEW**: `document.title` w widoku szczegółów zamówienia pokazuje numer zamówienia (np. "Zamówienie ZAM/123 - shopPro")
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## ver. 0.313 (2026-02-23) - Fix sync płatności Apilo + logowanie
|
## ver. 0.313 (2026-02-23) - Fix sync płatności Apilo + logowanie
|
||||||
|
|
||||||
- **FIX**: `syncApiloPayment()` i `syncApiloStatus()` — `(int)` cast na `apilo_order_id` (format `"PPxxxxxx"`) dawał `0`, przez co metody pomijały sync z API Apilo. Zmiana na `empty()`
|
- **FIX**: `syncApiloPayment()` i `syncApiloStatus()` — `(int)` cast na `apilo_order_id` (format `"PPxxxxxx"`) dawał `0`, przez co metody pomijały sync z API Apilo. Zmiana na `empty()`
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
1. Może warto przepisać zadania cron, na tabelę, tak żeby zadania cron się kolejkowały i wykonywały za podstawie wpisów z bazy danych, takż żeby własnie nie było sytuacji, że zamówienie będzie próbowało zmienić status w apilo, zanim to zamówienie tam trafi. Czy wszystkie takie zadania trafiałyby do kolejki i wykonywałyby się chronologicznie. Ewentualnie jakieś inne podejście możesz zaproponować.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?
|
<?
|
||||||
$current_ver = 313;
|
$current_ver = 314;
|
||||||
|
|
||||||
for ($i = 1; $i <= $current_ver; $i++)
|
for ($i = 1; $i <= $current_ver; $i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user