Source for file GuiPrint.php

Documentation is available at GuiPrint.php

  1. <?php
  2. /**
  3.  * 
  4.  * GuiPrint.php
  5.  *
  6.  * Generic class to show one html page with one record,
  7.  * based on a query. It is normally called from a control script
  8.  * that instaniates GuiList1 first.
  9.  *
  10.  * @package     FreeNAC
  11.  * @author      Sean Boran (FreeNAC Core Team)
  12.  * @copyright   2008 FreeNAC
  13.  * @license     http://www.gnu.org/copyleft/gpl.html   GNU Public License Version 3
  14.  * @version     SVN: $Id$
  15.  * @link        http://freenac.net
  16.  *
  17.  */
  18.  
  19.  
  20. class GuiPrint extends WebCommon {
  21.   // See also WebCommon and Common
  22.  
  23.  
  24.   function __construct($rep_name='')
  25.   {
  26.     parent::__construct();     // See also WebCommon and Common
  27.     $this->logger->setDebugLevel(1);   // set to 3 for debugging
  28.     $this->debug("__construct " .$_SESSION['login_data'.":$rep_name:"1);
  29.  
  30.     // Show Webpage start, is the constructor the right place?
  31.     //echo print_header(false);  //false=no links
  32.  
  33.     $txt=<<<TXT
  34. <div style='text-align: left;' class='text18'>
  35.   <p>{$rep_name}
  36. </div><br/>
  37. TXT;
  38.     echo $txt;
  39.   }
  40.  
  41.  
  42.   /**
  43.    * Generic query report
  44.    */
  45.   public function query($q
  46.   {
  47.     $conn=$this->getConnection()//  make sure we have a DB connection
  48.     $output="<table id='t2' width='1000' border='0' class='text14'>";
  49.  
  50.     try {
  51.       #$limit=$this->real_escape_string1($limit, $conn);
  52.       $rowcount=0;
  53.       #$q.=" LIMIT 1"; 
  54.       $this->debug("query() $q"2);
  55.  
  56.       $res $conn->query($q);
  57.       if ($res === FALSE)
  58.         throw new DatabaseErrorException($conn->error);
  59.  
  60.       // Title: Grab the list of field names
  61.       $fields=$res->fetch_fields();
  62.       while (($row $res->fetch_assoc()) !== NULL{
  63.         $rowcount++;
  64.         foreach ($fields as $field{
  65.           $fname=$field->name;
  66.           #$output.="<tr><td>$fname</td><td>{$row[$fname]}</td></tr>";
  67.           $output.="<tr><td>$fname</td><td>.$this->htmlescape($row[$fname]."</td></tr>";
  68.         
  69.       }
  70.  
  71.       $output.="<tr><td>Date printed</td><td>" .date("F j, Y, g:i a"."</td></tr>";
  72.  
  73.       // Inform the user if no data was returned
  74.       if ( ($rowcount)=={
  75.         $output.= "<br/><tr><td colspan='4' align='center' class='text16red'>The report is empty</td></tr><tr></tr><br/>";
  76.  
  77.       }
  78.       $res->close();
  79.  
  80.     catch (Exception $e{
  81.       #if ($in_db_conn === NULL and isset($conn))
  82.       if (isset($conn))
  83.         $conn->close();
  84.       throw $e;
  85.     }
  86.  
  87.     // close table, send back text
  88.     $output.="</table>";
  89.     return($output);
  90.   }
  91.  
  92.   function print_footer()            // Override 
  93.   {
  94.     $txt=<<<TXT
  95. <A HREF='javascript:javascript:history.go(-1)'< Back</A>        
  96. <A HREF='javascript:window.print()'>Print</A>
  97. TXT;
  98.  
  99.   // TBD: why does the second part not work?
  100.   #echo "<A HREF='javascript:javascript:history.go(-1)'<<< back</A><SCRIPT TYPE='text/javascript' <!-- var gb = new backlink(); gb.type='button'; gb.form=false; gb.text = 'Back'; gb.write(); //--></SCRIPT>\n";
  101.  
  102.     return($txt);
  103.   }
  104.  
  105.  
  106. // class
  107.  
  108. ?>

Documentation generated on Mon, 17 Nov 2008 01:10:37 +0100 by phpDocumentor 1.4.0