
<!DOCTYPE html>
<html lang="en">
<head>
	
	<!-- header -->
	<?php 
		use App\Libraries\MyEncrypt;
		$session = \Config\Services::session();


		echo view('admin/common_header'); ?>
	<!-- /header -->

	<!-- file upload JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/uploaders/fileinput.min.js');?>"></script>
	
	<!-- Bootsrap form validation JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/formValidation.js');?>"></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/bootstrap.js');?>"></script>
	

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

	<!-- file upload JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/boots/js/fileinput.min.js');?>"></script>
	
	<!-- bootsrap switch checkbox JS files -->
    <script src="<?php echo base_url('assets/boots/js/bootstrap-switch.js');?>"></script>

    <!-- notify JS files -->
    <script type="text/javascript" src="<?php echo base_url('assets/js/plugins/notifications/jgrowl.min.js');?>"></script>
    <style>
		.kv-file-content img.file-preview-image {
	    	width: 150px !important;
	    }
	</style>
   
</head>

<body class="navbar-top-md-md">
	<!-- <div class="pre_loader"></div> -->
	<!-- 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.pay_page_title'); ?></span></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 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">

				<!-- Horizontal form -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h5 class="panel-title">
						<?php 
							if(isset($this->data['gateway_name'])) { 
								$gate_name = $this->data['gateway_name'];
								echo ucwords($gateway_name);
								//echo lang('language_lang.'.$gate_name.'_gateway');
							}
						?>
						</h5>
						<div class="heading-elements">
							<ul class="icons-list">
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
                	</div>

                	<?php //echo "<pre>"; print_r($this->data);?>
                	
					<div class="panel-body">
						<div class="row">
							<div class="col-md-8">

								<form class="form-horizontal paymentsetting" action="<?= site_url($action);?>" method="post" enctype="multipart/form-data">
									<div>
										<?php 
										$validation = \Config\Services::validation();
											if($validation->listErrors()) { 
												$form_err_data = str_ireplace('<p>', '', $validation->listErrors());
												$form_err_data = str_ireplace('</p>', '', $form_err_data);
												$form_err_data = str_ireplace('.', '', $form_err_data);
										?>
												
												<script type="text/javascript">
												
												(function( $ ) {
													$.jGrowl.defaults.closer = false;
											        var from_daa = '<?php $form_err_data;?>';
													$.jGrowl(from_daa, {
											            header: '<?php echo lang('language_lang.'."error");?>',
											            theme: 'bg-danger'
											        });
											    
												})(jQuery);


												</script>
										<?php
											}
										?>
									</div>
									
									<?php
											$cls='';
										foreach ($forms as $key => $value) {

											$pay_id=$forms['payment_id'];
											if($key=='payment_name' || $key=='payment_id') {
												// $myencrypt = new MyEncrypt;
												// $payment_name = $myencrypt->encode($value);
												$payment_id = $myencrypt->encode($value);
									?>			
											
												<!-- <div class="form-group">
													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.lbl_payment_name'); ?> </label>
													<div class="col-lg-6">
														<div class="input-group1">
															<label><?php echo ucwords($value); ?></label>
														</div>

													</div>
												</div> -->
												<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $payment_id; ?>"/>

									<?php 	
											}
											else if($key=="address")
											{
												$address=$value;
												if(!empty($value))
													$value=$value;
												else
													$value='';
												?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>" id="<?php echo $key;?>" <?php echo $cls;?>>

													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.'.$key); ?> <span class="text-danger">*</span></label>
													<div class="col-lg-9">
														<div class="input-group1">
															<input type="text"  name="<?php echo $key; ?>" class="form-control" placeholder="<?php echo lang('language_lang.'.$key); ?>" value="<?php echo $value; ?>">
														</div>
														<?php echo $validation->getError($key, '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
													</div>
												</div>

												<?php

											} 



									 else if($key=='status') { 
												if(isset($value)) { 
													$pay_status = $value;
												} else {
													$pay_status = '';
												}
									?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>">
													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.lbl_payment_status'); ?> </label>
													<div class="col-lg-9">
														<div class="checkbox checkbox-switch">
															<label>
																<input type="checkbox" <?php if($pay_status){ echo 'checked="checked"'; }   ?> name="status" data-on-color="success" data-off-color="danger" data-on-text="<?php echo lang('language_lang.On');?>" data-off-text="<?php echo lang('language_lang.Off');?>" class="switchery">
															</label>
														</div>
														<?php echo $validation->getError($key, '<label class="validation-error-label">', '</label>'); ?>
													</div>
												</div>
									<?php 	
											} 
											elseif($key=='pay_mode') { 
												
												if(isset($value)) { 
													$payout = $value;
												} else {
													$payout = '';
												}

												
									?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>">
													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.pay_mode'); ?> </label>
													<div class="col-lg-9">
														<select name="pay_mode" id="pay_mode" class="form-control" onchange='change_mode1(this.value);'>
														<!--<option value="coin" < ?php if($payout=='coin'){ echo 'selected=="selected"'; }   ?>>< ?php echo lang('language_lang.coin');?></option>-->
													<option value="manual"  <?php if($payout=='manual'){ echo 'selected=="selected"'; }   ?>>Manual Mode</option>
													<option value="auto"  <?php if($payout=='auto'){ echo 'selected=="selected"'; }   ?>>Auto Payment Mode</option>
														</select>
														<?php echo $validation->getError($key, '<label class="validation-error-label">', '</label>'); ?>
													</div>
												</div>
									<?php 	
											}
											elseif($key=='coin_mode') { 
												
												if(isset($value)) { 
													$payout = $value;
												} else {
													$payout = '';
												}

												if($forms['pay_mode']=='coin' || $forms['pay_mode']=='address' || $forms['pay_mode']='block')
													$cls="style='display:none;'";
												
												
									?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>" id="<?php echo $key;?>" <?php echo $cls;?>>
													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.coin_mode'); ?> </label>
													<div class="col-lg-9">
														<select name="coin_mode" id="coin_mode" class="form-control" onchange='change_mode(this.value);'>
														<option value="BTC" <?php if($payout=='BTC'){ echo 'selected=="selected"'; }   ?>><?php echo lang('language_lang.coin_btc');?></option>
														<option value="LTC"  <?php if($payout=='LTC'){ echo 'selected=="selected"'; }   ?>><?php echo lang('language_lang.coin_ltc');?></option>
														<option value="DOGE"  <?php if($payout=='DOGE'){ echo 'selected=="selected"'; }   ?>><?php echo lang('language_lang.coin_dog');?></option>
														</select>
														<?php echo $validation->getError($key, '<label class="validation-error-label">', '</label>'); ?>
													</div>
												</div>
									<?php 	
											} 
											elseif($key=='instant_payout') { 
												
												if(isset($value)) { 
													$instant_payout = $value;
												} else {
													$instant_payout = '';
												}
									?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>">
													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.lbl_payment_instant_payout'); ?> </label>
													<div class="col-lg-9">
														<div class="checkbox checkbox-switch">
															<label>
																<input type="checkbox" <?php if($instant_payout=='On'){ echo 'checked="checked"'; }   ?> name="pay_mode" id="pay_mode" data-on-color="success" data-off-color="danger" data-on-text="<?php echo lang('language_lang.On');?>" data-off-text="<?php echo lang('language_lang.Off');?>" class="switchery">
															</label>
														</div>
														<?php echo $validation->getError($key, '<label class="validation-error-label">', '</label>'); ?>
													</div>
												</div>
									<?php 	
											}



											else {

												
												// $keyvalue = $myencrypt->encode($value);
												$keyvalue = $value;



												/*if($pay_id=='2')
												{	
													if($forms['pay_mode']=='coin')
													{
														if($key=='merchant_id' || $key=='ipn_secret' || $key=='number_of_confirmation' || $key=='private_key' || $key=='public_key')
														{													

															$cls="style=display:block";
														}
														else
														{
															$cls='style=display:none';
														}
														
														
													}
													else if($forms['pay_mode']=='block')
													{
														if($key=='merchant_id' || $key=='btc_address' || $key=='ipn_secret' || $key=='private_key' || $key=='public_key')
															$cls="style=display:none";
														else
															$cls='style=display:block';
														
													}
													else if($forms['pay_mode']=='address')
													{
														if($key=='number_of_confirmation')
														{
															$cls="style=display:block";
														}
														else
														{
															$cls="style=display:none";
														}
													 	
													}
													
												}
												else
												{
													/*if($payout=='block')
													$cls="style='display:block'";
												else
													$cls="style='display:none'";*/
												/*	$cls="";
												}*/

												if($forms['payment_id']< 6)
												{
													if($forms['pay_mode']=='block')
													{
														if($key=='private_key' || $key=='public_key' || $key=='api_key' || $key=='number_of_confirmation' || $key=='btc_address')
															$cls="style='display:block'";
													}
													else
													{
														if($key=='private_key' || $key=='public_key' || $key=='number_of_confirmation' || $key=='btc_address')
															$cls="style='display:block'";
														else
															$cls="style='display:none'";
													}
												}
												else
												{
													$cls='';	
												}

									?>
												<div class="form-group <?php if($validation->getError($key)) echo "has-error";?>" id="<?php echo $key;?>" <?php echo $cls;?> onchange="change_mode(this.value);" >

													<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.'.$key); ?> <span class="text-danger">*</span></label>
													<div class="col-lg-9">
														<div class="input-group1">
															<input type="text"  name="<?php echo $key; ?>" class="form-control" placeholder="<?php echo lang('language_lang.'.$key); ?>" value="<?php if(!empty($value)) { echo $keyvalue; } else { }; ?>">
														</div>
														<?php echo $validation->getError($key, '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
													</div>
												</div>
									<?php
											}		
										}
									?>

									<div class="text-right col-lg-12">
										<button type="submit" class="btn btn-primary"><?php echo lang('language_lang.button_update');  ?> <i class="icon-arrow-right14 position-right"></i></button>
									</div>

									
								</form>


							
								<h6 style="color:red;text-decoration:blink;font-size:16px;font-weight:bold;"> Important Notes:</h6>
								 <p style="font-size:14px;font-weight:bold;color:blue"><i class="fa fa-check-circle "></i> IF Manual Mode selected - User Payment to provide address information on above "Address" Field. 
								 And Request Their payment proof to admin backend. once admin confirm payment will reflect on user assets balance.</p>

								 <p style="font-size:14px;font-weight:bold;color:blue"><i class="fa fa-check-circle "></i> IF Auto Approval Mode selected - Every users should be create unique "Address" Generated from given payment api details . Every Deposit amount automated verification via backend update the asset balance wallet.</p>
							</div>
							

							
							
						</div>
					</div>
				</div>
				<!-- /horizotal form -->

			</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">
		jQuery.noConflict();
		(function( $ ) {
		$(function() {

			$(document).ready(function() {

				$.jGrowl.defaults.closer = false;

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

			    $('.paymentsetting').formValidation({
			    	framework: 'bootstrap',
		    		excluded: [':disabled'],
			        // icon: {
			        //     valid: 'glyphicon glyphicon-ok',
			        //     invalid: 'glyphicon glyphicon-remove',
			        //     validating: 'glyphicon glyphicon-refresh'
			        // },
			        fields: {
				        <?php
							foreach ($forms as $key => $value) {
								if($key!='payment_name' && $key!='logo' && $key!='status' && $key!='instant_payout' && $key!='payment_id') {
									$valid_key = 'valid_'.$key;
									$required_key = 'required_'.$key;
						?>
			            <?php echo $key;?>: {
			                message: '<?php echo lang('language_lang.'.$valid_key);?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo lang('language_lang.'.$required_key);?>'
			                    }
			                    <?php if($key=='email') { ?>
			                    ,emailAddress: {
                        			message: '<?php echo lang('language_lang.'.$valid_key);?>'
                    			}
                    			<?php }?>
			                }
			            },
				        <?php 
				    			}
				    		}
				    	?>
			    	}
			    })

			});

			$(".file-input-extensions1").fileinput({
				uploadUrl: "http://localhost/file-upload-single/1", // server upload action
			    uploadAsync: false,
			    minFileCount: 1,
			    maxFileCount: 1,
			    overwriteInitial: true,
			    showUpload: false,
			    <?php if(isset($payment_logo)) { ?>
			    	initialPreview: ["<?php echo base_url('content/payment/'.$payment_logo);?>"],
			    	initialPreviewAsData: true, // identify if you are sending preview data only and not the raw markup
			    	initialPreviewFileType: 'image', // image is the default and can be overridden in config below
			    <?php } ?>
			    allowedFileExtensions: ["jpg", "gif", "png", "jpeg"],
			    uploadExtraData: {
			        img_key: "1000"
			    }
			});
		    
		 	$('#icon-bck').on('click',function() {
				window.history.back();
			});
			
		    $(".switchery").bootstrapSwitch();
		   

		});
		})(jQuery);
	
		function change_mode1(str)
		{
			if(str=='block')
			{
				document.getElementById('api_key').style.display='block';
			}
			else
			{
				document.getElementById('api_key').style.display='none';
			}
			



		}

	</script>



</body>
</html>
