<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php

		$this->session = session();
		use App\Libraries\MyEncrypt;
		 echo 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>
    <!--<script type="text/javascript" src="<?php echo base_url();?>assets/js/pages/components_modals.js"></script>-->
    <style type="text/css">
	    .icons-list a[data-action="reload1"]:after {
		  content: '\e9fb';
		}
		.btns {
			padding: 5px;
		}
	</style>
</head>
<style>
.icons-list > li {
    display: inline-block;
    font-size: 26px;
    }
    .heading-elements .icons-list {
    margin-top: 5px;
}
</style>
<body class="navbar-top-md-md pace-done">

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

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


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

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


	<!-- Page header -->
	<div class="page-header">
		<div class="page-header-content">
			<!-- <div class="page-title">
				<h4><i id="icon-bck" class="icon-arrow-left52 position-left"></i> <span class="text-semibold"><?php echo lang('language_lang.users_page_title'); ?></h4>

				<ul class="breadcrumb breadcrumb-caret position-right">
					<?php foreach ($breadcrumbs as $breadcrumb) { if(isset($breadcrumb['href'])){?>
					    <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
					<?php } else { ?> <li><?php echo $breadcrumb['text']; ?></li><?php } } ?>
				</ul>
			</div> -->
			<?php

			// echo $module_name;

			 echo view('admin/'.$module_name.'_header'); ?>
		</div>
	</div>
	<!-- /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 lang('language_lang.currency_page_title'); ?></h5>
						<div class="heading-elements">
							<ul class="icons-list">
								<li><a href="<?php echo base_url('admin/finance/addlist');?>" class="icon-plus-circle2"></a></li>
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="reload1"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
					</div>
					<?php $currency_info = defaultcurrency();?>
					<!-- <div class="ajax-refresh">  -->
					<table class="table datatable-responsive-user table-hover">
						<col width="12%">
  						<col width="16%">
  						<col width="12%">
  						<col width="10%" >
  						<col width="14%">
  						<col width="10%">
  						<col width="12%" style="display:none;">
  						<col width="18%">
						<thead>
							<tr>
								<th></th>
								<th class=""><?php echo lang('language_lang.lbl_coin_name');?></th>
								<th class=""><?php echo lang('language_lang.lbl_coin_symbol');?></th>
								<th class=""><?php echo lang('language_lang.lbl_icon_picture');?></th>
								<th class="" ><?php echo lang('language_lang.lbl_coin_decimal');?></th>
								<th class=""><?php echo lang('language_lang.coin_mode');?></th>
								<th class="text-center"><?php echo lang('language_lang.lbl_status');?></th>
								<th class="text-center" style="display:none;"><?php echo lang('language_lang.lbl_whitepaper');?></th>
								<th class="text-center"><?php echo lang('language_lang.lbl_options');?></th>
							</tr>
						</thead>
						<tbody>
						<?php 
							// echo '<pre>'; 							
							// print_r($coin_info);
							// echo '</pre>'; 							

							if($coin_info) {
								
								// $row_count = count($users);
								// $this->load->library('MyEncrypt');
									$myencrypt = new MyEncrypt;
									$i=0;
								foreach ($coin_info as $row) {

									if($row->status=='1')
									{
										$label_status = 'label-success';
										$status = lang('language_lang.active');
									}
									else if($row->status=='0')
									{
										$label_status = 'label-danger';
										$status = lang('language_lang.in_active');
									}
									else if($row->status=='2')
									{
										$label_status = 'label-primary';
										$status = lang('language_lang.suspend');
									}


									

									if($row->coin_type=='1')
									{
										if($row->pay_status=='1')
											$payment="Crypto currency";
										else if($row->pay_status=='2')
												$payment="Ethereum Tokens";
										else if($row->pay_status=='3')
										{
											if($row->pay_mode=='3')
												$payment="Fiat Currency (Credit Card Payment)";
											else if($row->pay_mode=='4')
												$payment="Fiat Currency (Wire Transfer Payment)";
											else if($row->pay_mode=='5')
												$payment="Fiat Currency (Coin Payment)";
											else
												$payment="Fiat Currency (Perfect Money Payment)";											

										}
									}
									else
									{
										$payment="Non Live Coin";
									}
							?>
							<tr>
							    <td></td>
								<td class=""><?php echo ucwords($row->coin_name);?></td>
								<td class=""><?php echo $row->coin_symbol;?></td>
								<td class=""><img width="30" height="30" src="<?php echo base_url('uploads/coins/'.$row->coin_image);?>"/></td>
								<td class="" ><?php echo $row->coin_decimal;?></td>
								<td class=""><?php echo $payment;?></td>
								<?php
								if($row->status=='0')
								{?>
								    <td class="text-center"><span class="label <?php echo $label_status;?>"><a style="color:#fff;text-transform:none;font-size:13px;" data-popup="tooltip" title="<?php echo lang('language_lang.click_to_active');?>" onclick="changeinStatus('<?php echo $myencrypt->encode($row->coid); ?>')"><?php echo $status;?></a></span></td>
								<?php
								}
								else if($row->status=='1')
								{?>
 								    <td class="text-center"><span class="label <?php echo $label_status;?>"><a style="color:#fff;text-transform:none;font-size:13px;" data-popup="tooltip" title="<?php echo lang('language_lang.click_to_deactive');?>" onclick="changeStatus('<?php echo $myencrypt->encode($row->coid); ?>')"><?php echo $status;?></a></span></td>
                                <?php
                            	}
                            	else if($row->status=='2')
								{?>
 								    <td class="text-center"><span class="label <?php echo $label_status;?>"><a style="color:#fff;text-transform:none;font-size:13px;" data-popup="tooltip" title="<?php echo lang('language_lang.click_to_active');?>" onclick="changeActiveStatus('<?php echo $myencrypt->encode($row->coid); ?>')"><?php echo $status;?></a></span></td>
                                <?php
                            	}?>
                              	  <td class="text-center" style="display:none;"><?php if($row->whitepaper!=""){ echo '<a target="_blank" href='.base_url().'/uploads/'.$row->whitepaper.'>Click Here to view</a>'; }else{ echo '----';} ?></td>
                                	<td class="text-center" style='text-align: justify;'>
                                	<?php
                                		if($row->status=='1')
                                		{	
                                			if($row->market_currency=='0')
                                			{?>
                                		   		<a class="btn btn-primary" data-popup="tooltip" title="<?php echo lang('language_lang.lbl_add_market');?>" onclick="Addmarket('<?php echo $myencrypt->encode($row->coid);?>')" /><?php echo lang('language_lang.lbl_add_market');?></a>
                                		   	<?php
                                		   	}
                                		   	else
                                		   	{?>	
                                		   		<a class="btn btn-info" href="javascript:void(0);" /><?php echo lang('language_lang.lbl_added_market');?></a>
                                		   	<?}
                                		   	?>	
                                		<?php
                                		}
                                		else
                                		{
                                			echo '----';
                                		}
                                		?>

                                			<!-- <a class="btns" data-popup="tooltip" title="<?php echo lang('language_lang.arbit');?>" href="<?php echo base_url().'admin/finance/viewarbit/'.$myencrypt->encode($row->coid);?>" ><i class="fa fa-caret-square-o-up"></i>
                							</a> -->


	                                	<!--<a class="btns" data-popup="tooltip" title="< ?php echo lang('language_lang.lbl_view');?>" href="< ?php echo base_url().'admin/users/view/'.$myencrypt->encode($row->coid);?>"><i class="fa fa-search position-center"></i></a>-->

                                		<?php
                                			if($row->coid > 5)
                                			{
                                		?>

                                			<a class="btns" data-popup="tooltip" title="<?php echo lang('language_lang.edit');?>"  href="<?php echo base_url('admin/finance/addlist/'.$myencrypt->encode($row->coid));?>">
                                			<i class="fa fa-edit"></i>
                                			</a>
                                		
                                			<a class="btns" data-popup="tooltip" title="<?php echo lang('language_lang.delete');?>"  onclick="confirmdelete('<?php echo $myencrypt->encode($row->coid);?>')" href="javascript:void(0)" ><i class="fa fa-remove"></i>
                                			</a>
                                			<?php
	                                			
	                                			if($row->pay_mode=='4')
	                                			{
	                                			?>
	                                			<a class="btns" data-popup="tooltip"  title="<?php echo lang('language_lang.bank');?>"  href="<?php echo base_url('admin/bank?'.$myencrypt->encode($row->coid));?>" ><i class="fa fa-suitcase"></i>
	                                			</a>

	                                			<?php

	                                			}
	                                			?>
                                			<?php
                                			}
                                			else
                                			{
                                				?>
                                				<a class="btns" data-popup="tooltip" title="<?php echo lang('language_lang.edit');?>"  href="<?php echo base_url('admin/finance/addlist/'.$myencrypt->encode($row->coid));?>">
                                					<i class="fa fa-edit"></i>
                                					</a>
                                		
	                                			<a class="btns" data-popup="tooltip" style='cursor:not-allowed;' title="<?php echo lang('language_lang.delete');?>"  href="#" ><i class="fa fa-remove"></i>
	                                			</a>



                                				<?php

                                			}

                                		?>
                                	</td>
							</tr>
						<?php 
                         }
							}?>
						</tbody>
					</table>
					<!-- </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->getFlashData('error_message')) { ?>
				$.jGrowl("<?php echo $this->session->getFlashData('error_message');?>", {
		            header: '<?php echo lang("language_lang.error");?>',
		            theme: 'bg-danger'
		        });

            <?php } ?>
                    
            <?php if($this->session->getFlashData('success_message')) { ?>
                
                $.jGrowl("<?php echo $this->session->getFlashData('success_message');?>", {
		            header: '<?php echo lang("language_lang.success");?>',
		            theme: 'bg-success'
		        });

            <?php } ?>
            

			$('.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/users/dataview');?>',
		            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();
		            }
		        });
		        
		    });

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

	})(jQuery);
	
	function changeStatus(valus) {

		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
	            var valus1 =  valus;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/changeStatus');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp){
		                    window.location.href = "<?php echo base_url('admin/finance/listing');?>";
		                } 
		            }
		        });
		    }
        });
	}
	function changeActiveStatus(valus) {
		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	var valus1 =  valus;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/changeActiveStatus');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp){
		                    window.location.href = "<?php echo base_url('admin/finance/listing');?>";
		                }
		                
		            }
		        });
            }
        });
	}

	function confirmdelete(value) {
		swal({
            title: "<?php echo lang('language_lang.confirm_delete_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/mark_delete/');?>"+'/'+value;
            }
        });
    }


    function changeinStatus(valus) {
		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false) {
            	return false;
            } else {
            	var valus1 =  valus;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/changeinStatus');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp)
		                {
		                    window.location.href = "<?php echo base_url('admin/finance/listing');?>";
		                }
		            }
		        });
            }
        });
	}        



	function Addmarket(value)
	{
		swal({
            title: "<?php echo lang('language_lang.confirm_status_text');?>",
            showCancelButton: true,
            closeOnConfirm: false,
            confirmButtonColor: "#2196F3",
            showLoaderOnConfirm: true
        },
        function(inputValue){
            if (inputValue === false)
            {
            	return false;
            }
            else
            {
            	var valus1 =  value;
				jQuery.ajax({
		            type: 'post',
		            url:'<?php echo base_url('admin/finance/addMarket');?>',
		            data: {'id':valus1},
		            success : function(resp)
		            {
		                if(resp)
		                {
		                    window.location.href = "<?php echo base_url('admin/finance/listing');?>";
		                }
		            }
		        });
            }
        });
	}
	</script>
</body>
</html>
