<!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 table-hover">
							<colgroup>
								<col width="15%"/>
		  						<col width="10%"/>
		  						<col width="10%"/>
		  						<col width="15%"/>
		  						<col width="10%"/>
		  						<col width="10%"/>
		  						<col width="10%"/>
	  						</colgroup>
							<thead>
								<tr>
									<th class=""><?php echo $this->lang->line('lbl_date');?></th>
									<th class=""><?php echo $this->lang->line('lbl_user_name');?></th>
									<th class=""><?php echo $this->lang->line('lbl_type');?></th>
									<th class=""><?php echo $this->lang->line('lbl_market_pair');?></th>
									<th class=""><?php echo $this->lang->line('lbl_market_price');?></th>
									<th class=""><?php echo $this->lang->line('trans_amnt');?></th>
									<th class=""><?php echo $this->lang->line('lbl_total_amnt');?></th>
									<th class=""><?php echo $this->lang->line('exchange_receiver_Mode');?></th>
									<th class=""><?php echo $this->lang->line('lbl_status');?></th>
								</tr>
							</thead>
							<tbody>
							<?php 
							
								if($history) {

									
									
									$row_count = count($history);
									$this->load->library('MyEncrypt');
									$myencrypt = new MyEncrypt;
									foreach ($history as $row) {
										
									$users = $this->db->query("select * from uusers where uusersid = '".$row->userid."'");
									$user_det=$users->result();

									$receive  = $this->db->query("select * from uusers where uusersid = '".$row->rec_user."'");
									$receiver =$receive->result();

									$mark   = $this->db->query("select * from coin_info where coid = '".$row->market_type."'");
									$market = $mark->result();

									$par  = $this->db->query("select * from coin_info where coid = '".$row->pair."'");
									$pair = $par->result();

									
								?>
								<tr>
									<td class=""><?php echo date('Y-m-d H:i a', strtotime($row->date));?></td>
									<td class=""><?php echo $user_det[0]->username!="" ? $user_det[0]->username : '-----'; ?></td>
									<td class=""><?php echo $type;?></td>
									<td class=""><?php echo $market[0]->coin_symbol!="" ? $market[0]->coin_symbol : '---';?> / <?php echo $pair[0]->coin_symbol!=""  ? $pair[0]->coin_symbol : '----' ;?></td>
									<td class=""><?php echo $row->price;?> <?php echo $market[0]->coin_symbol!="" ? $market[0]->coin_symbol : '---';?>
									</td>
									<td class=""><?php echo $row->amount; ?>  <?php echo $pair[0]->coin_symbol!=""  ? $pair[0]->coin_symbol : '----' ;?>
									</td>
									<td class=""><?php echo ucfirst($row->total); ?> <?php echo $market[0]->coin_symbol!="" ? $market[0]->coin_symbol : '---' ;?></td>
									<td class=""><?php echo $receiver[0]->username!="" ? $receiver[0]->username : '-----'; ?> </td>
									<td class="text-center">
	                                	<a class="btns" data-popup="tooltip" title="<?php echo $this->lang->line('lbl_approve_withdraw');?>"  href="javascript:void(0)" onClick="payouts('<?php echo $myencrypt->encode($row->cid);?>')" ><i class="fa fa-thumbs-up"></i></a>
	                                	<a class="btns" data-popup="tooltip" title="<?php echo $this->lang->line('lbl_cancel_withdraw');?>"  href="javascript:void(0)" onClick="cancelpayouts('<?php echo $myencrypt->encode($row->cid);?>')" ><i class="fa fa-thumbs-down"></i></a>
	                                </td>


								</tr>
							<?php 

									}
								}  else { 

							?>
								<?php } ?>
							</tbody>
						</table>
					<?php } else { ?>
						<table class="table datatable-responsive table-hover">
							<col width="13%">
	  						<col width="12%">
	  						<col width="15%">
	  						<col width="22%">
	  						<col width="13%">
	  						<col width="11%">
	  						<?php if($this->uri->segment(3)=='deposit') { ?>
	  						<col width="10%">
	  						<?php } ?>
							<thead>
								<tr>
									<th class=""><?php echo $this->lang->line('lbl_date');?></th>
									<th class=""><?php echo $this->lang->line('lbl_transaction_id');?></th>
									<th class=""><?php echo $this->lang->line('lbl_user_name');?></th>
									<th class=""><?php echo $this->lang->line('lbl_description');?></th>
									<?php if($this->uri->segment(3)=='deposit') { ?>
									<th class=""><?php echo $this->lang->line('lbl_plans');?></th>
									<?php } ?>
									<th class=""><?php echo $this->lang->line('lbl_amount'). ' (<b>'.strtoupper($currency_info->currency_unit).'</b>)';?></th>
									<th class=""><?php echo $this->lang->line('lbl_payment_gateway');?></th>
									<?php if($this->uri->segment(3)=='deposit') { ?>
									<th class=""><?php echo $this->lang->line('lbl_options');?></th>
									<?php } ?>
								</tr>
							</thead>
							<tbody>
							<?php 
								if($history) {
									
									$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 = '----';

										if($row->is_delete =='0'){

								?>
								<tr>
								    
									<td class=""><?php echo date('Y-m-d H:i:s', strtotime($row->date));?></td>
									<td class=""><?php echo $row->transactionid;?></td>
									<td class=""><?php echo $row->username;?></td>
									<td class=""><?php echo ucfirst($row->description);?></td>
									<?php if($this->uri->segment(3)=='deposit') { ?>
									<td class=""><?php echo ucfirst($row->package_name);?></td>
									<?php } ?>
									<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 $payment_name;?></td>
									<?php if($row->type == 'deposit' || $row->type == 'reinvest') { ?>
									<td class="text-center">
	                                	<!-- <a class="btns" data-popup="tooltip" title="<?php echo $this->lang->line('lbl_approve_withdraw');?>"  href="javascript:void(0)" onClick="payouts('<?php echo $myencrypt->encode($row->historyid);?>')" ><i class="fa fa-thumbs-up"></i></a> -->
	                                	<!-- <a class="btns cancelbtn" value="<?php echo $myencrypt->encode($row->historyid);?>" data-popup="tooltip" title="<?php echo $this->lang->line('lbl_cancel_deposit');?>"  href="javascript:void(0)" ><i class="fa fa-thumbs-down"></i></a> -->
	                                	<button type="button" class="btn btn-danger" onclick="canceldeposit('<?php echo $myencrypt->encode($row->historyid);?>')" value="" data-popup="tooltip" title="<?php echo $this->lang->line('lbl_cancel_deposit');?>"><i class="fa fa-thumbs-down"></i></button>
	                                </td>
	                                <?php } ?>
								</tr>
							<?php 

									}
								}
								}  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: '<?php echo $this->lang->line("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();
			});
			    
		});

	})(jQuery);

	function cancelpayouts(id) {

		swal({
            title: "<?php echo $this->lang->line('confirm_cancel_request_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	window.location.href = "<?php echo base_url();?>admin/finance/Deletetrade/"+id;
            }
        });

	}

	function payouts(id) {

		swal({
            title: "<?php echo $this->lang->line('confirm_cancel_approve_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            cancelButtonColor: true,
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	window.location.href = "<?php echo base_url();?>admin/finance/approvetrade/"+id;
            }
        });

	}
	
	</script>

</body>
</html>
