<?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">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Invoice - SB</title>
    <style>
        :root {
            --primary-red: #d90000;
            --light-blue: #a0d8ef;
            --dark-blue: #0080b0;
            --gray-bg: #f2f2f2;
            --border-color: #333;
        }

        body {
            font-family: 'Noto Naskh Arabic', serif;
            background-color: #525659;
            margin: 0px;
            padding: 0px;
            display: flex;
            justify-content: center;
        }

        /* A4 Page Setup */
        .page {
            width: 210mm;
            min-height: 297mm;
            padding: 1mm;
            background: white;
            box-shadow: 0 0 10px rgba(0,0,0,0);
            box-sizing: border-box;
            position: relative;
        }

        /* Header Styles */
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 3px solid var(--border-color);
            padding-bottom: 10px;
            margin-bottom: 10px;
			
        }

        .header-logo-section { text-align: center; flex: 1; }
        .logo-circle {
            width: 80px;
            height: 80px;
            background: #bbb3c7;
            color: #fff;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            border: 4px solid gold;
        }

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

        .info-box {
            border: 1px solid #000;
            padding: 5px 0px 0px 0px;
            font-size: 12px;
            text-align: center;
        }

        /* Table Styles */
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }

        th {
            background-color: var(--light-blue);
            color: white;
            border: 1px solid #000;
            padding: 8px;
            text-shadow: 1px 1px 1px #000;
        }

        td {
            border: 1px solid #000;
            padding: 8px;
            text-align: center;
            font-weight: bold;
        }

        .price-col { background-color: var(--primary-red); color: white; width: 80px; }
        .total-col { background-color: #e8e8e8; }

        /* Footer Section */
        .footer-container {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
			
        }

        .summary-table { width: 45%; }
        .calculation-box {
            width: 45%;
            background-color: var(--light-blue);
            border: 1px solid #000;
            border-radius: 10px;
            padding: 10px;
			
        }

        .calc-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 5px;
            padding: 5px;
            border-radius: 20px;
            background: white;
            border: 1px solid #777;
        }

        .calc-row.blue { background: var(--dark-blue); color: white; }
        .calc-row.red { background: var(--primary-red); color: white; }

        .note-bar {
            background: var(--primary-red);
            color: white;
            padding: 10px;
            margin-top: 20px;
            text-align: center;
            font-weight: bold;
        }

        /* Printing Adjustments */
        @media print {
            body { background: none; padding: 0; }
            .page { box-shadow: none; margin: 0; width: 95%; }
            .no-print { display: none; }
            * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
        }
		:root {
            --brand-blue: #b3e5fc;
            --brand-red: #ff3d00;
            --brand-yellow: #ffffff;
            --dark-text: #1a1a1a;
        }
		.banner {
            background-color: var(--brand-yellow);
            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-family:'Noto Naskh Arabic', serif;
            font-size: 13px;
            margin: 5px 0;
            line-height: 1.4;
        }
		


  .arabic-text {
    font-family: 'Noto Naskh Arabic', serif;
    direction: rtl;
    font-size: 1.2rem;
    line-height: 1.6;
  }


    </style>
	
	
	
	
	<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>SB</title>
    <meta
      content="width=device-width, initial-scale=1.0, shrink-to-fit=no"
      name="viewport"
    />
    <link
      rel="icon"
      href="assets/img/kaiadmin/favicon.ico"
      type="image/x-icon"
    />

    <!-- Fonts and icons -->
    <script src="assets/js/plugin/webfont/webfont.min.js"></script>
    <script>
      WebFont.load({
        google: { families: ["Public Sans:300,400,500,600,700"] },
        custom: {
          families: [
            "Font Awesome 5 Solid",
            "Font Awesome 5 Regular",
            "Font Awesome 5 Brands",
            "simple-line-icons",
          ],
          urls: ["assets/css/fonts.min.css"],
        },
        active: function () {
          sessionStorage.fonts = true;
        },
      });
    </script>

    <!-- CSS Files -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
   <!-- <link rel="stylesheet" href="assets/css/plugins.min.css" />-->
    <link rel="stylesheet" href="assets/css/kaiadmin.min.css" />
	<link href="https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap" rel="stylesheet">

    <!-- CSS Just for demo purpose, don't include it in your project -->
    <!--<link rel="stylesheet" href="assets/css/demo.css" />-->
	
	
	
</head>
<body>

<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 width=100% >

		 
    <tr><td colspan=3 style=" border:0 solid yellow;background-color:var(--brand-yellow)">
	
	<div class="info-grid">
        <div class="info-box" style="font-size:14px;font-family: 'Noto Naskh Arabic', serif;">شکۆ:07508266026</div>
        <div class="info-box" style="font-size:14px;background: var(--primary-red); color: white;font-family: 'Noto Naskh Arabic', serif;">شاهۆ:07503200328</div>
        <div class="info-box" style="font-size:14px;font-family: 'Noto Naskh Arabic', serif;">ڕێبەند:07501860339</div>
		<div class="info-box">
		<div style="display: flex; align-items: center; background-color: white; border-radius: 20px; padding-right: 5px;  border: 1px solid #eee;">
		   <span style="background-color: #48a999; color: white; padding: 2px 15px 2px 15px; font-weight: bold; margin-top:0px">0328 320 0750</span>
            <span style="padding: 0px 15px 0px 10px; color: #48a999;"><img src="icon/fib2.png" height="13px"><img src="icon/k2.png" height="13px"></span>
        
		</div>
		</div>
		
    </div>
	</td></tr>
	</table>
	
	<table  style="font-family:'Noto Naskh Arabic', serif; font-size:9pt ; margin-top:0px" >
        <tr style="background: var(--gray-bg); ">
            <td style="font-family:'Noto Naskh Arabic', serif; font-size:11pt">بەڕێز / السيد: <?php echo $get_row['note'];?><br>ناونیشان / عنوان: <?php echo $get_row['address'];?></td>
            <td style="font-family:'Noto Naskh Arabic', serif; font-size:11pt">ژ.وەسڵ / ر.وصل:<?php echo $id;?><br>بەروار / التاريخ: <?php echo $get_row['sell_j_date'];?></td>
        </tr>
       
    </table>
	
	





  <table style="font-family:'Noto Naskh Arabic', serif; margin-top:0px">
        <thead>
            <tr style="background: #5d4e7a;color:white; text-align:center " >
                <th style="background: #5d4e7a;color:white">#</th>
				<th style="background: #5d4e7a;color:white">بابەت /المادة</th>
				
				<th style="background: #5d4e7a;color:white">سێت</th>
				<th style="background: #5d4e7a;color:white">عدد</th>
				<th style="background: #5d4e7a;color:white">نرخ / سعر</th>
				<th style="background: #5d4e7a;color:white">کۆ / جمع</th>
            </tr>
        </thead>
        <tbody>
		
		<?php 	$count=1;$sum=0;$added=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'");
				
				?>
				<tr style="font-size:10pt;border:1px solid grey">
				<td><?php echo $count; $count++;?></td>
				
				<?php
				$row_set=0;
				$row_num=0;
				$row_price=0;
				$jumla="";
				while($get_row=mysqli_fetch_array($gett)){ 
						
					//echo "<span style='background-color:pink; padding:2px 5px; font-size:8pt'>".$get_row['sell_j_i_set']." سێت  ".$get_row['code']." (".$get_row['sell_j_i_set']*$get_row['i_s_per']." عدد)</span> ";
						$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> ";
						
				}
				$added+=$row_num;
				?><td width=60%><?php echo $row0['name']."<br>". $jumla;?></td>
				<td ><?php echo $row_set;?></td>
				<td ><?php echo $row_num;?></td>
				<td ><?php echo $row0['sell_j_i_price'];?></td>
				<td ><?php echo $row_price; $sum+=$row_price;?></td>
				</tr>
				
				<?php }?>
				<tr bgcolor="lightgrey">
					<td></td>
					<td colspan=3></td>
					<td style="text-align:center"> کۆی گشتی</td>
					<td style="text-align:center;color:red"><?php echo $currency;?> <?php echo number_format($sum,2);?></td>
				</tr>
				
			<tr><th style="background-color:white; border:0px " colspan=6>
			<?php if($payed==0){?><h1 style="text-align:center; color:green">واصل نقدا</h1> <?php } ?>
			</th>
			</tr>
			
			
			
			
         
        </tbody>
    </table>
			<div >
            
        </div>
			
			
			
			 



<center><div ><img  src="icon/w.jpg" height=90px style="margin-right:20px"><img  src="icon/t.jpg" height=90px style="margin-right:20px"></div></center>
</div>  </div>