<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
$_SESSION['cuPages']='inv_brstocklist.php';   
$cuPage='inv_brstocklist.php';    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}
$mhead='carrier';
$menuh='Carrier';
$phead='carstock';
$page='Carrier Stock';
$dtnow = date("Y-m-d h:i:s", time());
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>

<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">

<div class="row">
<div class="col-md-12">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Carrier Stock Status</h3>
</div>
<div class="box-body">    
<div class="col-md-12 table-responsive">
<table class="table table-bordered table-striped table-hover table_list" id="datarec">
<thead>
<tr>
<th style="width:40px;" class="text-center">SN</th>
<th >Name</th>
<?php if(get_fild_data('tbl_setting','11','sval')==0){ ?>
<th style="width:80px;">Color</th>
<th style="width:80px;">Size</th>
<?php }?>
<th>SKU</th>    
<th class="text-center">Client Received</th>  
<th class="text-center">Client Delivered</th>  
<th class="text-center">Client Undelivered</th>  
<th class="text-center">Carrier Delivered</th>  
<th class="text-center">Carrier Received</th> 
<th class="text-center">Carrier Unreceived</th> 
<th class="text-center">In Hand</th> 
</tr>    
</thead>    
<tbody>
<?php
$tclrcv = 0;
$tcldeli = 0;
$tsorqty = 0;
$tcadeli = 0;
$tsrqty = 0;
$tclundeli = 0;
$tcarunrcv = 0; 
$tavqty = 0; 
$sql="SELECT pid,image,name,pcode,colid,sizid,SUM(clrcv) AS clrcv,SUM(cldeli) AS cldeli,SUM(cadeli) AS cadeli,SUM(carcv) AS carcv,SUM(avqty) AS avqty FROM tbl_carbrstock WHERE brid='$brid' GROUP BY pid ,sizid ORDER BY name ASC";    
$query=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($row=mysqli_fetch_array($query)){
$tclrcv+=$row['clrcv'];$tcldeli+=$row['cldeli'];
$tclundeli+=($row['clrcv']-$row['cldeli']);
$tsorqty+=$row['cadeli'];$tcadeli+=$row['carcv'];
$tcarunrcv+=($row['cadeli']-$row['carcv']);
$tcarunrcv+=$row['avqty'];
?>
<tr>
<td class="text-center"><?php echo count_id();?></td>
<td><b class="prodetail" id="PI_<?php echo $row['pid'];?>" style="cursor: pointer;"><?php echo $row['name']; ?></b></td>
<?php if(get_fild_data('tbl_setting','11','sval')==0){ ?>
<td><?php if($row['colid']!=0){echo get_fild_data('tbl_color',$row['colid'],'name');}?></td>
<td><?php if($row['sizid']!=0){echo get_fild_data('tbl_size',$row['sizid'],'name'); ?>-<?php echo get_fild_data('tbl_size',$row['sizid'],'sval'); } ?></td>
<?php }?>
<td><?php echo $row['pcode']; ?></td>
<td class="text-center"><?php echo $row['clrcv']; ?></td>
<td class="text-center"><?php echo $row['cldeli']; ?></td>
<td class="text-center"><?php echo ($row['clrcv']-$row['cldeli']); ?></td>  
<td class="text-center"><?php echo $row['cadeli']; ?></td>    
<td class="text-center"><?php echo $row['carcv']; ?></td>   
<td class="text-center"><?php echo ($row['cadeli']-$row['carcv']); ?></td>   
<td class="text-center"><?php echo $row['avqty']; ?></td>      
</tr>    
<?php } ?>     
</tbody>
<tfoot>
<tr>
<?php if(get_fild_data('tbl_setting','11','sval')==0){ ?>
<td class="text-center" colspan="5"><strong>-Total-</strong></td>
<?php }else{?>
    <td class="text-center" colspan="3"><strong>-Total-</strong></td>
<?php } ?>
<td class="text-center"><strong><?php echo $tclrcv; ?></strong></td>    
<td class="text-center"><strong><?php echo $tcldeli; ?></strong></td>    
<td class="text-center"><strong><?php echo $tclundeli; ?></strong></td>   
<td class="text-center"><strong><?php echo $tsorqty; ?></strong></td>    
<td class="text-center"><strong><?php echo $tcadeli; ?></strong></td>    
<td class="text-center"><strong><?php echo $tcarunrcv; ?></strong></td>  
<td class="text-center"><strong><?php echo $tavqty; ?></strong></td>    
</tr>    
</tfoot>    
</table>    
</div>

<div class="clearfix" ></div>     
<div class="row text-center" style="margin-top: 15px" >
<span style="font-size: 12px; font-style: oblique; font-weight: bold; color: red;">DELI: Delivered, UNDELI: Undelivered Product</span>
</div>    
</div>
</div>
</div>
</div>
 
<?php include('../layout/quick.php');?>     
</section>
<!-- /.main content -->
<?php include('../layout/details.php'); ?>    
</div>
<?php
include('../layout/footer.php');
?>
<!-- page script -->
<script src='../plugins/chart/Chart.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datarec').DataTable({stateSave: true});
});
    
$(document).on('click', '.prodetail', function(e) { 
id_arr = $(this).attr('id');
id = id_arr.split("_");
$.ajax({
url: 'axe_prodetails.php',
method: "POST",
data:{ prodet: 1,pid: id[1]},
success: function(data){
$('#profile').html(data);    
}
});    
    
$.ajax({
url: 'axe_prodetails.php',
method: "POST",
data:{ details: 1,pid: id[1] },
success: function(data){
$('#details').html(data);   
}
});    
    
$('.right-side-details').toggle('slide', { direction: 'right' }, 300);    
e.preventDefault();    
});
    
$(document).on('click', '#closedet', function() {
$('#profile').html('');
$('#details').html('');    
if($('.right-side-details').is(':visible')) {
$('.right-side-details').toggle('slide', { direction: 'right' }, 300);
}    
});     
</script>    
<!-- /page script -->
</html>    