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

<?php  include("sessioncheck.php"); 


   $year;


  if($_GET["year"]!=NULL ){

      $year= $_GET["year"];

    }

    else{
      $year= date("Y");

    }



$section=$_REQUEST['section'];

$year=$_REQUEST['year'];

$class=$_REQUEST['class_id'];

$branchId=$_SESSION['branch'];



$orderBy;



if (!isset($_REQUEST['orderBy'])) {



  $orderBy='asc';



} else {



$orderBy=$_REQUEST['orderBy'];



}



/*$WorkAssignListings = $m->query("SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$branchId' and sec.branch_id='$branchId' ORDER BY cls.class_id asc");*/



$query="SELECT * FROM edu_class_config where branch_id='$branchId' order by orderno asc ";



$WorkAssignListings = $m->query($query);







 $m->where("user_id", $_SESSION['user_id']);

$m->where ("branch_id", $_SESSION['branch']);

$m->where("page_id", 23);

$access = $m->get("users_privilege_detail");

 



?>





<!DOCTYPE html>

<html lang="en">

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!-- Meta, title, CSS, favicons, etc. -->

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title> View Challan | EduPortal </title>

       

    <?php include('RootMe/css_links.php');?>



 



  </head>





<script type="text/javascript">



function show_message(){

  

  $("#msg").slideDown('slow').delay(4000).slideUp('slow');

  $("#error").slideDown('slow').delay(5000).slideUp('slow');



}



</script>

 <script>

      



function getsec(id){



    if (window.XMLHttpRequest) {



      // code for IE7+, Firefox, Chrome, Opera, Safari



      xmlhttp=new XMLHttpRequest();



    } else { // code for IE6, IE5



      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");



    }



    xmlhttp.onreadystatechange=function() {



      if (xmlhttp.readyState==4 && xmlhttp.status==200) {



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

        // alert(xmlhttp.responseText);



      }



    }



    xmlhttp.open("GET","get_section_all.php?class_id="+id,true);



    xmlhttp.send();









  }

                 





  </script>



  <script type="text/javascript">

  

  function checkboxes(){

 // alert("786");

var chk_arr =  document.getElementsByName("students[]");

var chklength = chk_arr.length;             

var students;

var count=0;



  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...");



}

  

}



</script>



<style type="text/css">

    .center {

  margin-left: auto;

  margin-right: auto;

}

  </style>



  <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">



      <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; View Challan



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



  <?php

   if ($access[0]['delete_access']!=NULL) { 

   if (isset($_REQUEST['month'])) { ?>   

 



<!--   <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?&month=<?php echo $_REQUEST['month'];?>&year=<?php echo $_REQUEST['year'];?>&action=DeleteAllClassesMonthlyChallan" style="float: right;" onClick="return confirm('Are you sure you want to delete All Classes Challan');"  class="btn btn-danger">Delete All Classes Challan </a> -->



 <?php } }?>



      <form class="" action="view_challan.php" enctype="multipart/form-data" method="get">

        <div class="panel panel-default">

          <div class="panel-heading " id="heading"><!-- <?php echo $total_records;?> 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">Year</label>

                  <select name="year" class="form-control">

                    <option value="All">All</option>

                    <?php

                    $match;

                    if(!isset($_REQUEST['year'])){

                      $match=date("Y");

                    }else { $match=$_REQUEST['year']; }

                    for($i=2018;$i<2031;$i++){ ?> 

                      <option <?php if($match==$i){echo 'selected';}?> value="<?php echo $i; ?>"><?php echo $i; ?></option>

                    <?php } ?>  

                  </select>

                </div>

              </div> 



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

    <div class="form-group ">



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

    <input type="month" id="month" name="month" required class="form-control" min="" value="<?php if (isset($_REQUEST['month'])) {
    echo $_REQUEST['month'];
    } else { echo date("Y")."-".date("m");}?>">

    </div>

    </div> 





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



                       <div class="form-group ">



                          <label class="required">Fee Status</label>

                              <select name="fee" onChange="HideDate(this.value);" class="form-control"  >



                                <option value="All">All</option>

                          

                                <option <?php if($_GET['fee']=="1"){echo 'selected';}?> value='1'>PAID</option>

                                <option <?php if($_GET['fee']=="0"){echo 'selected';}?> value='0'>UNPAID</option>

                          



                                  

                              </select>

                            </div>





                    </div>

        

        

    

              <div class="col-md-3 pull-right" style="padding:2px;">

                <div class="form-group ">

                   <input type="hidden" name="addaccountAdmin" value="1">

                <button type="submit" class="btn btn-primary" style="margin-top: 24px;float: right;">Search</button>

                </div>

              </div>



             

            </div>

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

          </div>

        </div>

      </form>

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

    </div>



<?php  if(isset($_SESSION['msg_not_sent'])){?>



<div class="alert alert-danger" id="msg">

<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>

<strong>Warning!</strong> You can't send this SMS because your SMS Limit has been Exceed. Remaining SMS: <?php echo $sms_credit-$total_sms_monthly_used;?>

</div>





<?php  unset($_SESSION['msg_not_sent']);

           }?>

     

             



   <?php if (isset($_REQUEST['month'])) { ?>    







   <table data-page-length='100' class="table table-striped table-bordered center" style="width:100%">

          

          <thead>

            <tr>

                <th width="3%">S.No</th>

                <th width="27%">Class Name</th>

                <th width="70%">Details</th>                          

                               

            </tr>

        </thead>

        <tbody>





   

     

     <?php $count=1;



      foreach($WorkAssignListings as $WorkAssignListVal)

      { 





        // $m->where("session_id", $_REQUEST['session']);

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

        $m->where("classs_id", $WorkAssignListVal['class_id']);

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

        $m->where("from_year_month", $_REQUEST['month']);

        $m->where("branch_id", $_SESSION['branch']);

        $month_chalan=$m->get("eduportal_monthly_challan");



        // check for challan paid in this month


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

        $m->where("classs_id", $WorkAssignListVal['class_id']);

        $m->where("paid_status", 1);

        $m->where("from_year_month", $_REQUEST['month']);

        $m->where("branch_id", $_SESSION['branch']);

        $monthly_chalan_paid=$m->get("eduportal_monthly_challan");



        $query=" select * from eduportal_monthly_challan where branch_id='$branchId' order by challan_id desc limit 1 ";
        //print_r($query);
        $last_challan = $m->query($query);

             

      ?>



             <tr>

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

          <td><?php echo $WorkAssignListVal['Class_Name'];?></td>



          <?php if(count($month_chalan)>0) { ?>



          <td>



                



                <div class="col-md-3" >



              

                <button style="padding:6%;margin-top: -5px;" data-toggle="dropdown" class="btn btn-primary dropdown-toggle btn-sm" type="button" aria-expanded="true"><i class="fa fa-print m-right-xs"></i>&nbsp;Print Vouchers <span class="caret"></span>

                </button>









                <ul role="menu" class="dropdown-menu">               
               

                  <li><a href="print_all_vouchers_single.php?a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156&amp;class_id=<?php echo $WorkAssignListVal['class_id'];?>&month=<?php echo $_REQUEST['month'];?>&year=<?php echo $_REQUEST['year'];?>&section=All&fee=<?php echo $_REQUEST['fee'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1" target="_blank" >Single Vouchers</a> </li>
                                         

                  <li><a href="print_all_vouchers_db.php?a61oea61oe8lqc1oclfi4llgnioo156&amp;class_id=<?php echo $WorkAssignListVal['class_id'];?>&month=<?php echo $_REQUEST['month'];?>&year=<?php echo $_REQUEST['year'];?>&section=All&fee=<?php echo $_REQUEST['fee'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1" target="_blank" 

                 >Double Vouchers</a> </li>


                <li><a href="print_all_voucheres.php?a61oe8i4llgnioo156a61oa61oe8lqc1oclfi4llgnioo156&amp;class_id=<?php echo $WorkAssignListVal['class_id'];?>&month=<?php echo $_REQUEST['month'];?>&year=<?php echo $_REQUEST['year'];?>&section=All&fee=<?php echo $_REQUEST['fee'];?>&8lqc1oclfi4llgnioo156a61oe8lqc1oclfi4llgnioo156a61oe8lqc1"  target="_blank">Triple Vouchers</a> </li>


                    </ul>

              </div>

          


            <!--   	<div class="col-md-2" >  





                  <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?class_id=<?php echo $WorkAssignListVal['class_id'];?>&year=<?php echo $_GET['year'];?>&month=<?php echo $_GET['month'];?>&sms_left=<?php echo $sms_credit-$total_sms_monthly_used;?>&fee=All&action=SendFeeNotificationsClassWise" style="padding: 7px; font-size:14px;" onClick="return confirm('Are you sure you want to send fee SMS to parents');" class="btn btn-primary">Send Fee SMS </a>

	          

	           </div> -->

		                

              <!-- 	<div class="col-md-2" >  



                  <a target="_blank" href="view_challan_details.php?<?php echo session_id().session_id();?>&class_id=<?php echo $WorkAssignListVal['class_id'];?>&month=<?php echo $_GET['month'];?>&section=All&year=<?php echo $_GET['year'];?>&fee=<?php echo $_REQUEST['fee'];?>" class="btn btn-primary">View Challan</a>



	           </div> -->





             <div class="col-md-2" >  

              <?php if ($access[0]['delete_access']!=NULL /*&& count($monthly_chalan_paid)==0*/ && $last_challan[0]['from_year_month']==$_REQUEST['month'] && $last_challan[0]['year']==$_REQUEST['year']) { ?>

                  <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?class_id=<?php echo $WorkAssignListVal['class_id'];?>&month=<?php echo $_REQUEST['month'];?>&year=<?php echo $_REQUEST['year'];?>&section=<?php echo $_GET['section'];?>&action=DeleteAllMonthlyChallan" style="" onClick="return confirm('Are you sure you want to delete All Challan');"  class="btn btn-danger">Delete Challan </a>

              <?php } ?>

             </div>

              



               </td>

             

             <?php } else { ?>



              <td style="color: red;">Challan Not Created</td>



                </tr>



              <?php

      } } ?>



        </tbody>

        

    </table>





<?php  } else {?>

<br><br>

  <div  style="display:block;" class="alert alert-danger alert-dismissible">

      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>

       <strong>Warning !</strong> Please select Month and serarch !!!

  </div>

  <?php }?>







        </div> 

        </div>





            </div>

          </div>

        </div>

        <!-- /page content -->



    <?php include('RootMe/js_linksscript.php');?>



  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

    <script>

        $(document).ready(function() {

        $('#listofstudents').DataTable();

        $("th").removeClass("sorting");

        } 

        );



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



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

      });

    </script>

  </body>

</html>

