<?php include('connection/conn.php');
$id=$_GET['id'];
$get="select * from `get`,`customer` where `customer_id`=`get_customer` and `get_id`=$id";
$get_r=$conn->query($get);
$get_row=mysqli_fetch_array($get_r);
$c_id=$get_row['customer_id'];

$a=$get_row['amount'];

				$get10="select * from `sell_j_inv` where   `inv_code` = $id and `inv_type`='get'";
				$get_r10=$conn->query($get10);
				$get_row10=mysqli_fetch_array($get_r10);
				$id10=$get_row10['inv_id'];
					
				
				
				
				
				$get2="select * from `sell_j_inv` where  `customer`=$c_id  and `inv_id` < $id10";
				$get_r2=$conn->query($get2);
				$sum100=0;
				$sum_w100=0;
				$sum_t100=0;
				while($get_row2=mysqli_fetch_array($get_r2))
				{ 
				
				
					$type=$get_row2['inv_type'];
					$code=$get_row2['inv_code'];
					if($type=="sell")
					{
						$transfer="select * from `sell_j` where `sell_j_id`=$code";
						$transfer_r=$conn->query($transfer);
						$transfer_row=mysqli_fetch_array($transfer_r);
						$sell_j=$transfer_row['sell_j_id'];
					
								$p="select *  from `sell_j_item`,`item_set` where `sell_j`='$sell_j' and `i_s_barcode`=`sell_j_i_code`";
								$p_r=$conn->query($p);
								while($p_row=mysqli_fetch_array($p_r))
								{
									$per=$p_row['i_s_per'];
									$ss=$p_row['sell_j_i_set'];
									$pp=$p_row['sell_j_i_price'];
									$sum100+=$per*$ss*$pp;
								}
								
					}
					elseif($type=="get")
					{
						$get3="select * from `get` where `get_id`=$code";
						$get_r3=$conn->query($get3);
						$get_row3=mysqli_fetch_array($get_r3);
					
						$p=$get_row3['amount']; $sum100-=$p;
							
					
					}
					elseif($type=="debt")
					{
						$get3="select * from `sell_j` where `sell_j_id`=$code";
						$get_r3=$conn->query($get3);
						$get_row3=mysqli_fetch_array($get_r3);
					
						$p=$get_row3['amount']; $sum100+=$p;
							
					
					}
				}


?>
<!DOCTYPE html>
<html lang="ku" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>Payment Receipt - SB</title>
    <style>
        :root {
            --primary-red: #d90000;
            --light-blue: #a0d8ef;
            --dark-blue: #003366;
            --bg-gray: #f2f2f2;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #525659;
            margin: 0;
            padding: 20px;
            display: flex;
            justify-content: center;
        }

        .page {
            width: 210mm;
            background: white;
            padding: 10mm;
            box-shadow: 0 0 10px rgba(0,0,0,0.5);
            box-sizing: border-box;
        }

        /* Header matching original branding */
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid #000;
            padding-bottom: 15px;
            margin-bottom: 10px;
        }

        .logo-circle {
            width: 70px;
            height: 70px;
            background: #000;
            color: gold;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 24px;
            border: 3px solid gold;
        }

        /* Top Info Bar */
        .info-bar {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2px;
            margin-bottom: 15px;
        }

        .info-item {
            border: 1px solid #ccc;
            padding: 8px;
            font-size: 14px;
            text-align: center;
            background: var(--bg-gray);
        }

        /* Voucher Box */
        .voucher-container {
            border: 2px solid #444;
            border-radius: 15px;
            display: flex;
            overflow: hidden;
            margin-top: 20px;
        }

        .voucher-side-label {
            background-color: var(--primary-red);
            color: white;
            width: 150px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            font-size: 22px;
            font-weight: bold;
            text-align: center;
            padding: 20px;
            line-height: 1.6;
        }

        .voucher-content {
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .voucher-row {
            display: flex;
            border-bottom: 1px solid #ccc;
        }

        .voucher-row:last-child { border-bottom: none; }

        .v-value {
            flex: 1;
            padding: 15px;
            text-align: center;
            font-size: 20px;
            font-weight: bold;
        }

        .v-label {
            width: 250px;
            padding: 15px;
            background: #fdf2e9; /* Light cream/yellowish from image */
            border-right: 1px solid #ccc;
            font-weight: bold;
            color: #333;
        }

        /* Color Overrides for rows */
        .row-red .v-label { background: #ffcccc; color: #a00; }
        .row-red .v-value { color: var(--primary-red); }
        .row-blue .v-label { background: var(--light-blue); }
        .row-blue .v-value { color: var(--dark-blue); }

        @media print {
            body { background: none; padding: 0; }
            .page { box-shadow: none; margin: 0; width: 100%; }
            * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        }
		.banner {
            background-color: var(--brand-blue);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 20px;
            border-bottom: 2px dashed #005b96;
        }

        .banner-side { flex: 1; }
        .banner-center { flex: 0.5; text-align: center; }
        
        .header-title {
            color: #003366;
            font-size: 28px;
            margin: 0;
            font-weight: bold;
        }

        .header-sub {
            font-size: 13px;
            margin: 5px 0;
            line-height: 1.4;
        }
		.info-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 5px;
            margin-bottom: 10px;
        }
		.info-box {
            border: 1px solid #000;
            padding: 5px;
            font-size: 12px;
            text-align: center;
        }
    </style>
</head>
<body>

<div class="page">
     <div class="banner">
        <div class="banner-side" style="text-align: center;">
            <h1 class="header-title">پۆشاکی شاهۆ بەرزنجی</h1>
            <p class="header-sub">بۆ فرۆشتنی جل و بەرگی پیاوان بە کۆ<br>ناونیشان: هەولێر - بازاڕی داونتاون</p>
        </div>
        
        <div class="banner-center">
           <div class="header-logo-section">
            <div class=""><img  src="icon/logo.jpg" height=90px></div>
            <p style="font-size: 14px; margin: 5px 0 0 0;">SB Collection</p>
        </div>
        </div>

        <div class="banner-side" style="text-align: center;">
            <h1 class="header-title">ألبسة شاهو برزنجی</h1>
            <p class="header-sub">لبيع ألبسة رجالية بالجملة<br>أربيل - سوق داونتاون</p>
        </div>
    </div>
<hr>
    <div class="info-grid">
        <div class="info-box">شکۆ:07508266026</div>
        <div class="info-box" style="background: var(--primary-red); color: white;">شاهۆ:07503200328</div>
        <div class="info-box">ڕێبەند:07501860339</div>
    </div>

    <div class="info-bar">
        <div class="info-item">السید / بەڕێز: <br><?php echo $get_row['customer_name'];?></div>
        <div class="info-item">عنوان / ناونیشان: <br><?php echo $get_row['customer_address'];?></div>
        <div class="info-item">موبایل: <br><?php echo $get_row['customer_mobile'];?></div>
        <div class="info-item">تاريخ<br> <?php echo $get_row['get_date'];?></div>
    </div>

    <div class="voucher-container">
        

        <div class="voucher-content">
            <div class="voucher-row">
                 <div class="v-label">حسابی پێشتر : حساب القديم</div>
				 <div class="v-value"><?php echo $get_row['currency']." ".$sum100;?></div>
               
            </div>
            
            <div class="voucher-row row-red">
                <div class="v-label">بڕی واسڵکراو : مبلغ الواصل</div>
				<div class="v-value"><?php echo $get_row['currency']." ".$a;?></div>
                
            </div>

            <div class="voucher-row row-blue">
                <div class="v-label">حسابی کۆتایی : باقى</div>
				<div class="v-value"><?php $r=$sum100-$a; echo $get_row['currency']." ".$r;?></div>
                
            </div>
			<div class="voucher-row row-green">
                <div class="v-label">تێبینی</div>
				<div class="v-value"><?php echo $get_row['note'];?></div>
                
            </div>
        </div>
		<div class="voucher-side-label">
            وەسڵی<br>پارە وەرگرتن<br><span style="font-size: 16px; font-weight: normal;">سند قبض</span>
        </div>
    </div>
<br><br><br><br>
    <div style="margin-top: 50px; display: flex; justify-content: space-around; font-weight: bold;">
        
        <span>واژووی وەرگر / توقیع المستلم</span>
    </div>
	<div style="margin-top: 50px; display: flex; justify-content: space-around; font-weight: bold;">
        
        <span><img src="icon/t.jpg" height="100px"><img src="icon/w.jpg" height="100px"></span>
    </div>
</div>

</body>
</html>