<?php
	include('common/header.php');
	$dues = $this->page_data['dues'];
	//$due_day = $this->encrypt->encode(($dues));
	$customer_name='';
 //    echo "<pre>";
	// print_r($refill_sale);
?>
<div id="messages" style="color: green;"><h5><?php echo $this->session->flashdata('message'); ?></h5></div>
<div class="row">
 <section class="panel panel-default">
	<div class="panel-body bs-example form-horizontal">
	<div class="col-xs-12">
		<div class="table-header">
			<?php
              echo $this->page_data['heading'];
			 ?>
		</div>
		<div class="table-responsive">
		<table  id="example" class="table table-bordered dataTables" cellspacing="0" width="100%">
			<thead>
				<tr>
					<th>Sr No</th>		
					 <?php foreach($fields as $field_name => $field_display): ?>
            <th <?php if ($sort_by == $field_name) echo "class=\"sorting_$sort_order\"" ?>>
            <?php echo anchor("gc/refill_sale_data/list_refill_sale_data/0/0/$query_id/$field_name/" .
            (($sort_order == 'asc' && $sort_by == $field_name) ? 'desc' : 'asc') ,
            $field_display); ?>     </th>
          <?php endforeach; ?>			
					<!-- <th>Customer Name</th>
					<th>Sales Person Name</th>
					<th>Dispenser Name</th>
					<th>Refill Name</th>
					<th>Quantity</th>
					<th>Location</th>
					<th>Sales Type</th>
	s				<th>Installation Date</th>
					<th>Refill Date</th>
					<th>Refill Due Date</th>
					<th>Refill Duration</th>
					<th>Comments</th> -->
					<th>Action</th>
				</tr>	
			</thead>
			<tbody>
				<?php 
				$icnt=0;
	  			$count=count($refill_sale);
	  			if ($count>0) {
	  			
                 foreach ($refill_sale as $value) {
                  $dispenser_sales_id=$value->dispenser_sales_id;
                 $dispenser_refill_details_id=$value->dispenser_refill_details_id;
                // $id= $this->encrypt->encode($dispenser_sales_id);
                // $dispenser_refill_details_id= $this->encrypt->encode($dispenser_refill_details_id);
                 	$customer_name=$value->customer_name;
                 	$name=$value->first_name.' '.$value->last_name;
					$dispenser=$value->dispenser;
					$product_name=$value->product_name;
					$dispenser_quantity=$value->dispenser_quantity;
					$refill_location=$value->refill_location;
					$sales_type=$value->sales_type;
					$installation_date=$value->installation_date;
					$refill_date=$value->refill_date;
					$next_refill_date=$value->next_refill_date;
					$duration_days=$value->duration_days;
					$comments=$value->comments;
					$dispenser_id1=$value->dispenser_id;
					//$dispenser_id=$this->encrypt->encode($value->dispenser_id);
					
					$dispenser_id=encrypt_decrypt_parameters($dispenser_id1,'encrypt');
					
					$dispenser_refill_details_id;
					$dispenser_refill_details_id=encrypt_decrypt_parameters($dispenser_refill_details_id,'encrypt');
					$id=encrypt_decrypt_parameters($dispenser_sales_id,'encrypt');

					$icnt++;
					$sr=$offset+$icnt;

				 ?>
				<tr>
					<td><?php echo $sr; ?></td>
					<td><?php echo $customer_name; ?></td>
					<td><?php echo $name; ?></td>
					<td><?php echo $dispenser; ?></td>
					<td><?php echo $product_name; ?></td>			
					<td><?php echo $dispenser_quantity; ?></td>
					<td><?php echo $refill_location; ?></td>
					<td><?php echo $sales_type; ?></td>
					<?php 
                     if ($installation_date=='0000-00-00') {?>
					<td><?php echo $installation_date; ?></td><?php }else{?>
					<td><?php echo get_date_dmy_format_wo_time($installation_date); ?></td>
					<?php } ?>
					<?php 
                     if ($refill_date=='0000-00-00') {?>
					<td><?php echo $refill_date; ?></td><?php }else{?>
					<td><?php echo get_date_dmy_format_wo_time($refill_date); ?></td>
					<?php } ?>
					<?php 
                     if ($next_refill_date=='0000-00-00') {?>
					<td><?php echo $next_refill_date; ?></td><?php }else{?>
					<td><?php echo get_date_dmy_format_wo_time($next_refill_date); ?></td>
					<?php } ?>
					<td><?php echo $duration_days; ?></td>
					<td><?php echo $comments; ?></td>
					<td>
						<b><a href="<?php echo base_url();?>index.php/gc/refill_sale_data/change_refill/<?php echo $dispenser_refill_details_id;?>/<?php echo $dispenser_id; ?>/change" onclick="return confirm('Are you sure you want to change this refill?')">Change Refill</a></b>
					</td>
				</tr>
			<?php 
			//$srno=$srno+1;
		     }
		 }else{?>
 					<td colspan="14" class="text-center">no data found</td>
		 <?php } ?>
			
			</tbody>
		</table>
		</div>
		<?php
		 if($num_results > 0)	{ ?>
			<div class="block"> </div>
				<div class="clearfix">
				<div class="row">
					<?php 
						if (strlen($pagination)): 
							$label_disp="Refill Sales";
							$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>
<form method="post" action="<?php echo base_url()?>index.php/<?php echo REFILL_SALES_DATA;?>excel_refill_sale">
      <input type="hidden" name="excel_branch_name" value="<?php echo $excel_branch_id; ?>">
      <input type="hidden" name="excel_customer_name" value="<?php echo $excel_customer_id; ?>">  
      <input type="hidden" name="excel_dues" value="<?php echo $excel_dues; ?>">  	

		<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>
        	 <button class="btn btn-info" type="submit">
          		Export to Excel
        	</button>
        	</div>

     </form>   	

    </div>
		
	</div>
</div>
<div>
	<!-- /.page-row -->
    <!-- /.page-content --> 
</div>
<!-- /.main-content --> 
</div>
<!-- /#ace-settings-container --> 
</div>
<!-- /.main-container-inner --> 
<?php
	include('common/footer.php');
?>

