<?php require_once('../auth/auth.php');
$item_id = $_GET['pro_id'];
?>
<section class="content">
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-12">
				<div class="card responsive-card card- card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #718575;">
					<div class="card-header" style="padding: 3px 8px;">
						<h3 class="card-title"> <i class="fa fa-chart-line pr-2 "></i><?php echo language(331);?></h3>
						<div class="card-tools">
							<button type="button" class="btn btn-tool" data-card-widget="remove">
							<i style="color:white;" class="fas fa-times"></i>
							</button>
						</div>
					</div>
					<div class="card-body cscroll" style="max-height: 450px;">
						<table class="table table-sm" style="overflow-x: auto;margin-bottom:0px !important;text-shadow: 0 0 black !important;
							">
							<thead>
								<tr>
									<th class="text-center"> <?php echo language(15);?></th>
									<th class="text-center"> <?php echo language(331);?></th>
									<th class="text-center"> <?php echo language(217);?> (+) </th>
									<th class="text-center"> <?php echo language(218);?> (-) </th>
									<th class="text-center"> <?php echo language(75);?> </th>
								</tr>
							</thead>
							
							<tbody>
								
								<?php
								$bw= mysqli_query($conn,"SELECT bwid,war_location,warehouse_code,SUM(COALESCE(CASE WHEN  plus = '+' THEN qty end ,0 )) qty_debit ,  SUM(COALESCE(CASE WHEN  plus = '-' THEN qty end ,0 )) qty_credit    FROM business_w_house  INNER JOIN order_list ON  business_w_house.bwid=order_list.wh_id WHERE order_list.coid='$coid' AND order_list.bid='$bid' AND order_list.brid='$brid' AND order_list.active=1 AND order_list.pro_id='$item_id' GROUP BY order_list.wh_id ORDER BY bwid ASC") or die(mysqli_error($conn));
								$i=0;
								while($wh= mysqli_fetch_assoc($bw)){
								?>
								<tr>
									<th class="text-center"> <?php echo ++$i; ?>  </th>
									<th class="text-center">    <?php echo $wh["war_location"]; ?>   <strong class="ml-2"><?php echo $wh["warehouse_code"]; ?> </strong>
									</th>
									<th class="text-center"><?php echo $wh["qty_debit"]; ?> </th>
									<th class="text-center"><?php echo $wh["qty_credit"]; ?> </th>
									<th class="text-center"><?php echo ($wh["qty_debit"]-$wh["qty_credit"]); ?> </th>
								</tr>
								<?php }  ?>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>