Autosave: 20260518-185358
BIN
assets/uploads/marketing_images/6a0b55fd26f29.webp
Normal file
|
After Width: | Height: | Size: 274 KiB |
BIN
assets/uploads/marketing_images/6a0b5afa602ec.jpg
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/uploads/marketing_images/6a0b5beeda612.png
Normal file
|
After Width: | Height: | Size: 247 KiB |
BIN
assets/uploads/marketing_images/6a0b5cee638da.jpg
Normal file
|
After Width: | Height: | Size: 433 KiB |
BIN
assets/uploads/marketing_images/6a0b5f7159bfc.jpg
Normal file
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 167 KiB |
|
After Width: | Height: | Size: 229 KiB |
BIN
assets/uploads/vouchers/6a0b569404ba3-177.png
Normal file
|
After Width: | Height: | Size: 344 KiB |
BIN
assets/uploads/vouchers/6a0b5828bd053-222.png
Normal file
|
After Width: | Height: | Size: 455 KiB |
BIN
assets/uploads/vouchers/6a0b5a14deb46-627.png
Normal file
|
After Width: | Height: | Size: 325 KiB |
BIN
assets/uploads/vouchers/6a0b5c3a23251-847.png
Normal file
|
After Width: | Height: | Size: 288 KiB |
BIN
assets/uploads/vouchers/6a0b5cf969b1f-9133.png
Normal file
|
After Width: | Height: | Size: 412 KiB |
BIN
assets/uploads/vouchers/6a0b5daeb3d0f-103.png
Normal file
|
After Width: | Height: | Size: 350 KiB |
12
db/migrations/022_add_duplicados_to_estado.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- Add 'Duplicados' to the estado ENUM in the pedidos table
|
||||
ALTER TABLE pedidos MODIFY COLUMN estado ENUM(
|
||||
'ROTULADO 📦',
|
||||
'EN TRANSITO 🚛',
|
||||
'EN DESTINO 🏬',
|
||||
'COMPLETADO ✅',
|
||||
'Gestion',
|
||||
'RUTA_CONTRAENTREGA',
|
||||
'ENTREGA EXITOSA',
|
||||
'RETORNADO',
|
||||
'Duplicados'
|
||||
) DEFAULT 'ROTULADO 📦';
|
||||
415
duplicados.php
Normal file
@ -0,0 +1,415 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
function getStatusStyle($status) {
|
||||
$style = 'color: white;'; // Default text color
|
||||
$bgColor = '#0dcaf0'; // Default info blue
|
||||
|
||||
switch (strtoupper(trim($status))) {
|
||||
case 'ROTULADO':
|
||||
$bgColor = '#ffc107'; // yellow
|
||||
$style = 'color: black;';
|
||||
break;
|
||||
case 'EN TRANSITO':
|
||||
$bgColor = '#90EE90'; // light green
|
||||
$style = 'color: black;';
|
||||
break;
|
||||
case 'EN DESTINO':
|
||||
$bgColor = '#800080'; // purple
|
||||
break;
|
||||
case 'COMPLETADO':
|
||||
case 'COMPLETADO ✅':
|
||||
$bgColor = '#198754'; // dark green
|
||||
break;
|
||||
case 'GESTION':
|
||||
$bgColor = '#6c757d'; // secondary grey
|
||||
break;
|
||||
case 'DUPLICADOS':
|
||||
case 'DUPLICADO':
|
||||
$bgColor = '#fd7e14'; // orange
|
||||
break;
|
||||
}
|
||||
return "background-color: {$bgColor} !important; {$style}";
|
||||
}
|
||||
|
||||
function getPendientesStyle($pendientes) {
|
||||
if ($pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;'; // Warning yellow
|
||||
if ($pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;'; // Success green
|
||||
return 'background-color: #6c757d; color: white;'; // Secondary grey
|
||||
}
|
||||
|
||||
$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";
|
||||
if ($user_role === 'Asesor') {
|
||||
$years_query .= " WHERE asesor_id = ?";
|
||||
$years_stmt = $pdo->prepare($years_query);
|
||||
$years_stmt->execute([$user_id]);
|
||||
} else {
|
||||
$years_stmt = $pdo->query($years_query);
|
||||
}
|
||||
$years = $years_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
|
||||
// Filter logic
|
||||
$selected_month = $_GET['mes'] ?? '';
|
||||
$selected_year = $_GET['año'] ?? '';
|
||||
$search_query = $_GET['q'] ?? '';
|
||||
|
||||
$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 = 'Duplicados'";
|
||||
$params = [];
|
||||
|
||||
if ($user_role === 'Asesor') {
|
||||
$sql .= " AND p.asesor_id = ?";
|
||||
$params[] = $user_id;
|
||||
}
|
||||
|
||||
if (!empty($search_query)) {
|
||||
$sql .= " AND (p.nombre_completo LIKE ? OR p.dni_cliente LIKE ? OR p.celular LIKE ?)";
|
||||
$params[] = "%$search_query%";
|
||||
$params[] = "%$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;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY p.created_at DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$pedidos = $stmt->fetchAll();
|
||||
|
||||
$months = [
|
||||
1 => 'Enero', 2 => 'Febrero', 3 => 'Marzo', 4 => 'Abril', 5 => 'Mayo', 6 => 'Junio',
|
||||
7 => 'Julio', 8 => 'Agosto', 9 => 'Septiembre', 10 => 'Octubre', 11 => 'Noviembre', 12 => 'Diciembre'
|
||||
];
|
||||
|
||||
?>
|
||||
<?php
|
||||
$pageTitle = "Duplicados";
|
||||
include 'layout_header.php';
|
||||
?>
|
||||
|
||||
<?php if (isset($_SESSION['flash_message'])):
|
||||
$flash = $_SESSION['flash_message'];
|
||||
unset($_SESSION['flash_message']);
|
||||
?>
|
||||
<div class="alert alert-<?php echo htmlspecialchars($flash['type']); ?> alert-dismissible fade show" role="alert">
|
||||
<?php echo htmlspecialchars($flash['message']); ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<form method="GET" action="duplicados.php" class="row g-3 align-items-center">
|
||||
<div class="col-auto">
|
||||
<label for="q" class="form-label">Buscar</label>
|
||||
<input type="text" name="q" id="q" class="form-control" value="<?php echo htmlspecialchars($search_query); ?>" placeholder="Nombre, DNI o Celular">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="mes" class="form-label">Mes</label>
|
||||
<select name="mes" id="mes" class="form-select">
|
||||
<option value="">Todos</option>
|
||||
<?php foreach ($months as $num => $name): ?>
|
||||
<option value="<?php echo $num; ?>" <?php echo $selected_month == $num ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="año" class="form-label">Año</label>
|
||||
<select name="año" id="año" class="form-select">
|
||||
<option value="">Todos</option>
|
||||
<?php foreach ($years as $year): ?>
|
||||
<option value="<?php echo $year; ?>" <?php echo $selected_year == $year ? 'selected' : ''; ?>><?php echo $year; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto mt-4">
|
||||
<button type="submit" class="btn btn-info">Filtrar</button>
|
||||
<a href="duplicados.php" class="btn btn-secondary">Limpiar</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="pedidos-table" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Cliente</th>
|
||||
<th>DNI</th>
|
||||
<th>Celular</th>
|
||||
<th>Agencia</th>
|
||||
<th>Producto</th>
|
||||
<th>Sede de Envío</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Monto Debe</th>
|
||||
<th>Nº De Orden</th>
|
||||
<th>Codigo De Orden</th>
|
||||
<th>CLAVE</th>
|
||||
<th>DESCARGO</th>
|
||||
<th>PENDIENTES</th>
|
||||
<th>Estado</th>
|
||||
<?php if ($user_role !== 'Asesor'): ?><th>Asesor</th><?php endif; ?>
|
||||
<th>Fecha Creación</th>
|
||||
<th style="background-color: #bee5eb; color: #084298;">Mes</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($pedidos as $pedido): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($pedido['id']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['nombre_completo']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['dni_cliente'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['celular']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['agencia'] ?? 'SHALOM'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['sede_envio'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
|
||||
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
|
||||
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td>
|
||||
<?php
|
||||
$canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
|
||||
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
|
||||
?>
|
||||
<td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave">
|
||||
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
|
||||
</td>
|
||||
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="descargo">
|
||||
<?php echo htmlspecialchars($pedido['descargo'] ?? 'N/A'); ?>
|
||||
</td>
|
||||
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
|
||||
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">
|
||||
<?php echo htmlspecialchars(!empty($pedido['pendientes']) ? $pedido['pendientes'] : 'Seleccionar'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo htmlspecialchars($pedido['estado']); ?></span></td>
|
||||
<?php if ($user_role !== 'Asesor'): ?><td><?php echo htmlspecialchars($pedido['asesor_nombre'] ?? 'N/A'); ?></td><?php endif; ?>
|
||||
<td><?php echo htmlspecialchars($pedido['created_at']); ?></td>
|
||||
<td style="background-color: #e7f3ff; font-weight: bold; color: #084298; text-align: center;">
|
||||
<?php
|
||||
$date = new DateTime($pedido['created_at']);
|
||||
$monthNum = (int)$date->format('m');
|
||||
echo htmlspecialchars($months[$monthNum] ?? 'N/A');
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="pedido_form.php?id=<?php echo $pedido['id']; ?>" class="btn btn-sm btn-warning">Editar</a>
|
||||
<?php if ($user_role === 'Administrador'): ?>
|
||||
<a href="delete_pedido.php?id=<?php echo $pedido['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('¿Estás seguro de que quieres eliminar este pedido?');">Eliminar</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (empty($pedidos)): ?>
|
||||
<p class="text-center">No hay pedidos que coincidan con el filtro.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include 'layout_footer.php'; ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#pedidos-table').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
|
||||
},
|
||||
"order": [[ <?php echo ($user_role !== 'Asesor') ? 16 : 15; ?>, "desc" ]],
|
||||
"paging": false,
|
||||
"lengthChange": false,
|
||||
"info": false
|
||||
});
|
||||
});
|
||||
|
||||
function getPendientesStyleJS(pendientes) {
|
||||
if (pendientes === 'PENDIENTE') return 'background-color: #ffc107; color: black;';
|
||||
if (pendientes === 'GESTIONADO') return 'background-color: #198754; color: white;';
|
||||
return 'background-color: #6c757d; color: white;';
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const table = document.querySelector('.table');
|
||||
|
||||
table.addEventListener('click', function(e) {
|
||||
// Handle Pendientes editing
|
||||
if (e.target && (e.target.classList.contains('editable-pendientes') || e.target.closest('.editable-pendientes'))) {
|
||||
const cell = e.target.classList.contains('editable-pendientes') ? e.target : e.target.closest('.editable-pendientes');
|
||||
|
||||
if (cell.querySelector('select')) return; // Already editing
|
||||
|
||||
const currentVal = cell.dataset.value;
|
||||
const pedidoId = cell.dataset.id;
|
||||
|
||||
const select = document.createElement('select');
|
||||
select.className = 'form-select form-select-sm';
|
||||
|
||||
const options = [
|
||||
{val: '', text: 'Seleccionar'},
|
||||
{val: 'PENDIENTE', text: 'PENDIENTE'},
|
||||
{val: 'GESTIONADO', text: 'GESTIONADO'}
|
||||
];
|
||||
|
||||
options.forEach(opt => {
|
||||
const option = document.createElement('option');
|
||||
option.value = opt.val;
|
||||
option.text = opt.text;
|
||||
if (opt.val === currentVal) option.selected = true;
|
||||
select.appendChild(option);
|
||||
});
|
||||
|
||||
// Save original content to restore if needed
|
||||
const originalContent = cell.innerHTML;
|
||||
|
||||
cell.innerHTML = '';
|
||||
cell.appendChild(select);
|
||||
select.focus();
|
||||
|
||||
const save = () => {
|
||||
const newVal = select.value;
|
||||
|
||||
// Optimistic update
|
||||
cell.dataset.value = newVal;
|
||||
cell.innerHTML = `<span class="badge" style="${getPendientesStyleJS(newVal)}">${newVal || 'Seleccionar'}</span>`;
|
||||
|
||||
if (newVal === currentVal) return; // No change
|
||||
|
||||
// Send data to server
|
||||
fetch('update_pendientes.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: pedidoId, value: newVal })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error('Error:', data.error);
|
||||
cell.innerHTML = originalContent; // Revert
|
||||
cell.dataset.value = currentVal;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fetch Error:', error);
|
||||
cell.innerHTML = originalContent; // Revert
|
||||
cell.dataset.value = currentVal;
|
||||
});
|
||||
};
|
||||
|
||||
select.addEventListener('change', save);
|
||||
select.addEventListener('blur', save);
|
||||
}
|
||||
|
||||
if (e.target && e.target.classList.contains('editable')) {
|
||||
const cell = e.target;
|
||||
if (cell.querySelector('input') || cell.querySelector('textarea')) {
|
||||
return; // Already in edit mode
|
||||
}
|
||||
|
||||
const originalContent = cell.textContent.trim();
|
||||
const field = cell.dataset.field;
|
||||
let input;
|
||||
|
||||
if (field === 'descargo') {
|
||||
input = document.createElement('textarea');
|
||||
input.rows = 2;
|
||||
} else {
|
||||
input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
}
|
||||
|
||||
input.className = 'form-control form-control-sm';
|
||||
input.value = originalContent === 'N/A' ? '' : originalContent;
|
||||
|
||||
cell.innerHTML = '';
|
||||
cell.appendChild(input);
|
||||
input.focus();
|
||||
|
||||
const saveChanges = function() {
|
||||
const newValue = input.value.trim();
|
||||
const pedidoId = cell.dataset.id;
|
||||
const field = cell.dataset.field;
|
||||
|
||||
let endpoint = 'update_tracking.php'; // Default endpoint
|
||||
if (field === 'clave') {
|
||||
endpoint = 'update_clave.php';
|
||||
} else if (field === 'descargo') {
|
||||
endpoint = 'update_pedido_field.php';
|
||||
}
|
||||
|
||||
// Restore original content visually
|
||||
cell.textContent = newValue === '' ? 'N/A' : newValue;
|
||||
|
||||
// Send data to server
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: pedidoId, field: field, value: newValue })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error('Error:', data.error);
|
||||
// Optionally revert the change and show an error message
|
||||
cell.textContent = originalContent;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fetch Error:', error);
|
||||
cell.textContent = originalContent;
|
||||
});
|
||||
};
|
||||
|
||||
input.addEventListener('blur', saveChanges);
|
||||
input.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
input.blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.editable:hover {
|
||||
background-color: #f8f9fa;
|
||||
cursor: pointer;
|
||||
}
|
||||
.editable-pendientes:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
@ -220,11 +220,24 @@ $navItems = [
|
||||
'text' => 'Pedidos Duplicados',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
],
|
||||
'gestiones' => [
|
||||
'url' => 'gestiones.php',
|
||||
'gestiones_group' => [
|
||||
'icon' => 'fa-cogs',
|
||||
'text' => 'Gestiones',
|
||||
'roles' => ['Administrador', 'admin', 'superadmin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'superadmin', 'Asesor', 'Control Logistico'],
|
||||
'submenu' => [
|
||||
'gestiones' => [
|
||||
'url' => 'gestiones.php',
|
||||
'icon' => 'fa-cogs',
|
||||
'text' => 'Gestiones',
|
||||
'roles' => ['Administrador', 'admin', 'superadmin', 'Asesor', 'Control Logistico']
|
||||
],
|
||||
'duplicados' => [
|
||||
'url' => 'duplicados.php',
|
||||
'icon' => 'fa-clone',
|
||||
'text' => 'Duplicados',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
]
|
||||
]
|
||||
],
|
||||
'manage_users' => [
|
||||
'url' => 'manage_users.php',
|
||||
|
||||
@ -265,8 +265,18 @@ $videos = $stmt_videos->fetchAll(PDO::FETCH_ASSOC);
|
||||
<input type="text" name="material" class="form-control" placeholder="Ej: Acero, Plástico, etc.">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Ángulo del Video</label>
|
||||
<input type="text" name="angulo_video" class="form-control" placeholder="Ej: Cenital, 45 grados...">
|
||||
<label class="form-label d-flex justify-content-between">
|
||||
Ángulo del Video
|
||||
<button type="button" class="btn btn-sm btn-link p-0 text-decoration-none" onclick="addTextInput('angulo_video_container', 'angulo_video[]', 'Ej: Cenital, 45 grados...')">
|
||||
<i class="fas fa-plus-circle"></i> Añadir otro
|
||||
</button>
|
||||
</label>
|
||||
<div id="angulo_video_container">
|
||||
<div class="input-group mb-2">
|
||||
<input type="text" name="angulo_video[]" class="form-control" placeholder="Ej: Cenital, 45 grados...">
|
||||
<button class="btn btn-outline-danger" type="button" onclick="if(document.querySelectorAll('#angulo_video_container .input-group').length > 1) this.parentElement.remove()"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label d-flex justify-content-between">
|
||||
@ -390,8 +400,15 @@ $videos = $stmt_videos->fetchAll(PDO::FETCH_ASSOC);
|
||||
<input type="text" name="material" id="edit_material" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Ángulo del Video</label>
|
||||
<input type="text" name="angulo_video" id="edit_angulo_video" class="form-control">
|
||||
<label class="form-label d-flex justify-content-between">
|
||||
Ángulo del Video
|
||||
<button type="button" class="btn btn-sm btn-link p-0 text-decoration-none" onclick="addTextInput('edit_angulo_video_container', 'angulo_video[]', 'Ej: Cenital, 45 grados...')">
|
||||
<i class="fas fa-plus-circle"></i> Añadir otro
|
||||
</button>
|
||||
</label>
|
||||
<div id="edit_angulo_video_container">
|
||||
<!-- Se llenará dinámicamente -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label d-flex justify-content-between">
|
||||
@ -466,7 +483,18 @@ function addLinkInput(containerId, inputName, value = '') {
|
||||
div.className = 'input-group mb-2';
|
||||
div.innerHTML = `
|
||||
<input type="url" name="${inputName}" class="form-control" placeholder="https://..." value="${value}">
|
||||
<button class="btn btn-outline-danger" type="button" onclick="this.parentElement.remove()"><i class="fas fa-times"></i></button>
|
||||
<button class="btn btn-outline-danger" type="button" onclick="if(document.querySelectorAll('#${containerId} .input-group').length > 1) this.parentElement.remove()"><i class="fas fa-times"></i></button>
|
||||
`;
|
||||
container.appendChild(div);
|
||||
}
|
||||
|
||||
function addTextInput(containerId, inputName, placeholder = '', value = '') {
|
||||
const container = document.getElementById(containerId);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'input-group mb-2';
|
||||
div.innerHTML = `
|
||||
<input type="text" name="${inputName}" class="form-control" placeholder="${placeholder}" value="${value}">
|
||||
<button class="btn btn-outline-danger" type="button" onclick="if(document.querySelectorAll('#${containerId} .input-group').length > 1) this.parentElement.remove()"><i class="fas fa-times"></i></button>
|
||||
`;
|
||||
container.appendChild(div);
|
||||
}
|
||||
@ -477,7 +505,6 @@ function gestionarVideo(video) {
|
||||
document.getElementById('edit_orden').value = video.orden || 0;
|
||||
document.getElementById('edit_fecha_entrega').value = video.fecha_entrega || '';
|
||||
document.getElementById('edit_material').value = video.material || '';
|
||||
document.getElementById('edit_angulo_video').value = video.angulo_video || '';
|
||||
|
||||
// Llenar links dinámicos
|
||||
const fillLinks = (containerId, inputName, data) => {
|
||||
@ -494,6 +521,21 @@ function gestionarVideo(video) {
|
||||
}
|
||||
};
|
||||
|
||||
const fillTexts = (containerId, inputName, data, placeholder = '') => {
|
||||
const container = document.getElementById(containerId);
|
||||
container.innerHTML = '';
|
||||
if (data) {
|
||||
const texts = data.split(',');
|
||||
texts.forEach(text => {
|
||||
if (text.trim()) addTextInput(containerId, inputName, placeholder, text.trim());
|
||||
});
|
||||
}
|
||||
if (container.innerHTML === '') {
|
||||
addTextInput(containerId, inputName, placeholder);
|
||||
}
|
||||
};
|
||||
|
||||
fillTexts('edit_angulo_video_container', 'angulo_video[]', video.angulo_video, 'Ej: Cenital, 45 grados...');
|
||||
fillLinks('edit_links_insp_landing_container', 'link_inspiracion_landing[]', video.link_inspiracion_landing);
|
||||
fillLinks('edit_links_video_container', 'link_inspiracion_video[]', video.link_inspiracion_video);
|
||||
fillLinks('edit_links_video_final_container', 'link_video[]', video.link_video);
|
||||
|
||||
@ -110,7 +110,7 @@ if (empty($display_products)) {
|
||||
$stmt_sedes = $pdo->query("SELECT nombre_sede FROM sedes_shalom ORDER BY nombre_sede ASC");
|
||||
$sedes_shalom = $stmt_sedes->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$estados = ['ROTULADO 📦', 'EN TRANSITO 🚛', 'EN DESTINO 🏬', 'COMPLETADO ✅'];
|
||||
$estados = ['ROTULADO 📦', 'EN TRANSITO 🚛', 'EN DESTINO 🏬', 'COMPLETADO ✅', 'Duplicados'];
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
@ -34,7 +34,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$material = $_POST['material'] ?? '';
|
||||
$fecha_entrega = !empty($_POST['fecha_entrega']) ? $_POST['fecha_entrega'] : null;
|
||||
$orden = !empty($_POST['orden']) ? $_POST['orden'] : 0;
|
||||
$angulo_video = $_POST['angulo_video'] ?? '';
|
||||
|
||||
$angulo_video = '';
|
||||
if (isset($_POST['angulo_video'])) {
|
||||
$angulo_video = is_array($_POST['angulo_video']) ? implode(',', array_filter($_POST['angulo_video'])) : $_POST['angulo_video'];
|
||||
}
|
||||
|
||||
$link_inspiracion_landing = '';
|
||||
if (isset($_POST['link_inspiracion_landing'])) {
|
||||
@ -82,7 +86,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$instrucciones = $_POST['instrucciones'] ?? '';
|
||||
$fecha_entrega = !empty($_POST['fecha_entrega']) ? $_POST['fecha_entrega'] : null;
|
||||
$orden = !empty($_POST['orden']) ? $_POST['orden'] : 0;
|
||||
$angulo_video = $_POST['angulo_video'] ?? '';
|
||||
|
||||
$angulo_video = '';
|
||||
if (isset($_POST['angulo_video'])) {
|
||||
$angulo_video = is_array($_POST['angulo_video']) ? implode(',', array_filter($_POST['angulo_video'])) : $_POST['angulo_video'];
|
||||
}
|
||||
|
||||
$link_inspiracion_landing = '';
|
||||
if (isset($_POST['link_inspiracion_landing'])) {
|
||||
|
||||