<?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'>
										<span class="label label-success">Payout Rate [to Publishers - 1 view]</span>
										<span class="label label-warning">Cost Rate [to Advertisers - 1 view]</span>
										<span class="label">Revenue</span>
										<span class="label label-success">Interstitial</span>
										<span class="label label-warning">Video</span>
										<span class="label">Banner</span>
										<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;'>Region</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Interstitial</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Video</th>
																<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Banner</th>
                                            </tr>
                                        </thead>
										<tbody>
<?php
if(mysql_real_escape_string($_POST['changesettings'])) {
	$query = "SELECT * FROM Web_Countries";
	$result = mysql_query($query) or die('Error, query failed');
	while($row = mysql_fetch_array($result)){
		$actual = $row['id'];
		$ppvvalue = mysql_real_escape_string($_POST['priceppv']);
		if(!empty($ppvvalue)) {
			mysql_query("UPDATE Web_Countries SET ppv='$ppvvalue' WHERE id='$actual'");
		}
		$ppvvideo = mysql_real_escape_string($_POST['priceppvvideo']);
		if(!empty($ppvvideo)) {
			mysql_query("UPDATE Web_Countries SET ppvvideo='$ppvvideo' WHERE id='$actual'");
		}
		$ppvbvalue = mysql_real_escape_string($_POST['priceppvb']);
		if(!empty($ppvbvalue)) {
			mysql_query("UPDATE Web_Countries SET ppvb='$ppvbvalue' WHERE id='$actual'");
		}
		$ppvadv = mysql_real_escape_string($_POST['priceppvadv']);
		if(!empty($ppvadv)) {
			mysql_query("UPDATE Web_Countries SET ppvadv='$ppvadv' WHERE id='$actual'");
		}
		$cpvvideo = mysql_real_escape_string($_POST['pricecpvvideo']);
		if(!empty($cpvvideo)) {
			mysql_query("UPDATE Web_Countries SET cpvvideo='$cpvvideo' WHERE id='$actual'");
		}
		$ppvbadv = mysql_real_escape_string($_POST['priceppvbadv']);
		if(!empty($ppvbadv)) {
			mysql_query("UPDATE Web_Countries SET ppvbadv='$ppvbadv' WHERE id='$actual'");
		}
	}
	
echo"<p><div class='alert alert-success alert-dismissable'>
                                    Prices was saved
                                </div>";
}

echo "
   <tr>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
				<center>
					<b>All countries</b></br>
				</center>
			</td> 
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<div class='form-group has-success'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='priceppv' class='form-control'/>
				</div>
				<div class='form-group has-warning'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='priceppvadv' class='form-control'/>
				</div>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<div class='form-group has-success'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='priceppvvideo' class='form-control'/>
				</div>
				<div class='form-group has-warning'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='pricecpvvideo' class='form-control'/>
				</div>
			</td>
			<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'> 
				<div class='form-group has-success'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='priceppvb' class='form-control'/>
				</div>
				<div class='form-group has-warning'>
					<span class='input-group-addon'>{$acu['ISO']}</span>
					<input type='text' name='priceppvbadv' class='form-control'/>
				</div>
			</td>
	</tr>";


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

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

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