Exemple #1
0
 switch ($objModulo->getAction()) {
     case 'login':
     case 'validarCredenciales':
         $db = TBase::conectaDB();
         $rs = $db->Execute("select idUsuario, pass from usuario where upper(email) = upper('" . $_POST['usuario'] . "')");
         $result = array('band' => false, 'mensaje' => 'Error al consultar los datos');
         if ($rs->EOF) {
             $result = array('band' => false, 'mensaje' => 'El usuario no existe');
         } elseif (strtoupper($rs->fields['pass']) != strtoupper($_POST['pass'])) {
             $result = array('band' => false, 'mensaje' => 'Contraseña inválida');
         } else {
             $obj = new TUsuario($rs->fields['idUsuario']);
             if ($obj->getId() == '') {
                 $result = array('band' => false, 'mensaje' => 'Acceso denegado');
             } else {
                 if ($obj->getIdTipo() == 2) {
                     switch (date("w")) {
                         case 0:
                             $result = array('band' => false);
                             break;
                         case 6:
                             $rs2 = $db->Execute("select * from horario where now() between sabadoEntrada and sabadoSalida");
                             $result = array('band' => !$rs2->EOF, 'mensaje' => 'Acceso denegado en este horario');
                             break;
                         default:
                             $rs2 = $db->Execute("select * from horario where now() between lunesEntrada and lunesSalida");
                             $result = array('band' => !$rs2->EOF, 'mensaje' => 'Acceso denegado en este horario');
                     }
                 } else {
                     $result = array('band' => true);
                 }
     $supervisor = new TUsuario($sesion['usuario']);
     if ($supervisor->getIdTipo() == 2) {
         $rs = $db->Execute("select distinct estado, ciudad from consultorio where idSupervisor = " . $supervisor->getId() . " order by estado, ciudad");
     } else {
         $rs = $db->Execute("select distinct estado, ciudad from consultorio order by estado, ciudad");
     }
     while (!$rs->EOF) {
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("estados", $datos);
     break;
 case 'reporteCiudad':
     $db = TBase::conectaDB();
     $supervisor = new TUsuario($sesion['usuario']);
     $rs = $db->Execute("select d.ciudad, d.estado, c.nombre as servicio, sum(b.cantidad) as cantidad, descripcion as tipoServicio from reporte a join consulta b using(idReporte) join servicio c using(idServicio) join consultorio d using(idConsultorio) join tipoServicio e using(idTipo) where estado = '" . $_GET['estado'] . "' and ciudad = '" . $_GET['ciudad'] . "' and extract(month from a.fecha) = " . $_GET['mes'] . " and extract(year from a.fecha) = " . $_GET['anio'] . " " . ($supervisor->getIdTipo() == 2 ? " and idSupervisor = " . $supervisor->getId() : "") . " group by idServicio;");
     $datos = array();
     while (!$rs->EOF) {
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("consultas", $datos);
     $rs = $db->Execute("select f.idClasificacion, clasificacion, sum(b.cantidad) as cantidad from reporte a join consulta b using(idReporte) join servicio c using(idServicio) join consultorio d using(idConsultorio) join tipoServicio e using(idTipo) join clasificacion f using(idClasificacion) where estado = '" . $_GET['estado'] . "' and ciudad = '" . $_GET['ciudad'] . "' and extract(month from a.fecha) = " . $_GET['mes'] . " and extract(year from a.fecha) = " . $_GET['anio'] . " " . ($supervisor->getIdTipo() == 2 ? " and idSupervisor = " . $supervisor->getId() : "") . " group by idClasificacion;");
     $datos = array();
     while (!$rs->EOF) {
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("clasificacion", $datos);
     break;
 case 'listaReportes':
Exemple #3
0
define('TEMPLATE', DIR_PLANTILLAS . '/plantillas/');
define('CONFIG', 'librerias/smarty/repositorio/configs/');
define('CACHE', 'librerias/smarty/repositorio/cache/');
define('COMPILE', 'librerias/smarty/repositorio/compile/');
require_once 'librerias/smarty/Smarty.class.php';
$smarty = new Smarty();
$smarty->debugging = strtoupper($ini['sistema']['debug']) == 'ON';
$smarty->debugging = false;
$smarty->caching = strtoupper($ini['sistema']['caching']) == 'ON';
$smarty->cache_lifetime = 120;
$smarty->template_dir = TEMPLATE;
$smarty->config_dir = CONFIG;
$smarty->cache_dir = CACHE;
$smarty->compile_dir = COMPILE;
$tempUsuario = new TUsuario($sesion['usuario']);
$datosPlantilla = array("ruta" => DIR_PLANTILLAS . "/", "css" => DIR_PLANTILLAS . "/css/", "sesion" => $_SESSION[SISTEMA], "debug" => strtoupper($ini['sistema']['debug']) == "ON", "sesionIniciada" => $bandSesion ? '1' : '0', "tipoUsuario" => $tempUsuario->getIdTipo(), "nombreUsuario" => $tempUsuario->getNombre(), "vista" => $objModulo->getRutaVista(), "nombreAplicacion" => SISTEMA, "empresa" => $ini['sistema']['nombreEmpresa'], "empresaAcronimo" => $ini['sistema']['acronimoEmpresa'], "action" => $_GET['action'], "POST" => $_POST, "GET" => $_GET, "version" => "1.0", "alias" => "", "rutaModulos" => TEMPLATE, "modulo" => $modulo, "scriptsJS" => $objModulo->getScriptsJS(), "urlFotosTrabajadores" => $ini['sip']['fotos']);
foreach ($_GET as $indice => $valor) {
    $_GET[$indice] = ereg_replace('\\"', "", $_GET[$indice]);
    $_GET[$indice] = stripslashes($_GET[$indice]);
    $_GET[$indice] = ereg_replace("'", "''", $_GET[$indice]);
}
foreach ($_POST as $indice => $valor) {
    if ($objModulo->getDebugSeguridad()) {
        $_POST[$indice] = ereg_replace('\\"', "", $_POST[$indice]);
        $_POST[$indice] = ereg_replace("'", "''", $_POST[$indice]);
    }
}
define('TAMPAG', $ini['config']['TAMPAG']);
define('NUMPAG', $ini['config']['NUMPAG']);
require 'controlador/index.php';
if ($objModulo->getRutaControlador() != '') {
 public function generar()
 {
     /*Primero hay que checar si es supervisor o administrador*/
     global $sesion;
     $supervisor = new TUsuario($sesion['usuario']);
     $hoja =& $this->libro->addWorksheet('Reporte');
     $head =& $this->libro->addFormat(array('Size' => 8, 'bold' => 1, 'Color' => 'red'));
     $this->libro->setCustomColor(15, 192, 192, 192);
     $titulo =& $this->libro->addFormat(array('Size' => 8, 'bold' => 1, "Align" => "center", "border" => 1, "FgColor" => 15));
     $encabezado =& $this->libro->addFormat(array('Size' => 10, 'bold' => 1, "Align" => "center", "FgColor" => 15));
     $hoja->write(2, 1, utf8_decode("REPORTE DE CONSULTAS GENERAL"), $encabezado);
     $hoja->mergeCells(2, 1, 2, 9);
     $hoja->write(3, 1, utf8_decode("Generado el: " . date("Y-m-d")), $head);
     $hoja->mergeCells(3, 1, 3, 9);
     $titulo->setAlign("vcenter");
     $db = TBase::conectaDB();
     switch ($supervisor->getIdTipo()) {
         case 1:
             $rs = $db->Execute("select idConsultorio, idDoctor, idServicio, sum(cantidad) as cantidad from reporte a join consulta b using(idReporte) join consultorio d using(idConsultorio) join servicio e using(idServicio) join tipoServicio f using(idTipo) join clasificacion g using(idClasificacion) where extract(month from fecha) = " . $this->mes . " and extract(year from fecha) = " . $this->anio . " group by idConsultorio, idDoctor, idServicio");
             break;
         case 2:
             $rs = $db->Execute("select idConsultorio, idDoctor, idServicio, sum(cantidad) as cantidad from reporte a join consulta b using(idReporte) join consultorio d using(idConsultorio) join servicio e using(idServicio) join tipoServicio f using(idTipo) join clasificacion g using(idClasificacion) where extract(month from fecha) = " . $this->mes . " and extract(year from fecha) = " . $this->anio . " and idSupervisor = " . $supervisor->getId() . " group by idConsultorio, idDoctor, idServicio");
             break;
         default:
             return false;
     }
     $hoja->write(4, 1, utf8_decode("Estado"), $titulo);
     $hoja->mergeCells(4, 1, 5, 1);
     $hoja->write(4, 2, utf8_decode("Ciudad"), $titulo);
     $hoja->mergeCells(4, 2, 5, 2);
     $hoja->write(4, 3, utf8_decode("Consultorio"), $titulo);
     $hoja->mergeCells(4, 3, 4, 4);
     $hoja->write(5, 3, utf8_decode("Clave"), $titulo);
     $hoja->write(5, 4, utf8_decode("Nombre"), $titulo);
     $hoja->write(4, 5, utf8_decode("Doctor"), $titulo);
     $hoja->mergeCells(4, 5, 4, 6);
     $hoja->write(5, 5, utf8_decode("Nombre"), $titulo);
     $hoja->write(5, 6, utf8_decode("EMail"), $titulo);
     $hoja->write(4, 7, utf8_decode("Servicio"), $titulo);
     $hoja->mergeCells(4, 7, 4, 8);
     $hoja->write(5, 7, utf8_decode("Tipo"), $titulo);
     $hoja->write(5, 8, utf8_decode("Nombre"), $titulo);
     $hoja->write(4, 9, utf8_decode("Cantidad"), $titulo);
     $hoja->mergeCells(4, 9, 5, 9);
     $datos =& $this->libro->addFormat(array('Size' => 8, "border" => 1));
     $hoja->setColumn(4, 8, 30);
     $y = 6;
     while (!$rs->EOF) {
         $consultorio = new TConsultorio($rs->fields['idConsultorio']);
         $servicio = new TServicio($rs->fields['idServicio']);
         $doctor = new TDoctor($rs->fields['idDoctor']);
         $hoja->write($y, 1, utf8_decode($consultorio->getEstado()), $datos);
         $hoja->write($y, 2, utf8_decode($consultorio->getCiudad()), $datos);
         $hoja->write($y, 3, utf8_decode($consultorio->getClave()), $datos);
         $hoja->write($y, 4, utf8_decode($consultorio->getNombre()), $datos);
         $hoja->write($y, 5, utf8_decode($doctor->getNombre()), $datos);
         $hoja->write($y, 6, utf8_decode($doctor->getEmail()), $datos);
         $hoja->write($y, 7, utf8_decode($servicio->tipo->getDescripcion()), $datos);
         $hoja->write($y, 8, utf8_decode($servicio->getNombre()), $datos);
         $hoja->write($y, 9, utf8_decode($rs->fields["cantidad"]), $datos);
         $rs->moveNext();
         $y++;
     }
     return true;
 }
     $rs = $db->Execute("select * from encargados a join usuario using(idUsuario) join doctor using(idUsuario)");
     $datos = array();
     while (!$rs->EOF) {
         $obj = new TUsuario($rs->fields['idUsuario']);
         $rs->fields['tipo'] = $obj->getTipo();
         $rs->fields['json'] = json_encode($rs->fields);
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("lista", $datos);
     break;
 case 'listaUsuarios':
     $db = TBase::conectaDB();
     global $sesion;
     $usuario = new TUsuario($sesion['usuario']);
     if ($usuario->getIdTipo() == 2) {
         $rs = $db->Execute("select * from usuario left join doctor using(idUsuario) where idTipo = 3");
     } else {
         $rs = $db->Execute("select * from usuario left join doctor using(idUsuario)");
     }
     $datos = array();
     while (!$rs->EOF) {
         $obj = new TUsuario($rs->fields['idUsuario']);
         $rs->fields['tipo'] = $obj->getTipo();
         $rs->fields['json'] = json_encode($rs->fields);
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("lista", $datos);
     $rs = $db->Execute("select * from tipoUsuario");
     $datos = array();
Exemple #6
0
     $usuario = $_GET['usuario'] == '' ? $sesion['usuario'] : $_GET['usuario'];
     $db = TBase::conectaDB();
     global $sesion;
     $rs = $db->Execute("select * from reporte where idUsuario = " . $usuario . " and cast(fecha as date) = '" . $fecha . "'");
     $datos = array();
     while (!$rs->EOF) {
         $rs->fields['json'] = json_encode($rs->fields);
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("lista", $datos);
     break;
 case 'reporte':
     $db = TBase::conectaDB();
     $objUser = new TUsuario($sesion['usuario']);
     if ($objUser->getIdTipo() != 1) {
         $rs = $db->Execute("select * from usuario where idUsuario = " . $sesion['usuario']);
     } else {
         $rs = $db->Execute("select * from usuario order by nombre");
     }
     $datos = array();
     while (!$rs->EOF) {
         array_push($datos, $rs->fields);
         $rs->moveNext();
     }
     $smarty->assign("usuarios", $datos);
     break;
 case 'reportarUbicacion':
     $smarty->assign("origen", base64_decode($_GET['usuario']));
     $smarty->assign("destino", base64_decode($_GET['solicita']));
     break;