<?php
require_once(DIR_FS_ADMIN.DIR_WS_CLASSES.'configuration.php');
/**
 * configurations class 
 *
 */
class configurations extends databasetable
{
	/**
	 * initiates the configurations class
	 *
	 */
	function configurations(){
		$this->set_tablename(TABLE_CONFIGURATIONS);
		$this->set_index('configuration_id');
		/*
		$this->related_tables = array(
			0=>array('table'=>TABLE_CUSTOMERS_TO_COMPANIES,'key'=>$this->get_index() )
		);
		*/
	}
	
	/**
	 * return a configuration object
	 *
	 * @param integer $id
	 * @return object
	 */
	function get_configuration($id){
		$values = $this->get_row_by_index($id);
		$configuration_instance = new configuration( (object) current($values) );
		return $configuration_instance;
	}

	function get_configuration_groups(){
		$groups = array(0=>array('id'=>'','text'=>TEXT_SELECT));
		$query_raw = sprintf("SELECT configuration_group_id,configuration_group_title FROM configuration_group WHERE visible=1 ORDER BY sort_order,configuration_group_title");
		$query = $this->query($query_raw, true);
		if($query){
			foreach($query as $record){
				$groups[] = array('id'=>$record['configuration_group_id'],'text'=>$record['configuration_group_title']);
			}
		}
		return $groups;
	}
}
