107 lines
3.1 KiB
PHP
107 lines
3.1 KiB
PHP
<?php
|
|
require_once "connect.php";
|
|
require_once "armasql.php";
|
|
|
|
class ReportesModel {
|
|
static public function mdlListarReportes() {
|
|
$sql = "select r.id,
|
|
(select nombre
|
|
from tem_reuniones
|
|
where id = r.id_reunion) as reunion,
|
|
r.fecha,
|
|
(select nombre
|
|
from tem_usuarios
|
|
where id = r.id_usuario) as usuario,
|
|
(select nombre
|
|
from tem_grupos
|
|
where id = r.id_grupo ) as grupo
|
|
from tem_reportes r
|
|
order by id";
|
|
$stmt = Conexion::conectar()->prepare($sql);
|
|
$stmt->execute();
|
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
static public function mdlDatosReporte($id) {
|
|
try {
|
|
$stmt = Conexion::conectar()->prepare("select id, id_reunion, fecha, id_usuario, id_grupo, contenido_html from tem_reportes where id = :id");
|
|
$stmt->bindParam(":id", $id, PDO::PARAM_STR);
|
|
$stmt->execute();
|
|
|
|
return $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
return $e;
|
|
} finally {
|
|
$stmt = null;
|
|
}
|
|
}
|
|
|
|
static public function mdlEditarReporte($todos_los_campos) {
|
|
// Eliminar clave basura enviada por el editor
|
|
$todos_los_campos['contenido_html'] = $todos_los_campos['editor-value'];
|
|
unset($todos_los_campos['editor-value']);
|
|
|
|
$sql = construirSentenciaUpdate('tem_reportes', $todos_los_campos);
|
|
try {
|
|
$stmt = Conexion::conectar()->prepare($sql['sql']);
|
|
$stmt->execute($sql['parametros']);
|
|
if ($stmt->rowCount() > 0) {
|
|
$resultado = "OK";
|
|
} else {
|
|
$resultado = "No se realizaron cambios en el reporte";
|
|
}
|
|
$stmt = null;
|
|
return array(
|
|
'respuesta' => $resultado
|
|
);
|
|
} catch (\PDOException $e) {
|
|
return array(
|
|
'respuesta' => "Error en la base de datos: " . $e->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
static public function mdlNuevoReporte($todos_los_campos) {
|
|
// Eliminar clave basura enviada por el editor
|
|
$todos_los_campos['contenido_html'] = $todos_los_campos['editor-value'];
|
|
unset($todos_los_campos['editor-value']);
|
|
|
|
$sql = construirSentenciaInsert('tem_reportes', $todos_los_campos);
|
|
try {
|
|
$stmt = Conexion::conectar()->prepare($sql['sql']);
|
|
$stmt->execute($sql['parametros']);
|
|
if ($stmt->rowCount() > 0) {
|
|
$resultado = "OK";
|
|
} else {
|
|
$resultado = "No se dió de alta el reporte";
|
|
}
|
|
$stmt = null;
|
|
return array(
|
|
'respuesta' => $resultado,
|
|
'mensaje' => 'Error desconocido'
|
|
);
|
|
} catch (\PDOException $e) {
|
|
return array(
|
|
'respuesta' => "Error",
|
|
'mensaje' => "Error en la base de datos: " . $e->getMessage()
|
|
);
|
|
}
|
|
}
|
|
|
|
static public function mdlBorrarReporte($id) {
|
|
$resultado = "OK";
|
|
try {
|
|
$stmt = Conexion::conectar()->prepare("delete from tem_reportes where id = :id");
|
|
$stmt->bindParam(":id", $id, PDO::PARAM_STR);
|
|
$stmt->execute();
|
|
} catch (PDOException $e) {
|
|
$resultado = "Error: " . $e;
|
|
} finally {
|
|
$stmt = null;
|
|
return array(
|
|
'respuesta' => $resultado
|
|
);
|
|
}
|
|
}
|
|
}
|