<?php

//////////////////////////////////////////////////////////////
//===========================================================
// edit_kyc_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function edit_kyc_theme(){

global $theme, $globals, $kernel, $users, $l, $error, $done, $SESS, $kyc_info, $country_list;

$edit_kyc_lang['passport'] = __('Passport');
$edit_kyc_lang['photo'] = __('Photo');
$edit_kyc_lang['voter_id'] = __('Voter ID');
$edit_kyc_lang['driving_lic'] = __('Driving License');
$edit_kyc_lang['aadhar'] = __('Aadhar');
$edit_kyc_lang['gas_bill'] = __('Gas Bill');
$edit_kyc_lang['electricity_bill'] = __('Electricity Bill');
$edit_kyc_lang['bank_passbook'] = __('Bank Passbook');
$edit_kyc_lang['telephone_bill'] = __('Telephone Bill');

softheader($l['<title>']);
					
echo page_header(__('Edit KYC'), 'fas fa-id-card', '', 0, 0, '');

$breadcrumbs = array('dashboard', 'list_kyc', 'edit_kyc');

echo get_breadcrumb($breadcrumbs);

error_handle($error);

if(!empty($done)){
	show_alert(__('KYC record was edited successfully'));
}

$uploaded = '<i class="fas fa-check-circle text-success"></i>';
$not_uploaded = '<i class="fas fa-times-circle text-danger"></i>';
$kyc_details = $kyc_info['kyc_details'];

echo '

<script>
function show_reason(el){

	$("#reject_div").hide();
	if($("#"+el).val() == "2"){
		$("#reject_div").show();
	}	

};
</script>
<div id="form-container" class="card p-2 mx-3">
	<form accept-charset="'.$globals['charset'].'" name="edit_kyc" id="edit_kyc" method="post" action="" class="form-horizontal">
		<div class="row mx-auto w-100">
			<div class="col-sm-12 mx-auto w-100 ">
				<h4>'.__('KYC Details').'</h4>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3">
			<div class="col-sm-9">
				<div class="row mx-auto w-100 my-3">
					<div class="col-sm-3"><label class="control-label">'.__('Name').'</label></div>
					<div class="col-sm-3"><input type="text" name="fname" id="kyc_fname" class="form-control" value="'.optREQ('fname', $kyc_details['fname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="mname" id="kyc_mname" class="form-control" value="'.optREQ('mname', $kyc_details['mname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="lname" id="kyc_lname" class="form-control" value="'.optREQ('lname', $kyc_details['lname']).'"/></div>
				</div>
				<div class="row mx-auto w-100 my-3">
					<div class="col-sm-3"><label class="control-label">'.__('Maiden Name').'</label></div>
					<div class="col-sm-3"><input type="text" name="mfname" id="kyc_mfname" class="form-control" value="'.optREQ('mfname', $kyc_details['mfname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="mmname" id="kyc_mmname" class="form-control" value="'.optREQ('mmname', $kyc_details['mmname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="mlname" id="kyc_mlname" class="form-control" value="'.optREQ('mlname', $kyc_details['mlname']).'"/></div>
				</div>
				<div class="row mx-auto w-100 my-3">
					<div class="col-sm-3"><label class="control-label">'.__('Father/Spouse Name').'</label></div>
					<div class="col-sm-3"><input type="text" name="ffname" id="kyc_ffname" class="form-control" value="'.optREQ('ffname', $kyc_details['ffname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="fmname" id="kyc_fmname" class="form-control" value="'.optREQ('fmname', $kyc_details['fmname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="flname" id="kyc_flname" class="form-control" value="'.optREQ('flname', $kyc_details['flname']).'"/></div>
				</div>
				<div class="row mx-auto w-100 my-3">
					<div class="col-sm-3"><label class="control-label">'.__('Mothers Name').'</label></div>
					<div class="col-sm-3"><input type="text" name="mofname" id="kyc_mofname" class="form-control" value="'.optREQ('mofname', $kyc_details['mofname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="momname" id="kyc_momname" class="form-control" value="'.optREQ('momname', $kyc_details['momname']).'"/></div>
					<div class="col-sm-3"><input type="text" name="molname" id="kyc_molname" class="form-control" value="'.optREQ('molname', $kyc_details['molname']).'"/></div>
				</div>
			</div>
			<div class="col-sm-3 border">
				<div class="h-100 align-items-center justify-content-center d-flex">
				'.(!empty($kyc_details['document_images']['photo']) ? '<img src="data:image/png;base64,'.$kyc_details['document_images']['photo'].'" width="150"/>' : '<i class="fas fa-camera fa-10x text-muted"></i>').'
				</div>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Date of Birth').'</label>
			</div>
			<div class="col-sm-3">
				<input type="text" name="dob" id="dob" class="form-control" placeholder="DD/MM/YYYY" value="'.$kyc_details['dob'].'"/>
			</div>
			<div class="col-sm-3">
				<label class="control-label">'.__('Gender').'</label>
			</div>
			<div class="col-sm-3 d-flex">
				<div class="px-2">
					<input type="radio" name="gender" id="male" value="male" '.($kyc_details['gender'] == 'male' || $_REQUEST['gender'] == 'male' ? 'checked="checked"' : '').'/>
					<label  for="male">'.__('Male').'</label>
				</div>
				<div class="px-2">
					<input type="radio" name="gender" id="female" value="female" '.($kyc_details['gender'] == 'female' || $_REQUEST['gender'] == 'female' ? 'checked="checked"' : '').'/>
					<label  for="female">'.__('Female').'</label>
				</div>
				<div class="px-2">
					<input type="radio" name="gender" id="transgender" value="transgender" '.($kyc_details['gender'] == 'transgender' || $_REQUEST['gender'] == 'transgender' ? 'checked="checked"' : '').'/>
					<label  for="transgender">'.__('Transgender').'</label>
				</div>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('PAN').'</label>
			</div>
			<div class="col-sm-3">
				<input type="text" name="pan" id="pan" class="form-control" value="'.$kyc_details['pan'].'"/>
			</div>
			<div class="col-sm-3">
				<label class="control-label">'.__('Marital Status').'</label>
			</div>
			<div class="col-sm-3 d-flex">
				<div class="px-2">
					<input type="radio" name="marital_status" id="married" value="married" '.($kyc_details['marital_status'] == 'married' || $_REQUEST['marital_status'] == 'married' ? 'checked="checked"' : '').'/>
					<label for="married">'.__('Married').'</label>
				</div>
				<div class="px-2">
					<input type="radio" name="marital_status" id="unmarried" value="unmarried" '.($kyc_details['marital_status'] == 'unmarried' || $_REQUEST['marital_status'] == 'unmarried' ? 'checked="checked"' : '').' />
					<label for="unmarried">'.__('Unmarried').'</label>
				</div>
				<div class="px-2 ">
					<input type="radio" name="marital_status" id="others" value="others" '.($kyc_details['marital_status'] == 'others' || $_REQUEST['marital_status'] == 'others' ? 'checked="checked"' : '').' />
					<label for="others">'.__('Others').'</label>
				</div>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Nationality').'</label>
			</div>
			<div class="col-sm-3">
				<select id="nationality" name="nationality" class="form-control virt-select">';
					foreach($country_list as $ck => $cv){
						echo '<option value="'.$cv.'" '.($kyc_details['nationality'] == $cv ? 'selected="selected"' : '').'>'.$cv.'</option>';
					}
			echo '
				</select>
			</div>
			<div class="col-sm-3"></div>
			<div class="col-sm-3"></div>
		</div>
		<div class="row mx-auto w-100">
			<div class="col-sm-12 mx-auto w-100 ">
				<h5>'.__('Proof of Identity and Address').'</h5>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Passport').'</label>
			</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['passport']) ? $uploaded : $not_uploaded).'
			</div>
			<div class="col-sm-3">'.__('Voter ID').'</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['voter_id']) ? $uploaded : $not_uploaded).'
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Driving License').'</label>
			</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['driving_lic']) ? $uploaded : $not_uploaded).'
			</div>
			<div class="col-sm-3">'.__('Aadhar').'</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['aadhar']) ? $uploaded : $not_uploaded).'
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Gas Bill').'</label>
			</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['gas_bill']) ? $uploaded : $not_uploaded).'
			</div>
			<div class="col-sm-3">'.__('Electricity Bill').'</div>
			<div class="col-sm-3">
				'.(!empty($kyc_info['document_images']['electricity_bill']) ? $uploaded : $not_uploaded).'
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Document files which are uploaded').'</label>
			</div>
			<div class="col-sm-9">
				<div class="container">
  					<div class="row">
						<div class="" data-toggle="modal" data-target="#modal">';
				$i = 0;
				foreach($kyc_info['document_images'] as $k => $v) {
					echo '<a href="#lightbox" data-slide-to="'.$i++.'"><img src="data:image/png;base64, '.$v.'" class="img-thumbnail my-3" width="150"></a>';
				}
				echo '
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Address').'</label>
			</div>
			<div class="col-sm-9">
				<textarea class="form-control" cols="10">'.$kyc_info['kyc_details']['address'].'</textarea>
			</div>
		</div>
		<div class="row mx-auto w-100">
			<div class="col-sm-12 mx-auto w-100 ">
				<h5>'.__('Contact Details').'</h5>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Mobile Number').'</label>
			</div>
			<div class="col-sm-3">
				<input type="text" name="mobile_num" id="mobile_num" class="form-control" value="'.optREQ('mobile_num', $kyc_details['mobile_num']).'"/>
			</div>
			<div class="col-sm-3">
				<label class="control-label">'.__('Landline Number').'</label>
			</div>
			<div class="col-sm-3">
				<input type="text" name="landline_num" id="landline_num" class="form-control" value="'.optREQ('landline_num', $kyc_details['landline_num']).'"/>
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Email Address').'</label>
			</div>
			<div class="col-sm-3">
				<input type="text" name="email_address" id="email_address" class="form-control" value="'.optREQ('email_address', $kyc_details['email_address']).'"/>
			</div>
			<div class="col-sm-3">
				
			</div>
			<div class="col-sm-3">
			</div>
		</div>
		<div class="row mx-auto w-100 my-3 px-3">
			<div class="col-sm-3">
				<label class="control-label">'.__('Action').'</label>
			</div>
			<div class="col-sm-3 d-flex">
				<div class="px-2">
					<label for="approve">'.__('Approve').'</label>
					<input type="radio" name="kyc_status" id="approve" value="1" onchange="show_reason(this.id);" '.($kyc_info['kyc_status'] == '1' || $_REQUEST['kyc_status'] == '1' ? 'checked="checked"' : '').'/>
				</div>
				<div class="px-2">
					<label for="reject">'.__('Reject').'</label>
					<input type="radio" name="kyc_status" id="reject" value="2" onchange="show_reason(this.id);" '.($kyc_info['kyc_status'] == '2' || $_REQUEST['kyc_status'] == '2' ? 'checked="checked"' : '').' />
				</div>
			</div>
			<div class="col-sm-6" id="reject_div" '.($kyc_info['kyc_status'] == '2' || $_REQUEST['kyc_status'] == '2' ? '' : 'style="display:none;"').'>
				<label for="approve">'.__('Reject Reason').'</label>
				<textarea class="form-control" cols="10" name="kyc_reject_reason">'.(!empty($kyc_details['kyc_reject_reason']) ? $kyc_details['kyc_reject_reason'] : '').'</textarea>
			</div>
		</div>
		<span class="help-block"></span>
		<center><input type="submit" name="edit_kyc" value="'.__('Update').'" class="go_btn"></center>
	</form>

	<!-- Modal for showing images of uploaded docs -->
	<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="documents" aria-hidden="true">
		<div class="modal-dialog modal-dialog-centered" role="document">
			<div class="modal-content">
				<div class="modal-body">
					<div id="lightbox" class="carousel slide" data-ride="carousel" data-interval="5000" data-keyboard="true">
						<ol class="carousel-indicators">
						';	
							$li = 0;
							foreach($kyc_info['document_images'] as $k => $v) {
								echo '<li data-target="#lightbox" data-slide-to="'.$li++.'"></li>';
							}
							echo '

							
						</ol>
						<div class="carousel-inner">
						';	
							$i = 0;
							foreach($kyc_info['document_images'] as $k => $v) {
								echo '<div class="carousel-item '.(empty($i) ? 'active' : '').'"><pre>'.$edit_kyc_lang[$k].'</pre><img src="data:image/png;base64, '.$v.'" class="img-thumbnail my-3" class="w-100" alt=""></div>';
								$i++;
							}
							echo '
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>';

softfooter();

}
