<?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"> All Transaction Ledger</h3>
          <div class="card-tools">
            <button type="button" class="btn btn-tool" onclick="ExcelMe('#lgtable')"  title="Download Excel">
              <i class="far fa-file-excel"></i>
            </button>
            <button type="button" onclick="BfpdfMe('#lgtable<?php echo $acid;?>');" class="btn btn-tool" title="Download Pdf"><i class="fas fa-download"></i></button>
            <button type="button" class="btn btn-tool" printMe('#lgtable','header') 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-2">
        <?php if($bid_check>1 || $multi_bid > 1) {?>

             <div class="col-2">
              <div class="form-group">
                  <label> Select Business </label>
                  <select id="bbid" class="form-control" onchange="lives();">
                     <option value="0"> All Type</option>
                  </select>
               </div>
             </div>
        <?php } else { ?>
             <input type="hidden" id="bbid" value="<?php echo $bid;?>">
        <?php } if( $brid_check > 1 ||  $multi_brid > 1) { ?>

             <div class="col-2">
               <div class="form-group" >
                  <label> Select Branch </label>
                  <select  id="bbrid"  class="form-control select2" style="width: 100%;" required="true" onchange="lives();">
                     <option value="0"> All Type</option>
                  </select>
               </div>
             </div>
        <?php } else { ?>
             <input type="hidden" id="bbrid" value="<?php echo $brid;?>">
        <?php } ?>
             <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" onchange="lives();">
               </div>
             </div>
                <div class="col-md-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-md-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>
             <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" value="50">
               </div>
              </div> 
              
              
                   <div class="col-3">
                      <div class="form-group">
                         <label><?php echo language(377);?><b class="text-danger"> *</b>  </label>
                         <select name="vou_type" id="vou_type" class="form-control" required="true" onchange="lives();">
                             <option selected value="0"> <?php echo language(222); ?> </option> 
                            <option value="R"> Reeived </option>
                            <option value="P"> Payment </option>
                            <option value="C">Contra</option>
                            <option value="W_R"> Cash Sale Receive</option>
                            <option value="R_R"> Retail Sale Receive</option>
                            <option value="R_I"> Ins Sale Receive</option>
                            
                            
                         </select>
                      </div>
        </div>


                 <div class="col-3">
                      <div class="form-group">
                         <label><?php echo language(90);?><b class="text-danger"> *</b>  </label>
                         <select name="status" id="status" class="form-control" required="true" onchange="lives();">
                            <option selected value="0"> Pending </option>
                            <option  value="all"> <?php echo language(222); ?> </option> 

                            <option value="1"> Success </option>


                            
                            
                         </select>
                      </div>
        </div>
        
        
             <div class="col-2">
               <div class="form-group" >
                  <label><?php echo language(219);?></label>
                  <select id="acid" class="form-control" onchange="lives();">
                     <option value="0"> <?php echo language(222);?></option>
                     <?php 
                        $accat= mysqli_query($conn,"SELECT acid,ac_name,ac_alise,ac_number,balance FROM accounts LEFT JOIN ac_sub_g_category ON(accounts.gcatid=ac_sub_g_category.ac_g_catid) WHERE accounts.coid='$coid' AND bid='$bid' AND brid='$brid' AND active=1 ") or die (mysql_error());
                        while($acat= mysqli_fetch_assoc($accat)){
                          echo '<option value='.$acat["acid"].'>'.$acat["ac_name"]."-".$acat["ac_number"].' '.'('.$acat["ac_alise"].')</option>';
                        }?>   
                  </select>
               </div>
             </div>
             
             
                      <div class="col-2">
                  <div class="form-group">
                       <label><?php echo language(239); ?><b class="text-danger"> *</b></label>
                                 <select  name="s_uid"  id="s_uid" class="form-control" onchange="lives();">
                                     <option value="0"> <?php echo language(222);?> </option>
                                    <?php 
                                       $emdd_query= mysqli_query($conn,"SELECT uid,us_em_id FROM user  
                                          WHERE user.us_coid='$coid'  AND user.us_bid='$bid'  AND  user.us_brid='$brid'  AND user.us_status=1  ") or die (mysqli_error($conn));
                                       while($rouid= mysqli_fetch_assoc($emdd_query)){
                                          $get_emdata=$rouid["us_em_id"];
                                        $em_acname= mysqli_fetch_assoc(mysqli_query($conn,"SELECT em_acname FROM em_employee WHERE em_coid='$coid' AND em_bid='$bid' AND em_brid='$brid' AND em_id='$get_emdata' LIMIT 1"))['em_acname'];
                                        $id_card= mysqli_fetch_assoc(mysqli_query($conn,"SELECT id_card FROM em_employee WHERE em_coid='$coid' AND em_bid='$bid' AND em_brid='$brid' AND em_id='$get_emdata' LIMIT 1"))['id_card'];

                                        echo '<option value='.$rouid["us_em_id"].'>'.$em_acname.' ('.$id_card.')</option>';
                                       }?> 
                                 </select>
                 </div>
            </div>
            
            
            
          </div>
        </div>
        <div id="vouchar_display" class="mt-2"></div>
       </div>
    </div>
   </div>
            </div>
         </div>
</section>

<script type="text/javascript">
   $(document).ready(function(){
     $('select').select2();       
     pagecall('../cheque_payment/bank_cheques_live_search.php?search=0'+'&bbid=<?php echo $bid;?>'+'&bbrid=<?php echo $brid;?>'+'&s_uid=0'+'&nrow=50'+'&acid=0'+'&vou_type=0'+'&status=0'+'&fdate=<?php echo $date;?>'+'&edate=<?php echo $date;?>','#vouchar_display',0);
   });
     function lives() {
       var search      = $('#search').val()==''?0:$('#search').val();
       var bbid        = $('#bbid').val();
       var bbrid       = $('#bbrid').val();
       var fdate       = $('#fdate').val();
       var edate       = $('#edate').val();
       var nrow        = $('#nrow').val()==''?50:$('#nrow').val();
       var vou_type    = $('#vou_type').val();
       var acid        = $('#acid').val();
       var s_uid       =$('#s_uid').val();
       var status       =$('#status').val();
       $.get("../cheque_payment/bank_cheques_live_search.php",
         {
           search      : search,
           bbid        : bbid,
           bbrid       : bbrid,
           fdate       : fdate,
           edate       : edate,
           nrow        : nrow,
           vou_type    : vou_type,
           acid        : acid,
           s_uid       :s_uid,
           status       :status
         },
         function(html) {
           $("#vouchar_display").html(html);
         });
     }
     
       // FOR DATE PICKER //
    var timer = null;
    $('#fdate,#edate').change(function(){
      clearTimeout(timer);
      timer = setTimeout(lives, 100);
    });
      // FOR keyup //
    var timer1 = null;
    $('#search,#nrow').on('input',function(){
      clearTimeout(timer1);
      timer1 = setTimeout(lives, 500);
    });    
</script>








<script type="text/javascript">
   $("input:checkbox:not(:checked)").each(function() {
     var column = "table ." + $(this).attr("name");
     $(column).hide();
   });
   
   $("input:checkbox").click(function(){
     var column = "table ." + $(this).attr("name");
     $(column).toggle();
   });
   
   $('select').select2();
</script>