diff --git a/scmining.php b/scmining.php index 039c909..c829294 100644 --- a/scmining.php +++ b/scmining.php @@ -31,6 +31,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Add mineral to list if ($action === 'add_mineral') { $obj_id = (int)$_POST['obj_id']; + $return_search = trim($_POST['return_search'] ?? ''); + $return_page = max(1, (int)($_POST['return_page'] ?? 1)); + if ($obj_id > 0) { try { $stmt = $db->prepare("INSERT INTO tbl_scmining (cl_scmining_obj_id, cl_scmining_scan_value, cl_scmining_max_occurrence) VALUES (:obj_id, 0, 1)"); @@ -40,11 +43,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($e->getCode() == 23000) { auth_flash_set('error', 'Ce minéral est déjà dans la liste.'); } else { - auth_flash_set('error', 'Erreur lors de l\'ajout : ' . $e->getMessage()); + auth_flash_set('error', "Erreur lors de l'ajout : " . $e->getMessage()); } } } - header('Location: scmining.php'); + header('Location: ' . scmining_search_url($return_search, $return_page)); exit; } @@ -85,33 +88,72 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } // Search for adding items -function sc_rarity_label(?string $rarity): string +function sc_normalize_rarity(?string $rarity): string { - return match ($rarity) { - 'L' => 'Legendary', - 'E' => 'Epic', - 'R' => 'Rare', - 'U' => 'Uncommon', - 'C' => 'Common', - default => 'Non définie', - }; + return strtoupper(trim((string) $rarity)); } function sc_rarity_class(?string $rarity): string { + $rarity = sc_normalize_rarity($rarity); + return in_array($rarity, ['L', 'E', 'R', 'U', 'C'], true) ? 'rarity-' . $rarity : 'rarity-none'; } +function sc_rarity_style(?string $rarity): string +{ + return match (sc_normalize_rarity($rarity)) { + 'L' => 'color:#ff8000 !important;text-shadow:0 0 10px rgba(255,128,0,0.3);', + 'E' => 'color:#a335ee !important;text-shadow:0 0 10px rgba(163,53,238,0.3);', + 'R' => 'color:#0070dd !important;text-shadow:0 0 10px rgba(0,112,221,0.3);', + 'U' => 'color:#1eff00 !important;text-shadow:0 0 10px rgba(30,255,0,0.3);', + 'C' => 'color:#ffffff !important;', + default => 'color:#8f96a3 !important;', + }; +} + +function scmining_search_url(string $search = '', int $page = 1): string +{ + $params = []; + + if ($search !== '') { + $params['search'] = $search; + } + + if ($page > 1) { + $params['search_page'] = $page; + } + + return 'scmining.php' . ($params ? '?' . http_build_query($params) : ''); +} + $search = isset($_GET['search']) ? trim($_GET['search']) : ''; +$search_page = max(1, (int)($_GET['search_page'] ?? 1)); +$search_per_page = 10; $search_results = []; +$search_total_results = 0; +$search_total_pages = 0; + if ($search !== '') { - $stmt_search = $db->prepare("SELECT * FROM tbl_scobjs WHERE cl_scobjs_name LIKE :search AND cl_scobjs_id NOT IN (SELECT cl_scmining_obj_id FROM tbl_scmining) ORDER BY cl_scobjs_name ASC LIMIT 10"); - $stmt_search->execute(['search' => "%$search%"]); + $search_where = "FROM tbl_scobjs WHERE cl_scobjs_name LIKE :search AND cl_scobjs_id NOT IN (SELECT cl_scmining_obj_id FROM tbl_scmining)"; + + $stmt_search_count = $db->prepare("SELECT COUNT(*) " . $search_where); + $stmt_search_count->execute(['search' => "%$search%"]); + $search_total_results = (int)$stmt_search_count->fetchColumn(); + $search_total_pages = max(1, (int)ceil($search_total_results / $search_per_page)); + $search_page = min($search_page, $search_total_pages); + $search_offset = ($search_page - 1) * $search_per_page; + + $stmt_search = $db->prepare("SELECT * " . $search_where . " ORDER BY cl_scobjs_name ASC, cl_scobjs_id ASC LIMIT :limit OFFSET :offset"); + $stmt_search->bindValue(':search', "%$search%", PDO::PARAM_STR); + $stmt_search->bindValue(':limit', $search_per_page, PDO::PARAM_INT); + $stmt_search->bindValue(':offset', $search_offset, PDO::PARAM_INT); + $stmt_search->execute(); $search_results = $stmt_search->fetchAll(); } // Fetch current mining list -$sql_list = "SELECT m.*, o.cl_scobjs_name, o.cl_scobjs_uuid, o.cl_scobjs_type, o.cl_scobjs_subtype +$sql_list = "SELECT m.*, o.cl_scobjs_name, o.cl_scobjs_uuid, o.cl_scobjs_type, o.cl_scobjs_subtype, o.cl_scobjs_rarity FROM tbl_scmining m JOIN tbl_scobjs o ON m.cl_scmining_obj_id = o.cl_scobjs_id ORDER BY o.cl_scobjs_name ASC"; @@ -228,6 +270,12 @@ $current_session_user = $_SESSION['user'] ?? ''; box-shadow: 0 0 15px var(--primary-glow); } + .btn-modern.active { + background: var(--primary); + color: var(--bg-dark); + box-shadow: 0 0 15px var(--primary-glow); + } + .btn-modern.danger { border-color: var(--danger); color: var(--danger); } .btn-modern.danger:hover { background: var(--danger); color: #fff; } @@ -314,22 +362,25 @@ $current_session_user = $_SESSION['user'] ?? ''; .search-result-info { flex: 1; } .search-result-name { display: block; color: var(--primary); font-weight: bold; } .search-result-meta { display: block; font-size: 0.75rem; color: #888; } - .search-result-rarity { - display: inline-flex; - align-items: center; - gap: 0.35rem; - margin-top: 0.4rem; - font-size: 0.72rem; - text-transform: uppercase; - letter-spacing: 0.08em; + .search-results-summary { + margin-bottom: 1rem; + font-size: 0.8rem; + color: #9a9a9a; } - .search-result-rarity::before { - content: ''; - width: 8px; - height: 8px; - border-radius: 50%; - background: currentColor; - box-shadow: 0 0 8px currentColor; + .pagination-controls { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; + margin-top: 1rem; + } + .pagination-controls .btn-modern { + min-width: 42px; + } + .pagination-status { + font-size: 0.8rem; + color: #9a9a9a; + margin-left: auto; } .rarity-L { color: var(--rarity-L) !important; text-shadow: 0 0 10px rgba(255, 128, 0, 0.3); } @@ -409,27 +460,54 @@ $current_session_user = $_SESSION['user'] ?? '';
Aucun objet non listé trouvé.
+ + +