<?php 

function xxprofile_cb() {
	global $post_meta;
	$session = Session::getInstance();
	$user = new user;
	if(isset($_GET['id'])) {
		// if(!verify_token($_GET['token'])) {
		//     token_error();
		//     return_method();
		//     return;
	 //    }
		$id = $_GET['id'];
	} else $id = $session->id;
	$user_meta = $user->get_user_meta($id);
	$system_roles = get_system_roles(['student', 'software_engineer', 'contingent', 'fresher', 'candidate']);
	$token = new_token();
	?>
	<form method="post" action="contents/plugins/eedu_portal/ajax.php" id="form">
	<div class="row">	
		<div class="col-md-7">
			<div class="card">
				<div class="card-header">
	                <strong class="card-title">Edit User Profile</strong>
	                <button class="btn btn-primary pull-right" id="submit" style="top: 4px;position: absolute;right: 4px;">Update Profile</button>
	            </div>
	            <div class="card-body">
	            	
	            	<?php alert(); ?>
					
						<input type="hidden" name="id" id="id" value="<?php echo $id; ?>">
						<input type="hidden" name="action" id="action" value="edit_user_profile">
						
					<?php 
						input(['label' => 'Surname', 'id' => 'surname', 'required' => 'required', 'value' => $user_meta['surname']]);
		            	input(['label' => 'Other Names', 'id' => 'other_names', 'required' => 'required', 'value' => $user_meta['other_names']]);
		            	input(['label' => 'Email', 'id' => 'email', 'type' => 'email', 'value' => $user_meta['email']]);
		            	input(['label' => 'Phone Number', 'id' => 'phone', 'value' => $user_meta['phone']]);
		            	select(['label' => 'Gender', 'id' => 'gender'], ['Male' => 'Male', 'Female' => 'Female'], display_gender($user_meta['gender']));
		            	textarea(['label' => 'Residential Address', 'id' => 'address', 'value' => $user_meta['address']]);
		            	input(['label' => 'State of Origin', 'id' => 'state', 'value' => $user_meta['state']]);
		        		input(['label' => 'LGA', 'id' => 'lga', 'value' => $user_meta['lga']]);
		        		if(current_user_can('switch_user_role') && $user_meta['id'] != $session->id) {
		        			select(['label' => 'Role', 'id' => 'role'], $system_roles, $user_meta['role']);
		        			?>
		        			<?php if ($user_meta['status'] == 'active'): ?>
		        				<a href="our-academic-staff?action=<?php echo base64_encode('withdraw_staff') ?>&id=<?php echo $user_meta['id'] ?>&token=<?php echo $token; ?>" class="btn btn-outline-danger"><i class="fas fa-ban"></i>&nbsp;Withdraw Staff</a>
		        			<?php else: ?>
		        				<a href="our-academic-staff?action=<?php echo base64_encode('recall_staff') ?>&id=<?php echo $user_meta['id'] ?>&token=<?php echo $token; ?>" class="btn btn-outline-success"><i class="fas fa-share-square-o"></i>&nbsp;Recall Staff</a>
		        			<?php endif ?>
		        			
		        			<?php
		        		}
		        		// alert(); submit_btn('edit_user_profile', 'Update');
					 ?>
					
				</div>
			</div>
		
		</div>
		<div class="col-md-5">
			<?php do_action('get_teacher_stats', ['teacher_id' => $user_meta['id'], 'token' => $token, 'container-class' => 'col-lg-6']); ?>
			<div class="row">
				<div class="col-md-12">
					<div class="card">
	                	<div class="card-body">
	                        <div class="mx-auto d-block">
								<?php do_action('get_image_uploader', ['width' => 200, 'height' => 200, 'boundaryheight' => 300, 'boundarywidth' => 300, 'url' => $user_meta['profile_picture'], 'image-name' => 'profile_picture']) ?>
				            </div>
	                        <h5 class="text-sm-center mt-2 mb-1"><?php echo $user_meta['surname'].' '.$user_meta['other_names'] ?></h5>
	                        <div class="location text-sm-center"><i class="fas fa-map-marker"></i>&nbsp;<?php echo $user_meta['address'] ?></div>
	                        <?php do_action("profile_state", $user_meta); ?>
	                    </div>
	                    <hr>
	                    <div class="card-text text-sm-center">
	                        <a href="#"><i class="fas fa-facebook pr-1"></i></a>
	                        <a href="#"><i class="fas fa-twitter pr-1"></i></a>
	                        <a href="#"><i class="fas fa-linkedin pr-1"></i></a>
	                        <a href="#"><i class="fas fa-pinterest pr-1"></i></a>
	                    </div>
	                </div>
				</div>
			</div>
		</div>	
	</div>
	</form>
	<?php
	add_page_javascript('app/assets/js/page-scripts/submit.js');
}