<?php
class history extends databasetable
{
	var $customers_id;
	function history(){
		$this->set_tablename(TABLE_HISTORY);
		$this->set_index('history_id');
		$this->customers_id = $_SESSION['customer_id'];
	}
	
	/**
	  * add: adds a comment to yes system history
	  *
	  * @author		mario aspeleiter
	  * @version	1.0
	  * @param		$class		String	The History Class eg "system" or "companies"
	  * @param		$message	String	The Message for the History
	  * @param		$class_id	Integer	(optional) If the process has an id (eg in companies the companies_id) add it here. Default false
	  */
	function add($class,$message,$class_id=false){
		$class_id_string = '';
		if($class_id){
			$class_id_string = sprintf(", class_id='%s'",$class_id);
		}
		$insert_sql = sprintf("INSERT INTO %s SET customers_id='%s',date_added=now(),class='%s',message='%s' %s",
			$this->get_tablename(),
			$this->customers_id,
			$class,
			$message,
			$class_id_string
		);
		$this->query($insert_sql);
	}
}
