                  <style>
    .required{
        color: #bf5050;
    }
    </style>
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3></h3> 
                </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>Add District</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" action="<?php echo $base_url;?>district/save" method="post">

                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Country<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="country" class="form-control col-md-7 col-xs-12" name="country" required="required">
                            

                            <option value=''>Select Country</option>
                    <?php       $this->db->where('is_delete',0) ;
                                $com=$this->db->get('country')->result();
                              foreach ($com as $value) {
                  ?>
                    <option value="<?php echo $value->country_id; ?>"><?php echo $value->country_name?></option>

                  <?php } ?>
                          </select>
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Province<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="province" class="form-control col-md-7 col-xs-12" name="province" required="required">
                            

                            <option value=''>Select Province</option>
                    
                          </select>
                        </div>
                      </div>
                        <div class="item form-group" id="msg" style="display:none;">
                           <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name"> 
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="msgfield" style="background-color:#e86d6d; color:white;" class="form-control col-md-7 col-xs-12" value="Sorry! This District already exists!"  name="msg" type="text" readonly>
                        </div>
                      </div>
                     
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">District Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          
                          <input name="district" onKeyup="myFunction()" id="district" required="true" class="form-control abc">
                        </div>
                      </div>
                      
                      
                      
                      

                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <input id="send" type="submit" disabled="true" class="btn btn-success pull-right" value="Save" />
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            
                <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>District View</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">
 
                     <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap">
                      <thead>
                        <tr>
                          <th>#</th>
                          <th>District Name</th>
                          <th>Province Name</th>
                          <th>Country Name</th>
                          <?//php if(!$is_super){ ?>
                          <th>Actions</th>
                          <?//php } ?>
                        </tr>
                      </thead>

                      <tbody>
                        <?php $i=1; foreach ($district as  $value) { ?>
                        <tr>
                          <td><?php echo $i++; ?></td>
                          <td><?php echo $value['name']; ?></td>
                          <td><?php echo $value['province_name']; ?></td>
                          <td><?php echo $value['country_name']; ?></td>
                          
                          <?//php if(!$is_super){ ?>
                          <td>

                            <?php if($edit_delete['edit']){ ?>
                            
                                <a href='<?php echo base_url();?>district/edit/<?php echo base64_encode(json_encode($value['id'].SALT)); ?>'><i class="fa fa-edit"></i></a> 
                            <?php } if($edit_delete['delete']){ ?>
                            
                                <a href="<?php echo base_url();?>district/delete/<?php echo base64_encode(json_encode($value['id'].SALT)); ?>"> <i class="fa fa-trash"></i></a>
                            <?php } ?>
                            
                          </td>
                          <?//php } ?>
                        </tr>
                        <?php } ?>
                      </tbody>
                    </table>
                   
                      
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
        <!-- footer content -->
        <footer>
          <div class="pull-right">
            EduSolutions
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <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>

        <!-- Datatables -->
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/jszip/dist/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/pdfmake/build/vfs_fonts.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="<?php echo base_url(); ?>assets/vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
 
    <!-- Datatables -->
   
    <script src="<?php echo base_url()?>assets/select/js/select2.min.js"></script>
    <script>
 
     $('#country').select2({
     //selectOnClose: true,
    
   
    allowClear:true
    });
    </script>
   <script>
 
     $('#province').select2({
     //selectOnClose: true,
    allowClear:true
    });
    </script>
    <script>
    $(document).ready(function(){
        $(document).on("keypress",".abc",function(event){
        
            var englishAlphabetAndWhiteSpace = /[A-Za-z ]/g;


            var key = String.fromCharCode(event.which);


            if (event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 32 || event.keyCode == 95 || event.keyCode == 39 || englishAlphabetAndWhiteSpace.test(key)) {
                return true;
            }
            return false;
        });

        $(document).on("keypress",".abc1",function(event){
        
            var englishAlphabetAndWhiteSpace = /[A-Za-z0-9|-]/g;


            var key = String.fromCharCode(event.which);


            if (event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 32 || event.keyCode == 95 || event.keyCode == 39 || englishAlphabetAndWhiteSpace.test(key)) {
                return true;
            }


            return false;
        });
        $(document).bind("contextmenu", function (e) {
            //e.preventDefault();
        });
         //form only numbers
        $(document).on("keypress",".num",function(e){
        
            var evt = (e) ? e : window.event;
            var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
            if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                return false;
            }
            return true;
        });
        
                 //form only numbers & Other Expression
        $(document).on("keypress",".num1",function(e){
          
            var evt = (e) ? e : window.event;
            var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
            if (charCode == 45 || (charCode > 47 && charCode < 58)) {
                return true;
            }
            return false;
        });
            
        });
      
        
    </script>
    
    <script>
        $(document).ready(function(){
            $(document).on("change","#country",function(){
                var value = $(this).val();
                $.get("<?php echo base_url(); ?>load/province/role/"+value,{},function(d){
                    var pre = '<option value="">Select Province</opiton>';
                    $("#province").html(pre+d);
                });
            });
        });
    </script>
<script>
      $(function(){
        $(document).on("click","#go-search",function(){
          var p = 1;
          var s = $("#search").val();
          if(s=="")
            s="all";
          window.location = "<?php echo base_url();?>district/index/"+s+"/"+p;
        });
        $(document).on("click","button",function(){
          var val = $(this).attr("data-href");
          window.location = val;
        });
      });
    </script>

    <script>
      $(function(){
          var handleDataTableButtons = function() {
          if ($("#datatable-buttons").length) {
            $("#datatable-buttons").DataTable({
                dom: "lBfrtip",
              "bPaginate": true,
              "pageLength":35,
              "lengthMenu": [[35, 70, 100, -1], [35, 70, 100, "All"]],
              buttons: [
                {
                  extend: "copy",
                  className: "btn-sm"
                },
                {
                  extend: "csv",
                  className: "btn-sm"
                },
                {
                  extend: "excel",
                  exportOptions: {
                    columns: [ 0, 1, 2, 3 ]
                    },
                className: "btn-sm"
                },
                {
                  extend: "pdfHtml5",
                  exportOptions: {
                    columns: [ 0, 1, 2, 3 ]
                    },
                  className: "btn-sm"
                },
                {
                  extend: "print",
                  exportOptions: {
                    columns: [ 0, 1, 2, 3 ]
                },
                  className: "btn-sm"
                },
              ],
              responsive: true
            });
          }
        };

        TableManageButtons = function() {
          "use strict";
          return {
            init: function() {
              handleDataTableButtons();
            }
          };
        }();

        TableManageButtons.init();
      });
    </script>
 <script>
function myFunction() {
     val=$('#district').val();
     val1=$('#province').val();
     val2=$('#country').val();
     
     id = $('#district').attr('data-id');
     if(id){
       $.ajax({
         url: '<?php echo base_url(); ?>district/check_useredit/'+id+'/'+val+'/'+val1+'/'+val2,
        data: {},
        success: function (res) {
                            if(res == 1)
                            {
                             //alert("Already exists");
                             $("#send").prop('disabled',true)
                            $("#msg").css("display", "block");
                           
                           
                            }
                             else{
                                  $("#send").prop('disabled',false)
                             //alert("You can add class");
                             $("#msg").css("display", "none");
                            
                             }
                    },
                     error: function(){
                                        alert("failure");
                                    }
                });
    
     }else{
         $.ajax({
         url: '<?php echo base_url(); ?>district/check_user/'+val+'/'+val1+'/'+val2,
        data: {},
        success: function (res) {
                            if(res == 1)
                            {
                             //alert("Already exists");
                             $("#send").prop('disabled',true)
                            $("#msg").css("display", "block");
                          
                           
                            }
                             else{
                                  $("#send").prop('disabled',false)
                             //alert("You can add class");
                             $("#msg").css("display", "none");
                            
                             }
                    },
                     error: function(){
                                        alert("failure");
                                    }
                });
    
     }
     //alert($val);
    
}
</script>

  </body>
</html>