From e983920c843ceeee51c81ab74292641f7b4d11f5 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 5 Aug 2026 16:12:19 +0000 Subject: [PATCH] Autosave: 20260805-161402 --- call_center_pro.php | 6 +-- completados.php | 68 ++++++++++++++++++++++++---- edit_gasto.php | 2 + gestiones_callcenter.php | 8 ++-- includes/callcenter_test_helpers.php | 16 ++++++- inversion_general.php | 11 +++-- layout_header.php | 2 +- 7 files changed, 91 insertions(+), 22 deletions(-) diff --git a/call_center_pro.php b/call_center_pro.php index a545018b..b5880540 100644 --- a/call_center_pro.php +++ b/call_center_pro.php @@ -1339,7 +1339,7 @@ require_once 'layout_header.php'; $group): ?> @@ -1349,9 +1349,9 @@ require_once 'layout_header.php';
Dentro de
- Pedidos + Pedidos $childConfig): ?> - + diff --git a/completados.php b/completados.php index fe6c72cd..21614289 100644 --- a/completados.php +++ b/completados.php @@ -39,10 +39,14 @@ $pdo = db(); $user_id = $_SESSION['user_id']; $user_role = $_SESSION['user_role'] ?? 'Asesor'; -// Fetch years for the filter -$years_query = "SELECT DISTINCT YEAR(created_at) as year FROM pedidos WHERE estado = 'COMPLETADO ✅'"; +// Fetch years for the filter using the real completion date +$years_query = "SELECT DISTINCT YEAR(fecha_completado) as year FROM pedidos WHERE estado = 'COMPLETADO ✅' AND fecha_completado IS NOT NULL"; if ($user_role === 'Asesor') { $years_query .= " AND asesor_id = ?"; +} +$years_query .= " ORDER BY year DESC"; + +if ($user_role === 'Asesor') { $years_stmt = $pdo->prepare($years_query); $years_stmt->execute([$user_id]); } else { @@ -54,8 +58,19 @@ $years = $years_stmt->fetchAll(PDO::FETCH_COLUMN); // Filter logic $selected_month = $_GET['mes'] ?? ''; $selected_year = $_GET['año'] ?? ''; +$selected_day = $_GET['dia'] ?? ''; $search_query = $_GET['q'] ?? ''; +if (!empty($selected_day)) { + $selectedDayObject = DateTime::createFromFormat('Y-m-d', $selected_day); + if (!$selectedDayObject || $selectedDayObject->format('Y-m-d') !== $selected_day) { + $selected_day = ''; + } else { + $selected_month = ''; + $selected_year = ''; + } +} + $sql = "SELECT p.*, u.nombre_asesor as asesor_nombre FROM pedidos p LEFT JOIN users u ON p.asesor_id = u.id WHERE p.estado = 'COMPLETADO ✅'"; $params = []; @@ -71,19 +86,34 @@ if (!empty($search_query)) { $params[] = "%$search_query%"; } -if (!empty($selected_month)) { - $sql .= " AND MONTH(p.created_at) = ?"; - $params[] = $selected_month; -} -if (!empty($selected_year)) { - $sql .= " AND YEAR(p.created_at) = ?"; - $params[] = $selected_year; +if (!empty($selected_day)) { + $sql .= " AND DATE(p.fecha_completado) = ?"; + $params[] = $selected_day; +} else { + if (!empty($selected_month)) { + $sql .= " AND MONTH(p.fecha_completado) = ?"; + $params[] = $selected_month; + } + if (!empty($selected_year)) { + $sql .= " AND YEAR(p.fecha_completado) = ?"; + $params[] = $selected_year; + } } -$sql .= " ORDER BY p.fecha_completado DESC"; +$sql .= " ORDER BY COALESCE(p.fecha_completado, p.created_at) DESC"; $stmt = $pdo->prepare($sql); $stmt->execute($params); $pedidos = $stmt->fetchAll(); +$pedidos_count = count($pedidos); +$selected_day_label = ''; + +if (!empty($selected_day)) { + try { + $selected_day_label = (new DateTime($selected_day))->format('d/m/Y'); + } catch (Exception $e) { + $selected_day_label = $selected_day; + } +} $months = [ 1 => 'Enero', 2 => 'Febrero', 3 => 'Marzo', 4 => 'Abril', 5 => 'Mayo', 6 => 'Junio', @@ -93,6 +123,7 @@ $months = [ ?> @@ -103,6 +134,10 @@ include 'layout_header.php';
+
+ + +
diff --git a/gestiones_callcenter.php b/gestiones_callcenter.php index 0d2c38e6..3eb20306 100644 --- a/gestiones_callcenter.php +++ b/gestiones_callcenter.php @@ -236,7 +236,7 @@ $isMainTuaniStore = cc_test_is_tuani_main_store_key($storeKey); $isTuaniRecuperablesStore = $storeKey === 'tuani_recuperables'; $canShowTuaniLogisticaButton = $isMainTuaniStore || $isTuaniRecuperablesStore; $viewCardColumnClass = $isTuaniRecuperablesStore ? 'col-md-6 col-xl-2' : 'col-md-6 col-xl-2'; -$callCenterDefaultView = $isMainTuaniStore ? cc_test_callcenter_pro_default_view_key($storeKey) : $view; +$callCenterDefaultView = ($isMainTuaniStore || $isTuaniRecuperablesStore) ? cc_test_callcenter_pro_default_view_key($storeKey) : $view; $viewCards = $isTuaniRecuperablesStore ? [ 'pendientes_hoy' => [ @@ -1593,7 +1593,7 @@ require_once 'layout_header.php'; $group): ?> @@ -1603,9 +1603,9 @@ require_once 'layout_header.php';
Dentro de
- Pedidos + Pedidos $childConfig): ?> - + diff --git a/includes/callcenter_test_helpers.php b/includes/callcenter_test_helpers.php index 2c926d48..07229bc2 100644 --- a/includes/callcenter_test_helpers.php +++ b/includes/callcenter_test_helpers.php @@ -262,9 +262,23 @@ function cc_test_is_tuani_main_store_key(string $storeKey): bool return in_array($storeKey, ['flower', 'otra_tienda'], true); } +function cc_test_is_tuani_recoverables_store_key(string $storeKey): bool +{ + $storeKey = trim(mb_strtolower($storeKey)); + return $storeKey === 'tuani_recuperables'; +} + function cc_test_callcenter_pro_default_view_key(string $storeKey): string { - return cc_test_is_tuani_main_store_key($storeKey) ? 'ultimos_3_dias' : 'pendientes_hoy'; + if (cc_test_is_tuani_main_store_key($storeKey)) { + return 'ultimos_3_dias'; + } + + if (cc_test_is_tuani_recoverables_store_key($storeKey)) { + return 'todos'; + } + + return 'pendientes_hoy'; } if (!function_exists('cc_test_normalize_phone_digits')) { diff --git a/inversion_general.php b/inversion_general.php index 32549b12..a47a9657 100644 --- a/inversion_general.php +++ b/inversion_general.php @@ -88,12 +88,14 @@ $gastos = $stmt->fetchAll(PDO::FETCH_ASSOC); $gastos_por_tipo = [ 'Publicidad' => [], 'Inversion de Mercaderia' => [], - 'Gastos Personales' => [] + 'Gastos Personales' => [], + 'Gastos Administrativos' => [] ]; $totales_por_tipo = [ 'Publicidad' => 0, 'Inversion de Mercaderia' => 0, - 'Gastos Personales' => 0 + 'Gastos Personales' => 0, + 'Gastos Administrativos' => 0 ]; foreach ($gastos as $gasto) { @@ -105,6 +107,7 @@ foreach ($gastos as $gasto) { } $pageTitle = 'Inversión General'; +$pageDescription = 'Control mensual de inversión, publicidad, mercadería, gastos personales y gastos administrativos.'; include 'layout_header.php'; ?> @@ -140,6 +143,7 @@ include 'layout_header.php'; +
@@ -165,7 +169,8 @@ include 'layout_header.php'; $tipos_de_gasto = [ 'Publicidad' => 'Gastos de Publicidad', 'Inversion de Mercaderia' => 'Inversión de Mercadería', - 'Gastos Personales' => 'Gastos Personales' + 'Gastos Personales' => 'Gastos Personales', + 'Gastos Administrativos' => 'Gastos Administrativos' ]; ?> diff --git a/layout_header.php b/layout_header.php index c21cc061..2d195657 100644 --- a/layout_header.php +++ b/layout_header.php @@ -57,7 +57,7 @@ if ($currentCallCenterStore !== '') { if ($currentCallCenterView !== '') { $callCenterPersistentParams['view'] = $currentCallCenterView; } -$callCenterProDefaultView = ($currentCallCenterStore !== '' && cc_test_is_tuani_main_store_key($currentCallCenterStore)) ? 'ultimos_3_dias' : ''; +$callCenterProDefaultView = ($currentCallCenterStore !== '' && (cc_test_is_tuani_main_store_key($currentCallCenterStore) || cc_test_is_tuani_recoverables_store_key($currentCallCenterStore))) ? cc_test_callcenter_pro_default_view_key($currentCallCenterStore) : ''; $appendCallCenterParams = static function (string $url) use ($callCenterPersistentParams, $callCenterProDefaultView, $isAdmin): string { if (empty($callCenterPersistentParams)) { return $url;