<?php require_once('../auth/auth.php');?>
<section class="content">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-12">
        <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
          <div class="card-header" style="padding: 3px 8px;">
            <h3 class="card-title"><?php echo language(66); ?> </h3>
            <div class="card-tools">
              <button type="button" class="btn btn-tool" onclick="ExcelMe('#inv_table')"  title="Download Excel">
              <i class="far fa-file-excel"></i>
              </button>
              <button type="button" onclick="BfpdfMe('#inv_table');" class="btn btn-tool" title="Download Pdf"><i class="fas fa-download"></i></button>
              <button type="button" class="btn btn-tool" onclick="printMe('#edraft_show')" title="Print Now"><i class="fas fa-print"></i></button>
              <button type="button" class="btn btn-tool" data-card-widget="remove" data-dismiss="modal"><i class="fas fa-times"></i></button>
            </div>
          </div>
          <div class="card-body p-1">
            <div class="col-md-12" style="border:1px solid #969c9d;background: hsla(0,0%,50.2%,.11);border-radius: 5px;">
              <div class="row mt-1 mb-n2">
                <input type="hidden" id="bbid" value="<?php echo $bid;?>">
                <input type="hidden" id="bbrid" value="<?php echo $brid;?>">
                <div class="col-2">
                  <div class="form-group" >
                    <label><?php echo language(68);?></label>
                    <input type="text" id="search" class="form-control form-control-sm text-center" oninput="lives();">
                  </div>
                </div>
                <div class="col-1">
                  <div class="form-group" >
                    <label><?php echo language(72);?></label>
                    <input type="number" id="nrow" title="View Limit" class="form-control form-control-sm text-center inputselect" value="50" onblur="lives();">
                  </div>
                </div>
                
                <div class="col-2">
                  <div class="form-group">
                    <label><?php echo language(257);?></label>
                    <input type="text" id="fdate" class="form-control form-control-sm text-center" onmouseover="lcdate(this)" readonly="true" required="true"value="<?php echo $date;?>">
                  </div>
                </div>
                <div class="col-2">
                  <div class="form-group">
                    <label><?php echo language(258);?></label>
                    <input type="text" id="edate" class="form-control form-control-sm text-center" onmouseover="lcdate(this)" readonly="true" required="true" value="<?php echo $date;?>">
                  </div>
                </div>
                <input type="hidden" value="SDRAFT" id="itype">
              </div>
            </div>
            <div id="edraft_show" class="mt-2"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
<script type="text/javascript">
   $(document).ready(function(){
     $('select').select2();       
     pagecall('../sales/draft_list_view.php?search=0'+'&bbid=<?php echo $bid;?>'+'&bbrid=<?php echo $brid;?>'+'&nrow=50'+'&itype=SDRAFT'+'&fdate=<?php echo $date;?>'+'&edate=<?php echo $date;?>','#edraft_show',0);
   });
     function lives() {
       let search      = $('#search').val()==''?0:$('#search').val();
       let bbid        = $('#bbid').val();
       let bbrid       = $('#bbrid').val();
       let itype       = $('#itype').val();
       let nrow        = $('#nrow').val()==''?50:$('#nrow').val();
       let fdate       = $('#fdate').val();
       let edate       = $('#edate').val();
       $.get("../sales/draft_list_view.php",
         {
           search      : search,
           bbid        : bbid,
           bbrid       : bbrid,
           itype       : itype,
           nrow        : nrow,
           fdate       : fdate,
           edate       : edate
         },
         function(html) {
           $("#edraft_show").html(html);
         });
     }
    var timer = null;
      $('#fdate,#edate').change(function(){
      clearTimeout(timer);
      timer = setTimeout(lives, 100);
    });
</script>

