<?php
    include('common/header.php');
?>
<div class="row">
  <section class="panel panel-default">
     <header class="panel-heading bg-info lt font-bold">
         Refill Transaction Details
     </header>

    <div class="panel-body bs-example form-horizontal">
        <div class="col-sm-3" >  </div>
     <div class="col-sm-6" >  
                 
        <div class="table-responsive">
            <table cellspacing="0"class="table table-bordered table-condensed">
                <tr>
                   <td>Customer Name</td>
                   <td><?php echo $customer_name; ?></td>
                </tr>  
                 <tr>
                   <td>Dispenser Name</td>
                   <td><?php echo $dispenser_product_name; ?></td>
                </tr> 
                <!--  <tr>
                   <td>Total Quantity</td>
                   <td><?php echo $dispenser_quantity; ?></td>
                </tr>  -->
            </table>
        </div>
    </div>
       
        
      

    </div>
  </section>
</div>

<div class="row">
    <div class="col-xs-12">
        <section class="panel panel-default">
             <div class="panel-body bs-example form-horizontal">
        <div class="table-header">
            
        </div>
       
                
        <div class="table-responsive">
        <table  id="example" cellspacing="0" width="100%" class="table table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="text-center" style="color: black;">Sr no</th>
            

                    <th class="text-center" style="color: black;">Refill Name</th>
                    <th class="text-center" style="color: black;">Quantity</th>
                    <th class="text-center" style="color: black;">Programming Duration Days</th>
                    <th class="text-center" style="color: black; width: 110px;">Refill Date</th>
                    <th class="text-center" style="color: black; width: 110px;">Next Due Date</th>
                    <th class="text-center" style="color: black; width: 110px;">Is Returned</th>
                    <th class="text-center" style="color: black; width: 110px;">Is Stop</th>
                    <th class="text-center" style="color: black;">Comments</th>
                   
                </tr>   
            </thead>
            <tbody>
                <?php 
                 //$icnt=0;
                
                
               if (!empty($refill_transaction)) {
                  $sr=1;
                foreach ($refill_transaction as $value) {
                    $product_name=$value['product_name'];
                    $quantity=$value['quantity'];
                    $duration_days=$value['duration_days'];
                    $refill_date=$value['refill_date'];
                    $next_refill_date=$value['next_refill_date'];
                    $comments=$value['comments'];
                    $stop_refill=$value['stop_refill'];
                    $dispenser_refill_details_id=$value['dispenser_refill_details_id'];
                    $unit_of_measurment=$value['unit_of_measurment'];
                   // $is_returned=$value['is_returned'];
                  //  $dispenser_return_comments=$value['dispenser_return_comments'];
                    // $icnt++;
                    // $sr=$offset+$icnt;
                    // $sr=$offset+$icnt;
					        
             
        
                    ?>        
                <tr>
                    <td class="text-center"><?php echo $sr; ?></td>
                    <td class="text-center"><?php echo $product_name;?></td>
                    <td class="text-center"><?php echo $quantity ." ".$unit_of_measurment;?></td>
                    <td class="text-center"><?php echo $duration_days;?></td>
                    <td class="text-center"><?php echo $refill_date;?></td>
                    <td class="text-center"><?php echo $next_refill_date;?></td>
                    <td class="text-center"><?php 
                    $is_returned_dispenser= get_data_value_return_result(TABLE_TRACKING_DETAILS,'is_returned','dispenser_refill_details_id',$dispenser_refill_details_id,'where');

                    
					if($is_returned_dispenser=="")
					{
						echo "no";
					}
					else
					{
						echo $is_returned_dispenser;
					}
					?>
					</td>
                    <td class="text-center"><?php echo $stop_refill;?></td>
                    <td>  
                          <?php 
                          $dispenser_return_comments= get_data_value_return_result(TABLE_TRACKING_DETAILS,'comments','dispenser_refill_details_id',$dispenser_refill_details_id,'where');

                          if ($is_returned_dispenser=='yes' &&  $stop_refill=='no'){
                            echo $dispenser_return_comments;
                          }else if($is_returned_dispenser=='no' &&  $stop_refill=='yes'){
                            echo $comments;
                          }else if($is_returned_dispenser=='yes' &&  $stop_refill=='yes'){
                            echo $comments;
                          }else{  
                            echo $comments;
                          }?>
                        </td>

                </tr> 
               <?php 
               $sr=$sr+1;
               }
           
          }
             
             ?>
        </tbody>
        </table>
     
        </div>
    <!--                <?php
     if($num_results > 0) { ?>
      <div class="block"> </div>
        <div class="clearfix">
        <div class="row">
          <?php 
            if (strlen($pagination)): 
              $label_disp="List Of Refill Transaction";
              $data['label_disp']=$label_disp;
              $data['count']=$count;
              $this->load->view('pagination_view.php',$data);
            endif; ?>
            </div>
        </div>
          <div class="block"> </div>
      <?php } ?> -->
</div>
   
    
</section>
          
        <div class="clearfix form-actions">
          <div class="col-md-offset-5 col-md-5">
            <button class="btn btn-info" type="button" onclick="javascript:window.history.back();" >
                Back
            </button>           
          </div>
    </div>
    </form>
    </div>
</div>
<div>
    <!-- /.page-row -->
    <!-- /.page-content --> 
</div>
<!-- /.main-content --> 
</div>
<!-- /#ace-settings-container --> 
</div>
<!-- /.main-container-inner --> 
<?php
    include('common/footer.php');
?>
<script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
    destroy: true,
    searching: true,
    ordering: false,
    "lengthMenu": [20, 40, 60, 80, 100],
    "pageLength": 20,
    "order": [],
    "columnDefs": [
      { "orderable": false, "targets":  [] }
      ]
  } );
});
</script> 
