<script type="text/javascript">
$(document).ready(function(){

	$('#reset_filters').click(function(){
		document.location.href='<?php echo site_url('affiliates/payments/'.$affiliate->username)?>';
	});

	
	$('.sort').click(function(){
		var url = '<?php echo current_url()?>?<?php echo $filters?>&';
		document.location.href= url + 'orderby[' + $(this).attr('id')  + ']=' + $(this).attr('order'); 
	});
		
	$(".payments_info").fancybox({
			'transitionIn' : 'none',
			'transitionOut' : 'none'
	}); 
});
</script>
<div class="container">
	<div class="conthead">
		<?php $this->load->view('includes/affiliate_buttons')?>
	</div>
	<div id="observer">0</div>
	<div class="contentbox">
		<?php if(sizeof($payments) == 0):?>
			<div style="text-align:center; width:100%; " class="clear"><h3><?php echo lang('No payments found.')?></h3></div>
		<?php else:?>
			<table width="100%" border="0">
				<thead>
					<tr>
						<?php $this->load->view('table_sorting',array('name'=>lang('ID'),				'key'=>'id') )?>
						<?php $this->load->view('table_sorting',array('name'=>lang('Paid date'),		'key'=>'paid_date') )?>
						<?php $this->load->view('table_sorting',array('name'=>lang('Amount chips'),		'key'=>'amount_chips') )?>
						<th style="width: 120px; text-align: left;"><?php echo lang('Payment info') ?></th>
						<?php $this->load->view('table_sorting',array('name'=>lang('Comments'),			'key'=>'comments') )?>
						<?php $this->load->view('table_sorting',array('name'=>lang('Status'),			'key'=>'status') )?>
					</tr>
				</thead>
				<tbody>
				<?php $i = 1?>
				<?php foreach ($payments as $payment):?>
					<tr <?php echo ($i%2 == 0) ? 'class="alt"' : NULL?>>
						<td><?php echo $payment->id?></td>
						<td><?php echo date('d M Y H:i' ,$payment->paid_date);?></td>
						<td><?php echo print_amount_by_currency($payment->amount_chips,TRUE)?> (<?php echo sprintf(lang('%s chips'),$payment->amount_chips)?>)</td>
						<td>
							<a href="#payment_info_<?php echo $i?>" class="payments_info"><?php echo $payment->payment_name?></a>
							<div class="payments_info_content" id="payment_info_<?php echo $i?>" style="margin:20px;">
								<h3><?php echo sprintf(lang('Payments info for <strong>%s</strong> account.'), $affiliate->username)?></h3>
								<?php  $fields = unserialize($payment->payment_fields_data)?>
								<?php if(is_array($fields)):?>
									<span style="display:inline-block; width:auto; font-weight: bold;"><?php echo $payment->payment_name?></span> <br/>
									<?php foreach($fields as $field => $value):?>											
										<span style="display:inline-block; width:70px; text-align:right;"><?php echo ucfirst($field) ?>:</span>
										<span style="display:inline-block; width:auto; font-weight: bold;"><?php echo $value ?></span><br/>
									<?php endforeach?>
								<?php endif?>
							</div>
						</td>
						<td><?php echo $payment->comments?></td>
						<td><?php echo $payment->status?></td>
					</tr>
					<?php $i++?>
				<?php endforeach?>
			</tbody>
			</table>
		<?php endif?>
		<br />
		<div class="extrabottom">
			<?php echo $pagination?>
			<div class="bulkactions">
			</div>
		</div>
	</div>
</div>