Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
     $doc->setTurno($_POST['turno']);
     $doc->setMes($_POST['mes']);
     $doc->setAnio($_POST['anio']);
     $documento = $doc->output();
     if ($documento == '') {
         $result = array("doc" => "", "band" => false);
     } else {
         if ($_POST['enviar'] == 'no') {
             $result = array("doc" => $documento, "band" => true);
         } else {
             global $sesion;
             $email = new TMail();
             $consultorio = new TConsultorio($_POST['consultorio']);
             $email->setTema("Reporte " . utf8_decode($consultorio->getClave() . " " . $consultorio->getNombre()));
             $email->setDestino($consultorio->supervisor->getEmail(), utf8_decode($consultorio->supervisor->getNombreCompleto()));
             $doctor = new TDoctor($_POST['usuario'] == '' ? $sesion['usuario'] : $_POST['usuario']);
             $datos = array();
             $datos['nombreCompleto'] = $consultorio->supervisor->getNombreCompleto();
             $datos['nombreDoctor'] = $doctor->getNombreCompleto();
             $email->setBodyHTML(utf8_decode($email->construyeMail(file_get_contents("repositorio/mail/reporteDoctor.txt"), $datos)));
             $email->adjuntar($documento);
             $result = array("doc" => $documento, "band" => $email->send(), "emailSupervisor" => $consultorio->supervisor->getEmail());
         }
     }
     print json_encode($result);
     break;
 case 'generalExcel2':
     #Este incluye todas las consultas realizadas en un mes
     require_once getcwd() . "/repositorio/excel/general.php";
     $doc = new RReporte();
     $doc->setMes($_POST['mes']);
Ejemplo n.º 3
0
     $obj->setApp($_POST['app']);
     $obj->setApm($_POST['apm']);
     $obj->setEmail($_POST['email']);
     $obj->setPass($_POST['pass']);
     $obj->setTipo($_POST['tipo']);
     $obj->setEstado($_POST['estado']);
     echo json_encode(array("band" => $obj->guardar()));
     break;
 case 'del':
     $obj = new TUsuario($_POST['usuario']);
     echo json_encode(array("band" => $obj->eliminar()));
     break;
 case 'autocomplete':
     $db = TBase::conectaDB();
     $rs = $db->Execute("select idUsuario from usuario a join doctor b using(idUsuario) where (nombre like '%" . $_GET['term'] . "%' or app like '%" . $_GET['term'] . "%' or apm like '%" . $_GET['term'] . "%' or concat(nombre, ' ', app, ' ', apm) like '%" . $_GET['term'] . "%' or concat(app, ' ', apm, ' ', nombre) like '%" . $_GET['term'] . "%') and idUsuario not in (select idUsuario from encargados where idSupervisor = " . $_GET['sup'] . ")");
     $obj = new TDoctor();
     $datos = array();
     while (!$rs->EOF) {
         $el = array();
         $obj->setId($rs->fields['idUsuario']);
         $el['id'] = $obj->getId();
         $el['label'] = $obj->getNombreCompleto();
         $el['identificador'] = $obj->getId();
         array_push($datos, $el);
         $rs->moveNext();
     }
     echo json_encode($datos);
     break;
 case 'addsup':
     $obj = new TUsuario($_POST['supervisor']);
     echo json_encode(array("band" => $obj->addSupervisado($_POST['doctor'])));