<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php $this->load->view('admin/common_header'); ?>
	<!-- /main navbar -->

	<!-- select box theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/selects/bootstrap_select.min.js"></script>

	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/tables/datatables/datatables.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/tables/datatables/extensions/responsive.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/selects/select2.min.js"></script>

	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/app.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/pages/datatables_responsive.js"></script>
	<!-- /theme JS files -->

	<!-- notify JS files -->
    <script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/jgrowl.min.js"></script>

    <!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/bootbox.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/sweet_alert.min.js"></script>
    
    <style type="text/css">
	    .icons-list a[data-action="reload1"]:after {
		  content: '\e9fb';
		}
		.btns {
			padding: 5px;
		}
	</style>
</head>

<body class="navbar-top-md-md pace-done">

	<!-- Fixed navbars wrapper -->
	<div class="navbar-fixed-top">

		<!-- Main navbar -->
		<?php $this->load->view('admin/mainnav'); ?>
		<!-- /main navbar -->


		<!-- Second navbar -->
		<?php $this->load->view('admin/secondnav'); ?>
		<!-- /second navbar -->

	</div>
	<!-- /fixed navbars wrapper -->


	<!-- Page header -->
	<?php $this->load->view('admin/'.$module_name.'_header'); ?>
	<!-- /page header -->


	<!-- Page container -->
	<div class="page-container">

		<!-- Page content -->
		<div class="page-content">

			<!-- Main content -->
			<div class="content-wrapper">
			
				<!-- Basic responsive configuration -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h5 class="panel-title"><?php echo $page_title; ?></h5>
						<div class="heading-elements">
							<ul class="icons-list">
								<!-- <li><a href="<?php echo base_url();?>admin/users/add" class="glyphicon-plus"></a></li> -->
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="reload"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
					</div>
					<?php $currency_info = defaultcurrency();?>
					<?php if($type) { ?>
					<table class="table datatable-responsive-history table-hover">
						<col width="8%">
	  						<col width="16%">
	  						<col width="15%">
	  						<col width="20%">
	  						<col width="15%">
	  						<col width="15%">
	  						<col width="11%">
						<thead>
							<tr><th></th>
								<th class=""><?php echo $this->lang->line('exp_report_sno');?></th>
								<th class=""><?php echo $this->lang->line('lbl_user_name');?></th>
								<th class=""><?php echo $this->lang->line('exp_planname_lbl');?></th>
								<th class=""><?php echo $this->lang->line('menu_deposit'). ' (<b>'.strtoupper($currency_info->currency_unit).'</b>)';?></th>
								<th class=""><?php echo $this->lang->line('exp_invest_lbl');?></th>
								<th class=""><?php echo $this->lang->line('exp_maturity_lbl');?></th>
								<th class=""><?php echo $this->lang->line('lbl_payment_gateway');?></th>
								<!-- <th class="text-center"><?php echo $this->lang->line('lbl_action'); ?></th> -->
							</tr>
						</thead>
						<tbody>
						<?php 
							if($history) {
								
								$row_count = count($history);
								$this->load->library('MyEncrypt');
								$myencrypt = new MyEncrypt;
								$i=1;
								foreach ($history as $row) {

									$condition = "payment_key in('status') AND payment_id = '".$row->payment_id."'";
									$payment = $this->finance_model->PaymentName($condition);
									if($payment) {
										$payment_name = ucfirst($payment->payment_name);
									} else {
										$payment_name = "----";
									}

									$plan_condition = 'planid = '.$row->planid;
									$plan_name = $this->common_model->GetRow('plans', $plan_condition);
									if($plan_name) {
										$package_plan = ucfirst($plan_name->plan_name);
									} else {
										$package_plan = '----';
									}


									
							?>
							<tr>
							    <td></td>
							    <td><?php echo $i; ?></td>
								<td class=""><?php echo $row->username;?></td>
								<td class=""><?php echo $package_plan;?></td>
								<td class=""><?php echo $currency_info->currency_symbol."".number_format($row->amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit);?></td>
								<td class=""><?php echo $row->invest_date;?></td>
								<td class=""><?php echo $row->mature_date;?></td>
								<td class=""><?php echo $payment_name;?></td>
								<!-- <td><button type="button" class="btn btn-success btn-sm" onclick="" data-popup="tooltip" title="<?php echo $this->lang->line('exp_release_tooltip');?>"><?php echo $this->lang->line('exp_release_depoit_plc');?> <i class="fa fa-plus-circle position-right"></i></button></td> -->
							</tr>
						<?php 

								$i++; }
							}  else { 

						?>
							<?php } ?>
						</tbody>
					</table>
					<?php } else { ?>
						<table class="table datatable-responsive-row-control table-hover">
							<col width="8%">
	  						<col width="12%">
	  						<col width="15%">
	  						<col width="20%">
	  						<col width="15%">
	  						<col width="15%">
	  						<col width="15%">
							<thead>
								<tr>
								<th></th>
									<th class=""><?php echo $this->lang->line('exp_report_sno');?></th>
									<th class=""><?php echo $this->lang->line('lbl_user_name');?></th>
									<th class=""><?php echo $this->lang->line('exp_planname_lbl');?></th>
									<th class=""><?php echo $this->lang->line('menu_deposit'). ' (<b>'.strtoupper($currency_info->currency_unit).'</b>)';?></th>
									<th class=""><?php echo $this->lang->line('exp_invest_lbl');?></th>
									<th class=""><?php echo $this->lang->line('exp_maturity_lbl');?></th>
									<th class=""><?php echo $this->lang->line('lbl_payment_gateway');?></th>
									<!-- <th class="text-center"><?php echo $this->lang->line('lbl_action'); ?></th> -->
								</tr>
							</thead>
							<tbody>
							<?php 
								if($history) {
									$i=1;
									$row_count = count($history);
									$this->load->library('MyEncrypt');
									$myencrypt = new MyEncrypt;
									foreach ($history as $row) {
										$condition = "payment_key in('status') AND payment_id = '".$row->payment_id."'";
										$payment = $this->finance_model->PaymentName($condition);
										if($payment) {
											$payment_name = ucfirst($payment->payment_name);
										} else {
											$payment_name = "----";
										}

										$plan_condition = 'planid = '.$row->planid;
									    $plan_name = $this->common_model->GetRow('plans', $plan_condition);
									    if($plan_name) {
											$package_plan = ucfirst($plan_name->plan_name);
										} else {
											$package_plan = '----';
										}

								?>
								<tr>
									<td></td>
									<td><?php echo $i; ?></td>
									<td class=""><?php echo $row->username;?></td>
									<td class=""><?php echo $package_plan;?></td>
									<td class=""><?php echo $currency_info->currency_symbol."".number_format($row->amount, $currency_info->deimal_point, '.', '').' '.strtoupper($currency_info->currency_unit);?></td>
									<td class=""><?php echo $row->invest_date;?></td>
									<td class=""><?php echo $row->mature_date;?></td>
									<td class=""><?php echo $payment_name;?></td>
									<!-- <td><button type="button" class="btn btn-success btn-sm" onclick="" data-popup="tooltip" title="<?php echo $this->lang->line('exp_release_tooltip');?>"><?php echo $this->lang->line('exp_release_depoit_plc');?> <i class="fa fa-plus-circle position-right"></i></button></td> -->
								</tr>
							<?php 

									$i++; }
								}  else { 

							?>
								<?php } ?>
							</tbody>
						</table>
					<?php } ?>
					<!-- </div> -->
				</div>
				<!-- /basic responsive configuration -->

			</div>
			<!-- /main content -->

		</div>
		<!-- /page content -->


		<!-- Footer -->
		<div class="footer text-muted">
			<?php echo site_footer();?>
		</div>
		<!-- /footer -->

	</div>
	<!-- /page container -->

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

	    $(document).ready(function() {

	    	$.jGrowl.defaults.closer = false;

				<?php if($this->session->flashdata('error_message')) { ?>
					$.jGrowl("<?php echo $this->session->flashdata('error_message');?>", {
			            header: 'Error!',
			            theme: 'bg-danger'
			        });
	            <?php } ?>
	                    
	            <?php if($this->session->flashdata('success_message')) { ?>
	                $.jGrowl("<?php echo $this->session->flashdata('success_message');?>", {
			            header: '<?php echo $this->lang->line("success");?>',
			            theme: 'bg-success'
			        });
	            <?php } ?>

	            $('#icon-bck').on('click',function() {
					window.history.back();
				});

				$('.panel [data-action=reload1]').click(function (e) {
			        e.preventDefault();
			        var block = $(this).parent().parent().parent().parent().parent();
			        jQuery.ajax({
			            url:'<?php echo base_url();?>admin/finance/expirehistory',
			            beforeSend: function() {
				            $(block).block({ 
					            message: '<i class="icon-spinner2 spinner"></i>',
					            overlayCSS: {
					                backgroundColor: '#fff',
					                opacity: 0.8,
					                cursor: 'wait',
					                'box-shadow': '0 0 0 1px #ddd'
					            },
					            css: {
					                border: 0,
					                padding: 0,
					                backgroundColor: 'none'
					            }
					        });
					        $('.panel .panel-heading').find('.dataTables_wrapper').remove();
					        
					        $('#DataTables_Table_0_wrapper').remove();
				        },
				        complete: function() {
				            $(block).unblock();
				        },
			            success : function(resp)
			            {
			            	$('.panel .panel-heading').after(resp);
			            	location.reload();
			            }
			        });
			        
			    });
			    
		});

	})(jQuery);
    
	
	</script>

</body>
</html>
