<?php 
require("../connection.php");
include("../user.php");
$user_id=$_SESSION['user'];
$username=$_SESSION['user_name'];
$branch_id=$_SESSION['branch_id'];
$ho_access=$_SESSION['ha'];
	
?>
<html>
<head>
  <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo TITLE;?></title>
    <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="apple-touch-icon" href="../images/bluebase.png">
    <link rel="shortcut icon" href="../images/bluebase.png">

    <link rel="stylesheet" href="../css/normalize.min.css">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/themify-icons.css">
    <link rel="stylesheet" href="../css/pe-icon-7-stroke.min.css">
    <link rel="stylesheet" href="../css/flag-icon.min.css">
    <link rel="stylesheet" href="../assets/css/cs-skin-elastic.css">
    <link rel="stylesheet" href="../assets/css/style.css">
    <link href="../css/chartist.min.css" rel="stylesheet">
    <link href="../css/jqvmap.min.css" rel="stylesheet">

    <link href="../css/weather-icons.css" rel="stylesheet" />
    <link href="../css/fullcalendar.min.css" rel="stylesheet" />

<script src="../js/jquery-1.12.4.min.js"></script>
<script src="../js/jquery-3.3.1.js"></script>
<script src="../js/jquery.dataTables.min.js"></script>


    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../js/jquery.matchHeight.min.js"></script>
    <script src="../assets/js/main.js"></script>
    <script src="../js/jquery-3.3.1.min.js"></script>
   <style>
    #weatherWidget .currentDesc 
	{
        color: #ffffff!important;
    }
        .traffic-chart {
            min-height: 335px;
        }
        #flotPie1  {
            height: 150px;
        }
        #flotPie1 td {
            padding:3px;
        }
        #flotPie1 table {
            top: 20px!important;
            right: -10px!important;
        }
        .chart-container {
            display: table;
            min-width: 270px ;
            text-align: left;
            padding-top: 10px;
            padding-bottom: 10px;
        }
        #flotLine5  {
             height: 105px;
        }

        #flotBarChart {
            height: 150px;
        }
        #cellPaiChart{
            height: 160px;
        }
th{
	text-transform:uppercase;
}
td{
	text-transform:uppercase;
}
    </style>

<link rel="stylesheet" href="/project_temp/datatable/css/jquery.dataTables.min.css">
<script src="/project_temp/datatable/js/jquery.datatables.min.js"></script>
<!-- button --><link rel="stylesheet" type="text/css" href="/project_temp/button/css/buttons.css" /><!-- button -->

<script>
$(document).ready(function() {
		$('#example').DataTable();
		} );
</script>
</head>
<body>
 <?php require('../sidemenu.php');?>
  <!-- /#left-panel -->
    <!-- Right Panel -->
    <div id="right-panel" class="right-panel">
        <!-- Header-->
        <?php require('../header.php');?>
		<div class="content">
            <!-- Animated -->
            <div class="animated fadeIn">
		<div style="background-color:white;margin-bottom:10px;">
	<strong style="color:blue"><center>Stock Inward Received List</center></strong>
	</div>
<table id="example" class="table table-striped table-bordered" >
        <thead>
            <tr>
                <th>S.No</th>
                <th>Receive Date</th>
                <th>Vechicle Number</th>
                <th>Number Of Quantity</th>
                <th>From Location</th>
                <th>To Location</th>
                <th>Status</th>
            </tr>
        </thead>
		
        <tbody>
		<?php 
		if($ho_access=="yes")
		{
		$row=mysqli_query($con,"SELECT st.id,st.transaction_id,st.date,st.vehicle_no,st.from_location,st.to_location,st.flag,st.status,bm.id,bm.branch_name,count(sd.transaction_id)as quantity,case WHEN st.STATUS=0 THEN 'In Transit' else 'RECEIVED' end as sta,bmm.branch_name as tolocation  FROM `stock_inward` st join stock_inward_detail sd on st.transaction_id=sd.transaction_id left join branch_master bm on st.from_location=bm.id  
left join branch_master bmm on st.to_location=bmm.id 
group by st.transaction_id");
		}
		else{
			
			
			$row=mysqli_query($con,"SELECT st.id,st.transaction_id,st.date,st.vehicle_no,st.from_location,st.to_location,st.flag,st.status,bm.id,bm.branch_name,count(sd.transaction_id)as quantity,case WHEN st.STATUS=0 THEN 'In Transit' else 'RECEIVED' end as sta,bmm.branch_name as tolocation  FROM `stock_inward` st join stock_inward_detail sd on st.transaction_id=sd.transaction_id left join branch_master bm on st.from_location=bm.id  
left join branch_master bmm on st.to_location=bmm.id 
where bm.id='$branch_id' group by st.transaction_id");
			
			
		}
		
		
		
		
		
		$s=1;
				while($type=mysqli_fetch_array($row))
				{
					?>
            <tr>
			   <td><?php echo $s++ ;?></td>
               <td><?php echo date("d-m-Y",strtotime($type['date']));?></td>
               <td><?php echo $type['vehicle_no'];?></td>
			   <td><?php echo $type['quantity'];?></td>
               <td><?php echo $type['branch_name'];?></td>
               <td><?php echo $type['tolocation'];?></td>
               <?php 
			 $sts=$type['sta'];
			   if ($sts=="In Transit")
				{
				?>
                <td style="color:red;"><?php echo $type['sta'];?></td>
				<?php
				}
				else {
				?>
				<td style="color:green;"><?php echo $type['sta'];?></td>
				<?php
				}
				?>
		
            </tr>
				<?php } ?>
		</tbody>
    </table>
	</div>
	</div>
	<div class="clearfix"></div>
	</div>
	</body>
	</html>
	
 <?php require("../mainjavascript.js");?>


