Merge branch 'hotfix/errorInformeManten#27' into develop

This commit is contained in:
2014-04-07 23:54:10 +02:00

View File

@@ -102,7 +102,8 @@ class AportaContenido {
* @param array $perfil Permisos de acceso del usuario * @param array $perfil Permisos de acceso del usuario
* @param String $opcion Opción elegida por el usuario * @param String $opcion Opción elegida por el usuario
*/ */
public function __construct($baseDatos, $registrado, $usuario, $perfil, $opcion) { public function __construct($baseDatos, $registrado, $usuario, $perfil, $opcion)
{
$this->bdd = $baseDatos; $this->bdd = $baseDatos;
$this->miMenu = new Menu('inc/inventario.menu'); $this->miMenu = new Menu('inc/inventario.menu');
$this->registrado = $registrado; $this->registrado = $registrado;
@@ -117,7 +118,8 @@ class AportaContenido {
* @param string $idioma idioma para formatear la fecha, p.ej. es_ES * @param string $idioma idioma para formatear la fecha, p.ej. es_ES
* @return string * @return string
*/ */
public function fechaActual($formato = '', $idioma = 'es_ES') { public function fechaActual($formato = '', $idioma = 'es_ES')
{
if ($formato == '') if ($formato == '')
$formato = "%d-%b-%y"; $formato = "%d-%b-%y";
setlocale(LC_TIME, $idioma); setlocale(LC_TIME, $idioma);
@@ -128,7 +130,8 @@ class AportaContenido {
* *
* @return string Mensaje el usuario debe registrarse. * @return string Mensaje el usuario debe registrarse.
*/ */
private function mensajeRegistro() { private function mensajeRegistro()
{
return 'Debe registrarse para acceder a este apartado'; return 'Debe registrarse para acceder a este apartado';
} }
@@ -140,10 +143,11 @@ class AportaContenido {
* @param string $parametros Parámetros del método * @param string $parametros Parámetros del método
* @return string Contenido devuelto por el método * @return string Contenido devuelto por el método
*/ */
public function __call($metodo, $parametros) { public function __call($metodo, $parametros)
{
switch ($metodo) { // Dependiendo del método invocado switch ($metodo) { // Dependiendo del método invocado
case 'titulo': // devolvemos el título case 'titulo': // devolvemos el título
return PROGRAMA." v".VERSION; return PROGRAMA . " v" . VERSION;
case 'usuario': case 'usuario':
if ($this->registrado) if ($this->registrado)
return "Usuario=$this->usuario"; return "Usuario=$this->usuario";
@@ -159,10 +163,10 @@ class AportaContenido {
}); });
}); });
</script>"; </script>";
$campo = '<input type="hidden" name="fechaCabecera" id="fechaCabecera" value="'.$this->fechaActual("%d/%m/%Y").'">'; $campo = '<input type="hidden" name="fechaCabecera" id="fechaCabecera" value="' . $this->fechaActual("%d/%m/%Y") . '">';
$etiqueta = '<label for="fechaCabecera" onClick="$(' . "'#fechaCabecera'" . ").data('DateTimePicker').show();" . '">' . $this->fechaActual() . '</label>'; $etiqueta = '<label for="fechaCabecera" onClick="$(' . "'#fechaCabecera'" . ").data('DateTimePicker').show();" . '">' . $this->fechaActual() . '</label>';
return $etiqueta . $campo . $script; return $etiqueta . $campo . $script;
case 'aplicacion': return PROGRAMA." v".VERSION; case 'aplicacion': return PROGRAMA . " v" . VERSION;
case 'menu': // el menú case 'menu': // el menú
if ($this->registrado) { if ($this->registrado) {
return $this->miMenu->insertaMenu(); return $this->miMenu->insertaMenu();
@@ -218,12 +222,12 @@ class AportaContenido {
$creditos = "$('#creditos').modal({keyboard: false});"; $creditos = "$('#creditos').modal({keyboard: false});";
return $mensaje . '<br><br><center><img src="img/logo.png" alt="' . PROGRAMA . '" onClick="' . $creditos . '" >' . return $mensaje . '<br><br><center><img src="img/logo.png" alt="' . PROGRAMA . '" onClick="' . $creditos . '" >' .
'<br><br><label onClick="'.$creditos.'">' . CENTRO . '</label></center><br><br>' . CREDITOS; '<br><br><label onClick="' . $creditos . '">' . CENTRO . '</label></center><br><br>' . CREDITOS;
case 'articulos': case 'articulos':
case 'ubicaciones': case 'ubicaciones':
case 'test': case 'test':
case 'elementos': case 'elementos':
$this->DatosURL(); $this->cargaDatosURL();
if ($this->datosURL['opc'] == "informe") { if ($this->datosURL['opc'] == "informe") {
if (!$this->pefil['Informe']) { if (!$this->pefil['Informe']) {
$this->procesaURL(); $this->procesaURL();
@@ -240,8 +244,7 @@ class AportaContenido {
$informe = new InformePDF($this->bdd, $salida, $this->registrado); $informe = new InformePDF($this->bdd, $salida, $this->registrado);
$informe->crea($salida); $informe->crea($salida);
$informe->cierraPDF(); $informe->cierraPDF();
$informe->imprimeInforme(); return $this->devuelveInforme($informe);
return;
} else { } else {
return $this->mensajePermisos("Informes"); return $this->mensajePermisos("Informes");
} }
@@ -271,8 +274,7 @@ class AportaContenido {
$informe = new InformePDF($this->bdd, $salida, $this->registrado); $informe = new InformePDF($this->bdd, $salida, $this->registrado);
$informe->crea($salida); $informe->crea($salida);
$informe->cierraPDF(); $informe->cierraPDF();
$informe->imprimeInforme(); return $this->devuelveInforme($informe);
return;
} else { } else {
return $this->mensajePermisos("Informes"); return $this->mensajePermisos("Informes");
} }
@@ -296,17 +298,6 @@ class AportaContenido {
} else { } else {
return $this->mensajePermisos('Informes'); return $this->mensajePermisos('Informes');
} }
// case 'descuadres':
// if ($this->perfil['Informe']) {
// $enlace = 'xml/informe' . ucfirst($opcion) . '.xml';
// $informe = new InformePDF($this->bdd, $enlace, $this->registrado);
// $informe->crea($enlace);
// $informe->cierraPDF();
// $informe->imprimeInforme();
// return;
// } else {
// return $this->mensajePermisos('Informes');
// }
case 'importacion': case 'importacion':
if ($this->perfil['Modificacion'] && $this->perfil['Borrado']) { if ($this->perfil['Modificacion'] && $this->perfil['Borrado']) {
$import = new Importacion($this->bdd, $this->registrado); $import = new Importacion($this->bdd, $this->registrado);
@@ -348,6 +339,7 @@ class AportaContenido {
return "Marca {$metodo} queda sin procesar"; return "Marca {$metodo} queda sin procesar";
} }
} }
public function cargaDatosURL() public function cargaDatosURL()
{ {
$this->datosURL['opc'] = isset($_GET['opc']) ? $_GET['opc'] : 'inicial'; $this->datosURL['opc'] = isset($_GET['opc']) ? $_GET['opc'] : 'inicial';
@@ -357,16 +349,31 @@ class AportaContenido {
$this->datosURL['buscar'] = isset($_GET['buscar']) ? $_GET['buscar'] : null; $this->datosURL['buscar'] = isset($_GET['buscar']) ? $_GET['buscar'] : null;
$this->datosURL['id'] = isset($_GET['id']) ? $_GET['id'] : null; $this->datosURL['id'] = isset($_GET['id']) ? $_GET['id'] : null;
} }
/** /**
* *
* @param string $tipo * @param string $tipo
* @return string * @return string
*/ */
public function mensajePermisos($tipo) { public function mensajePermisos($tipo)
{
return $this->panel("ERROR", "No tiene permiso para acceder a $tipo", "danger"); return $this->panel("ERROR", "No tiene permiso para acceder a $tipo", "danger");
} }
public function panel($cabecera, $mensaje, $tipo) { private function devuelveInforme($informe)
{
$letras = "abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$nombre = "tmp/informe" . substr(str_shuffle($letras), 0, 10) . ".pdf";
$informe->guardaArchivo($nombre);
return '<div class="container">
<!--<a href="' . $nombre . '" target="_blank"><span class="glyphicon glyphicon-cloud-download" style="font-size:1.5em;"></span>Descargar Informe</a>-->
<object data="' . $nombre . '" type="application/pdf" width="100%" height="700" style="float:left;">
</object>
</div>';
}
public function panel($cabecera, $mensaje, $tipo)
{
$panel = '<div class="panel panel-' . $tipo . '"><div class="panel-heading">'; $panel = '<div class="panel panel-' . $tipo . '"><div class="panel-heading">';
$panel .= '<h3 class="panel-title">' . $cabecera . '</h3></div>'; $panel .= '<h3 class="panel-title">' . $cabecera . '</h3></div>';
$panel .= '<div class="panel-body">'; $panel .= '<div class="panel-body">';
@@ -374,7 +381,6 @@ class AportaContenido {
$panel .= '</div>'; $panel .= '</div>';
return $panel; return $panel;
} }
} }
?> ?>