Location: PHPKode > projects > ARTIS WaterMon > artis-watermon-beta/reservoir.class.php
<?php

// Toowoomba City Council Water Monitoring System
// Developed by Sam Moffatt (hide@address.com)
// Reservoir Data Class

require_once("functions.php");

class reservoir {
	// Variables
	var $resid;			// Reservior ID
	var $datasource;	// Location of the CSV file
	var $dbinfo;		// Details about the database (array)
	var $name;			// res name (human friendly)
	var $shortname;		// res name (short)
	var $data;			// Data from CSV
	var $top,$left;		// res HTML position	
	
	// Constructor
	function reservoir($newresid, $shortname, $left,$top, $newdatasource="http://www.toowoomba.qld.gov.au/eBiz/artis/SCADA2000.CSV", $newdbinfo="") {
		$this->dbinfo = Array();
		if(is_array($newdbinfo)) {
			// New database information
		} else {
			// Default database
		}
		if(($newdatasource != "") && (is_string($newdatasource))) {
			$this->datasource = $newdatasource;
		} else if(is_array($newdatasource)) {
			$this->data = $newdatasource;
		} else {
			// Isn't a string and isn't an array, fall back
			$this->datasource = "http://www.toowoomba.qld.gov.au/eBiz/artis/SCADA2000.CSV";
		}
		if(!isset($this->data)) { $this->data = loadCSV($this->datasource); }
		$this->top = $top;
		$this->left = $left;
		$this->resid = $newresid;
		$this->shortname = $shortname;
	}

	function getID() {
		return $this->resid;
	}
	
	function getName() {		
		return "{$this->data[$this->resid]['title']} ($this->resid)";
	}
	
	function getShortName() {
		return $this->shortname;
	}
	
	function getTimeStamp() {
		return $this->data[$this->resid]['stamp'];
	}
	
	function getStatus() {
		return $this->data[$this->resid]['state'];
	}
	
	function setTop($top) {
		$this->top = $top;
	}
	
	function setLeft($left) {
		$this->left = $left;
	}
	
	// Return the reservoir with div
	// - Allows position override
	function getHTML($left=0,$top=0) {
	if($top == 0) {
		$top = $this->top;
	}
	if($left == 0) {
		$left = $this->left;
	}
	?>
  <div style="z-index: 2; position: absolute; left: <?php echo $left; ?>; top: <?php echo $top; ?>;" align="center">
 <DIV ID="9" STYLE="position:relative;"><?php echo $this->getShortName(); ?><br><?php echo $this->getTimeStamp(); ?></b></div>

 <div style="position:relative; width: 100;"><table border="1">

 <table STYLE=" border:1px solid #B3ABF4;" cellspacing=0 cellpadding=0 border=1   >
 <tr>

 <td style="border-bottom:1px solid #B3ABF4;" align="center" bgcolor="#90D3D3" valign="middle" nowrap colspan=3 class="texttiny"><font color="#000080"> <?php echo round($this->getStatus(),1) ?> % </td></tr>
 <tr>

 <td background="" align="right" valign="bottom" height=100 width=0><img src="images/bbar.gif" width = 60 height=<?php echo round($this->getStatus()); ?> border=0 alt=" "></td>

 </table><br></div> </div>

		 <?php
	}
	

}

?>
Return current item: ARTIS WaterMon