<?
session_start();

REQUIRE_ONCE('functions.php');

REQUIRE_ONCE('face.php');

$r="SELECT * FROM products order by p_name  ASC";
$sql=mysqli_query($dbc,$r);
$type='SALES';

Permission($_SESSION['department'],$type);
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.0.0.58475 -->
        <meta charset="utf-8">
        <title>Products View</title>
        <!--<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">-->
        <meta name="HandheldFriendly" content="True"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
        <meta name="HandheldFriendly" content="true" />
        <meta name="MobileOptimized" content="true" />

        <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
        <link rel="stylesheet" href="style.css" media="screen">
        <!--[if lte IE 7]><link rel="stylesheet" href="style.ie7.css" media="screen" /><![endif]-->
        <link rel="stylesheet" href="style.responsive.css" media="all">


        <script src="data/jquery-3.5.1.js"></script>
        <script src="script.js"></script>
        <script src="script.responsive.js"></script>
        <meta name="description" content="NEURO DATA">
        <meta name="keywords" content="EZ-SACCO">
 <nav class="art-nav clearfix">
                <?php headermenu($_SESSION['department'],'SALES'); ?> 
            </nav>

<head>

<link rel="stylesheet" href="tables.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="data/tables.min.css" />

</head>
<script type="text/javascript" src="data/data.min.js"></script>
<script type="text/javascript" src="data/data.bootstrap.min.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
      
        <link href="css/datepicker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
//<![CDATA[

/*
        A "Reservation Date" example using two datePickers
        --------------------------------------------------

        * Functionality

        1. When the page loads:
                - We clear the value of the two inputs (to clear any values cached by the browser)
                - We set an "onchange" event handler on the startDate input to call the setReservationDates function
        2. When a start date is selected
                - We set the low range of the endDate datePicker to be the start date the user has just selected
                - If the endDate input already has a date stipulated and the date falls before the new start date then we clear the input's value

        * Caveats (aren't there always)

        - This demo has been written for dates that have NOT been split across three inputs

*/

function makeTwoChars(inp) {
        return String(inp).length < 2 ? "0" + inp : inp;
}

function initialiseInputs() {
        // Clear any old values from the inputs (that might be cached by the browser after a page reload)
        document.getElementById("sd").value = "";
        document.getElementById("ed").value = "";

        // Add the onchange event handler to the start date input
        datePickerController.addEvent(document.getElementById("sd"), "change", setReservationDates);
}

var initAttempts = 0;

function setReservationDates(e) {
        // Internet Explorer will not have created the datePickers yet so we poll the datePickerController Object using a setTimeout
        // until they become available (a maximum of ten times in case something has gone horribly wrong)

        try {
                var sd = datePickerController.getDatePicker("sd");
                var ed = datePickerController.getDatePicker("ed");
        } catch (err) {
                if(initAttempts++ < 10) setTimeout("setReservationDates()", 50);
                return;
        }

        // Check the value of the input is a date of the correct format
        var dt = datePickerController.dateFormat(this.value, sd.format.charAt(0) == "m");

        // If the input's value cannot be parsed as a valid date then return
        if(dt == 0) return;

        // At this stage we have a valid YYYYMMDD date

        // Grab the value set within the endDate input and parse it using the dateFormat method
        // N.B: The second parameter to the dateFormat function, if TRUE, tells the function to favour the m-d-y date format
        var edv = datePickerController.dateFormat(document.getElementById("ed").value, ed.format.charAt(0) == "m");

        // Set the low range of the second datePicker to be the date parsed from the first
        ed.setRangeLow( dt );
        
        // If theres a value already present within the end date input and it's smaller than the start date
        // then clear the end date value
        if(edv < dt) {
                document.getElementById("ed").value = "";
        }
}

function removeInputEvents() {
        // Remove the onchange event handler set within the function initialiseInputs
        datePickerController.removeEvent(document.getElementById("sd"), "change", setReservationDates);
}

datePickerController.addEvent(window, 'load', initialiseInputs);
datePickerController.addEvent(window, 'unload', removeInputEvents);

//]]>
</script>

<!--sa error trapping-->
<script type="text/javascript">
function validateForm()
{
var x=document.forms["com"]["date"].value;
if (x==null || x=="")
  {
  alert("you must enter your start  Date(click the calendar icon)");
  return false;
  }

}
</script>
<div id="header">
	<div id="logo">
		
	</div>
<?



?>
</div><div id="layer2" style="margin-right:1000px;">
<form name="export" action="export.php" method="post">
    <input type="image" value=<img src="excel.png" width="50" height="41"/></a>
    <input type="hidden" value="<? echo $csv_hdr; ?>" name="csv_hdr">
    <input type="hidden" value="<? echo $csv_output; ?>" name="csv_output">
	
</form></div></center>
 <p align="center"><a rel="facebox" href="ad_products.php">Add New Sale Products Not Present In Database</a> </p>
<script>
$(document).ready(function() {
    $('#example').DataTable();
} );
</script>

 <style>
   .nav-pills .nav-link.active {
    background-color: #9ACD32 !important;
   }  
 .btn{
      background-color: #9ACD32 !important;
     position: relative;
    display:block;
     padding: 10px 25px 10px 25px;
  border: 2px solid #34495e;
  border-radius: 4px;
  color: #34495e;
  margin-right: 15px;
  
 }
 .btn:hover{
     cursor:pointer;
      background-color:#3E4958;
 }

</style> 

<body>
    <div class="table-responsive">
	<table id="example" class="table table-striped table-bordered" style="width:100%">
        <thead style="background-color:#008080;">
            <tr>
                <th>Product</th>
              
                <th>Category</th>
                <th>Qty Left</th>
                <th>Retail Price</th>
                 
           
                <th>Buy Price</th>
				  <th>Action</th>
            </tr>
        </thead>
        <tbody>
			  <?
   while($row = mysqli_fetch_array($sql))
{ 
	  echo '<tr><td>'.$row['p_name'].'</td>';
//	echo '<td>'.$row['code'].'</td>';
  
	   echo '<td>'.$row['category'].'</td>';
	  
      echo '<td><div align="center">'.$row['left_p'].'</div></td>';
      echo '<td><div align="center">'.$row['price'].'</div></td>';
	//   echo '<td><div align="center">'.$row['minimum'].'</div></td>';
	  //echo '<td><div align="center">'.$row['distro'].'</div></td>';
	        echo '<td><div align="center">'.$row['buying'].'</div></td>';
			  //   echo '<td><div align="center">'.$row['vat'].'</div></td>';
	   //echo '<td><div align="center">'.$row['reorder'].'</div></td>';
      echo '<td><div align="center">'.'<a rel="facebox" href=edt_product.php?id=' . $row["product_id"] .'>edit</a>'.'|'.
	  '<a rel="facebox" href=delete_product.php?id=' . $row["product_id"] .'>del</a>'.' </div></td>';
    echo '</tr>';
 }

 
 ?>

   </tbody>
        </table></div>
        



	
</body>

</html>