<?php
/**
 * Basic Information Display
 *
 * Basic Information and Display as Format HTML Tables.
 * @package     Display
 * @author      Simon <simon.youngest@gmail.com>
 * @date				2011-3-28
 * @version     0.1
 */
 class basic_info{
 
	public $columns; 	//Number of Column
	public $rows;			//Number of rows
	public $content; 	//Content to display,2-D
	
	/* Array with items<$itemNum;  If need add No at 0, use function: array_unshift*/
	public $titles;		
	/* Main title of Basic Information as: lot information */
	public $main_title;
	
	public $num_flag;	//Is first column is No? Set 1 if yes.
	public $aligns;		//Align method for each column;
	public $width;		
	public $display;
	//Get Formated Display of Content
	function get_Content_Display(){
		global $tableTop,$interval;
		if($this->content[0]==NULL) {
			$this->display="<p align='center'><font size='3' color='red'><i><b>Query result is null</b></i></font></p>";
			return;
		}
		/* Get number of rows if not defined */
		if($this->rows == NULL) $this->rows=count($this->content[0]);

		$this->display="<table width='".$this->width."' align='center' >\n";
		
		/* Main title display */
		if(strlen($this->main_title)>0) {
			$this->display.="<tr><td colspan='5' align='center' style='font-size:14px;padding:5px;'><h3>";
			$this->display.=$this->main_title;
			$this->display.="</h3></td></tr>\n";
		}
		
			/* Get Row number of HTML */
		$html_row=ceil(count($this->content[0])/2);
		//display data
		for($i=0;$i<$html_row;$i++){
			$j=$i+1;
			$this->display.="<tr >\n";
			$this->display.="<td bgcolor='".$tableTop."' width='18%' style='font-size:14px;padding:5px;'>\n";
			$this->display.=$this->content[0][2*$i];
			$this->display.="</td><td bgcolor='".$interval."' width='31%' style='font-size:14px;padding:5px;'>\n";
			$this->display.=$this->content[1][2*$i];
			$this->display.="</td>\n";
			$this->display.="<td >&nbsp;</td>\n";
			$this->display.="<td bgcolor='".$tableTop."' width='18%' style='font-size:14px;padding:5px;'>\n";
			$this->display.=$this->content[0][2*$i+1];
			$this->display.="</td><td bgcolor='".$interval."' width='31%' style='font-size:14px;padding:5px;'>\n";
			$this->display.=$this->content[1][2*$i+1];
			$this->display.="</td>\n";
			$this->display.="</tr>\n";
		}
		$this->display.="</table>";	
	}
	
	function display(){
		echo $this->display;
	}
 }
?>
 
