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

$get="select * from `customer2` where  `customer_id`=$id";
$get_r=$conn->query($get);
$get_row=mysqli_fetch_array($get_r);

$name=$get_row['customer_name'];
$mob=$get_row['customer_mobile'];
$add=$get_row['customer_address'];


?>
<html>
	<head>
		<style>
		@media print {body {-webkit-print-color-adjust: exact;}}
		</style>
	</head>
	<body style="font-family: nrt;">
		<div style="width:750px"  id="right">
			<table dir=rtl id="mydiv" height="" width="100%" border=0>
				<tr>
					<td width=325px style="font-size:11pt">
						<center>
						<font style="font-size:14pt">کۆگای ئاراس پۆلۆ</font><br>
						بۆ بازرگانی جل و بەرگ<br>
						بە تاک و بە کۆ
						</center>
					</td>
					
					<td style="text-align:left"  width=100px>
					<img src="icon/logo.png" width="100">
					<font style="font-size:14pt">کشف حساب</font>
					</td>
					<td width=325px style="font-size:11pt">
						<center>
						<font style="font-size:14pt">Aras Polo Store</font><br>
						
						
						</center>
					</td>
				</tr>
				</table>
				<br>
			<table dir=rtl id="mydiv" height="" width="740px" border=0 style="font-size:16pt">
				<tr style="text-align:right" bgcolor="#f0f0f0">
					<th width=350px> <?php echo $name;?></th>
					<th width=200px><?php echo $add;?></th>
					<th width=200px><?php echo $mob;?></th>
				</tr>
			</table>
			
			<br>
			
			<table style="text-align:center;font-size:10pt" bgcolor="#d1eaf0" id='mydiv' width='740px' dir=rtl align="center">					
				<tr bgcolor="#708090" style="color:#ffffff">
					<td>مامەڵە</td>
					<td>بەروار</td>
					<td>ژمارەی وصل</td>
					
					
					<td>بڕی پارە</td>
					<td>باقی پارە</td>
				</tr>
				<?php
				$count=1;
				
				$get2="select * from `sell_j_inv` where  `customer`=$id order by `date`";
				$get_r2=$conn->query($get2);
				$sum=0;
				$sum_w=0;
				$sum_t=0;
				while($get_row2=mysqli_fetch_array($get_r2))
				{ 
				if($count%2==0) $col="#f9f9f9"; else $col="white"; 
				$count++;
					$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'];
					?>
						
						<?php 
						/*$item="select * from `sell_j_item` where `sell_j`=$sell_j ";
						$item_r=$conn->query($item);
						while($item_row=mysqli_fetch_array($item_r)){*/
						?>
						<tr bgcolor="<?php echo $col;?>">
							<th style="color:#7A7DCE">فرۆشتن</th>
							<td style="color:#bb141c;background-color:#f0f0f0; font-size:8pt"><?php echo $transfer_row['sell_j_date'];?></td>
							<td><a href="sell_j_print.php?sell_j_id=<?php echo $transfer_row['sell_j_id'];?>"><?php echo $transfer_row['sell_j_id'];?></td>
							
							<?php
								$p="select sum(`sell_j_i_number`*`sell_j_i_price`) as `t` from `sell_j_item` where `sell_j`='$sell_j'";
								$p_r=$conn->query($p);
								$p_row=mysqli_fetch_array($p_r);
							?>
							<td><?php echo number_format($p_row['t'],0); $sum+=$p_row['t'];?> </td>
							
							
							
							
							<th width=120px dir=ltr bgcolor="#a9a9a9"> <?php echo number_format($sum,0);?></th>
						</tr>
						<?php //}
					}
					elseif($type=="get")
					{
						$get="select * from `get` where `get_id`=$code";
						$get_r=$conn->query($get);
						$get_row=mysqli_fetch_array($get_r);
					?>
						<tr bgcolor="<?php echo $col;?>">
							<th style="color:green">پارە وەرگرتن</th>
							<td style="color:#bb141c;background-color:#f0f0f0;font-size:8pt"><?php echo $get_row['get_date'];?></td>
							<td><?php echo $get_row['get_id'];?></td>
							<th dir=ltr style="color:#bb141c" bgcolor="#cccccc"><?php echo number_format($p=$get_row['amount'],0); $sum-=$p;?></th>
							<th dir=ltr bgcolor="#a9a9a9"> <?php echo number_format($sum,0);?></th>
						</tr>
					<?php
					}
					
					
				
					
				
					
				}?>
				<tr bgcolor="#f9f9f9">
					
					<th colspan=2>کۆی گشتی باقی پارە</th>
					<th colspan=2><?php if($sum<0) echo "ماوە لای ئێمە"; elseif($sum>0) echo "ماوە لای ئەوان";?></th>
					<th dir=ltr style="color:#ffffff" bgcolor="#708090"> <?php echo number_format($sum,0);?></th>
					
				</tr>
			</table>
			<br>
			<table width=100%>
				<tr style="font-size:10pt" bgcolor="#f0f0f0">
					<th width=60%>07504529902 - 07504686054</th>
					<th width=40%>info@araspolo.com</th>
				</tr>
			</table>
		</div>
	</body>
</html>


