<?php
/**
 * view_db_settings.php - Page to ask for DB username and password
 *
 * @author $Author: dtong $
 * @version $Id: view_db_settings.php,v 1.2 2011/02/09 12:24:47 dtong Exp $
 * @copyright Copyright (c) 2011, Tiller Software Co., Ltd.
*/
if (!defined('INSTALL_PROCESS')) exit('No direct script access allowed');
$json_data = rawurlencode(json_encode($data));
?>
<center>
<form method="post" name="install_form">
	<input type="hidden" name="cmd" value="<?php echo CMD_DB_SETTINGS_HANDLE?>" />
	<input type="hidden" name="data" value="<?php echo $json_data?>" />
	<fieldset style="width:600px"><legend>MySQL Database Settings (Step 2 of <?php echo TOTAL_STEPS?>)</legend>
	<?php if ( $data->db_root_password_valid ) { ?>
	<p style="color:red">MySQL root access obtained. Please continue...</p>
	<?php } ?>
		<p class="notice" style="margin:10px">This can be an existing MySQL account or a new account to be created.</p>

		<div>
			<label class="red_text">DB Username:</label>
			<input class="text_box" type="text" name="username" value="<?php echo @$data->db_username?>" />
			<span id="area" class="text error" ><?php echo @$error->username_error?></span>
		</div>
		<div>
			<label class="red_text">DB Password:</label>
			<input class="text_box" type="password" id="password" name="password"
					 value="<?php echo @$data->db_password?>" />
			<span class="text error" id="area"><?php echo @$error->password_error?></span></div>
		<div>
			<label></label>
			<input class="left" type="checkbox" onclick="return toggle_password('password', this.checked)"
					 style="background-color:white;" />
			<span class="left" style="font-size: 85%; display: block; margin-top: 2px; margin-left: 2px;">Show password</span>
		</div>
		<div>
			<label class="red_text">DB Schema Name:</label>
			<input class="text_box" type="text" name="schema" value="<?php echo @$data->db_schema?>" />
			<span class="text error" id="area"><?php echo @$error->schema_error?></span>
		</div>
		<div>
			<label class="red_text">DB Host:</label>
			<input class="text_box" type="text" name="host" value="<?php echo @$data->db_host?>" />
			<span class="text error" id="area"><?php echo @$error->host_error?></span>
		</div>
		<div>
			<span class="text error" id="area" style="font-size:14px;"><?php echo @$error->error?></span>
		</div>
		<?php if (isset($error->show_root_msg) && $error->show_root_msg) { ?>
			<div>
				<span class="text error" id="area" style="font-size:14px;">
					Failed to connect database. Please correct your settings and try again.
					<br/><br/>OR<br /><br />
					If you have the MySQL root password and you would like to create a new database schema and/or a new
					database user account then please
					<a href="" onClick="install_form.cmd.value='<?php echo CMD_DB_ASKROOT?>';install_form.submit();return false" style="font-size:14px;" >click here</a>.
				</span>
			</div>
		<?php } ?>
		<div style="text-align:left;font-size:10px;padding-top:20px">
			If you create the database/schema yourself then it is required to use the "utf8" character set and the "utf8_general_ci"
			collation for your database if you plan to store data in languages other than English.
			If you are not sure then please do not create the database/schema yourself and supply the MySQL root password
			(URL link to root password entry offered in the next step) so
			the installation will assign the character set and collation properly for you.
		</div>
	</fieldset>

	<div style="margin-top:30px">
		<input type="submit" name="previous" value="Previous" class="btn"
						 onmouseout="if(this.className) this.className='btn';"
						 onmouseover="if(this.className) this.className='btnhov';"
						 onClick="install_form.cmd.value='<?php echo CMD_CHECK_REQUIREMENTS?>'; install_form.submit();return false;" />
		<input type="submit" name="next" value="Next" class="btn"
				 onmouseout="if(this.className) this.className='btn';"
				 onmouseover="if(this.className) this.className='btnhov';" />
	</div>
</form>
</center>