PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Andres Dario Gutierrez Poveda   Report Generator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of usage
Class: Report Generator
Compose and generate MySQL query reports in HTML
Author: By
Last change: *
Date: 19 years ago
Size: 2,450 bytes
 

Contents

Class file image Download
<?php
include('/path/to/Reportes.class.php');
   
$style = "<style>";
$style .= ".grid {font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000}";
$style .= "</style>";
   
echo
$style;
   
$mireporte = new Reporte();

if (!(
$link=mysql_connect($host,$user,$pass))){
    echo
"Error conectando a la base de datos.\n";
    exit();
}
if (!
mysql_select_db($db,$link)){
    echo
"Error seleccionando la base de datos.\n";
    exit();
}

/** Name of the report*/
$mireporte->set_reporte_nombre("Reporte de equipos");

/** Pass the link to the database */
$mireporte->set_reporte_link($link);

/** Name of the central table */
$mireporte->set_reporte_tabla("equipo");

/** Fields that you want to show in the result report*/
$mireporte->set_reporte_campos("serial,mac,firmware,alias,password,ip,fecha_entrada,accesorios");

/** Special Condition to retrieve data, if non leave it 1*/
$mireporte->set_reporte_condicion("1");

/** Field to sort the output data in the report */
$mireporte->set_reporte_ordenar("alias ASC");

/** Colors of the title,headers,left frame,font */
$mireporte->set_reporte_colores("#003399","#0066AB","#0099CC","#FFFFFF");

/** Header for each fields of the table */
$mireporte->set_reporte_encabezados(array("serial","mac","firmware","alias","password","ip","fecha_entrada","accesorios","fk_modeloid","fk_estadoid","fk_ubicacionid","fk_propietarioid"),
                                                                            array(
"Serial","MAC","Firmware","Alias","Password","IP","Fecha Entrada","Accesorios","Modelo","Estado","Ubicaci&#243n","Propietario"));

/** Retrieve data from normalized data. Name of the field that references, name of the tabla that is referenced, primary key of that table, field of the table that you want to show, the way to sort the data */ $mireporte->normalizar_referencia("fk_modeloid","modelo","id","nombre","nombre ASC");
   
$mireporte->normalizar_referencia("fk_estadoid","estadoequipo","id","nombre","nombre ASC");
   
$mireporte->normalizar_referencia("fk_ubicacionid","empresa","id","nombre","nombre ASC");
   
$mireporte->normalizar_referencia("fk_propietarioid","empresa","id","nombre","nombre ASC");
   
/** Check if submit is set. If it is show the result report, if not show the choices for the user. */
if(isset($_POST['submit'])){
    echo
$mireporte->get_reporte();
    echo
$feedback = $mireporte->get_reporte_feedback();
}else{
    echo
$mireporte->get_prereporte();
}
?>