<?php
	/**
	* @package DTC
	* @todo internationalization some text's
	* @version  $Id: reseller.php,v 1.3 2006/05/08 10:24:48 seeb Exp $
	* 
	**/
//////////////////////////////////////
// Database management for one user //
//////////////////////////////////////
// Todo : add a button for creating a MySql databe for one user
// and add credential to it !
function drawReseller($admin){
	global $lang;
	global $txt_draw_tatabase_your_list;
	global $conf_mysql_db;
	global $adm_login;
	global $adm_pass;
	global $pro_mysql_admin_table;

	global $txt_draw_database_chpass;
	global $txt_password;
	global $txt_your_child_accounts;
	global $txt_action;
	
	global $conf_demo_version;

	$hidden = "<input type=\"hidden\" name=\"adm_login\" value=\"$adm_login\">
		<input type=\"hidden\" name=\"addrlink\" value=\"".$_REQUEST["addrlink"]."\">
		<input type=\"hidden\" name=\"adm_pass\" value=\"$adm_pass\">";

	$out = "<b><u>".$txt_your_child_accounts[$lang]."</u></b>";
	$out .= "<table>
	<tr><td>Login</td><td>".$txt_password[$lang]."</td><td>".$txt_action[$lang]."</td></tr>";
	if($admin["info"]["ob_head"] != ""){
		$next_adm = $admin["info"]["ob_head"];
		while($next_adm != $adm_login){
			$q = "SELECT * FROM $pro_mysql_admin_table WHERE adm_login='$next_adm';";
			$r = mysql_query($q)or die("Cannot query $q line ".__LINE__." file ".__FILE__." sql said ".mysql_error());
			$n = mysql_num_rows($r);
			if($n != 1)	die("Could not fetch one of the child accounts !!!");
			$a = mysql_fetch_array($r);
			$next_adm = $a["ob_next"];
			$out .= "<tr><td><form action=\"".$_SERVER["PHP_SELF"]."\">$hidden
			<input type=\"hidden\" name=\"action\" value=\"change_child_account_values\">
			<input type=\"hidden\" name=\"account_name\" value=\"".$a["adm_login"]."\">".$a["adm_login"]."</td>
			<td><input type=\"text\" name=\"new_adm_pass\" value=\"\"></td><td><input type=\"submit\" value=\"Save\"></form>
			<form action=\"".$_SERVER["PHP_SELF"]."\">$hidden
			<input type=\"hidden\" name=\"action\" value=\"delete_child_account\">
			<input type=\"hidden\" name=\"account_name\" value=\"".$a["adm_login"]."\"><input type=\"submit\" value=\"Del\"></form></td></tr>";
		}
//		TMDselectTables("treeindex",$pro_mysql_admin_table,"childrens");
	}
	$out .= "<tr><td><form action=\"".$_SERVER["PHP_SELF"]."\">
	$hidden<input type=\"hidden\" name=\"action\" value=\"add_child_account\">
	<input type=\"text\" name=\"new_adm_login\" value=\"\"></td>
	<td><input type=\"text\" name=\"new_adm_pass\" value=\"\"></td>
	<td><input type=\"submit\" value=\"Create\"></form></td></tr></table>";
	return $out;
}

?>
