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

<?php


     $branch=$_SESSION['branch']; 
     if ($_REQUEST['month']!=NULL) {
      $month=$_REQUEST['month']; 
     } else {
     $month=date('Y-m');    
     }

   $session;

   if($_REQUEST['session']!=NULL){

      $session=$_REQUEST['session'];
      
    }else {
      
      $session=$_SESSION['current_session'];
    }


     /* code for advance Search*/


$sql = "SELECT esd.student_id, esd.ref_no, esd.candidate_roll_no, esd.first_name, esd.last_name, esd.class_id, esd.section_id, esd.date_of_adms, emc.from_year_month
FROM edu_student_details esd
LEFT JOIN eduportal_monthly_challan emc ON esd.student_id = emc.student_id AND emc.from_year_month = '$month'
WHERE esd.branch_id = '$branch' AND esd.status='0' AND emc.student_id IS NULL";

if (isset($_REQUEST['class_id'])) {
if ($_REQUEST['class_id'] !== 'All') {
$sql .= " AND esd.class_id = '" . $_REQUEST['class_id'] . "'";
}

if ($_REQUEST['section'] !== 'All') {
$sql .= " AND esd.section_id = '" . $_REQUEST['section'] . "'";
}
}

$sql .= " ORDER BY CAST(esd.class_id AS SIGNED), CAST(esd.section_id AS SIGNED), CAST(SUBSTRING_INDEX(esd.candidate_roll_no, '-', 1) AS UNSIGNED) ASC, 
CAST(SUBSTRING_INDEX(esd.candidate_roll_no, '-', -1) AS UNSIGNED) ASC";
//echo $sql;
$WorkAssignListings = $m->query($sql);

// $sql = "SELECT esd.student_id, esd.ref_no, esd.candidate_roll_no, esd.first_name, esd.last_name, esd.class_id, esd.section_id FROM edu_student_details esd 
// LEFT JOIN eduportal_monthly_challan emc
// ON esd.student_id = emc.student_id
// AND emc.branch_id = '$branch' ";

// if ($_REQUEST['class_id'] !== 'All') {
//     $sql .= " AND emc.classs_id = '" . $_REQUEST['class_id'] . "'";
// }

// if ($_REQUEST['section'] !== 'All') {
//     $sql .= " AND esd.section_id = '" . $_REQUEST['section'] . "'";
// }

// $sql .= " AND emc.from_year_month = '$month'";

// $sql .= " WHERE esd.branch_id = '$branch'";

// if ($_REQUEST['class_id'] !== 'All') {
//     $sql .= " AND esd.class_id = '" . $_REQUEST['class_id'] . "'";
// }

// if ($_REQUEST['section'] !== 'All') {
//     $sql .= " AND esd.section_id = '" . $_REQUEST['section'] . "'";
// }

// $sql .= " AND emc.student_id IS NULL";
// //echo $sql;
// $WorkAssignListings = $m->query($sql);


 

 ?>

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

 <link href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css" rel="stylesheet">

  </head>
  <script type="text/javascript">


function getsecall(str)

{



   if(str=="")

      alert("Please select any Class");

  else

     var ajx;  // The variable that makes Ajax possible!

  

  if(window.XMLHttpRequest)

  ajx=new XMLHttpRequest();

  ajx.onreadystatechange = function()

  {



    if(ajx.readyState == 4)

    {

          // alert(ajx.responseText); 

         document.getElementById("txt_section").innerHTML= ajx.responseText;

    }

  }

  ajx.open("GET", "get_section_all.php?class_id="+str);

  ajx.send(); 



}

  </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">
            <div class="row" style="background-color: white;">
  
   <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
    
     <a href="multi_fee_reports.php">Fee Reports </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
          
      Missing Invoice Students Report

      <br><br>

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



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



      <form class="" action="missing_invoice_students.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <div class="panel-heading"><?php //echo count($WorkAssignListings);?> <!-- Students 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" />



          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            <div class="col-md-12" id="" style="">
            
              <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Grade</label>

            
                    <select name="class_id" onChange="getsecall(this.value)" class="form-control" >
                     <option value="All">All</option> 
                    <?php
                    $m->where("branch_id", $_SESSION['branch']);
                    $WorkAssignList = $m->get("edu_class_config");
                    foreach($WorkAssignList as $WorkAssignListVal)
                    { ?>

                       <option <?php if($_REQUEST['class_id']==$WorkAssignListVal['class_id']){echo 'selected';}?> value="<?php echo $WorkAssignListVal['class_id']; ?>"><?php echo $WorkAssignListVal['Class_Name']; ?></option>


                            <?php
                    } ?>

                    </select>

                  
                </div>
              </div>


              <div class="col-md-2 col-xs-12" style="padding: 8px;">
                <div class="form-group ">
                  <label class="required">Section</label>

            
                    <select name="section" id="txt_section" class="form-control">
                      
                        <option value="All">All</option> 
                   <?php

                              if($_REQUEST['section']!='')

                              { 
                              $m->where("class_id", $_REQUEST['class_id']);

                              $secondLevel = $m->get("edu_adm_section_detail");

                              foreach($secondLevel as $secondLevel_val)

                              {

                               ?>

                                <option <?php if($_REQUEST['section']==$secondLevel_val['section_id']){echo "selected";} ?> value="<?php echo $secondLevel_val['section_id']; ?>"><?php echo trim(utf8_encode_all($secondLevel_val['section_name'])); ?></option>

                              <?php }   ?>

                                

                          <?php } ?>



                    </select>

                  
                </div>
              </div>
              


                <div class="col-md-2 col-xs-12" style="padding: 8px;">
                    <div class="form-group ">

                    <label class="required">Month</label>

                    <input type="month" id="month" name="month" required class="form-control" value="<?php
                    if ($month!=NULL) {
                    echo $month;
                    } else {
                    echo date("Y")."-".date("m"); }?>">


                    </div>
                    </div>

                        


        <div class="col-md-2" style="padding:2px;margin-top: 29px;">
        <div class="form-group ">
        <input type="hidden" name="addaccountAdmin" value="1">
        <button type="submit" class="btn btn-primary">Search</button>
        <a style="" href="print_missing_invoice_students.php?session=d702958bebc5b126fcc2ecba847749b7d702958bebc5b126fcc2ecba847749b7d702958bebc5b126fcc2ecba847749b7d702958bebc5b126fcc2ecba847749b7d702958bebc5b126fcc2ecba847749b7&class_id=<?php echo $_REQUEST['class_id'];?>&section=<?php echo $_REQUEST['section'];?>&month=<?php echo $_REQUEST['month'];?>" class="btn btn-primary">Print</a>
       

        </div>

        </div>

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


 
<table class="table table-bordered table-striped" id="myTable">   
   
        <thead>
            <tr style="background-color: #042954; color: white;">

              
                <th width="3%">S.No</th>        
                <th width="8%" style="text-align:center;">Adm/Roll</th>
                <th width="8%" style="text-align:center;"> Student Name </th>
                <th width="8%" style="text-align:center;"> Father Name </th>
                <th width="8%" style="text-align:center;"> Admission Date </th>
                <th width="8%" style="text-align:center;"> Grade </th>
                <th width="8%" style="text-align:center;"> Section </th>
          
                                
            </tr>
        </thead>
        <tbody>

     <?php 

      $count=1;
      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $std=$WorkAssignListVal['student_id'];
        $dateOfAdm=date("Y-m", strtotime($WorkAssignListVal['date_of_adms']));

        if ($dateOfAdm > $_REQUEST['month']) {
        continue;
        }       
         
      ?>

<tr>
<td><?php echo $count++;?></td>
<td><?php echo $WorkAssignListVal['ref_no']."/".$WorkAssignListVal['candidate_roll_no'];?></td>
<td><?php echo $WorkAssignListVal['first_name'];?></td>
<td><?php echo $WorkAssignListVal['last_name'];?></td>
<td><?php echo date("d-M-Y", strtotime($WorkAssignListVal['date_of_adms']));?></td>
<td><?php echo getClassName($m,$WorkAssignListVal['class_id']);?></td>
<td><?php echo getSectionName($m,$WorkAssignListVal['section_id']);?></td>


</tr> <?php   } ?>
 
        </tbody>
        
    </table>

  </div>

    </form>

    <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');?> 
  <!-- <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> -->
    <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>

    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.7.1/css/buttons.bootstrap4.min.css">

    <script>
        $(document).ready(function() {
            var table = $('#myTable').DataTable({
                dom: 'Bfrtip',
                buttons: [
                    'excel'
                ]
            });
        });
    </script>


  
  </body>
</html>
