Correxiones sintaxis
This commit is contained in:
@@ -4,6 +4,7 @@ require_once __DIR__ . '/../helpers/env.php';
|
||||
require_once __DIR__ . '/../helpers/crypto.php';
|
||||
require_once __DIR__ . '/../helpers/session.php';
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../helpers/bitacoras.php';
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
@@ -30,12 +31,13 @@ function aprobarUsuarios()
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT request_id, company_name, rfc, email, phone, request_date, opinion_file
|
||||
FROM solicitudes_importadores
|
||||
WHERE request_status = 'pending'
|
||||
ORDER BY request_date DESC";
|
||||
|
||||
$sql = "SELECT request_id, company_name, rfc, email, phone, request_date, opinion_file
|
||||
FROM solicitudes_importadores
|
||||
WHERE request_status = 'pending'
|
||||
ORDER BY request_date DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
$solicitudes = [];
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$solicitudes[] = $row;
|
||||
@@ -47,6 +49,7 @@ function aprobarUsuarios()
|
||||
function aprobar_usuario()
|
||||
{
|
||||
$conn = getConnection();
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$id || !is_numeric($id)) {
|
||||
@@ -106,10 +109,11 @@ function aprobar_usuario()
|
||||
$email_encrypt = encrypt($email);
|
||||
|
||||
// Insertar en usuarios_sistema y obtener ID en la misma consulta
|
||||
$sqlInsert = "INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por, preferencias_catalogos)
|
||||
$sqlInsert = "INSERT INTO usuarios_sistema
|
||||
(nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por, preferencias_catalogos)
|
||||
OUTPUT INSERTED.id_usuario
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE(), 0, ?, 1)";
|
||||
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE(), 0, ?, 1)
|
||||
";
|
||||
$stmtInsert = sqlsrv_query($conn, $sqlInsert, [
|
||||
$nombre_encrypt, $email_encrypt, $password_hash, $tipo, $_SESSION['usuario_id']
|
||||
]);
|
||||
@@ -126,12 +130,8 @@ function aprobar_usuario()
|
||||
throw new Exception("No se pudo obtener el ID del usuario creado. ID obtenido: " . var_export($idUsuarioRow, true));
|
||||
}
|
||||
|
||||
error_log("✓ Usuario creado exitosamente con ID: " . $id_usuario);
|
||||
|
||||
// Insertar en informacion_general
|
||||
$sqlInfo = "INSERT INTO informacion_general
|
||||
(id_usuario, nombre, rfc, correo, telefono)
|
||||
VALUES (?, ?, ?, ?, ?)";
|
||||
$sqlInfo = "INSERT INTO informacion_general (id_usuario, nombre, rfc, correo, telefono) VALUES (?, ?, ?, ?, ?)";
|
||||
$stmtInfo = sqlsrv_query($conn, $sqlInfo, [
|
||||
$id_usuario, $nombre, $rfc, $email, $telefono
|
||||
]);
|
||||
@@ -144,7 +144,8 @@ function aprobar_usuario()
|
||||
$sqlPref = "INSERT INTO preferencias_catalogos_usuario
|
||||
(id_usuario, locaciones, vinculacion, transportistas, transportes, choferes, proveedores,
|
||||
productos_frecuentes, solicitudes_importacion, expediente_electronico, configuracion, cerrar_sesion)
|
||||
VALUES (?, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)";
|
||||
VALUES (?, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
|
||||
";
|
||||
$stmtPref = sqlsrv_query($conn, $sqlPref, [$id_usuario]);
|
||||
|
||||
if (!$stmtPref) {
|
||||
@@ -152,9 +153,12 @@ function aprobar_usuario()
|
||||
}
|
||||
|
||||
// Actualizar solicitud
|
||||
$sqlUpdate = "UPDATE solicitudes_importadores
|
||||
SET request_status = 'approved', approval_date = GETDATE(), approved_by = ?
|
||||
WHERE request_id = ?";
|
||||
$sqlUpdate = "UPDATE solicitudes_importadores
|
||||
SET request_status = 'approved',
|
||||
approval_date = GETDATE(),
|
||||
approved_by = ?
|
||||
WHERE request_id = ?
|
||||
";
|
||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$_SESSION['usuario_id'], $id]);
|
||||
|
||||
if (!$stmtUpdate) {
|
||||
@@ -242,7 +246,13 @@ function altaUsuarios()
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT * FROM usuarios_sistema WHERE activo = 1 ORDER BY creado_en DESC";
|
||||
$sql = "SELECT u.*, creador.nombre as nombre_creador
|
||||
FROM usuarios_sistema u
|
||||
LEFT JOIN usuarios_sistema creador
|
||||
ON u.creado_por = creador.id_usuario
|
||||
WHERE u.activo = 1
|
||||
ORDER BY u.creado_en DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
$usuarios = [];
|
||||
@@ -293,9 +303,11 @@ function guardar_usuario()
|
||||
}
|
||||
|
||||
// 4. Insertar usuario
|
||||
$sqlInsert = "INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por)
|
||||
$sqlInsert = "INSERT INTO usuarios_sistema
|
||||
(nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por)
|
||||
OUTPUT INSERTED.id_usuario
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE(), 0, ?)";
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE(), 0, ?)
|
||||
";
|
||||
$params = [$nombre_encrypted, $email_encrypted, $password_hash, $tipo, $_SESSION['usuario_id']];
|
||||
$stmtInsert = sqlsrv_query($conn, $sqlInsert, $params);
|
||||
|
||||
@@ -309,9 +321,7 @@ function guardar_usuario()
|
||||
$id_usuario = $idUsuarioRow['id_usuario'] ?? null;
|
||||
|
||||
// 6. Insertar en informacion_general
|
||||
$sqlInfo = "INSERT INTO informacion_general
|
||||
(id_usuario, nombre, correo)
|
||||
VALUES (?, ?, ?)";
|
||||
$sqlInfo = "INSERT INTO informacion_general (id_usuario, nombre, correo) VALUES (?, ?, ?)";
|
||||
$stmtInfo = sqlsrv_query($conn, $sqlInfo, [$id_usuario, $nombre, $email]);
|
||||
|
||||
if (!$stmtInfo) {
|
||||
@@ -322,7 +332,8 @@ function guardar_usuario()
|
||||
$sqlPref = "INSERT INTO preferencias_catalogos_usuario
|
||||
(id_usuario, locaciones, vinculacion, transportistas, transportes, choferes, proveedores,
|
||||
productos_frecuentes, solicitudes_importacion, expediente_electronico, configuracion, cerrar_sesion)
|
||||
VALUES (?, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)";
|
||||
VALUES (?, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
|
||||
";
|
||||
$stmtPref = sqlsrv_query($conn, $sqlPref, [$id_usuario]);
|
||||
|
||||
if (!$stmtPref) {
|
||||
@@ -348,7 +359,7 @@ function guardar_usuario()
|
||||
|
||||
// Determinar el tipo de usuario para el mensaje
|
||||
$tipoUsuarioTexto = match($tipo) {
|
||||
'importador' => 'importador',
|
||||
'importador' => 'importador',
|
||||
'super_admin' => 'administrador'
|
||||
};
|
||||
|
||||
@@ -407,7 +418,14 @@ function usuariosInactivos()
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
$sql = "SELECT * FROM usuarios_sistema WHERE activo = 0 ORDER BY creado_en DESC";
|
||||
|
||||
$sql = "SELECT u.*, creador.nombre as nombre_creador
|
||||
FROM usuarios_sistema u
|
||||
LEFT JOIN usuarios_sistema creador
|
||||
ON u.creado_por = creador.id_usuario
|
||||
WHERE u.activo = 0
|
||||
ORDER BY u.creado_en DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
$usuarios = [];
|
||||
@@ -428,12 +446,13 @@ function aprobarAgencias()
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT request_id, agencia_name, rfc, email, phone, request_date, opinion_file
|
||||
FROM solicitudes_agencias
|
||||
WHERE request_status = 'pending'
|
||||
ORDER BY request_date DESC";
|
||||
|
||||
$sql = "SELECT request_id, agencia_name, rfc, email, phone, direccion, request_date, opinion_file
|
||||
FROM solicitudes_agencias
|
||||
WHERE request_status = 'pending'
|
||||
ORDER BY request_date DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
$solicitudes = [];
|
||||
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
$solicitudes[] = $row;
|
||||
@@ -445,6 +464,7 @@ function aprobarAgencias()
|
||||
function aprobar_agencia()
|
||||
{
|
||||
$conn = getConnection();
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
$usuario_id = $_SESSION['usuario_id'];
|
||||
|
||||
@@ -489,8 +509,10 @@ function aprobar_agencia()
|
||||
$admin_email_encrypt = encrypt($admin_email);
|
||||
|
||||
// Insertar en agencias_aduanales
|
||||
$sqlInsert = "INSERT INTO agencias_aduanales (nombre_agencia, rfc_agencia, direccion, telefono, email, creado_en, creado_por)
|
||||
VALUES (?, ?, ?, ?, ?, GETDATE()), ?";
|
||||
$sqlInsert = "INSERT INTO agencias_aduanales
|
||||
(nombre_agencia, rfc_agencia, direccion, telefono, email, creado_en, creado_por)
|
||||
VALUES (?, ?, ?, ?, ?, GETDATE(), ?)
|
||||
";
|
||||
$stmtInsert = sqlsrv_query($conn, $sqlInsert, [
|
||||
$nombre_encrypt, $rfc, $direccion, $phone, $email_encrypt, $usuario_id
|
||||
]);
|
||||
@@ -510,8 +532,9 @@ function aprobar_agencia()
|
||||
}
|
||||
|
||||
// Insertar en usuarios_sistema
|
||||
$sqlInsert2 = "INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos factores, creado_por)
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE()), 0, ?";
|
||||
$sqlInsert2 = "INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por)
|
||||
VALUES (?, ?, ?, ?, 1, GETDATE(), 0, ?)
|
||||
";
|
||||
$stmtInsert2 = sqlsrv_query($conn, $sqlInsert, [
|
||||
$admin_name_encrypt, $admin_email_encrypt, $password_hash, $tipo, $usuario_id
|
||||
]);
|
||||
@@ -539,9 +562,7 @@ function aprobar_agencia()
|
||||
}
|
||||
|
||||
// Insertar en informacion_general
|
||||
$sqlInfo = "INSERT INTO informacion_general
|
||||
(id_usuario, nombre, correo)
|
||||
VALUES (?, ?, ?)";
|
||||
$sqlInfo = "INSERT INTO informacion_general (id_usuario, nombre, correo) VALUES (?, ?, ?)";
|
||||
$stmtInfo = sqlsrv_query($conn, $sqlInfo, [
|
||||
$id_usuario, $admin_name, $admin_email
|
||||
]);
|
||||
@@ -552,7 +573,9 @@ function aprobar_agencia()
|
||||
|
||||
// Actualizar solicitud
|
||||
$sqlUpdate = "UPDATE solicitudes_agencias
|
||||
SET request_status = 'approved', approval_date = GETDATE(), approved_by = ?
|
||||
SET request_status = 'approved',
|
||||
approval_date = GETDATE(),
|
||||
approved_by = ?
|
||||
WHERE request_id = ?";
|
||||
$stmtUpdate = sqlsrv_query($conn, $sqlUpdate, [$usuario_id, $id]);
|
||||
|
||||
@@ -616,6 +639,7 @@ function altaAgencias()
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$sql = "SELECT * FROM agencias_aduanales ORDER BY creado_en DESC";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
@@ -638,11 +662,8 @@ function guardar_agencia()
|
||||
|
||||
try {
|
||||
if (!sqlsrv_begin_transaction($conn)) {
|
||||
error_log("ERROR: No se pudo iniciar la transacción");
|
||||
throw new Exception("Error al iniciar transacción");
|
||||
}
|
||||
|
||||
error_log("Transacción iniciada correctamente");
|
||||
|
||||
// 1️⃣ Captura y validación de datos
|
||||
$nombre_agencia = trim($_POST['nombre_agencia'] ?? '');
|
||||
@@ -653,20 +674,13 @@ function guardar_agencia()
|
||||
$nombre_admin = trim($_POST['nombre_admin'] ?? '');
|
||||
$correo_admin = trim($_POST['correo_admin'] ?? '');
|
||||
|
||||
error_log("Datos recibidos:");
|
||||
error_log("- Nombre agencia: " . $nombre_agencia);
|
||||
error_log("- RFC: " . $rfc_agencia);
|
||||
error_log("- Correo agencia: " . $correo_agencia);
|
||||
|
||||
if (empty($nombre_agencia) || empty($rfc_agencia) || empty($correo_agencia) ||
|
||||
empty($telefono) || empty($direccion) || empty($nombre_admin) || empty($correo_admin)) {
|
||||
error_log("ERROR: Datos incompletos");
|
||||
throw new Exception("Datos incompletos");
|
||||
}
|
||||
|
||||
// 2️⃣ Verificar función de encriptación
|
||||
if (!function_exists('encrypt')) {
|
||||
error_log("ERROR: Función encrypt no existe");
|
||||
throw new Exception("Función de encriptación no disponible");
|
||||
}
|
||||
|
||||
@@ -676,27 +690,21 @@ function guardar_agencia()
|
||||
$nombre_admin_enc = encrypt($nombre_admin);
|
||||
$correo_admin_enc = encrypt($correo_admin);
|
||||
|
||||
error_log("Datos encriptados correctamente");
|
||||
|
||||
// 3️⃣ CREAR USUARIO ADMINISTRADOR Y OBTENER SU ID EN UNA SOLA CONSULTA
|
||||
$password_plain = bin2hex(random_bytes(5));
|
||||
$password_hash = password_hash($password_plain, PASSWORD_DEFAULT);
|
||||
|
||||
error_log("Password generado: " . $password_plain);
|
||||
|
||||
// ✅ SOLUCIÓN: INSERT con OUTPUT para obtener el ID inmediatamente
|
||||
$sqlInsertAdmin = "
|
||||
INSERT INTO usuarios_sistema (nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por)
|
||||
OUTPUT INSERTED.id_usuario
|
||||
VALUES (?, ?, ?, 'admin_agencia', 1, GETDATE(), 0, ?);
|
||||
";
|
||||
|
||||
$paramsAdmin = [$nombre_admin_enc, $correo_admin_enc, $password_hash, $_SESSION['usuario_id']];
|
||||
$stmtAdmin = sqlsrv_query($conn, $sqlInsertAdmin, $paramsAdmin);
|
||||
$sqlInsertAdmin = "INSERT INTO usuarios_sistema
|
||||
(nombre, email, password_hash, tipo_usuario, activo, creado_en, dos_factores, creado_por)
|
||||
OUTPUT INSERTED.id_usuario
|
||||
VALUES (?, ?, ?, 'admin_agencia', 1, GETDATE(), 0, ?);
|
||||
";
|
||||
$paramsAdmin = [$nombre_admin_enc, $correo_admin_enc, $password_hash, $_SESSION['usuario_id']];
|
||||
$stmtAdmin = sqlsrv_query($conn, $sqlInsertAdmin, $paramsAdmin);
|
||||
|
||||
if (!$stmtAdmin) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("ERROR SQL Admin: " . print_r($errors, true));
|
||||
throw new Exception("Error al crear administrador: " . print_r($errors, true));
|
||||
}
|
||||
|
||||
@@ -705,26 +713,20 @@ function guardar_agencia()
|
||||
$id_admin = $rowAdmin['id_usuario'] ?? null;
|
||||
|
||||
if (!$id_admin) {
|
||||
error_log("ERROR: ID de administrador es null");
|
||||
throw new Exception("No se pudo obtener ID de administrador");
|
||||
}
|
||||
|
||||
error_log("Usuario administrador creado exitosamente con ID: " . $id_admin);
|
||||
|
||||
// 4️⃣ CREAR AGENCIA Y OBTENER SU ID
|
||||
$sqlInsertAgencia = "
|
||||
INSERT INTO agencias_aduanales (nombre_agencia, rfc_agencia, direccion, telefono, email, id_administrador, activo, creado_en, creado_por)
|
||||
OUTPUT INSERTED.id_agencia
|
||||
VALUES (?, ?, ?, ?, ?, ?, 1, GETDATE(), ?)
|
||||
";
|
||||
$paramsAgencia = [$nombre_agencia_enc, $rfc_agencia, $direccion, $telefono, $correo_agencia_enc, $id_admin, $_SESSION['usuario_id']];
|
||||
|
||||
error_log("Ejecutando SQL Agencia con ID admin: " . $id_admin);
|
||||
$stmtAgencia = sqlsrv_query($conn, $sqlInsertAgencia, $paramsAgencia);
|
||||
$sqlInsertAgencia = "INSERT INTO agencias_aduanales
|
||||
(nombre_agencia, rfc_agencia, direccion, telefono, email, id_administrador, activo, creado_en, creado_por)
|
||||
OUTPUT INSERTED.id_agencia
|
||||
VALUES (?, ?, ?, ?, ?, ?, 1, GETDATE(), ?)
|
||||
";
|
||||
$paramsAgencia = [$nombre_agencia_enc, $rfc_agencia, $direccion, $telefono, $correo_agencia_enc, $id_admin, $_SESSION['usuario_id']];
|
||||
$stmtAgencia = sqlsrv_query($conn, $sqlInsertAgencia, $paramsAgencia);
|
||||
|
||||
if (!$stmtAgencia) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("ERROR SQL Agencia: " . print_r($errors, true));
|
||||
throw new Exception("Error al crear agencia: " . print_r($errors, true));
|
||||
}
|
||||
|
||||
@@ -733,36 +735,27 @@ function guardar_agencia()
|
||||
$id_agencia = $rowAgencia['id_agencia'] ?? null;
|
||||
|
||||
if (!$id_agencia) {
|
||||
error_log("ERROR: ID de agencia es null");
|
||||
throw new Exception("No se pudo obtener ID de agencia");
|
||||
}
|
||||
|
||||
error_log("Agencia creada exitosamente con ID: " . $id_agencia);
|
||||
|
||||
// 5️⃣ CREAR RELACIÓN AGENTE-AGENCIA
|
||||
$sqlInsertRelacion = "INSERT INTO agente_agencia (id_agente, id_agencia, fecha_asignacion, activo, asignado_por)
|
||||
VALUES (?, ?, GETDATE(), 1, ?)";
|
||||
$paramsRelacion = [$id_admin, $id_agencia, $_SESSION['usuario_id']];
|
||||
|
||||
error_log("Creando relación agente-agencia");
|
||||
$stmtRelacion = sqlsrv_query($conn, $sqlInsertRelacion, $paramsRelacion);
|
||||
$sqlInsertRelacion = "INSERT INTO agente_agencia
|
||||
(id_agente, id_agencia, fecha_asignacion, activo, asignado_por)
|
||||
VALUES (?, ?, GETDATE(), 1, ?)
|
||||
";
|
||||
$paramsRelacion = [$id_admin, $id_agencia, $_SESSION['usuario_id']];
|
||||
$stmtRelacion = sqlsrv_query($conn, $sqlInsertRelacion, $paramsRelacion);
|
||||
|
||||
if (!$stmtRelacion) {
|
||||
$errors = sqlsrv_errors();
|
||||
error_log("ERROR SQL Relación: " . print_r($errors, true));
|
||||
throw new Exception("Error al crear relación agente-agencia: " . print_r($errors, true));
|
||||
}
|
||||
|
||||
error_log("Relación agente-agencia creada exitosamente");
|
||||
|
||||
// 6️⃣ CONFIRMAR TRANSACCIÓN ✅
|
||||
if (!sqlsrv_commit($conn)) {
|
||||
error_log("ERROR: No se pudo confirmar la transacción");
|
||||
throw new Exception("Error al confirmar transacción");
|
||||
}
|
||||
|
||||
error_log("Transacción confirmada exitosamente");
|
||||
|
||||
// Registrar en bitácora
|
||||
registrar_bitacora_agencia($id_agencia, $nombre_agencia, 'CREACION', $_SESSION['usuario_id']);
|
||||
|
||||
@@ -804,7 +797,6 @@ function guardar_agencia()
|
||||
</div>";
|
||||
|
||||
$mail->send();
|
||||
error_log("Correo enviado exitosamente a: " . $correo_admin);
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error al enviar correo: " . $e->getMessage());
|
||||
@@ -813,7 +805,6 @@ function guardar_agencia()
|
||||
}
|
||||
|
||||
// 8️⃣ Redirigir con éxito
|
||||
error_log("=== FIN EXITOSO guardar_agencia ===");
|
||||
header("Location: /IMPORTADORES/administrador/altaAgencias?success=created");
|
||||
exit;
|
||||
|
||||
@@ -825,13 +816,11 @@ function guardar_agencia()
|
||||
error_log("Transacción revertida exitosamente");
|
||||
}
|
||||
|
||||
error_log("=== FIN CON ERROR guardar_agencia ===");
|
||||
header("Location: /IMPORTADORES/administrador/altaAgencias?error=save_failed");
|
||||
exit;
|
||||
} finally {
|
||||
if ($conn) {
|
||||
sqlsrv_close($conn);
|
||||
error_log("Conexión cerrada");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -844,7 +833,13 @@ function agenciasActivas()
|
||||
}
|
||||
|
||||
$conn = getConnection();
|
||||
$sql = "SELECT * FROM agencias_aduanales ORDER BY creado_en DESC";
|
||||
|
||||
$sql = "SELECT aa.*, u.nombre as nombre_admin
|
||||
FROM agencias_aduanales aa
|
||||
INNER JOIN usuarios_sistema u
|
||||
ON aa.id_administrador = u.id_usuario
|
||||
ORDER BY creado_en DESC
|
||||
";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
|
||||
$agencias = [];
|
||||
@@ -864,7 +859,7 @@ function suspender()
|
||||
|
||||
$conn = getConnection();
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
$id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$id || !is_numeric($id)) {
|
||||
header("Location: /IMPORTADORES/administrador/altaUsuarios?error=invalid_id");
|
||||
@@ -963,7 +958,7 @@ function reset_password()
|
||||
|
||||
$sqlEmail = "SELECT email FROM usuarios_sistema WHERE id_usuario = ?";
|
||||
$stmtEmail = sqlsrv_query($conn, $sqlEmail, [$id]);
|
||||
$row = sqlsrv_fetch_array($stmtEmail, SQLSRV_FETCH_ASSOC);
|
||||
$row = sqlsrv_fetch_array($stmtEmail, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
$sql = "UPDATE usuarios_sistema SET password_hash = ? WHERE id_usuario = ?";
|
||||
$stmt = sqlsrv_query($conn, $sql, [$passwordHash, $id]);
|
||||
@@ -980,7 +975,8 @@ function reset_password()
|
||||
exit;
|
||||
}
|
||||
|
||||
function enviar_password_directamente($email_encrypted, $pass) {
|
||||
function enviar_password_directamente($email_encrypted, $pass)
|
||||
{
|
||||
$email = decrypt($email_encrypted);
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
Reference in New Issue
Block a user