<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>

<?php
$branch=$_SESSION['branch'];
$sql = "SELECT * FROM eduportal_product_config where branch_id='$branch' ";

if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {
        $from=date("Y-m-d",strtotime($_REQUEST['from']));  

      }else {
        $from=date("Y-m-01");  
      }
     
      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {
        $to=date("Y-m-d",strtotime($_REQUEST['to']));
      }else {
        $to=date("Y-m-t");  
      } 
      
     
    $sql .= "and post_date BETWEEN '" .$from. "' AND '" .$to. "' ";

$Products = $m->query($sql);
 //print_r($categories);
 
     ?>

<!DOCTYPE html>
<html lang="en">
  <head>
   
    <title> View Students | EduPortal </title>
     <?php include('RootMe/css_links.php');?> 
  </head>
  


<script>

  function HideDate1(str){
  
  if(str=="1"){
    
    document.getElementById("from").style.display="block";
    document.getElementById("to").style.display="block";
    document.getElementById("col1").style.display="block";
    document.getElementById("col2").style.display="block";
  }
  else {
    
    document.getElementById("from").style.display="none";
    document.getElementById("to").style.display="none";
    document.getElementById("col1").style.display="none";
    document.getElementById("col2").style.display="none";
  }
}

</script>

<script type="text/javascript">
  
  function checkboxes(){
  
var chk_arr =  document.getElementsByName("students[]");
var chklength = chk_arr.length;             
var students;
var count=0;
//alert(chk_arr);
  for(k=0;k< chklength;k++)
  {
      
      if(chk_arr[k].checked){
         var vl=chk_arr[k].value.split(",");
         students=students+","+vl[1];
        count++;  
        
    }

  } 
   // alert(students);
if(count>0){

  window.location="messages.php?students="+students;
}else {
  
  alert("Please choose any students from checkboxes...");

}
  
}




  function checkboxes_urdu(){
  
    var chk_arr =  document.getElementsByName("students[]");
    var chklength = chk_arr.length;             
    var students;
    var count=0;
    //alert(chk_arr);
      for(k=0;k< chklength;k++)
      {
          
          if(chk_arr[k].checked){
             var vl=chk_arr[k].value.split(",");
             students=students+","+vl[1];
            count++;  
            
        }

      } 
       // alert(students);
    if(count>0){

      window.location="newurdusms.php?students="+students;
    }else {
      
      alert("Please choose any students from checkboxes...");

    }
      
}


</script>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
            <div class="right_col" role="main">

               <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                   
                  Product List
                      
                              <br><br>
                              
            <div class="row" style="background-color: white;">
  

<section class="add_sub_agent" id="table_sub_agent">
  <div class="container">


 <div class="" style="margin-top:10px;">



      <form class="" action="canteen_products.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><?php echo count($Products);?> Books Records <span style="float:right;margin-top: -7px;">

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


      <a href="add_product.php" style="float: right;" class="btn btn-success">Add Product</a>

          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12">  


                 <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col1">
                 <div class="form-group ">

                 <label class="required"> From Date</label>
                 <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"  >
                       
                  </div>
                  </div>                      
             

                  <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;"  id="col2">

                       <div class="form-group ">

                          <label class="required"> To Date</label>
                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control"  >
                       
                          </div>
                  </div>  

                                  
                  
                  <div class="col-md-1 " style="padding:8px;">
                <div class="form-group ">
                   <input type="hidden" name="addaccountAdmin" value="1">
                <button type="submit" class="btn btn-primary" style="margin-top: 24px;">Search</button>
                </div>
              </div> 
              
               <div class="col-md-3 " style="padding:8px;">
                <div class="form-group ">
                <a href="print_book_product_list.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>" target="_blank" class=" btn btn-primary" style="margin-top: 24px;"> Print Report </a>

                <a href="canteen_products_export_excel.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&from=<?php echo $_GET['from'];?>&to=<?php echo $_GET['to'];?>" target="_blank" class=" btn btn-success" style="margin-top: 24px;"> Export Excel </a>

                </div>
              </div> 
        </div>   
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

      

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">
  
   
        <thead>
            <tr>

              
                <th width="5%">S.No</th>
                <th width="8%">Product Name</th>
                <th width="8%">Product Code</th>
                <th width="8%">Product Brand</th>
                <th width="9%"> Product Category </th>
                <th width="8%"> Unit Cost </th>
                <th width="8%"> Sale Price </th>
                <th width="8%"> Unit Quantity </th>
                <th width="8%"> Total Pirce </th>               
                <th width="8%">Action </th>
          
               
                
            </tr>
        </thead>
        <tbody>

     <?php 

      $count=1;
      foreach($Products as $Product)
      { 

        $m->where("brand_id", $Product['product_brand']);
        $brand_name=$m->get("eduportal_brand_config");

        $m->where("category_id", $Product['product_category']);
        $category_name=$m->get("eduportal_category_config");

        $nt+=$Product['unit_qty']*$Product['sale_price']; 

                
      ?>

        <tr>

          <td style="text-align:center; padding: 2px;"><?php echo $count++;?></td>        

          <td style="padding: 2px;" > <?php echo $Product['product_name'];?></td>

          <td style="padding: 2px;" > <?php echo $Product['product_code'];?></td>

          <td style="padding: 2px;" > <?php echo $brand_name[0]['brand_name'];?></td>

          <td style="padding: 2px;" > <?php echo $category_name[0]['category_name'];?></td>

          <td style="padding: 2px;" > <?php echo $Product['unit_cost'];?></td>

          <td style="padding: 2px;" > <?php echo $Product['sale_price'];?></td>

          <td style="padding: 2px;" > <?php echo $Product['unit_qty'];?></td>

          <td style="padding: 2px;" > <?php echo $Product['unit_qty']*$Product['sale_price'];?></td>

          
          <td>        
            

              <a style="padding: 0px 5px; font-size:14px;"  href="add_product.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&product=<?php echo $Product['product_id'];?>" style="cursor:pointer;"  class="btn btn-success"> <i class="fa fa-pencil" aria-hidden="true"></i></a>

              

        <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?product_id=<?php echo $Product['product_id'];?>&action=DeleteProduct" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger"><i class="fa fa-remove"></i> </a>

 
        
        </td>
  

  </tr> <?php   } ?>


<tr style="background-color:#022A55;color: white;"> 

<td colspan="8" style="font-size:18px;text-align: center;">Total</td>
<td colspan="2" class=" center" style="border-right:1px solid black;font-size:18px;text-align: center;"><?php echo number_format($nt,2);?></td>


</tr>
 
        </tbody>
        
    </table>

  </div>

    

    <br><br>


  </div>
  <div class="clearfix"></div>
</section>

        </div> 
        </div>


            </div>
          </div>
        </div>


     
        <!-- /page content -->


 <!-- jQuery -->
    <script src="js/ajax_functions.js"></script>
  <?php include('RootMe/js_linksscript.php');?> 
  <!-- Links for Datatable-->

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
 <script>
        
  $(document).ready(function() {
    $('#listofstudents').DataTable({
      "pageLength": 100
    });
    } 
  );

  $("#checkAll").change(function () {

      $("input:checkbox").prop('checked', $(this).prop("checked"));
  });


</script>
  
  </body>
</html>
