<?php
$path="../../";
include("../../map.php");
?>
<div class="row text-center">
<?php
$order_waiting = $order_approved = $order_success = $new_clients = 0;
$ototal0 = $ototal1 = $ototal4 = 0;
$nca = [];
// 1. Bugünün tarihi
$today = date('Y-m-d');
// 2. Sipariş verilmemiş müşterileri çek
$sqlcc = mysqli_query($conn, "SELECT id, t1, t2, t4, ts1 FROM t5 ORDER BY id DESC");
$client_ids = [];
$clients = [];
while ($c = mysqli_fetch_assoc($sqlcc)) {
    $clients[$c['id']] = $c;
    if (substr($c["ts1"], 0, 10) == $today) {
        $client_ids[] = $c['id'];
    }
}
if (!empty($client_ids)) {
    // Bu ID'lere ait siparişleri al
    $ids_str = implode(',', $client_ids);
    $sqlco = mysqli_query($conn, "SELECT DISTINCT s1 FROM eticaret WHERE ne='siparis' AND s1 IN ($ids_str)");
    $siparisli_ids = [];
    while ($sip = mysqli_fetch_assoc($sqlco)) {
        $siparisli_ids[] = $sip['s1'];
    }
    foreach ($client_ids as $cid) {
        if (!in_array($cid, $siparisli_ids)) {
            $c = $clients[$cid];
            $nca[] = [ 'id' => $c["id"], 'Ad Soyad' => $c["t1"], 'Gsm' => $c["t4"], 'Tarih' => $c["ts1"] ];
            $new_clients++;
        }
    }
}
$sqls = mysqli_query($conn, "SELECT * FROM eticaret WHERE ne='siparis' AND DATE(ts1) = '$today'"); while ($siparis = mysqli_fetch_assoc($sqls)) {
    $gtoplam = 0;
    
    switch ($siparis["s4"]) {
        case 0:
            $order_waiting++;
            include("modules/ecommerce/ecommerce_order_calc.php");
            $ototal0 += $gtoplam;
            break;
        case 1:
            $order_approved++;
            include("modules/ecommerce/ecommerce_order_calc.php");
            $ototal1 += $gtoplam;
            break;
        case 4:
            $order_success++;
            include("modules/ecommerce/ecommerce_order_calc.php");
            $ototal4 += $gtoplam;
            break;
    }
}
?>
<div class="v3-col-md-3 v3-col-xs-6">
<section class="card card-featured-left card-featured-tertiary mb-3">
<div class="card-body">
	<div class="widget-summary">
		<div class="widget-summary-col widget-summary-col-icon">
			<div class="summary-icon">
				<i class="fas fa-user-plus text-warning"></i>
			</div>
		</div>
		<div class="widget-summary-col">
			<div class="summary" style="margin-top: 20px;">
				<div class="info">
					<strong class="amount digi fs50"><?php echo $new_clients;?></strong>
				</div>
			</div>
			<div class="summary-footer">
				<span style="float:left;"><?php echo ctranslate("Yeni Üye")?></span>
				<a class="text-muted text-uppercase cp" href="?ne=uye&islem=uyeler&key=&sayfa=&durum=order&order=s4+asc">(<?php echo ctranslate("İncele")?>)</a>
			</div>
		</div>
	</div>
</div>
</section>
</div>
<div class="v3-col-md-3 v3-col-xs-6">
<section class="card card-featured-left card-featured-tertiary mb-3">
<div class="card-body">
	<div class="widget-summary">
		<div class="widget-summary-col widget-summary-col-icon">
			<div class="summary-icon">
				<i class="fas fa-pause text-warning"></i>
			</div>
		</div>
		<div class="widget-summary-col">
			<div class="summary" style="margin-top: 20px;">
				<div class="info">
					<strong class="amount digi fs50"><?php echo $order_waiting;?></strong>
				</div>
			</div>
			<div class="summary-footer">
				<div style="position: absolute; top: 5px; right: 5px;"><?php echo wprice($ototal0);?> <?php echo $ikpb?></div>
				<span style="float:left;"><?php echo ctranslate("Bekleyen Siparişler")?></span>
				<a class="text-muted text-uppercase" href="?islem=siparisler&ne=eticaret&s4=0">(<?php echo ctranslate("İncele")?>)</a>
			</div>
		</div>
	</div>
</div>
</section>
</div>
<div class="v3-col-md-3 v3-col-xs-6">
<section class="card card-featured-left card-featured-tertiary mb-3">
<div class="card-body">
	<div class="widget-summary">
		<div class="widget-summary-col widget-summary-col-icon">
			<div class="summary-icon">
				<i class="fas fa-check text-warning"></i>
			</div>
		</div>
		<div class="widget-summary-col">
			<div class="summary" style="margin-top: 20px;">
				<div class="info">
					<strong class="amount digi fs50"><?php echo $order_approved;?></strong>
				</div>
			</div>
			<div class="summary-footer">
				<div style="position: absolute; top: 5px; right: 5px;"><?php echo wprice($ototal1);?> <?php echo $ikpb?></div>
				<span style="float:left;"><?php echo ctranslate("Onaylanan Siparişler")?></span>
				<a class="text-muted text-uppercase" href="?islem=siparisler&ne=eticaret&s4=1">(<?php echo ctranslate("İncele")?>)</a>
			</div>
		</div>
	</div>
</div>
</section>
</div>
<div class="v3-col-md-3 v3-col-xs-6">
<section class="card card-featured-left card-featured-tertiary mb-3">
<div class="card-body">
	<div class="widget-summary">
		<div class="widget-summary-col widget-summary-col-icon">
			<div class="summary-icon">
				<i class="fas fa-check-double text-warning"></i>
			</div>
		</div>
		<div class="widget-summary-col">
			<div class="summary" style="margin-top: 20px;">
				<div class="info">
					<strong class="amount digi fs50"><?php echo $order_success;?></strong>
				</div>
			</div>
			<div class="summary-footer">
				<div style="position: absolute; top: 5px; right: 5px;"><?php echo wprice($ototal4);?> <?php echo $ikpb?></div>
				<span style="float:left;"><?php echo ctranslate("Tamamlanan Siparişler")?></span>
				<a class="text-muted text-uppercase" href="?islem=siparisler&ne=eticaret&s4=4">(<?php echo ctranslate("İncele")?>)</a>
			</div>
		</div>
	</div>
</div>
</section>
</div>
</div>