<?php
include('views/_header.tpl.php');
?>

<style>
	body { background:#f9f9f9; }
	.spacer { padding-top:45px; }
	#mmen { display:none; }
    .form-profile { padding:20px; }
    table { background:#fff; }
    p, td { font-weight:200; }
    table td { padding: 5px; } 
    
	.admintable td,
	.admintable th {
		padding: 10px;
		border: solid #eee 1px;
		text-align: center;
		font-size:17px;
	}
	
	.btn {
		font-weight: 300;
		padding: 15px 25px;
		font-size: 15px;
		border-radius: 50px;
	-moz-border-radius: 50px;
	-webkit-border-radius: 50px;
	}
	.admintable td {
		font-size: 17px;
		font-weight: 300;
	}

	.admintable th {
		font-size: 17px;
		font-weight: 600;
		text-transform: uppercase;
		padding: 7px !important;
		color: #aaa;
	}

	.dropbtn {
		/*background-color: #db5444;
		color: white;
		margin: 5px 5px 5px 5px;
		width: 190px;
		min-width:190px;
		font-size: 17px;
		padding: 15px 15px;
		border: none;
		cursor: pointer;
		font-weight:300;
		border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px;*/
	}

	.dropbtn:hover,
	.dropbtn:focus {
		/*background-color: #2980B9;*/
	}

	.dropdown {
		/*position: relative;*/
		display: inline-block;
	}
	.export{
		/*margin-bottom: 100px;*/
		/* border-radius: 15px;*/
	}
	.dropdown-content {
		display: none;
		position: absolute;
		background-color: #f1f1f1;
		min-width: 160px;
		overflow: visible;
		box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
		z-index: 1;
	}

	.dropdown-content a {
		color: black;
		padding: 8px 16px;
		text-decoration: none;
		width: 100%;
		display: block;
		text-align: left !important;
	}

	.dropdown a:hover {
		background-color: #ddd;
	}

	.show {
		display: block;
	}
	/**
	*
	* @var SEARCH BAR
	*
	*/
	.searching {
		display: flex;
		flex-direction: row;
		margin: 10px 0px;
		justify-content: start;
		gap: 10px;
		align-items: center;
	}

	.search {
		padding: 10px;
	}

	.submit {
		background-color: #005493;
	}
	.ut-header{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}
	.export_buttons a {
		float: left;
		display: inline-block;
		padding: 15px 25px;
		background: #efefef;
		color: #555;
		font-size: 14px;
		font-weight: 300;
		text-align: center;
		margin-right: 1px;
	}
	.export_buttons a:hover {
		background: #bbb;
		color: #fff;'
	}
	
/* ######################################################### */
/*                        MOBILE STYLES                      */
/* ######################################################### */

/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 979px) {
        .form-profile {
            padding: 20px 0px;
            width: 85%;
        }        
}

/* Landscape phone to portrait tablet */
@media (max-width: 767px) {

}

/* Landscape phones and down */
@media (max-width: 586px) {
	.spacer { padding-top:55px; }
	.form-profile { padding-top:0px; }	
	.tablescroll { height: 500px; overflow-x:scroll; }
	.blockit { width:100%; display:block; background:none;  text-align:center; margin-bottom:10px; }
	.blockithalf { float:left; width:50%; display:inline-block; background:none; text-align:center; margin-bottom:10px; 
	-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }	
	.right { padding-right:0px; }
	.viewall { margin-left:0px; }
}

/* Landscape phones and down */
@media (max-width: 480px) {
	.spacer { padding-top:15px; }
	.form-profile { padding-top:0px; }
	.tablescroll { height: 500px; overflow-x:scroll; }
	.blockit { width:100%; display:block; background:none; text-align:center; margin-bottom:10px; }	
	.blockithalf { float:left; width:50%; display:inline-block; background:none; text-align:center; margin-bottom:10px; 
	-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
	.right { padding-right:0px; }
	.viewall { margin-left:0px; }
}    

@media (max-width: 320px) {
	.tablescroll { height: 300px; overflow-x:scroll; }
}    	
</style>

<?php
if ($_SESSION['user']['id'] == 4) { ?>
<?php } else { ?>
<?php } ?>


<div class="form form-profile aif" style='width:auto'>

	<h1 style="text-align:center;">
		<a href="/admin/dash">
			<i class="fa fa-sliders" aria-hidden="true" style=""></i></a>&nbsp; Cards
		<a href="/admin/submissions"><img src="/static/client/scroll_hands.png" style="height:30px;" alt="<>" /></a>
	</h1>

	<div class="tablescroll" style="background:#fff;">
		<table class="admintable" style="width:100%; overflow:hidden;">
		<!--<table class="admintable" style="margin:10px; width:98%;">-->
			<tr>
				<th width="50" style="text-align: center;">Order ID#</th>
				<th width="100" style="text-align: left;">Brand</th>
				<th width="135" style="text-align: left; max-width:115px;">Card No</th>
				<th width="40" style="text-align: center;">CVV</th>
				<th width="60">EXP</th>
				<th width="60">Zip</th>
				<th width="60">Cust ID</th>
				<th width="100">Signature</th>
				<th width="100">Date</th>
				<!--<th width=80">Actions</th>-->
			</tr>
			<?php
			// Add Address, Legal Guardian and Gender
			require("config/settings.php");
			require("config/encrypt.php");
			foreach ($submissions as $sub) {	
				
				$sub["order_no"] = Security::aescbc_decrypt($sub["order_no"], $enckey);
				$sub["brand"] = Security::aescbc_decrypt($sub["brand"], $enckey);
				$sub["card_no"] = Security::aescbc_decrypt($sub["card_no"], $enckey);
				$sub["cvv"] = Security::aescbc_decrypt($sub["cvv"], $enckey);
				$sub["expiration"] = Security::aescbc_decrypt($sub["expiration"], $enckey);
				$sub["zip"] = Security::aescbc_decrypt($sub["zip"], $enckey);
				$sub["customer_id"] = Security::aescbc_decrypt($sub["customer_id"], $enckey);
				$sub["signature_name"] = Security::aescbc_decrypt($sub["signature_name"], $enckey);
				
				$card_number = join(" ", str_split($sub["card_no"], 4));
				
				echo "<tr>
				<td style='padding:10px;'>{$sub['order_no']}</td>
				<td style='padding:10px; text-transform:uppercase; text-align: left; font-size:14px;'>{$sub['brand']}</td>
				<td style='padding:10px;'>{$card_number}</td>
				<td style='padding:10px;'>{$sub['cvv']}</td>
				<td style='padding:10px;'>{$sub['expiration']}</td>
				<td style='padding:10px;'>{$sub['zip']}</td>
				<td style='padding:10px;'>{$sub['customer_id']}</td>
				<td style='padding:10px;'>{$sub['signature_name']}</td>
				<td style='padding:10px; text-align:center;'>{$sub['date']}</td>
				
				<td style='padding:10px; text-align:center; display:none;'>
					<a href='/admin/?sub&edit={$sub['id']}' style='font-size:14px;'>edit</a> |
					<a href='/admin/?sub&del={$sub['id']}' class='confirm' style='font-size:14px;'>delete</a>
				</td></tr>";
			}
			?>
		</table>
	</div><!-- SCROLL DIV -->

	<div style="margin:10px;">
		<br />
		<div style="text-align:center; font-size:17px; font-weight:300; line-height:28px;">
			<a href="/forms/pay" class='btn btn-blue'>+ Add a new Card &raquo;</a>
		</div>
		
		<!--<a href='/admin/?sub&add' class='btn btn-blue' style="display:inline-block">+ Add New Card</a>-->

		<div class="clear"></div>
		<br /><br /><br /><br /><br />
	</div>
</div><!-- FORM DIV -->

<script>

</script>


<style>
	.admintable td,
	.admintable th {
		padding: 3px;
		border: solid #eee 1px;
	}
</style>
<?php
include 'views/_footer.tpl.php';
?>