<link href="<?php echo base_url(); ?>assets/build/css/form.css" rel="stylesheet">        
    <style>
    label{
      font-size:small !important;
    }
    form.register input {
      height:34px !important;
    }
    form.register fieldset.row1 label{
      width:90px !important;
    }
    </style>    
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Return 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>Return Book</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">
                 <div class="alert alert-warning alert-dismissable" style="display:none;">
                    <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                    <strong>Warning!</strong> No Data Available Along this ISBN<span class="isb"></span> Please Try Another.
                </div>
                   <form method="post"  action="<?php echo $base_url; ?>Liberary_item/returnitem" class="register">
            <fieldset class="row1">
                <legend>Putt ISBN Number First
                </legend>
                <p>
                    <label style="margin-left:78px;">ISBN# *
                    </label>
                        <input type="text"  id="isbn" name="isbn" class="form-control" style="width:431px !important; " required/>
                        <input type="hidden" name="issueId" id="issueId"/>
                        <input type="hidden" name="late_days"  id="late_days"/> 
                        <input type="hidden" name="itemId"  id="itemId"   /> 
                        <input type="hidden" name="user_id"  id="user_id"   /> 
                        <input type="hidden" name="user_type"  id="user_type"   /> 
                        
                    </p>
                <p>
                    <label>Category *
                    </label>
                        <input type="text" class="form-control text-center" id="category" readonly/>
                    <label>Type *
                    </label>
                        <input type="text" class="form-control text-center" id="type" readonly/>
                     <label>Name *
                    </label>
                        <input type="text" class="form-control text-center " id="name" readonly/>
                </p>
                 <p>
                    <label>Edition *
                    </label>
                     <input type="text" class="form-control text-center" id="edition" readonly/>
                    <label>Publisher *
                    </label>
                        <input type="text"  class="form-control text-center" id="publisher" readonly/>
                    <label>Writer*
                    </label>
                        <input type="text" class="form-control text-center" id="writer" readonly/>
                </p>
                <p>
                    <label>Almirah No*
                    </label>
                        <input type="text" class="form-control text-center" id="almirah" readonly/>
                    <label>Shelf No*
                    </label>
                        <input type="text" class="form-control text-center" id="shelf" readonly/>
                        <label>Receiving Date*
                    </label>
                        <input type="text" class="form-control text-center" id="recdate" style="color:red;" readonly />
                    </p>
                <p>
                    <label>User Name*
                    </label>
                        <input type="text" class="form-control text-center"  id="username" readonly/>
                    <label>Designation*
                    </label>
                        <input type="text" class="form-control text-center"  id="designation" readonly/>
                    <label>Fine*
                    </label>
                        <input type="text" name="fine"  id="fine" class="form-control text-center" readonly  /> 
                </p>
               
            </fieldset>
  <!-- Personal Detail-------->
            
            <div><button class="button" id="issue" type="submit">ReturnBook &raquo;</button></div>
        </form>
                </div>
                </div>
              </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
        <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.devbridge-autocomplete/1.2.27/jquery.autocomplete.js"></script>
        <script>
            //var $j = jQuery.noConflict();
        </script>
        <script>
         $(function(){    
        $(document).on('change','#isbn',function(){
          var val=$("#isbn").val();
          if(val!="" && val.length>=7){
              $(".alert").hide();
                $.ajax({
                    url:"<?php echo base_url(); ?>Liberary_item/ShowIssueData/"+val,
                    data:{},
                    success:function(result){
                        var d=JSON.parse(result);
                        console.log(d);
                        if(d==null){
                            $(".isb").html(val);
                            $(".alert").show();
                        $('#catagory').val("");
                        $('#type').val("");
                        $('#name').val("");
                        $('#edition').val("");
                        $('#publisher').val("");
                        $('#writer').val("");
                        $('#almirah').val("");
                        $('#shelf').val("");
                        $('#recdate').val("");
                        $('#issueId').val("");
                        $('#itemId').val("");
                        $('#username').val("");
                        $('#designation').val("");
                        }else{
                        $(".alert").hide();
                        $('#catagory').val(d.catname);
                        $('#type').val(d.iname);
                        $('#name').val(d.name);
                        $('#edition').val(d.edition);
                        $('#publisher').val(d.publisharname);
                        $('#writer').val(d.writername);
                        $('#almirah').val(d.almirahname);
                        $('#shelf').val(d.shelf_no);
                        $('#recdate').val(d.issue_date);
                        $('#issueId').val(d.id);
                        $('#itemId').val(d.item_id);
                        $('#user_type').val(d.user_type);
                        $('#user_id').val(d.user_id);
                        if(d.user_type==1){
                            $('#username').val(d.userinfo.student_name);
                            $('#designation').val('Student');
                        }else if(d.user_type==2){
                            $('#username').val(d.userinfo.firstname);
                            $('#designation').val('Teacher');
                        }else if (d.user_type==3){
                            $('#username').val(d.userinfo.firstname);
                            $('#designation').val('Staff');
                        }
                        $('#ItemId').val(d.id);
        //=======================date comparison=============================
                        var start = new Date(d.issue_date),
                        end   = new Date(),
                        diff  = new Date(end - start),
                        days  =Math.round( diff/1000/60/60/24);
                        $('#late_days').val(days);
                        if(d.user_type==1 )
                        {
                            if(days <=14){
                            }else{
                            var fine=5;
                            var extradays=days-14;
                            var totalfine=extradays*fine;
                            $('#fine').val(totalfine);
                        }
                        }else if (d.user_type==2 || d.user_type==3 ){
                            if(days <=14){
                            }else{
                                var fine=5;
                                var extradays=days-14;
                                var totalfine=extradays*fine;
                                $('#fine').val(totalfine);
                            }
                        }
                    }
                    }
                
                });
                }else{
                     $(".isb").html("Please Add Correct ISBN Greater or Equal Then 7 Characters");
                        $(".alert").show();
                }
        });
        $(document).on('change','#paid_fine',function(){
          var val=$('#paid_fine').val();
          var totalfine=$('#fine').val();
          if(val>totalfine){
          alert("Your Submitted Amount is Greater Plz Check it");
             $("#issue").attr('disabled', true);
          }else{
                $("#issue").attr('disabled', false);
          }
          });
//===============================end of select full=============================================            
 });
    </script>