<?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
	}
}

///////////////////////////////////////////////////////////////////
			if(isset($_POST['addcashback'])) {
				$paymail = $_POST['paymail'];
				$gateway = $_POST['gateway'];
				$amount = $_POST['amount'];
				if($gateway == '1') {
					$edit = mysql_query("UPDATE Accounts_Premium_Payments SET paypal_cashbackverified=paypal_cashbackverified + '$amount' WHERE ppemail='$paymail'");
				}
				if($gateway == '2') {
					$edit = mysql_query("UPDATE Accounts_Premium_Payments SET payza_cashbackverified=payza_cashbackverified + '$amount' WHERE pzemail='$paymail'");					
				}
				if($gateway == '5') {
					$edit = mysql_query("UPDATE Accounts_Premium_Payments SET skrill_cashbackverified=skrill_cashbackverified + '$amount' WHERE skrillemail='$paymail'");
				}	
				?>
					<div style="margin-top: -80px;" class="alert alert-success" role="alert">
						<strong>Well done!</strong> Withdraw edited
					</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/Active is: Admin Account
			</small>
		</h1>
 	 </div>
 	 </br>
	<div class="row">
      <div class="col-md-8 col-md-offset-2">
        <div class="well">
			<div class="row">
				<center>
				<form name="csrf_form" id="campaignform" action="" method="POST">
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<input class="form-control" placeholder="Payment Email" name="paymail" type="text">
								<input value="Add" class="btn btn-default" style="width: 150px;" name="addcashback" type="submit">
							</span>	
							</center>				
					</div>
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<center>
							<span class="input-group-btn">
								<div class="form-group has-success">
										<div class="input-group">
               						<span class="input-group-addon">Gateway:</span>
               						<input id="hm1" class="toggle toggle-left" name="gateway" value="1" checked="" type="radio"><label style="min-width:30.2%;width:auto" class="btn btn-default" for="hm1">Paypal</label>
											<input id="hm2" class="toggle toggle-right" name="gateway" value="2" type="radio"><label style="min-width:30.2%;width:auto" class="btn btn-default" for="hm2">Payza</label>
											<input id="hm3" class="toggle toggle-right" name="gateway" value="5" type="radio"><label style="min-width:30.2%;width:auto" class="btn btn-default" for="hm3">Skrill</label>
           							</div>
								</div>
								<input class="form-control" placeholder="Received amount" name="amount" type="text">
							</span>	
							</center>				
					</div>
					<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
				</form>
				</br>
				</center>
			</div>
        </div>
      </div>
    </div>
   <div class="text-center">
      <h1><small>Payments Managers</small></h1>
 	</div>
		<div class="col-sm-12">
          <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;'>#</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Username</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>PayPal Email</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Payza Email</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Skrill Email</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>PayPal CashBack</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Payza CashBack</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Skrill CashBack</th>
											</tr>
										</thead>
<?php
	$query = "SELECT * FROM Accounts_Premium_Payments ORDER BY id ASC";
	$result = mysql_query($query) or die('Error, query failed');
	if(mysql_num_rows($result)<1){
  		?>
			<tr>
				<td>0 Payment Managers</td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
   	<?php
   }else{
   	while($row = mysql_fetch_array($result))
				{
					$ida = $row['id'];
					$paypal_cashback = $row['paypal_cashback'];
					$paypal_cashbackverified = $row['paypal_cashbackverified'];
					$payza_cashback = $row['payza_cashback'];
					$payza_cashbackverified = $row['payza_cashbackverified'];
					$skrill_cashback = $row['skrill_cashback'];
					$skrill_cashbackverified = $row['skrill_cashbackverified'];
					$paypalrow = $paypal_cashback - $paypal_cashbackverified;
					$payzarow = $payza_cashback - $payza_cashbackverified;
					$skrillrow = $skrill_cashback - $skrill_cashbackverified;
					if($paypalrow > 0) {
						$hexpp = '#D9534F';
					}else {
						$hexpp = '#5CB85C';
					}
					if($payzarow > 0) {
						$hexpz = '#D9534F';
					}else {
						$hexpz = '#5CB85C';
					}
					if($skrillrow > 0) {
						$hexsk = '#D9534F';
					}else {
						$hexsk = '#5CB85C';
					}
							$numberoflink = $numberoflink + 1;
							?>
										<tr>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $numberoflink; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['username']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['ppemail']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['pzemail']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['skrillemail']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: <?php echo $hexpp;?>;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $paypalrow; ?></h5>
											</td>
											<td style='color: #FFF; background-color: <?php echo $hexpz;?>;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $payzarow; ?></h5>
											</td>
											<td style='color: #FFF; background-color: <?php echo $hexsk;?>;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $skrillrow; ?></h5>
											</td>
										</tr>
							<?php
	}//
}//
?>
									</table>
        </div>
        
</div>

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