<?php include('connection/conn.php');
$id=$_GET['sell_j_id'];

$bef="select `inv_id` from `sell_j_inv` where `inv_code`=$id";
$bef_r=$conn->query($bef);
$bef_row=mysqli_fetch_array($bef_r);
$bef_id=$bef_row['inv_id'];

$get="select * from `sell_j`,`customer` where `customer_id`=`sell_j_customer` and `sell_j_id`=$id";
$get_r=$conn->query($get);
$get_row=mysqli_fetch_array($get_r);
$type=$get_row['type'];
$payed=$get_row['payed'];
$currency=$get_row['currency'];
$c_id=$get_row['customer_id'];
?>

<!DOCTYPE html>
<html lang="ku" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>Delivery Label - SB</title>
    <style>
        :root {
            --brand-blue: #b3e5fc;
            --brand-red: #ff3d00;
            --brand-yellow: #ffc107;
            --dark-text: #1a1a1a;
        }

        body {
            font-family: 'Segoe UI', Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        /* A4 half-page height approximately */
        .label-container {
            width: 210mm;
            background: white;
            border: 2px solid #005b96;
            box-sizing: border-box;
            padding: 0;
            position: relative;
        }

        /* Top Banner Section */
        .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;
        }

        /* Grid Table */
        .grid-table {
            width: 100%;
            border-collapse: collapse;
        }

        .grid-table td {
            border: 1px solid #005b96;
            padding: 15px;
            vertical-align: middle;
            text-align: center;
            font-weight: bold;
            font-size: 18px;
			
        }

        .label-cell {
            background-color: #fff1f0;
            width: 30%;
            font-size: 20px;
        }

        .data-cell {
            color: var(--brand-red);
            font-size: 24px;
        }

        /* Bottom Status Bar */
        .status-bar {
            display: flex;
            width: 100%;
            background-color: var(--brand-yellow);
            border-top: 1px solid #005b96;
        }

        .status-item {
            flex: 1;
            padding: 12px;
            border-right: 1px solid #005b96;
            text-align: center;
            font-weight: bold;
        }

        .status-label {
            background-color: var(--brand-red);
            color: white;
            width: 150px;
        }

        .footer-contacts {
            display: flex;
            justify-content: space-around;
            background: white;
            padding: 5px;
            font-size: 12px;
        }

        .pill {
            background: #eee;
            border-radius: 15px;
            padding: 2px 10px;
            border: 1px solid #ccc;
        }

        @media print {
            body { background: none; padding: 0; }
            .label-container { box-shadow: none; border: 2px solid #000; }
            * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        }
		 .header-logo-section { text-align: center; flex: 1; }
        .logo-circle {
            width: 80px;
            height: 80px;
            background: #fff;
            color: #fff;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            border: 4px solid gold;
        }
		:root {
            --primary-red: #d90000;
            --light-blue: #a0d8ef;
            --dark-blue: #0080b0;
            --gray-bg: #f2f2f2;
            --border-color: #333;
        }
		 /* Top Info Grid */
        .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="label-container">
   <div class="page">
        <div class="banner" style="background-color:#bbb3c7">
        <div class="banner-side" style="text-align: center;">
            <h1  class="header-title">پۆشاکی شاهۆ </h1>
            <p class="header-sub" >بۆ فرۆشتنی جل و بەرگی پیاوان بە کۆ<br>ناونیشان: هەولێر - بازاڕی داونتاون<br> نهۆمی ژێر زەمین ژمارەی دوکان-H33</p>
			<div style="background-color: #5d4e7a; color: white; padding: 3px 12px; border-radius: 20px; font-size: 18px;font-family: 'Noto Naskh Arabic', serif;">
           شاهۆ احسان بەرزنجی
        </div>
        </div>
		
		
        
        <div class="banner-center">
           <div class="header-logo-section">
            <div class=""><img  src="icon/logo.png" height=90px></div>
        </div>
        </div>

        <div class="banner-side" style="text-align: center;">
            <h1 class="header-title">ألبسة شاهو </h1>
            <p class="header-sub">لبيع ألبسة رجالية بالجملة<br>اربیل سوق داونتاون<br> تابق سرداب- رقم محل-H33</p>
			<div style="background-color: #5d4e7a; color: white; padding: 3px 12px; border-radius: 20px; font-size: 18px;font-family: 'Noto Naskh Arabic', serif;">
            شکۆ احسان بەرزنجی
        </div>
		
		
		
		
		
        </div>
		
		
		
		
    </div>
	

    <table class="grid-table">
	
	
	
        <tr><td class="label-cell"> بەڕێز / السيد: </td>
            <td class="data-cell"><?php echo $get_row['customer_name'];?></td>
            
        </tr>
        <tr>
<td class="label-cell">ناونیشان</td>
<td class="data-cell" style="height: 80px;"><?php echo $get_row['customer_address'];?></td>
            
        </tr>
        <tr><td class="label-cell">ژمارەی مۆبایل / رقم تلفون</td>
            <td class="data-cell" style="font-size: 30px;"><?php echo $get_row['customer_mobile'];?></td>
            
        </tr>
    </table>


<?php 	$sum=0;
				$gett0="select * from `sell_j_item`,`items`,`item_set` where `sell_j_i_code`=`i_s_barcode` and `i_s_code`=`code` and `sell_j`=$id group by `group_code`";
				$num0=$conn->query($gett0);
				while($row0=mysqli_fetch_array($num0))
				{
				$g_c=$row0['group_code'];
				
				
				$gett=$conn->query("select * from `sell_j_item`,`items`,`item_set` where `sell_j_i_code`=`i_s_barcode` and `i_s_code`=`code` and `sell_j`=$id and `group_code`='$g_c'");
				
				
				$row_set=0;
				$row_num=0;
				$row_price=0;
				$jumla="";
				while($get_row=mysqli_fetch_array($gett)){ 
						
						$row_set+=$get_row['sell_j_i_set'];
						$row_num+=($get_row['sell_j_i_set']*$get_row['i_s_per']);
						$row_price+=($get_row['sell_j_i_set']*$get_row['sell_j_i_price']*$get_row['i_s_per']);
						$jumla.="<span style='background-color:lightgrey; padding:2px 5px; font-size:5pt; border-radius:5px'>".$get_row['sell_j_i_set']." سێت  ".$get_row['code']." (".$get_row['sell_j_i_set']*$get_row['i_s_per']." عدد)</span> ";
						
				}
				
				 $sum+=$row_price;}?>
			


    <div class="status-bar">
	
	
	<div class="status-item status-label">حساب</div>
	 <div class="status-item" style="background: #ffffff;"><?php echo $currency;?> <?php echo number_format($sum,2);?> </div>
	<div class="status-item" style="background: #ffa000; text-decoration:none">
	<?php if(isset($_GET['g'])){ ?>
	<a  style="color:green; text-decoration:none" href="delivery.php?sell_j_id=<?php echo $id;?>">بە گەیاندنەوە</a>
	<?php } else{ ?>
	<a  style="color: red; text-decoration:none" href="delivery.php?g=0&&sell_j_id=<?php echo $id;?>">بەبێ گەیاندن (بدون توصيل)</a>
	<?php }?>
	
	</div>
        <div class="status-item" style="flex: 0.4; background: white;">
            <span style="font-size: 12px;">رقم القائمة:</span> <?php echo $id;?>
        </div>
        
       
    </div>

    
</div>

</body>
</html>