<?php
// INCLUDE HEADER IN PAGE
include('other_header.php');
// GET CURRENT DATE AND TIME
$date = date('Y-m-d H:i:s');
if(isset($_POST['success'])) {
	if($_POST['success'] == 'loggedin') {
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong>Well done!</strong> Successfully logged in.
	</div>
	<?php
	}
}
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/Active is: Admin Account
			</small>
		</h1>
 	 </div>
 	 </br>
 	 <div class="panel panel-default">
									<div class="panel-body">
									<form method='post'>
										<input style="margin-left: 90%;" type='submit' name='changesettings' value='Change' class='btn btn-primary'></br>
									<table class="table table-bordered" style="width:100%;max-width:100%"  data-effect="fade">
                                        <thead>
                                            <tr>
                                              	<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Device</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>FrontEnd</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Admin</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>AD Loader</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>User Panel</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Support Panel</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Payments Panel</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Widget</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Premium Login</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Email</th>
                                            </tr>
                                        </thead>
										<tbody>
<?php
if(mysql_real_escape_string($_POST['changesettings'])) {
	$query = "SELECT * FROM Web_Set_Templates";
	$result = mysql_query($query) or die('Error, query failed');
	while($row = mysql_fetch_array($result)){
		$actual = $row['id'];
		$frontendv = mysql_real_escape_string($_POST['frontend' . $actual . '']);
		if(!empty($frontendv)) {
			mysql_query("UPDATE Web_Set_Templates SET frontend='$frontendv' WHERE id='$actual'");
		}
		$backendv = mysql_real_escape_string($_POST['backend' . $actual . '']);
		if(!empty($backendv)) {
			mysql_query("UPDATE Web_Set_Templates SET backend='$backendv' WHERE id='$actual'");
		}
		$shortendv = mysql_real_escape_string($_POST['shortend' . $actual . '']);
		if(!empty($shortendv)) {
			mysql_query("UPDATE Web_Set_Templates SET shortend='$shortendv' WHERE id='$actual'");
		}
		$panelendv = mysql_real_escape_string($_POST['panelend' . $actual . '']);
		if(!empty($panelendv)) {
			mysql_query("UPDATE Web_Set_Templates SET panelend='$panelendv' WHERE id='$actual'");
		}
		$supportendv = mysql_real_escape_string($_POST['supportend' . $actual . '']);
		if(!empty($supportendv)) {
			mysql_query("UPDATE Web_Set_Templates SET supportend='$supportendv' WHERE id='$actual'");
		}
		$paymentsendv = mysql_real_escape_string($_POST['paymentsend' . $actual . '']);
		if(!empty($paymentsendv)) {
			mysql_query("UPDATE Web_Set_Templates SET paymentsend='$paymentsendv' WHERE id='$actual'");
		}
		$widgetendv = mysql_real_escape_string($_POST['widgetend' . $actual . '']);
		if(!empty($widgetendv)) {
			mysql_query("UPDATE Web_Set_Templates SET widgetend='$widgetendv' WHERE id='$actual'");
		}
		$premiumloginv = mysql_real_escape_string($_POST['premiumlogin' . $actual . '']);
		if(!empty($premiumloginv)) {
			mysql_query("UPDATE Web_Set_Templates SET premiumlogin='$premiumloginv' WHERE id='$actual'");
		}
		$emailendv = mysql_real_escape_string($_POST['emailend' . $actual . '']);
		if(!empty($emailendv)) {
			mysql_query("UPDATE Web_Set_Templates SET emailend='$emailendv' WHERE id='$actual'");
		}
	}
	
echo"<p><div class='alert alert-success alert-dismissable'>Templates saved</div>";
}

$query = "SELECT * FROM Web_Set_Templates";
$result = mysql_query($query) or die('Error, query failed');

// print the random numbers
while($row = mysql_fetch_array($result))
{
			?>		
			<tr>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
				<input class='btn btn-primary' type='hidden' name='id<?php echo $row['id'];?>' value='<?php echo $row['id'];?>'>
				<center>
					<b><?php echo $row['device'];?></b></br>
				</center>
			</td> 
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>		
			<select style="width:100%" class="form-control" name='frontend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['frontend']?>"><?php echo $row['frontend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE frontend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
			</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='backend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['backend']?>"><?php echo $row['backend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE backend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='shortend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['shortend']?>"><?php echo $row['shortend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE shortend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='panelend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['panelend']?>"><?php echo $row['panelend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE panelend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='supportend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['supportend']?>"><?php echo $row['supportend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE supportend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='paymentsend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['paymentsend']?>"><?php echo $row['paymentsend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE paymentsend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='widgetend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['widgetend']?>"><?php echo $row['widgetend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE widgetend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='premiumlogin<?php echo $row['id'];?>'>
				<option value="<?php echo $row['premiumlogin']?>"><?php echo $row['premiumlogin']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE premiumlogin='1'  ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<select style="width:100%" class="form-control" name='emailend<?php echo $row['id'];?>'>
				<option value="<?php echo $row['emailend']?>"><?php echo $row['emailend']?></option>
				<?php
					$countrieslist = mysql_query("SELECT * FROM Web_Themes_All WHERE emailend='1' ORDER BY id ASC");
					while($rowc = mysql_fetch_array($countrieslist)) 
					{
						echo"<option value='{$rowc['directory']}'>{$rowc['name']}</option>";
					}
				?>
				</select>
			</td>
	</tr>
	<?php
}


echo"</tbody>
</table>
</form>";

?>
                </div>
                <!-- // #main -->
                
            </div>
        </div>
</div>

<?php
include('other_footer.php');
?>
