File "informes.php"
Full Path: /home/limout/public_html/CablesPireV2-20240827214508/informes.php
File size: 6.51 KB
MIME-type: text/x-php; charset=utf-8
Charset: utf-8
<?php
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
require_once( 'config.php' );
require_once( 'makeSecure.php' );
require_once( 'includes/smarty.php' );
// INICIO Cargamos las clases que necesitamos
include_once( 'includes/clases/clase_general.php' );
include_once( 'includes/clases/clase_empresas.php' );
include_once( 'includes/clases/clase_categorias.php' );
include_once( 'includes/clases/clase_productos.php' );
include_once( 'includes/clases/clase_equiposv2.php' );
include_once( 'includes/clases/clase_inspecciones.php' );
// FIN Cargamos las clases que necesitamos
// Datos genéricos
require_once( 'includes/comunesAdmin.php' );
switch(@$_GET['accion'])
{
case 'genera-pdf':
$iInspeccionId = (int)$_GET[ 'id_inspeccion' ];
$iEquipoId = (int)$_GET[ 'id_equipo' ];
$oInspeccion = new inspecciones;
$oInspeccion->iInspeccionId = $iInspeccionId;
$oInspeccion->busca_inspecciones();
$oInspeccion->busca_equipos_inspeccion( $iInspeccionId );
$iNumEquipo = filter_var( $oInspeccion->aInspecciones[ $iInspeccionId ][ 'aEquipos' ][ $iEquipoId ][ 'nombre' ], FILTER_SANITIZE_NUMBER_INT);
$smarty->assign( 'iNumEquipo', $iNumEquipo );
$smarty->assign( 'sAction', $sUrl . 'inspecciones.php?accion=confirmar_editar');
$smarty->assign( 'aInspeccion', $oInspeccion->aInspecciones[ $iInspeccionId ] );
$smarty->assign( 'aEquipo', $oInspeccion->aInspecciones[ $iInspeccionId ][ 'aEquipos' ][ $iEquipoId ] );
$smarty->assign( 'iMensaje', ( isset( $_GET[ 'mensaje' ] ) && $_GET[ 'mensaje' ] > 0 ) ? $_GET[ 'mensaje' ] : '' );
$smarty->assign( 'sMensaje', ( isset( $_GET[ 'mensaje' ] ) && $_GET[ 'mensaje' ] > 0 ) ? $aMensajes[ $_GET[ 'mensaje' ] ] : '' );
/*if( $iInspeccionId == '93' )
{
$bPintaPdf = true;
print "<pre>";
print_r($oInspeccion->aInspecciones[ $iInspeccionId ][ 'aEquipos' ][ $iEquipoId ]);
print "</pre>";
}
else*/
$bPintaPdf = false;
if( $bPintaPdf != true )
{
$html = $smarty->fetch( 'informes/plantilla-pdf.tpl');
// Incluímos la configuración básica de domPdf...
include_once( 'includes/clases/dompdf/dompdf_config.inc.php' );
$filename = 'reports/inspeccion-' . $iInspeccionId . '_' . date( 'd-m-Y' ) . '.pdf';
# Instanciamos un objeto de la clase DOMPDF.
$pdf_parser = new DOMPDF();
# Definimos el tamaño y orientación del papel que queremos.
# O por defecto cogerá el que está en el fichero de configuración.
$pdf_parser->set_paper("A4", "portrait");
# Cargamos el contenido HTML.
$pdf_parser->load_html( $html );
# Renderizamos el documento PDF.
$pdf_parser->render();
# Enviamos el fichero PDF al navegador.
$pdf_parser->stream( "inspeccion-" . $iInspeccionId . "_" . date( 'd-m-Y' ) . ".pdf", array( "Attachment" => true ) );
$pdf_parser->__destruct();
header("Content-Type: application/pdf");
header("Content-disposition: attachment; filename=inspeccion-" . $iInspeccionId . '_' . date( 'd-m-Y' ) . ".pdf" );
}
else
$smarty->display( 'informes/plantilla-pdf.tpl');
break;
case 'ver':
$iInspeccionId = (int)$_GET[ 'id_inspeccion' ];
$oInspeccion = new inspecciones;
$oInspeccion->iInspeccionId = $iInspeccionId;
$oInspeccion->busca_inspecciones();
$oInspeccion->busca_equipos_inspeccion( $iInspeccionId );
$oEmpresa = new empresas;
$oEmpresa->iEmpresaId = $_SESSION[ 'iEmpresaId' ];
$oEmpresa->busca_empresa();
$iNumEquipo = filter_var( $oInspeccion->aInspecciones[ $iInspeccionId ][ 'aEquipos' ][ $iEquipoId ][ 'nombre' ], FILTER_SANITIZE_NUMBER_INT);
$smarty->assign( 'iNumEquipo', $iNumEquipo );
$smarty->assign( 'aInspeccion', $oInspeccion->aInspecciones[ $iInspeccionId ] );
$smarty->assign( 'aEmpresa', $oEmpresa->aEmpresa );
unset( $oEmpresa );
$smarty->display( 'informes/formulario.tpl');
break;
default:
if( isset( $_SESSION[ 'iEmpresaId' ] ) && $_SESSION[ 'iEmpresaId' ] > 0 )
{
$oInspecciones = new inspecciones;
$oInspecciones->sTermBusqueda = ( isset( $_POST[ 'nombre' ] ) && $_POST[ 'nombre' ] != '' ) ? trim( $_POST[ 'nombre' ] ) : '';
$oInspecciones->dFechaBusqueda = ( isset( $_POST[ 'fecha' ] ) && $_POST[ 'fecha' ] != '' ) ? trim( $_POST[ 'fecha' ] ) : '';
$oInspecciones->iEmpresaBusqueda = (int)$_SESSION[ 'iEmpresaId' ];
$bAptoBusqueda = ( isset( $_POST[ 'apto' ] ) && trim( $_POST[ 'apto' ] ) == 'on' ) ? 1 : 0;
$oInspecciones->busca_inspecciones( $bAptoBusqueda );
$smarty->assign('aInspecciones',$oInspecciones->aInspecciones );
$smarty->assign('sTermBusqueda', $oInspecciones->sTermBusqueda );
$smarty->assign('dFechaBusqueda', $oInspecciones->dFechaBusqueda );
$smarty->assign('bAptoBusqueda', $bAptoBusqueda );
$smarty->assign('iEmpresaBusqueda', (int)$_SESSION[ 'iEmpresaId' ] );
$smarty->assign('accion', 'listado');
unset( $oInspecciones );
$smarty->display('informes/listado.tpl');
}
else
{
$smarty->assign('aInspecciones',array() );
$smarty->assign('sTermBusqueda', '' );
$smarty->assign('dFechaBusqueda', '' );
$smarty->assign('bAptoBusqueda', '' );
$smarty->assign('iEmpresaBusqueda', (int)$_SESSION[ 'iEmpresaId' ] );
$smarty->assign('accion', 'listado-no-empresa');
unset( $oInspecciones );
$smarty->display('informes/listado-no-empresa.tpl');
}
break;
}
?>