<?
session_start();
include('includes/config.php');
include('defs.php');

if(strlen($_SESSION['aid'])==0)
  { header('location:index.php');
}

$usr=$_SESSION['uname'];



 ?>


 <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>GLAKB  | View Todays Purchases</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
  <!--Function Email Availabilty---->

</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
  <!-- Navbar -->
<?php include_once("includes/navbar.php");?>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
 <?php include_once("includes/sidebar.php");?>

 
  <div class="content-wrapper">

<?
$result12 = mysqli_query($link, "select Role from user_details where Name='$usr' ");
$row12=  mysqli_fetch_object($result12);
$role = $row12->Role;
$mrole = $row12->Role;
if($role=='Operator')
{
$result = mysqli_query($link, "select Role from user_priv where Name='$usr' and Form='View-Purchase' ");
$row=  mysqli_fetch_object($result);
$role = $row->Role;
if($role=='0')
{
{
echo"<center>";
echo"<br><br><br><br><br>";
echo"<img src='users.png' width='160' height='160'><br>";
echo "<font size=6 color=red><b>ACCESS DENIED!</b><br>";
echo "<font size=4 color=darkblue><b>You Do Not Have Permission to View This Page.</b><br>";
goto a;
}
}
}

echo "                <form name='m_head' action='' onSubmit='return formconfirm()' method=POST >";


              ?>
<script language="javascript" type="text/javascript">

   window.onload= function show()
                        {
                                if(document.m_head.strdept.value =="")
                                        {

                                                document.m_head.strdept.focus()
                                        }
                                        }
                                        



  function show_cbo1()
                {
                        var val = document.getElementById('item3').value;
                        
                        location.href = "search.php?Name="+val;
                }

function formconfirm() {


if((document.m_head.item3.value) == '')
{
alert("Please Seelct Category to Search!");
document.m_head.item3.focus();
return false;
}


    if((document.m_head.strdept.value) == '')
        
    {
            alert("Please Enter Search Value!");
document.m_head.strdept.focus();

            return false;
        }

    



return true;
}
  </script>


<html>
<head>
<style>
#customers {
  font-family: Times-Roman;
  border-collapse: collapse;
  width: 98%;
}

#customers td, #customers th {
  border: 1px solid #4444;
  padding: 4px;
}

#customers tr:nth-child(even){background-color:gainsboro ;}


#customers th {
  padding-top: 5px;
  padding-bottom: 5px;
  text-align: center;
  background-color:dodgerblue;
  color: white;
}
</style>
 <link rel="stylesheet" href="css/style.css">





 <table align="center" id="customers">
    
<tr>
<th colspan="14"><font size="4">TODAYS PURCHASES / PURCHASES RETURN DETAILS</th>

  </tr> 
                           
                           
     
<?
date_default_timezone_set("Asia/Karachi");
$date2=date("Y-m-d"); 


if($mrole=='Administrator')
{
$result = mysqli_query($link, "SELECT * FROM p_details where Inv_Date='$date2' order by Id");
}

if($mrole=='Operator')
{
$result = mysqli_query($link, "SELECT * FROM p_details where Inv_Date='$date2' and addby='$usr'  order by Id");
}


        
                echo "        <td align=center>";
          echo "                <b><font size=3 color=darkblue> S.No </b>";
        echo "        </td>";

   
echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Warehouse</b>";
        echo "        </td>";
echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Invoice#</b>";
        echo "        </td>";

           echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Company Name</b>";
        echo "        </td>";
         echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Gross Total</b>";
        echo "        </td>";
 echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Discount</b>";
        echo "        </td>";
    
             echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Net Total</b>";
        echo "        </td>";

      
      
       echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>DC #</b>";
        echo "        </td>";
      
 echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Purchase #</b>";
        echo "        </td>";
        echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>Invoice By</b>";
        echo "        </td>";
 echo "        <td align=center>";
        echo "                <b><font size=3 color=darkblue>VIEW</b>";
        echo "        </td>";
     

        echo "</tr>";
        $count=0;
        $one=1;
        $pmma=0;
$pdis=0;
$tot=0;
$tons=0;


                                        while($row = mysqli_fetch_object($result))
                                        {
                                        $count=$one+$count;
$tot=$row->Total+$tot;
$tons=$row->N_Total+$tons;
$tdis=$row->Dis+$tdis;

$invt=$row->Inv_N."-".$row->Inv_No;

echo "<td align=center><font size=3 color=black>$count</td>";
echo "<td align=center><font size=3 color=black>$row->Warehouse</td>";
echo "<td align=center><font size=3 color=black>$invt</td>";
echo "<td align=center><font size=3 color=black>$row->Company</td>";
echo "<td align=center><font size=3 color=black>$row->Total</td>";
echo "<td align=center><font size=3 color=black>$row->Dis</td>";
echo "<td align=center><font size=3 color=black>$row->N_Total</td>";
echo "<td align=center><font size=3 color=black>$row->DC_No</td>";
echo "<td align=center><font size=3 color=black>$row->Pur_No</td>";

echo "<td align=center><font size=3 color=black>$row->addby</td>";

echo "<td align=center><a href =rep_pur_inv1.php?inv=$row->Inv_No target='_blank'><img src='viw.png' width='30' height='30'></a></td>";


echo "<tr>";
}
  echo "        <td align=center colspan=4>";
  echo "                <b><font size=3 color=darkblue>Grand Total</b>";
       
  
echo "<td align=center><font size=3 color=black><b>$tot</b></td>";
echo "<td align=center><font size=3 color=black><b>$tdis</b></td>";



echo "<td align=center><font size=3 color=black><b>$tons</b></td>";
echo "<td align=center colspan=5</td>";
  echo "
                                </form>
                                </table>
                        ";
a:
            include "footer.php";
?>

</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- bs-custom-file-input -->
<script src="../plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- Page specific script -->
<script>
$(function () {
  bsCustomFileInput.init();
});
</script>
</body>
</html>
<?php  ?>