<?php
require_once (PATH_CONTROLLERS . "Common.php") ;
require_once (PATH_MODELS . "admin/UpdateDatabaseClass.php") ;
require_once (PATH_CODE . "Constants.php") ;

class Config {
	private $type = "" ;
	private $datas = array() ;

	function __construct() {
	}
	function __destruct() {
		unset($this->datas) ;
	}
	public function processRequest($params) {
		$this->type = REQ_VIEW ;
		try {
			if (isset($_SESSION[SE_DB])) {
				unset($_SESSION[SE_DB]);
			}
			if (isset($params) && count($params) > 0) {
				if (isset($params['type']))
					$this->type = $params['type'] ;
			}
			// Log::write($params);
			switch ($this->type) {
				case REQ_UPDATE:
					$this->saveConfig($params) ;
					break ;
				case REQ_GET:
					$this->getUserKey() ;
					break ;
				case REQ_QUERY:
					$this->testConnection($params) ;
					break ;
				case "UPDATE_DATABASE":
					$this->updateDatabase($params) ;
					break ;
				case "CLEAR_TRANSACTION":
					$this->clearTransaction($params) ;
					break ;
				case REQ_VIEW:
					$this->getView() ;
					break ;
				case "PROCESS_BACKUP":
					$this->processBackup($params);
					break ;
				case "PROCESS_RESTORE":
					$this->processRestore($params);
					break ;
				default:
					$this->sendJsonResponse(Status::Error,"invalid request.","",$this->type) ;
					break ;
			}
			return true ;
		} catch (Exception $e) {
			die ($e->getMessage()) ;
		}
	}
	private function saveConfig($params) {
		try {

			$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
			$config = new ConfigDb(PATH_CODE . 'db.xml') ;
			$config->loadConfig() ;
			$config->setHost($this->getParam($params,'server',""));
			$config->setDbName($this->getParam($params,'dbname',"")) ;
			$config->setUserName($this->getParam($params,'dbuser',"")) ;
			$config->setPassword($pwd);
			$port = $this->getParamInt($params,'dbport',0) ;
			if ($port > 0)
				$config->setPortNo($port) ;
			else
				$config->setPortNo("") ;
			$config->setDbType($this->getParam($params,'dbtype',DbType::MsSql)) ;

			$pwd = Util::decryptData($this->getParam($params,'dbpwdnotif',""),$_SESSION['key']) ;
			$config->setHostNotif($this->getParam($params,'servernotif',""));
			$config->setDbNameNotif($this->getParam($params,'dbnamenotif',"")) ;
			$config->setUserNameNotif($this->getParam($params,'dbusernotif',"")) ;
			$config->setPasswordNotif($pwd);
			$port = $this->getParamInt($params,'dbportnotif',0) ;
			if ($port > 0)
				$config->setPortNoNotif($port) ;
			else
				$config->setPortNoNotif("") ;
			$config->setDbTypeNotif($this->getParam($params,'dbtypenotif',DbType::MsSql)) ;

			$config->setBackupFilename($this->getParam($params,'backupfilename',""));

			$config->saveConfig() ;
			$this->sendJsonResponse(Status::Ok,"System Configuration successfully saved.","",$this->type) ;
		} catch (Exception $e) {
			Log::write('[Admin]' . $e->getMessage());
			$this->sendJsonResponse(Status::Error,"Sorry, there is a error in updating system configuration.","",$this->type) ;
		}
		unset($coy) ;
	}
	private function testConnection($params) {
		$status = "" ;
		$mesg = "" ;
		$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
		$host = $this->getParam($params,'server',"") ;
		$name = $this->getParam($params,'dbname',"") ;
		$user = $this->getParam($params,'dbuser',"") ;
		$port = $this->getParam($params,'dbport',"") ;
		$type = $this->getParam($params,'dbtype',"") ;


		if ($type == "") {
			$status = Status::Error ;
			$mesg = "Missing database type info." ;
		}
		if ($status == "") {
			if ($host == "" || $name == "") {
				$status = Status::Error ;
				$mesg = "Missing Server/Database info." ;
			}
		}
		if ($status == "") {
			if ($user == "" || $pwd == "") {
				$status = Status::Error ;
				$mesg = "Missing Database user name/password info." ;
			}
		}

		if ($status == "") {
			try {
				if ($type == DbType::MySql) {
					MySqlDb::testConnection($host,$name,$user,$pwd,$port) ;
				} else if ($type == DbType::MySqli) {
					MySqliDb::testConnection($host,$name,$user,$pwd,$port) ;
				} else {
					MsSqlDb::testConnection($host,$name,$user,$pwd,$port) ;
				}
				$mesg = "Database Connection Testing - Ok."  ;
			} catch (Exception $e) {
				$status = Status::Error ;
				$mesg = $e->getMessage() ;
			}
		}
		echo $mesg ;
	}
    private function updateDatabase($params){
		$status = "" ;
		$mesg = "" ;
		$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
		$host = $this->getParam($params,'server',"") ;
		$name = $this->getParam($params,'dbname',"") ;
		$user = $this->getParam($params,'dbuser',"") ;
		$port = $this->getParam($params,'dbport',"") ;
		$type = $this->getParam($params,'dbtype',"") ;

		if ($type == "") {
			$status = Status::Error ;
			$mesg = "Missing database type info." ;
		}
		if ($status == "") {
			if ($host == "" || $name == "") {
				$status = Status::Error ;
				$mesg = "Missing Server/Database info." ;
			}
		}
		if ($status == "") {
			if ($user == "" || $pwd == "") {
				$status = Status::Error ;
				$mesg = "Missing Database user name/password info." ;
			}
		}

		if ($status == "") {
			try {
                $clsUpdateDabatase = new UpdateDatabaseClass(null);
				if ($type == DbType::MySql) {
					MySqlDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MySqlDb($host, $name,$user,$pwd,$port));
				} else if ($type == DbType::MySqli) {
					MySqliDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MySqliDb($host, $name,$user,$pwd,$port));
				} else {
					MsSqlDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MsSqlDb($host, $name,$user,$pwd,$port));
				}

				$all_clear = true ;
				$db =  new MsSqlDb($host, $name,$user,$pwd,$port);

				$db->open() ;
				$res = $clsUpdateDabatase->processUpdateGlobalDatabase();
				if ($res != ""){
					$all_clear = false ;
				} 
			        
                if ($res == ""){
                    $mesg = "Successful in updating database.";
                } else {
                    $mesg = $res;
                }
				$db->close() ;
			} catch (Exception $e) {
				$status = Status::Error ;
				$mesg = $e->getMessage() ;
			}
		}
		echo $mesg ;
    }
	private function clearTransaction($params){
		$status = "" ;
		$mesg = "" ;
		$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
		$host = $this->getParam($params,'server',"") ;
		$name = $this->getParam($params,'dbname',"") ;
		$user = $this->getParam($params,'dbuser',"") ;
		$port = $this->getParam($params,'dbport',"") ;
		$type = $this->getParam($params,'dbtype',"") ;
		$dbbu = $this->getParam($params,'dbbu',"") ;
		if ($type == "") {
			$status = Status::Error ;
			$mesg = "Missing database type info." ;
		}
		if ($status == "") {
			if ($host == "" || $name == "") {
				$status = Status::Error ;
				$mesg = "Missing Server/Database info." ;
			}
		}
		if ($status == "") {
			if ($user == "" || $pwd == "") {
				$status = Status::Error ;
				$mesg = "Missing Database user name/password info." ;
			}
		}

		if ($status == "") {
			try {
                $clsUpdateDabatase = new UpdateDatabaseClass(null);
				if ($type == DbType::MySql) {
					MySqlDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MySqlDb($host, $name,$user,$pwd,$port));
				} else if ($type == DbType::MySqli) {
					MySqliDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MySqliDb($host, $name,$user,$pwd,$port));
				} else {
					MsSqlDb::testConnection($host,$name,$user,$pwd,$port) ;
                    $clsUpdateDabatase = new UpdateDatabaseClass(new MsSqlDb($host, $name,$user,$pwd,$port));
				}

				$all_clear = true ;
				$db =  new MsSqlDb($host, $name,$user,$pwd,$port);

				$db->open() ;

				$res = "";
                if ($res == ""){
                    $mesg = "Successful in clearing transaction.";
                } else {
                    $mesg = $res;
                }
			} catch (Exception $e) {
				$status = Status::Error ;
				$mesg = $e->getMessage() ;
			}
		}
		echo $mesg ;
    }
	private function getUserKey() {
		$key = Util::createMD5(time().'planetz',"","",true) ;
		$_SESSION['key'] = $key ;
		$this->sendJsonResponse(Status::Ok,"",$key,$this->type) ;
	}
	private function loadConfig() {
		$config = new ConfigDb(PATH_CODE . 'db.xml') ;
		$config->loadConfig() ;
		$this->datas['server'] = $config->getHost();
		$this->datas['dbname'] = $config->getDbName();
		$this->datas['dbuser'] = $config->getUserName() ;
		$this->datas['dbpwd'] = $config->getPassword();
		$this->datas['dbtype'] = $config->getDbType() ;
		$port = (int)$config->getPortNo() ;
		if ($port > 0)
			$this->datas['dbport'] = $port ;
		else
			$this->datas['dbport'] = "" ;

		$this->datas['servernotif'] = $config->getHostNotif();
		$this->datas['dbnamenotif'] = $config->getDbNameNotif();
		$this->datas['dbusernotif'] = $config->getUserNameNotif() ;
		$this->datas['dbpwdnotif'] = $config->getPasswordNotif();
		$this->datas['dbtypenotif'] = $config->getDbTypeNotif() ;
		$port = (int)$config->getPortNoNotif() ;
		if ($port > 0)
			$this->datas['dbportnotif'] = $port ;
		else
			$this->datas['dbportnotif'] = "" ;

		$this->datas['backupfilename'] =  $config->getBackupFilename();
		unset($config) ;
	}
	private function getDbName() {
		return $this->datas['dbname'] ;
	}
	private function getServer() {
		return $this->datas['server'] ;
	}
	private function getDbUser() {
		return $this->datas['dbuser'] ;
	}
	private function getDbPwd() {
		return $this->datas['dbpwd'] ;
	}
	private function getDbPort() {
		return $this->datas['dbport'] ;
	}
	private function getDbType() {
		return $this->datas['dbtype'] ;
	}
	private function getDbNameNotif() {
		return $this->datas['dbnamenotif'] ;
	}
	private function getServerNotif() {
		return $this->datas['servernotif'] ;
	}
	private function getDbUserNotif() {
		return $this->datas['dbusernotif'] ;
	}
	private function getDbPwdNotif() {
		return $this->datas['dbpwdnotif'] ;
	}
	private function getDbPortNotif() {
		return $this->datas['dbportnotif'] ;
	}
	private function getTypeListNotif() {
		return $this->datas['dbtypenotif'] ;
	}
	private function getBackupFilename() {
		return $this->datas['backupfilename'] ;
	}

	private function getView() {
		$this->loadConfig();
		ob_start() ;
		include (PATH_VIEWS . "admin/ConfigView.php") ;
		echo Util::minifyHtml(ob_get_clean()) ;
	}
	private function getTypeList() {
		$arr = array() ;
		$arr[] = array ('code'=>DbType::MsSql,'desc'=>'Microsoft SQL Server' );
		$arr[] = array ('code'=>DbType::MySql,'desc'=>'MySql' ) ;
		$arr[] = array ('code'=>DbType::PostgreSql,'desc'=>'Postgres Sql' ) ;
		$arr[] = array ('code'=>DbType::MySqli,'desc'=>'MySqli' ) ;
		return Util::createOptionValue($arr,$this->getDbType()) ;
	}
	private function sendJsonResponse($status="",$mesg="",$data="",$type="") {
		header('Content-type: application/json');
		$arr = array(FIELD_STATUS => $status, FIELD_MESG => $mesg, FIELD_DATA => $data, FIELD_TYPE => $type);
		echo json_encode($arr) ;
	}
	private function getParam($params,$key,$default) {
		if (!isset($params[$key]) || empty($params[$key])) {
			return $default ;
		} else {
			return $params[$key] ;
		}
	}
	private function getParamInt($params,$key,$default) {
		$result = $default ;
		if (isset($params[$key]) && $params[$key] != "") {
			if (is_numeric($params[$key]))
				$result = $params[$key] ;
		}
		return $result ;
	}

	// private function processRestore($params){
	// 	if(!file_exists(PATH_DATABASE_BACKUP)){
	// 		mkdir(PATH_DATABASE_BACKUP);
	// 	}

	// 	$filename = PATH_DATABASE_BACKUP . $params['restorefilename'];
	// 	if(file_exists($filename)){
	// 		$output = null;
	// 		$retval = null;
	// 		$status ="";
	// 		$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
	// 		$host = $this->getParam($params,'server',"") ;
	// 		$name = $this->getParam($params,'dbname',"") ;
	// 		$user = $this->getParam($params,'dbuser',"") ;
	// 		$port = $this->getParam($params,'dbport',"") ;
	// 		$type = $this->getParam($params,'dbtype',"") ;
	// 		$dbbu = $this->getParam($params,'dbbu',"") ;
	// 		if ($type == "") {
	// 			$status = Status::Error ;
	// 			$mesg = "Missing database type info." ;
	// 		}
	// 		if ($status == "") {
	// 			if ($host == "" || $name == "") {
	// 				$status = Status::Error ;
	// 				$mesg = "Missing Server/Database info." ;
	// 			}
	// 		}
	// 		if ($status == "") {
	// 			if ($user == "" || $pwd == "") {
	// 				$status = Status::Error ;
	// 				$mesg = "Missing Database user name/password info." ;
	// 			}
	// 		}

	// 		try {
			

	// 			$db =  new MsSqlDb($host, $name,$user,$pwd,$port);

	// 			$db->open() ;

	// 			$fileContent = file_get_contents($filename);
				

	// 			$db->executeSql($fileContent);
	// 			$db->close() ;

	// 			$mesg = "Database has been restored.";

	// 			$status = Status::Ok;
	// 		} catch (\Exception $e) {
	// 			$mesg = $e->getMessage();
	// 			$status = Status::Error ;
				
	// 		}
			

	// 		$this->sendJsonResponse($status , $mesg, "", $this->type);
	// 	} else {
	// 		$this->sendJsonResponse(Status::Error,"There is an error during restoring process.","",$this->type) ;

	// 	}
	// }
	private function processRestore($params){
		if(!file_exists(PATH_DATABASE_BACKUP)){
			mkdir(PATH_DATABASE_BACKUP);
		}

		$filename = PATH_DATABASE_BACKUP . $params['restorefilename'];
		if(file_exists($filename)){
			$output = null;
			$retval = null;
			$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;

			$cmd_query = 'ALTER DATABASE ' . $params['dbname'] . ' SET SINGLE_USER WITH ROLLBACK IMMEDIATE'.
						' RESTORE DATABASE ' . $params['dbname'] . ' FROM  DISK = \''. $filename .'\' '.
						' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 5 '.
						' ALTER DATABASE ' . $params['dbname'] . ' SET MULTI_USER';

			$cmd = 'sqlcmd -S "'.$params['server'] .'" -Q ' .
			'" '.$cmd_query.' "  -U ' . $params['dbuser'] . ' -P ' . $pwd . ' 2>&1';

			// $cmd = 'sqlcmd -S "." -Q ' .
			// '"ALTER DATABASE ' . $params['dbname'] . ' SET SINGLE_USER WITH ROLLBACK IMMEDIATE '.
			// 'RESTORE DATABASE ' . $params['dbname'] . ' FROM DISK = \'' . $filename . '\' ' .
			// 'WITH MOVE \'' . $params['dbname'] . '\' TO \'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\\' . $params['dbname'] . '.mdf\', ' .
			// 'MOVE \'' . $params['dbname'] . '_log\' TO \'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\\' . $params['dbname'] . '_log.ldf\', ' .
			// 'REPLACE '.
			// 'ALTER DATABASE ' . $params['dbname'] . ' SET MULTI_USER "  -U ' . $params['dbuser'] . ' -P ' . $pwd . ' 2>&1';

			$res = exec($cmd, $output, $retval);
			Log::write($cmd);
			Log::write($output);

			end($output);
			$key = key($output);

			$mesg = "";
			if(isset($output[$key])) {
				$mesg = $output[$key];
			}else if(isset($output[3])) {
				$mesg = $output[3];
			} else if (isset($output[2])) {
				$mesg = $output[2];
			} else {
				$mesg = $output[0];
			}

			$this->sendJsonResponse(Status::Ok, $mesg, "", $this->type);
		} else {
			$this->sendJsonResponse(Status::Error,"There is an error during restoring process.","",$this->type) ;

		}
	}

	// private function processBackup($params) {
		// Log::write($params);
		// if(!file_exists(PATH_DATABASE_BACKUP)){
		// 	mkdir(PATH_DATABASE_BACKUP);
		// }

		// // $output = null;
		// // $retval = null;
		// $filename = PATH_DATABASE_BACKUP . $params['backupfilename'] . ".sql";

		// $status = "" ;
		// $mesg = "" ;
		// $pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
		// $host = $this->getParam($params,'server',"") ;
		// $name = $this->getParam($params,'dbname',"") ;
		// $user = $this->getParam($params,'dbuser',"") ;
		// $port = $this->getParam($params,'dbport',"") ;
		// $type = $this->getParam($params,'dbtype',"") ;
		// $dbbu = $this->getParam($params,'dbbu',"") ;

		// if ($type == "") {
		// 	$status = Status::Error ;
		// 	$mesg = "Missing database type info." ;
		// }
		// if ($status == "") {
		// 	if ($host == "" || $name == "") {
		// 		$status = Status::Error ;
		// 		$mesg = "Missing Server/Database info." ;
		// 	}
		// }
		// if ($status == "") {
		// 	if ($user == "" || $pwd == "") {
		// 		$status = Status::Error ;
		// 		$mesg = "Missing Database user name/password info." ;
		// 	}
		// }

		// if ($status == "") {
		// 	try {
        //         $clsUpdateDabatase = new UpdateDatabaseClass(null);
		// 		if ($type == DbType::MySql) {
		// 			MySqlDb::testConnection($host,$name,$user,$pwd,$port) ;
        //             $clsUpdateDabatase = new UpdateDatabaseClass(new MySqlDb($host, $name,$user,$pwd,$port));
		// 		} else if ($type == DbType::MySqli) {
		// 			MySqliDb::testConnection($host,$name,$user,$pwd,$port) ;
        //             $clsUpdateDabatase = new UpdateDatabaseClass(new MySqliDb($host, $name,$user,$pwd,$port));
		// 		} else {
		// 			MsSqlDb::testConnection($host,$name,$user,$pwd,$port) ;
        //             $clsUpdateDabatase = new UpdateDatabaseClass(new MsSqlDb($host, $name,$user,$pwd,$port));
		// 		}

        //         $all_clear = true ;
		// 		$db =  new MsSqlDb($host, $name,$user,$pwd,$port);

		// 		$sql_query = "";

		// 		$db->open() ;

		// 		$cls = new BusinessUnitClass($db);

		// 		$filter= '';
		// 		if(trim($dbbu) != '')
		// 			$filter = BusinessUnitTable::C_CODE . " = '" . $dbbu ."'";

		// 		$rows = $cls->getTable($filter) ;
		// 		//Log::write($rows );
		// 		$sql_query_table ="";

		// 		$sql_query_table .= $clsUpdateDabatase->processBackupGlobalDatabase();

		// 		if(!is_null($rows) && count($rows)>0){
					
		// 			foreach ($rows as $i => $row) {
		// 				$_SESSION[SE_BU] = $row[BusinessUnitTable::C_CODE];
		// 				$sql_query_table .= $clsUpdateDabatase->processBackupLocalDatabase();
		// 				if ($sql_query_table == ""){
		// 					$all_clear = false ;
		// 				} 
		// 			}
		// 		}
		// 		//Log::write($sql_query_table);

        //         if ($all_clear){
        //             $mesg = "Successful in updating database.";
        //         } else {
        //             $mesg = "Cannot process backup request.";
        //         }
		// 		$db->close() ;

		// 		if(file_exists($filename)){
		// 			unlink($filename);
		// 		}
		// 		$myfile = fopen($filename, "w") or die("Unable to open file!");
		// 		fwrite($myfile, $sql_query .$sql_query_table);
		// 		fclose($myfile);

		// 		$status = Status::Ok ;
		// 	} catch (Exception $e) {
		// 		$status = Status::Error ;
		// 		$mesg = $e->getMessage() ;
		// 	}
		// }
		//echo $mesg ;

	
	//}
	private function processBackup($params) {
		// Log::write($params);
		if(!file_exists(PATH_DATABASE_BACKUP)){
			mkdir(PATH_DATABASE_BACKUP);
		}

		$output = null;
		$retval = null;
		$filename = PATH_DATABASE_BACKUP . $params['backupfilename'] . ".bak";

		//filename update
		$dt = new DateTime();
		$filename = str_replace("[DATE]", $dt->format('Y-m-d'), $filename);
		$filename = str_replace("[TIME]", $dt->format('H-i-s'), $filename);
		$filename = str_replace("[DBNAME]", $params['dbname'], $filename);

		if(file_exists($filename)){
			unlink($filename);
		}

		$pwd = Util::decryptData($this->getParam($params,'dbpwd',""),$_SESSION['key']) ;
		$query = 'BACKUP DATABASE ' . $params['dbname'] . ' TO DISK = \'' . $filename . '\'';
		$cmd = 'sqlcmd -S "' . $params['server'] . '" -Q "' . $query . '" -U ' . $params['dbuser'] . ' -P ' . $pwd . ' 2>&1';
		//$cmd = "dir";

		//$output2 = shell_exec($cmd);
		$res = exec($cmd, $output, $retval);
		Log::write($cmd);
		Log::write($output);
		//Log::write($output2);


		$files = scandir(PATH_DATABASE_BACKUP);
		$this->sendJsonResponse(Status::Ok,"Backup database has been successfully processed.",$files,$this->type) ;
	}

	private function getRestoreFiles(){
		if(!file_exists(PATH_DATABASE_BACKUP)){
			mkdir(PATH_DATABASE_BACKUP);
		}
		$arr = array() ;
		$files = scandir(PATH_DATABASE_BACKUP);

		$arr[] = array('code' => '0', 'desc' => '-- Select file --');
		foreach($files as $file){
			if($file != "." && $file != ".."){
				$arr[] = array ('code'=>$file,'desc'=>$file );
			}
		}
		return Util::createOptionValue($arr) ;
	}
	private function getBuBackup(){
	
	

		try {
			$arr = array() ;
			$config = new ConfigDb(PATH_CODE . 'db.xml') ;
			$config->loadConfig() ;
	
			$db =  new MsSqlDb($config->getHost(),$config->getDbName(),$config->getUserName(),$config->getPassword(),$config->getPortNo());
	
			$db->open() ;

			$cls = new BusinessUnitClass($db);
			
			$rows = $cls->getTable() ;
			$sql_query_table ="";
			if(!is_null($rows) && count($rows)>0){
				foreach ($rows as $i => $row) {
				
					$arr[] = array ('code'=>$row[BusinessUnitTable::C_CODE],'desc'=>$row[BusinessUnitTable::C_CODE]);
				}
			}
		
			$db->close() ;
			return Util::createOptionValue($arr) ;

		} catch (\Exception $e) {
			$arr = array() ;
			return Util::createOptionValue($arr) ;
		}
		
	}
}
?>
