<?php
define('USERNAME_REQUIRED', TRUE);
define('ACCOUNT_REQUIRED', TRUE);
include("../global.php");
$username = $core->EscapeString($_SESSION['username']);
if(!$users->UserPermission('hk_basics', $username))
{
header("Location: nopermission.php");
die;
}
?>
<script language="javascript">
	$('.tooltip').tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    showBody: " - ", 
	    fade: 250 
	});

	function DisplayLoad(ButtonID) {
		$('button#' + ButtonID).attr('disabled', 'disabled');
	}

	function SubmitGeneral() {
		$('button#General').attr('disabled', 'disabled');
		$.ajax({
		   type: "POST",
		   url: "functions/basics_update_general.php",
		   data: "cms_url=" + $('#cms_url').val() + "&cms_name=" + $('#cms_name').val() + "&maintenance=" + $('#maintenance').val(),
		   success: function(){
		    $('button#General').html('Updated!')
		     .delay(1200)
		     .queue(function(n) {
        	 	$('button#General').html('Update');
        	 	$('button#General').removeAttr("disabled");
        	 	n();
        	 })
		   }
		 });
	}

	function SubmitClient() {
		$('button#Client').html('Updating...');
		$('button#Client').attr('disabled', 'disabled');
		$.ajax({
		   type: "POST",
		   url: "functions/basics_update_client.php",
		   data: "client_ip=" + $('#client_ip').val() + "&client_port=" + $('#client_port').val() + "&client_mus=" + $('#client_mus').val() + "&client_texts=" + $('#client_texts').val() + "&client_variables=" + $('#client_variables').val() + "&client_swf_path=" + $('#swf_path').val() + "&client_habbo_swf=" + $('#habbo_swf').val(),
		   success: function(){
		    $('button#Client').html('Updated!')
		     .delay(1200)
		     .queue(function(n) {
        	 	$('button#Client').html('Update');
        	 	$('button#Client').removeAttr("disabled");
        	 	n();
        	 })
		   }
		 });
	}

	function SubmitHotel() {
		$('button#Hotel').html('Updating...');
		$('button#Hotel').attr('disabled', 'disabled');
		$.ajax({
		   type: "POST",
		   url: "functions/basics_update_hotel.php",
		   data: "timer=" + $('#timer').val() + "&pixels=" + $('#pixels').val() + "&credits=" + $('#credits').val() + "&motd=" + $('#motd').val(),
		   success: function(){
		    $('button#Hotel').html('Updated!')
		     .delay(1200)
		     .queue(function(n) {
        	 	$('button#Hotel').html('Update');
        	 	$('button#Hotel').removeAttr("disabled");
        	 	n();
        	 })
		   }
		 });
	}
</script>
<div>
	<h1>Basics</h1>
	<div class="formPiece">
		<div>
			<h3>General</h3>
		</div>
		<div>
			<img src="img/info_16.png" class="tooltip" title="Hotel Name - " />
			<label for="cms_name">Hotel Name: </label><input type="text" value="<?php echo $core->CmsSetting('cms_name'); ?>" name="cms_name" id="cms_name" /><br />
			
			<img src="img/info_16.png" class="tooltip" title="Website URL - The url to your websites root directory" />
			<label for="cms_url">CMS URL: </label><input type="text" value="<?php echo $core->CmsSetting('cms_url'); ?>" name="cms_url" id="cms_url" /><br />
            
            <img src="img/info_16.png" class="tooltip" title="Maintenance" />
			<label for="cms_url">Maintenance: </label><select name="maintenance" id="maintenance"><option value="true" <?php if($core->CmsSetting('maintenance') == 'true') echo 'selected'; ?>>True</option><option value="false" <?php if($core->CmsSetting('maintenance') == 'false') echo 'selected'; ?>>False</option></select><br />
	
			<button id="General" onClick="SubmitGeneral();">Update</button>
		</div>
	</div>
	<div class="formPiece">
		<div>
			<h3>Client</h3>
		</div>
		
		<div>
			<div class="infobox infobox_info">The hotel may need to reboot for these settings to update</div><br /><br />

			<img src="img/info_16.png" class="tooltip" title="IP Address - The IP address to your hotel emulator" />
			<label for="client_ip">IP Address: </label><input type="text" value="<?php echo $core->CmsSetting('client_ip'); ?>" name="client_ip" id="client_ip" /><br />

			<img src="img/info_16.png" class="tooltip" title="Port - The port that your emulator is running on" />
			<label for="client_port">Port: </label><input type="text" value="<?php echo $core->CmsSetting('client_port'); ?>" name="client_port" id="client_port" /><br />

			<img src="img/info_16.png" class="tooltip" title="MUS Port - The port that your emulators MUS is running on" />
			<label for="client_mus">MUS Port: </label><input type="text" value="<?php echo $core->CmsSetting('client_mus'); ?>" name="client_mus" id="client_mus" /><br />

			<img src="img/info_16.png" class="tooltip" title="External Texts - The url to your external texts" />
			<label for="client_texts">External Texts: </label><input type="text" value="<?php echo $core->CmsSetting('client_texts'); ?>" name="client_texts" id="client_texts" /><br />

			<img src="img/info_16.png" class="tooltip" title="External Variables - The url to your external variables" />
			<label for="client_variables">External Variables: </label><input type="text" value="<?php echo $core->CmsSetting('client_variables'); ?>" name="client_variables" id="client_variables" /><br />
            
            <img src="img/info_16.png" class="tooltip" title="SWF Path - The url to your SWF Path" />
			<label for="swf_path">SWF Path: </label><input type="text" value="<?php echo $core->CmsSetting('client_swf_path'); ?>" name="swf_path" id="swf_path" /><br />
            
            <img src="img/info_16.png" class="tooltip" title="Habbo SWF - The url to your Habbo SWF" />
			<label for="habbo_swf">Habbo SWF: </label><input type="text" value="<?php echo $core->CmsSetting('client_habbo_swf'); ?>" name="habbo_swf" id="habbo_swf" /><br />

			<button id="Client" onClick="SubmitClient();">Update</button>
		</div>
	</div>
	<div class="formPiece">
		<div>
			<h3>Hotel</h3>
		</div>
		
		<div>
			<div class="infobox infobox_info">The hotel may need to reboot for these settings to update</div><br /><br />

			<img src="img/info_16.png" class="tooltip" title="Message of the Day - The message shown to users when the log into the hotel" />
			<label for="motd">Message of the Day: </label><input type="text" value="<?php echo $core->ServerSetting('motd'); ?>" name="motd" id="motd" /><br />

			<img src="img/info_16.png" class="tooltip" title="Timer - The time, in minutes, between each server tick" />
			<label for="timer">Timer: </label><input type="text" value="<?php echo $core->ServerSetting('timer'); ?>" name="timer" id="timer" /><br />

			<img src="img/info_16.png" class="tooltip" title="Credits - This is the number of credits users are given every time the server timer ticks" />
			<label for="credits">Credits: </label><input type="text" value="<?php echo $core->ServerSetting('credits'); ?>" name="credits" id="credits" /><br />

			<img src="img/info_16.png" class="tooltip" title="Pixels - This is the number of pixels users are given every time the server timer ticks" />
			<label for="pixels">Pixels: </label><input type="text" value="<?php echo $core->ServerSetting('pixels'); ?>" name="pixels" id="pixels" /><br />

			<button id="Hotel" onClick="SubmitHotel();">Update</button>
		</div>
	</div>
</div>