<style>
    .required{
        color: #bf5050;
    }
    
</style>
<!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Class Wise Vouchers</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

                    <form class="form-horizontal form-label-left" id="theform" action="<?php echo $base_url; ?>voucher/create" method="post">

                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="class">Date<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                         
            <input type="input"  min="<?php echo date('d-m-Y'); ?>" max="<?php echo date('d-m-Y',strtotime('first day of +1 month')); ?>" id="date" class="form-control date datepicker" name="date" pattern="([0-9]{2}|[0-9]{1})[-]([0-9]{2}|[0-9]{1})[-][0-9]{4}" required-temp="true" placeholder="dd-mm-yyyy"value="<?= $date; ?>" >           
                        </div>
                      </div>
                       <?php if($this->user_model->is_super()){ ?>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Branch <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="branch" class="form-control col-md-7 col-xs-12" name="branch" required="required">
                            <option value=''>Select Branch</option>
                      <?php
                            foreach ($branch as $value) {
                      ?>
                            <option value="<?php echo $value['id']; ?>"><?php echo $value['name']?></option>

                      <?php } ?>
                          </select>
                        </div>
                      </div>
                      <?php  }else{$branch=$this->user_model->getbranch();?>
                          <input id="branch" name="branch" type="hidden" value="<?= $branch ?>">
                      <?php  } ?>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="class">Class <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="class" class="form-control col-md-7 col-xs-12" name="class" required="required">
                            <option value="">Select Class</option>
                          </select>
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Section <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="section" name="section" class="form-control col-md-7 col-xs-12" required>
                            <option value="">Select Section</option>
                          </select>
                            <span class="text-danger" style="font-weight:bold;"><input type="checkbox" name="tution_check" id="tution_check" disabled title="Select Section First"/>(Tution Fee not included)</span>
                        
                        </div>
                      </div>

                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Student <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="student" multiple name="student[]"  class="form-control col-md-7 col-xs-12 mdb-select" multiple searchable="Search here.." required>
                             
                          </select>
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="class">Additional months fee</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="add_months" class="form-control col-md-7 col-xs-12" multiple name="add_months[]">
                            <?php 
                                foreach ($add_months as $key => $value) {
                                    echo "<option value='$value'>".date('F-Y',strtotime($value))."</option>";
                                }
                            ?>
                          </select>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <h3>Other Fee</h3>
                      <div id="fee_wrapper" class="row">
                        <div class="col-md-offset-3 col-md-6 col-sm-6 col-xs-12">
                          <div class="form-control col-md-7 col-xs-12">
                            Select Above Values to show other fee's
                          </div>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <input class='btn btn-success' type="submit" value="Create Voucher" style="float:right;" id='send' />   
                                
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

        <!-- footer content -->
        <footer>
          <div class="pull-right">
            Prudmac
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
   
    
    <!-- CSS -->
    <link href="<?php echo base_url(); ?>assets/multi_select/jquery.multiselect.css" rel="stylesheet">
     <!-- jQuery -->
    <!--<script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>-->
    <script src="<?php echo base_url(); ?>assets/multi_select/jquery.multiselect.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    <!-- Custom JS -->
    <script src="<?php echo base_url(); ?>assets/js/main.js"></script>
    <!-- Bootstrap -->
    <script src="<?php echo base_url(); ?>assets/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo base_url(); ?>assets/vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="<?php echo base_url(); ?>assets/vendors/nprogress/nprogress.js"></script>
    <!-- Chart.js -->
    <script src="<?php echo base_url(); ?>assets/vendors/Chart.js/dist/Chart.min.js"></script>
    <!-- gauge.js -->
    <script src="<?php echo base_url(); ?>assets/vendors/gauge.js/dist/gauge.min.js"></script>
    <!-- bootstrap-progressbar -->
    <script src="<?php echo base_url(); ?>assets/vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
    <!-- iCheck -->
    <script src="<?php echo base_url(); ?>assets/vendors/iCheck/icheck.min.js"></script>
    <!-- Skycons -->
    <script src="<?php echo base_url(); ?>assets/vendors/skycons/skycons.js"></script>
    <!-- Flot -->
    <script src="<?php echo base_url(); ?>assets/vendors/Flot/jquery.flot.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/Flot/jquery.flot.pie.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/Flot/jquery.flot.time.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/Flot/jquery.flot.stack.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/Flot/jquery.flot.resize.js"></script>
    <!-- Flot plugins -->
    <script src="<?php echo base_url(); ?>assets/js/flot/jquery.flot.orderBars.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/flot/date.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/flot/jquery.flot.spline.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/flot/curvedLines.js"></script>
    <!-- jVectorMap -->
    <script src="<?php echo base_url(); ?>assets/js/maps/jquery-jvectormap-2.0.3.min.js"></script>
    <!-- bootstrap-daterangepicker -->
    <script src="<?php echo base_url(); ?>assets/js/moment/moment.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/datepicker/daterangepicker.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="<?php echo base_url(); ?>assets/build/js/custom.min.js"></script>
   <!-- Jquery UI-daterangepicker -->
    <script src="<?php echo base_url(); ?>assets/vendors/datepicker/jquery-ui.min.js"></script>
    <script src="<?php echo base_url()?>assets/select/js/select2.min.js"></script>
   <script>
 
    <?php if($this->user_model->is_super()){ ?>
    $('#branch').select2({
     //selectOnClose: true,
    placeholder: "Select a Branch",
    allowClear:true
    });
    <?php } ?>
     $('#class').select2({
     //selectOnClose: true,
    placeholder: "Select a Class",
    allowClear:true
    });
    $('#section').select2({
     //selectOnClose: true,
    placeholder: "Select a Section",
    allowClear:true
    });
    
    
    </script>
<script type="text/javascript">

  $(function(){
      $('#theform').submit(function(e){
        $("input[type='submit']", this)
          .val("Please Wait...")
          .attr('disabled', 'disabled');
        return true;
      });
});

</script>
    <script>

 $( function() {
    $( '.date' ).datepicker({ dateFormat: 'd-m-yy' }).val();
  } );
</script>
        
    <script>
      $(function(){
        $(function(){
          var val = $('#branch').val();
          $.get("<?php echo base_url(); ?>load/classs/role/"+val,{},function(ret){
            var d = '<option value="">Select Class</option>';
            $("#class").html(d+ret);
          });
        });
        $(document).on("change","#branch", function(){
          var val = $(this).val();
          $.get("<?php echo base_url(); ?>load/classs/role/"+val,{},function(ret){
            var d = '<option value="">Select Class</option>';
            $("#class").html(d+ret);
          });
        });
        
        $(document).on("change","#date", function(){
                
          var date = $(this).val();
          var cl = $("#class").val();
          var se = $("#section").val();
          if(date && cl && se){
              $.get("<?php echo base_url(); ?>load/check_voucher/"+cl+"/"+se+"/"+date,{},function(ret){
                $("#student").html(ret);
                jq('#student').multiselect('reload');
              });
              $.get("<?php echo base_url(); ?>load/other_fee/"+cl,{},function(ret){
                $("#fee_wrapper").html(ret);
              });
          }
          
        });
        
        $(document).on("change","#class", function(){
                
          var val = $(this).val();
          $.get("<?php echo base_url(); ?>load/section/role/"+val,{},function(d){
                    var pre = '<option value="">Select Section</opiton>';
                    $("#section").html(pre+d);
                });
          
        });
        $('#section').change(function(){
            $("#tution_check").attr("disabled",false);
            var se= $(this).val();
            var cl=$('#class').val();
            var date = $('#date').val();
          $.get("<?php echo base_url(); ?>load/check_voucher/"+cl+"/"+se+"/"+date,{},function(ret){
            $("#student").html(ret);
            jq('#student').multiselect('reload');
          });
          $.get("<?php echo base_url(); ?>load/other_fee/"+cl,{},function(ret){
            $("#fee_wrapper").html(ret);
          });
        });
        
        $(document).on("click","#tution_check",function(){
           if(this.checked){
            var se= $("#section").val();
            var cl=$('#class').val();
            $.get("<?php echo base_url(); ?>load/student/"+cl+"/"+se,{},function(ret){
            $("#student").html(ret);
            jq('#student').multiselect('reload');
          });
            }
           else{
            var se= $("#section").val();
            var cl=$('#class').val();
            var date = $('#date').val();
          $.get("<?php echo base_url(); ?>load/check_voucher/"+cl+"/"+se+"/"+date,{},function(ret){
            $("#student").html(ret);
            jq('#student').multiselect('reload');
          });  
           }
        });
        
      
        jq('#student').multiselect({
                columns: 1,
                'selectAll': true,
                 search: true,
                placeholder: 'Select Students'
        });
        jq('#add_months').multiselect({
                columns: 1,
                'selectAll': true,
                 search: true,
                placeholder: 'Add Aditional Months Fee'
        });
      });
    </script>
  </body>
</html>