commit 06a5f64fb29a1362b2bd075c0c9690bfe9f43d88 Author: unknown Date: Tue Jun 2 17:07:50 2026 -0400 juridico diff --git a/juridico/actions/document_download.php b/juridico/actions/document_download.php new file mode 100644 index 0000000..719b146 --- /dev/null +++ b/juridico/actions/document_download.php @@ -0,0 +1,50 @@ +prepare("SELECT file_path, title FROM documents WHERE id = :id"); + $stmt->execute(['id' => $id]); + $doc = $stmt->fetch(); + + if ($doc) { + $file_path = '../uploads/' . $doc['file_path']; + + if (file_exists($file_path)) { + $ext = pathinfo($doc['file_path'], PATHINFO_EXTENSION); + $download_name = preg_replace('/[^a-zA-Z0-9_-]/', '_', $doc['title']) . '.' . $ext; + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="' . $download_name . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file_path)); + + ob_clean(); + flush(); + readfile($file_path); + exit; + } else { + $_SESSION['error'] = 'El archivo físico no se encuentra en el servidor.'; + } + } else { + $_SESSION['error'] = 'Documento no encontrado.'; + } + } catch (PDOException $e) { + $_SESSION['error'] = 'Error al consultar la base de datos.'; + } +} else { + $_SESSION['error'] = 'ID de documento no proporcionado.'; +} + +header('Location: ../documents.php'); +exit; +?> diff --git a/juridico/actions/document_upload.php b/juridico/actions/document_upload.php new file mode 100644 index 0000000..78c20ee --- /dev/null +++ b/juridico/actions/document_upload.php @@ -0,0 +1,56 @@ +prepare("INSERT INTO documents (reference_number, title, description, type, file_path, uploaded_by) VALUES (:ref, :title, :desc, :type, :path, :user_id)"); + $stmt->execute([ + 'ref' => $reference_number, + 'title' => $title, + 'desc' => $description, + 'type' => $type, + 'path' => $filename, + 'user_id' => $uploaded_by + ]); + $_SESSION['success'] = 'Documento registrado y subido correctamente.'; + } catch (PDOException $e) { + $_SESSION['error'] = 'Error al registrar en la base de datos.'; + if (file_exists($dest_path)) unlink($dest_path); + } + } else { + $_SESSION['error'] = 'Error al mover el archivo subido al servidor.'; + } + } else { + $_SESSION['error'] = 'Debe seleccionar un archivo válido.'; + } + + header('Location: ../documents.php'); + exit; +} +?> diff --git a/juridico/actions/login_action.php b/juridico/actions/login_action.php new file mode 100644 index 0000000..646fc16 --- /dev/null +++ b/juridico/actions/login_action.php @@ -0,0 +1,35 @@ +prepare("SELECT * FROM users WHERE username = :username"); + $stmt->execute(['username' => $username]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_name'] = $user['name']; + $_SESSION['user_role'] = $user['role']; + + header('Location: ../dashboard.php'); + exit; + } else { + $_SESSION['error'] = 'Usuario o contraseña incorrectos.'; + header('Location: ../index.php'); + exit; + } + } catch (PDOException $e) { + $_SESSION['error'] = 'Error del sistema. Contacte al administrador.'; + header('Location: ../index.php'); + exit; + } +} else { + header('Location: ../index.php'); + exit; +} +?> diff --git a/juridico/actions/user_create.php b/juridico/actions/user_create.php new file mode 100644 index 0000000..a5883de --- /dev/null +++ b/juridico/actions/user_create.php @@ -0,0 +1,40 @@ +prepare("INSERT INTO users (username, password, name, role) VALUES (:username, :password, :name, :role)"); + $stmt->execute([ + 'username' => $username, + 'password' => $password, + 'name' => $name, + 'role' => $role + ]); + $_SESSION['success'] = 'Usuario creado correctamente.'; + } catch (PDOException $e) { + if ($e->getCode() == 23000) { // UNIQUE constraint failed + $_SESSION['error'] = 'El nombre de usuario ya existe.'; + } else { + $_SESSION['error'] = 'Error al crear el usuario. Código: ' . $e->getCode(); + } + } + + header('Location: ../users.php'); + exit; +} diff --git a/juridico/config/database.php b/juridico/config/database.php new file mode 100644 index 0000000..390545f --- /dev/null +++ b/juridico/config/database.php @@ -0,0 +1,11 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); +} catch (PDOException $e) { + die("Error de conexión a la base de datos: " . $e->getMessage()); +} +?> diff --git a/juridico/dashboard.php b/juridico/dashboard.php new file mode 100644 index 0000000..701813e --- /dev/null +++ b/juridico/dashboard.php @@ -0,0 +1,156 @@ + 0, + 'entradas' => 0, + 'salidas' => 0, + 'archivos' => 0, + 'usuarios' => 0 +]; + +try { + $stmt = $db->query("SELECT type, COUNT(*) as count FROM documents GROUP BY type"); + while ($row = $stmt->fetch()) { + if ($row['type'] == 'entrada') $stats['entradas'] = $row['count']; + if ($row['type'] == 'salida') $stats['salidas'] = $row['count']; + if ($row['type'] == 'archivo_interno') $stats['archivos'] = $row['count']; + $stats['total'] += $row['count']; + } + + $stmt = $db->query("SELECT COUNT(*) FROM users"); + $stats['usuarios'] = $stmt->fetchColumn(); + + // Documentos recientes + $stmt = $db->query("SELECT d.*, u.name as user_name FROM documents d LEFT JOIN users u ON d.uploaded_by = u.id ORDER BY d.created_at DESC LIMIT 5"); + $recent_docs = $stmt->fetchAll(); +} catch (PDOException $e) { + $error = "Error al cargar las estadísticas."; +} +?> + +
+

Panel de Control

+

Resumen de la actividad del departamento de Consultoría Jurídica.

+
+ + +
+

+
+ + + +
+ +
+
+

Total Registros

+
+ +
+
+

+
+ + +
+
+

Oficios Entrada

+
+ +
+
+

+
+ + +
+
+

Oficios Salida

+
+ +
+
+

+
+ + +
+
+

Usuarios Activos

+
+ +
+
+

+
+
+ + +
+
+

Documentos Recientes

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Referencia / ExpedienteAsuntoTipoFecha Registro
No hay documentos registrados aún.
+ + + + + +

+

Por:

+
+ 'bg-emerald-100 text-emerald-800 border-emerald-200', + 'salida' => 'bg-amber-100 text-amber-800 border-amber-200', + 'archivo_interno' => 'bg-slate-100 text-slate-800 border-slate-200' + ]; + $typeLabels = [ + 'entrada' => 'Entrada', + 'salida' => 'Salida', + 'archivo_interno' => 'Archivo Interno' + ]; + $class = $typeClasses[$doc['type']] ?? 'bg-gray-100 text-gray-800 border-gray-200'; + $label = $typeLabels[$doc['type']] ?? ucfirst($doc['type']); + ?> + + + + + +
+
+
+ + diff --git a/juridico/database/juridico.sqlite b/juridico/database/juridico.sqlite new file mode 100644 index 0000000..4f915ff Binary files /dev/null and b/juridico/database/juridico.sqlite differ diff --git a/juridico/document_add.php b/juridico/document_add.php new file mode 100644 index 0000000..7579c6a --- /dev/null +++ b/juridico/document_add.php @@ -0,0 +1,104 @@ + + +
+
+ + + +
+

Registrar Documento

+

Ingreso de nuevos oficios o expedientes al archivo digital.

+
+
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+ +
+

PDF, Word o Imágenes hasta 10MB

+
+
+
+
+
+ +
+ + Cancelar + + +
+
+
+ + + + diff --git a/juridico/documents.php b/juridico/documents.php new file mode 100644 index 0000000..a3c8bbc --- /dev/null +++ b/juridico/documents.php @@ -0,0 +1,171 @@ +prepare($query); + $stmt->execute($params); + $documents = $stmt->fetchAll(); +} catch (PDOException $e) { + $error = "Error al cargar los documentos."; +} +?> + +
+
+

Archivos y Expedientes

+

Consulta y gestiona el archivo digital de la dirección.

+
+ + + + Registrar Oficio + + +
+ + +
+
+
+
+
+ +
+ +
+
+
+ +
+ + + + Limpiar + + +
+
+ + +
+

+
+ + +
+

+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Referencia / ExpedienteAsuntoClasificaciónRegistrado porAcciones
+
+ +

No se encontraron documentos.

+

Ajusta los filtros o registra un nuevo oficio.

+
+
+ + + + +
+ + +
+
+

+

+
+ 'bg-emerald-100 text-emerald-800 border-emerald-200', + 'salida' => 'bg-amber-100 text-amber-800 border-amber-200', + 'archivo_interno' => 'bg-slate-100 text-slate-800 border-slate-200' + ]; + $typeLabels = [ + 'entrada' => 'Entrada', + 'salida' => 'Salida', + 'archivo_interno' => 'Archivo Interno' + ]; + $class = $typeClasses[$doc['type']] ?? 'bg-gray-100'; + $label = $typeLabels[$doc['type']] ?? ucfirst($doc['type']); + ?> + + '; ?> + '; ?> + '; ?> + + + +
+
+ +
+ +
+
+ + Descargar + +
+
+
+ + diff --git a/juridico/includes/auth.php b/juridico/includes/auth.php new file mode 100644 index 0000000..73ba852 --- /dev/null +++ b/juridico/includes/auth.php @@ -0,0 +1,39 @@ + 'Super Administrador', + 'admin' => 'Administrador', + 'supervisor' => 'Supervisor', + 'user' => 'Usuario Normal' + ]; + return $roles[$_SESSION['user_role']] ?? 'Desconocido'; +} +?> diff --git a/juridico/includes/footer.php b/juridico/includes/footer.php new file mode 100644 index 0000000..b004804 --- /dev/null +++ b/juridico/includes/footer.php @@ -0,0 +1,15 @@ + + + + + + diff --git a/juridico/includes/header.php b/juridico/includes/header.php new file mode 100644 index 0000000..0fec434 --- /dev/null +++ b/juridico/includes/header.php @@ -0,0 +1,103 @@ + + + + + + + Consultoría Jurídica - Gestión de Documentos + + + + + + + + + + + + +
+ +
+
+ + DIR. JURÍDICA +
+ +
+ + +
diff --git a/juridico/index.php b/juridico/index.php new file mode 100644 index 0000000..962858d --- /dev/null +++ b/juridico/index.php @@ -0,0 +1,95 @@ + + + + + + + Acceso - Consultoría Jurídica + + + + + + + + +
+ +
+
+ +

SISTEMA JURÍDICO

+

Gestión de Documentos

+
+ + +
+
+
+ +
+
+

+ +

+
+
+
+ + +
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ + diff --git a/juridico/logout.php b/juridico/logout.php new file mode 100644 index 0000000..e5ab4b6 --- /dev/null +++ b/juridico/logout.php @@ -0,0 +1,6 @@ + diff --git a/juridico/public/css/style.css b/juridico/public/css/style.css new file mode 100644 index 0000000..747c984 --- /dev/null +++ b/juridico/public/css/style.css @@ -0,0 +1,57 @@ +/* Custom Scrollbar */ +.custom-scrollbar::-webkit-scrollbar { + width: 6px; + height: 6px; +} + +.custom-scrollbar::-webkit-scrollbar-track { + background: transparent; +} + +.custom-scrollbar::-webkit-scrollbar-thumb { + background-color: #cbd5e1; + border-radius: 20px; +} + +.custom-scrollbar::-webkit-scrollbar-thumb:hover { + background-color: #94a3b8; +} + +aside .custom-scrollbar::-webkit-scrollbar-thumb { + background-color: #334155; +} + +aside .custom-scrollbar::-webkit-scrollbar-thumb:hover { + background-color: #475569; +} + +/* Animations */ +@keyframes fadeIn { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } +} + +.animate-fade-in { + animation: fadeIn 0.4s ease-out forwards; +} + +.animate-fade-in-delayed { + animation: fadeIn 0.4s ease-out 0.15s forwards; + opacity: 0; +} + +/* Form inputs focus ring override to match accent color */ +input:focus, textarea:focus, select:focus { + outline: none; + box-shadow: 0 0 0 2px rgba(194, 65, 12, 0.2); + border-color: #c2410c; +} + +/* Glass effect for modal/cards if needed */ +.glass-card { + background: rgba(255, 255, 255, 0.95); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); + border: 1px solid rgba(255, 255, 255, 0.2); + box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05); +} diff --git a/juridico/setup.php b/juridico/setup.php new file mode 100644 index 0000000..5473a34 --- /dev/null +++ b/juridico/setup.php @@ -0,0 +1,56 @@ +exec($query); + } + + // Crear Super Administrador por defecto si no existe + $stmt = $db->prepare("SELECT COUNT(*) FROM users WHERE username = 'superadmin'"); + $stmt->execute(); + if ($stmt->fetchColumn() == 0) { + $password = password_hash('superadmin123', PASSWORD_DEFAULT); + $stmt = $db->prepare("INSERT INTO users (username, password, name, role) VALUES ('superadmin', :password, 'Super Administrador Principal', 'superadmin')"); + $stmt->execute(['password' => $password]); + echo "Usuario superadmin creado con éxito. Contraseña: superadmin123\n"; + } + + echo "Base de datos inicializada correctamente.\n"; +} catch (PDOException $e) { + die("Error inicializando la base de datos: " . $e->getMessage()); +} +?> diff --git a/juridico/uploads/doc_6a1dea56a6af8_1780345430.docx b/juridico/uploads/doc_6a1dea56a6af8_1780345430.docx new file mode 100644 index 0000000..8f088c6 Binary files /dev/null and b/juridico/uploads/doc_6a1dea56a6af8_1780345430.docx differ diff --git a/juridico/users.php b/juridico/users.php new file mode 100644 index 0000000..93ebce5 --- /dev/null +++ b/juridico/users.php @@ -0,0 +1,143 @@ +query("SELECT * FROM users ORDER BY created_at DESC"); + $users = $stmt->fetchAll(); +} catch (PDOException $e) { + $error = "Error al cargar los usuarios."; +} +?> + +
+
+

Gestión de Usuarios

+

Administra el acceso al sistema de Consultoría Jurídica.

+
+ +
+ + +
+

+
+ + +
+

+
+ + +
+
+ + + + + + + + + + + + + + + + + + + +
Nombre / UsuarioRol de AccesoFecha CreaciónAcciones
+
+
+ +
+
+

+

@

+
+
+
+ 'bg-purple-100 text-purple-800 border-purple-200', + 'admin' => 'bg-blue-100 text-blue-800 border-blue-200', + 'supervisor' => 'bg-amber-100 text-amber-800 border-amber-200', + 'user' => 'bg-slate-100 text-slate-800 border-slate-200' + ]; + $roleLabels = [ + 'superadmin' => 'Super Admin', + 'admin' => 'Administrador', + 'supervisor' => 'Supervisor', + 'user' => 'Usuario Normal' + ]; + $class = $roleClasses[$u['role']] ?? 'bg-gray-100'; + $label = $roleLabels[$u['role']] ?? $u['role']; + ?> + + + + + + + + + +
+
+
+ + + + +