     <link href="<?php echo base_url(); ?>assets/vendors/select2/dist/css/select2.min.css" rel="stylesheet">
    <script src="<?php echo base_url(); ?>assets/vendors/select2/dist/js/select2.js"></script>
       
    
        

  <!--<div id='ajaxload' style='position:fixed;top:0;left:0;bottom:0; width:100%;height:100%;z-index:1000;background:rgba(2,132,130,0.5);'>-->
  <!--          <i class='fa fa-spinner fa-spin fa-4x' style='position: relative;top: 50%;left: 50%;margin-top: -50px;margin-left: -50px;'></i>-->
  <!--      </div>-->
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Item/Product</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 Books</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>
 <?php if ($this->session->flashdata('msg')): ?>
<div class="alert alert-success">
<?php echo $this->session->flashdata('msg'); ?>
</div>
<?php endif ?>
<!--Liberary_item/save_item-->
                  <div class="x_content">
<h4 align="right">Recent Added Book</h4>
     <form id="form" class="form-horizontal form-label-left" action="<?php echo $base_url; ?>Liberary_item/save_item" method="post">
<input type="hidden" name="item_id"  value="<?php if($filter==1){ echo $item['id'];} else{echo "0";} ?>" id="item_id"  />
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Catagroy<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="cat" name="cat_id" class="form-control col-md-7 col-xs-12"  required="required">
                          <option value="">--Select Catagory Here--</option>
                          <?php 
                          if(!empty($cat))
                          {
                          foreach($cat as $key=>$category){?>
                          <option <?php if($item['cat_id']==$category['id']){echo "selected";} ?> value="<?php echo $category['id']; ?>"><?php echo $category['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="b_head">Type<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="type" name="type_id" class="form-control col-md-7 col-xs-12"  required="required">
                          <option value="">--Select Type Here--</option>
                          <?php foreach($type as $key=>$type){?>
                          <option <?php if($item['type_id']==$type['id']){echo "selected";} ?> value="<?php echo $type['id']; ?>"><?php echo $type['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="b_head">Almirah# 
                        <!--<span class="required">*</span>-->
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                             <!--required="required"-->
                          <select id="almirah" name="almirah" class="form-control col-md-7 col-xs-12">
                          <option value="">--Select Almirah Here--</option>
                          <?php 
                          if($item!=null){ 
                          foreach($almirah as $key=>$cat)
                          {
                          ?>
                          <option <?php if($item['almirah_no']==$cat['id']){echo "selected";} ?> value="<?php echo $cat['id']; ?>"><?php echo $cat['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="b_head">Shelf#
                        </label>
                        <!--<span class="required">*</span>-->
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <!--required="required"-->
                          <select id="shelf" name="shelf" class="form-control col-md-7 col-xs-12"  >
                          <option value="">--Select Shelf Here--</option>
                          <?php if($item!=null){ foreach($shelf as $key=>$cat){?>
                          <option <?php if($item['shelf_no']==$cat['id']){echo "selected";} ?>  value="<?php echo $cat['id']; ?>"><?php echo $cat['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="b_head">Writer Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="writer" name="writer" class="form-control col-md-7 col-xs-12"  required="required">
                          <option value="">--Select Writer Here--</option>
                          <?php foreach($writer as $key=>$writer){?>
                          <option <?php if($item['writer_id']==$writer['id']){echo "selected";} ?> value="<?php echo $writer['id']; ?>"><?php echo $writer['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="b_head">Publisher Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="publisher" name="publisher" class="form-control col-md-7 col-xs-12"  required="required">
                          <option value="">--Select Publisher Here--</option>
                          <?php foreach($publisher as $key=>$publisher){?>
                          <option <?php if($item['publisher_id']==$publisher['id']){echo "selected";} ?> value="<?php echo $publisher['id']; ?>"><?php echo $publisher['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="b_head">ISBN
                        <!--<span class="required">*</span>-->
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <!--required="required" -->
                          <input id="isbn" name="isbn" value="<?php if(!empty($item['isbn'])){ echo $item['isbn']; } ?>" class="form-control col-md-7 col-xs-12 abc1" maxlength="25"  placeholder="ISBN...." type="text">
                        </div>
                      </div>
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="name" name="name" value="<?php if(!empty($item['name'])){ echo $item['name'];} ?>" class="form-control col-md-7 col-xs-12" placeholder="Name of Book...." required="required" type="text">
                        </div>
                      </div>
                       
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Edition
                        <!--<span class="required">*</span>-->
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <!--required="required"-->
                          <input id="" name="edition" value="<?php if(!empty($item['edition'])){ echo $item['edition'];} ?>"  class="form-control col-md-7 col-xs-12" maxlength="25"  placeholder="Edition...."  type="text">
                        </div>
                      </div>
                      
                      
                         <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Price<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="f_cell" onkeypress="return Validate(event);" name="price" value="<?php if(!empty($item['price'])){ echo $item['price'];} ?>"  class="form-control col-md-7 col-xs-12" maxlength="25"  placeholder="Price...." required="required" type="text">
                        </div>
                      </div>



                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <button  type="submit" id="send" class="btn btn-success">Add</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
      
     
        
        <!-- Custom JS -->
    <script src="<?php echo base_url(); ?>assets/js/main2.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/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.min2.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/bootstrap-datepicker.js"></script>
    

    
    <!-- Multiselect -->
    <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>
        
        <script type="text/javascript">
     var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#cat').select2({
            
        });
      });
    </script>
    
<script type="text/javascript">
var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#type').select2({
            
        });
      });
    </script>
    
<script type="text/javascript">
var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#almirah').select2({
            
        });
      });
    </script>
    <script type="text/javascript">
    var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#shelf').select2({
            
        });
      });
    </script>
    
    <script type="text/javascript">
    var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#writer').select2({
            
        });
      });
    </script>
    
    <script type="text/javascript">
    var jq = jQuery.noConflict();
        jq(document).ready(function(){
      
        jq('#publisher').select2({
            
        });
      });
    </script>
    
   <script>
   var jq = jQuery.noConflict();
jq(document).ready(function() {
    var check_id=jq("#item_id").val();
    if(check_id!=0)
    {
       jq("#isbn").prop("readonly",true); 
    }else
    {
       jq("#isbn").prop("readonly",false);  
    }
     jq("#send").click(function(e){
         var check_id=jq("#item_id").val();
         e.preventDefault();
       var isb=jq("#isbn").val();
        if(check_id==0)
               {
         jq.get("<?php echo base_url(); ?>Liberary_item/verify_isbn/"+isb,{},function(d){
             if(d ==1) 
                {
                    swal("ISBN Is Already Taken");
                }else
                {
                    jq("#form").submit();
                }
               
                });
              }else
                 {
                      jq("#form").submit();
                 }
        });
});
   </script>
   
        <script>
        var jq = jQuery.noConflict();
         jq(function(){
//===================================== for edit function================================
                jq(document).on('click','.edit',function(e){
                  e.preventDefault();
                      var id=jq(this).attr("data-id");
            jq.ajax({
                    url: "<?php echo base_url(); ?>Liberary_definations/SearchById/"+id+"/almirah",
                    data: {},
                      success: function(d) {
                        var re = jQuery.parseJSON(d);
                              jq('#almirah_name').val(re.name);
                              jq('#almirah_id').val(re.id);
                              jq('#cat_id').val(re.cat_id);
                              jq('#shelf').val(re.total_shelf);
                              jq('#books').val(re.shelf_total_books);
                           }
                    });
                      });
//==========================================for dropdowns================================================
            jq(document).on('change','#cat',function(){
                var val=jq(this).val();
               
                jq.get("<?php echo base_url(); ?>Liberary_item/search_almirah/"+val,{},function(d){
                  var almirah=jQuery.parseJSON(d);
                  var pre="<option value=''>Select Almirah</option>";
                  jq('#almirah').html(pre);
                  jq.each( almirah, function( i,v ){
                      var value="<option value='"+v['id']+"'>"+v['name']+"</option>";
                      jq('#almirah').append(value);
                  }); 
                });
              });
          jq(document).on('change','#almirah',function(){
                var val=jq(this).val();
                jq.get("<?php echo base_url(); ?>Liberary_item/search_shelf/"+val,{},function(d){
                    var pre="<option value=''>--Select Shelf--</option>";
                    //console.log(d);
                    jq('#shelf').html(pre+d);
                });
              });
});
    </script>
    
     
    
    
    <script>
    var jq = jQuery.noConflict();
window.setTimeout(function() {
jq(".alert").fadeTo(500, 0).slideUp(500, function(){
    jq(this).remove(); 
});
}, 3000);
        
    </script>
    
    <script type="text/javascript">
        function Validate(event) {
            var regex = new RegExp("^[0-9?=.*!@#$%^&*]+$");
            var key = String.fromCharCode(event.charCode ? event.which : event.charCode);
            if (!regex.test(key)) {
                event.preventDefault();
                return false;
            }
        }       
    </script>
  
<footer>
          <div >
<p style="text-align:center !important;">EduSolutions</p>
          </div>
          <div class="clearfix"></div>
        </footer>
       
        <!-- /footer content -->
      </div>
    </div>



    
    <!-- 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/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.min2.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/bootstrap-datepicker.js"></script>
    

    
    <!-- Multiselect -->
    <script src="<?php echo base_url(); ?>assets/multi_select/jquery.multiselect.js"></script>

    <script src="https://cdn.jsdelivr.net/sweetalert2/6.4.3/sweetalert2.min.js"></script>    

  

<script>
var jq = jQuery.noConflict();
 jq(function () {
    jq(".date").datepicker();
    date(".now");
    jq(".date").focusout(function () {
        if (jq(this).val().trim() == "") {
            date(".date");
        }
    });

    function date(selector) {
        var dNow = new Date();
        var localdate = dNow.getFullYear()+'/' +(dNow.getMonth() + 1)+'/' + dNow.getDate();
       
    }

});
</script>
    <script>
    var jq = jQuery.noConflict();
    jq(".abc").on("keypress", function (event) {

            var englishAlphabetAndWhiteSpace = /[A-Za-z ]/g;


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


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

         jq('.abc').on("paste", function (e) {
            e.preventDefault();
        });
        jq(".abc1").on("keypress", 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 == 37 || event.keyCode == 39 || englishAlphabetAndWhiteSpace.test(key)) {
                return true;
            }


            return false;
        }); jq('.abc1').on("paste", function (e) {
            e.preventDefault();
        });
        // $(document).bind("contextmenu", function (e) {
        //     e.preventDefault();
        // });
         //form only numbers
        jq(".num").on("keypress", 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;
        });
    </script>
    

    
  </body>
</html>    
    
   