<?php
	$path="../../";
	include("../../map.php");
	include("script.php"); 
	$balances = file_get_contents(__DIR__.'/datas/balances.json');
	$result = json_decode($balances, true);
	$total_try=0; $total_usd=0; $total_eur=0;
	foreach($result as $key=>$value){
		if ($value["currency"]=="TRY"){ $total_try = $total_try + $value["balance"]; }
		if ($value["currency"]=="USD"){ $total_usd = $total_usd + $value["balance"]; }
		if ($value["currency"]=="EUR"){ $total_eur = $total_eur + $value["balance"]; }
	}
?>
<div class="mt10">
	<div class="v3-col-md-4 bank_list">
		<section class="card card-featured-left card-featured-secondary">
			<div class="card-body">
				<div class="widget-summary">
					<div class="widget-summary-col widget-summary-col-icon">
						<div class="summary-icon">
							<i class="fa fa-try" style=""></i>
						</div>
					</div>
					<div class="widget-summary-col">
						<div class="summary">
							<h4 class="title"><?php echo ctranslate("#TL Varlıklarım"); ?></h4>
							<div class="info">
								<strong class="amount"><?php echo number_format(($total_try),2,',','.');?> <i class="fa fa-try" style=""></i></strong>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
	<div class="v3-col-md-4 bank_list">
		<section class="card card-featured-left card-featured-secondary">
			<div class="card-body">
				<div class="widget-summary">
					<div class="widget-summary-col widget-summary-col-icon">
						<div class="summary-icon">
							<i class="fa fa-eur" style=""></i>
						</div>
					</div>
					<div class="widget-summary-col">
						<div class="summary">
							<h4 class="title"><?php echo ctranslate("#EUR Varlıklarım"); ?></h4>
							<div class="info">
								<strong class="amount"><?php echo number_format(($total_eur),2,',','.');?> <i class="fa fa-eur" style=""></i></strong>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
	<div class="v3-col-md-4 bank_list">
		<section class="card card-featured-left card-featured-secondary">
			<div class="card-body">
				<div class="widget-summary">
					<div class="widget-summary-col widget-summary-col-icon">
						<div class="summary-icon">
							<i class="fa fa-usd" style=""></i>
						</div>
					</div>
					<div class="widget-summary-col">
						<div class="summary">
							<h4 class="title"><?php echo ctranslate("#USD Varlıklarım"); ?></h4>
							<div class="info">
								<strong class="amount"><?php echo number_format(($total_usd),2,',','.');?> <i class="fa fa-usd" style=""></i></strong>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
</div>
<div class="table_div mdn">
<table class="table bank_table">
	<tbody>
<?php
	$sqllb=mysqli_query($conn, "select * from genel where t2='extre' order by s10 asc"); while($lbank=mysqli_fetch_assoc($sqllb)){
	foreach($result as $key=>$value){
		if($value["bankID"]==$lbank["s1"] and $value["currency"]=="TRY"){ $total_try = $total_try + $value["balance"]; }
		if($value["bankID"]==$lbank["s1"] and $value["currency"]=="USD"){ $total_usd = $total_usd + $value["balance"]; }
		if($value["bankID"]==$lbank["s1"] and $value["currency"]=="EUR"){ $total_eur = $total_eur + $value["balance"]; }
	}	
?>
	<tr data-id="<?php echo $i;?>" class="bank_column">
		<td style="text-align:center; display: grid;"><span class="daytd"><?php echo date("d");?></span><span class="datetd"><?php echo dtarih(date("Y-m"),"ua yyyy");?></span><span class="timetd"><?php echo $time; ?></span></td>
		<td style="text-align:center; vertical-align: middle;"><img src="https://cdn.crmplus.com.tr/images/banks/b<?php echo $lbank["s1"]?>.png" title="<?php echo ihb($lbank["n4"])?>" style="max-height: 65px;"></td>
		<td style="text-align:right; vertical-align: middle; font-weight: 700 !important;"><?php echo number_format(($total_try),2,',','.');?></span> <i class="fa fa-try" style=""></i></td>
		<td style="text-align:right; vertical-align: middle; font-weight: 700 !important;"> <span class="count" style="font-size:15px !important;"><?php echo number_format(($total_eur),2,',','.');?> </span><i class="fa fa-eur" style=""></i></td>
		<td style="text-align:right; vertical-align: middle; font-weight: 700 !important;"> <span class="count" style="font-size:15px !important;"><?php echo number_format(($total_usd),2,',','.');?></span> <i class="fa fa-usd" style=""></i></td>
	</tr>
<?php $total_try=0; $total_usd=0; $total_eur=0;}?>
	</tbody>	
</table>
</div>