<?php 

function candidate_profile_cb() {
	$session = Session::getInstance();
	global $app;
    $user_meta = $app->user_meta;
	global $post_meta;
	$user = new user;
	if(isset($_GET['id'])) {
		$id = $_GET['id'];
		if($user_meta['role'] == 'student' && $user_meta['id'] == $id) {
			do_action('student_profile', ['id' => $id]);
			return;
		}
		if($user_meta['role'] == 'student' && $user_meta['id'] != $id) {
			return_method();
		}
		if($user_meta['role'] == 'teacher') {
			do_action('student_profile', ['id' => $id]);
			return;
		}
	} else {
		if($user_meta['role'] == 'student') {
			do_action('student_profile', ['id' => $session->id]);
			return;
		} else {
			return_method();
		}
	}
	$umeta = $user->get_user_meta($id);
	$classes = select_options_from_classes_of_admission();
	$token = new_token();
	?>
<div class="col-lg-12">
    <div class="card">
        <form method="post" id="form" enctype="multipart/form-data">
            <div class="card-header">
                <h4>Profile</h4>
                <button class="btn btn-primary pull-right" id="submit" style="top: 4px;position: absolute;right: 4px;">Update</button>
            </div>
            <div class="card-body">
                <div class="custom-tab">
                    <?php alert(); ?>
                    <nav>
                        <div class="nav nav-tabs" id="nav-tab" role="tablist">
                            <a class="nav-item nav-link" id="custom-nav-home-tab" data-toggle="tab" href="#basic-information" role="tab" aria-controls="custom-nav-home" aria-selected="true">Basic Information</a>
                            <a class="nav-item nav-link" id="custom-nav-profile-tab" data-toggle="tab" href="#parents-guardian" role="tab" aria-controls="custom-nav-profile" aria-selected="false">Parents/Guardian</a>
                            <a class="nav-item nav-link active show" id="custom-nav-contact-tab" data-toggle="tab" href="#other-information" role="tab" aria-controls="custom-nav-contact" aria-selected="false">Profile Information</a>
                            <?php do_action('_after_candidate_profile_more_info_link'); ?>
                        </div>
                    </nav>
                    <div class="tab-content pl-3 pt-2" id="nav-tabContent">
                        <div class="tab-pane fade" id="basic-information" role="tabpanel" aria-labelledby="custom-nav-home-tab">
                            <div class="offset-md-2 col-md-8">
                                <div class="card">
                                    <div class="card-body">
                            <?php
                            	input(['label' => '', 'id' => 'id', 'value' => $umeta['id'], 'type' => 'hidden']); 
                            	input(['label' => 'Surname', 'id' => 'surname', 'required' => 'required', 'value' => $umeta['surname']]);
			                	input(['label' => 'Other Names', 'id' => 'other_names', 'required' => 'required', 'value' => $umeta['other_names']]);
			                	input(['label' => 'Date of Birth', 'id' => 'dob', 'type' => 'date', 'value' => $umeta['dob']]);
			                	select(['label' => 'Gender', 'id' => 'gender'], ['Male' => 'Male', 'Female' => 'Female'], display_gender($umeta['gender']));
			                	select(['label' => 'Class', 'id' => 'class_of_admission', 'required' => 'required'], $classes, $umeta['class_of_admission']);
			                	textarea(['label' => 'Residential Address', 'id' => 'address', 'value' => $umeta['address']]);
			                	input(['label' => "Student's Phone Number", 'id' => 'phone', 'value' => $umeta['phone'], 'type' => 'phone']);
			                	input(['label' => 'State of Origin', 'id' => 'state', 'value' => $umeta['state']]);
		                		input(['label' => 'LGA', 'id' => 'lga', 'value' => $umeta['lga']]);
		                		input(['label' => 'Genotype', 'id' => 'genotype', 'value' => $umeta['genotype']]);
		                		input(['label' => 'Blood Group', 'id' => 'blood_group', 'value' => $umeta['blood_group']]);
		                		textarea(['label' => 'Physical Challenges', 'id' => 'physical_challenges', 'value' => $umeta['physical_challenges']]);
                             ?>
                         </div></div></div>
                        </div>
                        <div class="tab-pane fade" id="parents-guardian" role="tabpanel" aria-labelledby="custom-nav-profile-tab">
                            <div class="offset-md-2 col-md-8">
                                <div class="card">
                                    <div class="card-body">
                            <?php
		                		label('Nominee 1', 'h4');
		                		input(['label' => 'Fullname', 'id' => 'n1_fullname', 'value' => $umeta['n1_fullname']]);
		                		input(['label' => 'Relationship', 'id' => 'n1_relationship', 'value' => $umeta['n1_relationship']]);
		                		input(['label' => 'Phone', 'id' => 'n1_phone', 'value' => $umeta['n1_phone']]);
		                		input(['label' => 'Email', 'id' => 'n1_email', 'value' => $umeta['n1_email']]);
		                		echo '<hr>';
		                		label('Nominee 2', 'h4');
		                		input(['label' => 'Fullname', 'id' => 'n2_fullname', 'value' => $umeta['n2_fullname']]);
		                		input(['label' => 'Relationship', 'id' => 'n2_relationship', 'value' => $umeta['n2_relationship']]);
		                		input(['label' => 'Phone', 'id' => 'n2_phone', 'value' => $umeta['n2_phone']]);
		                		echo '<hr>';
		                		label('Nominee 3', 'h4');
		                		input(['label' => 'Fullname', 'id' => 'n3_fullname', 'value' => $umeta['n3_fullname']]);
		                		input(['label' => 'Relationship', 'id' => 'n3_relationship', 'value' => $umeta['n3_relationship']]);
		                		input(['label' => 'Phone', 'id' => 'n3_phone', 'value' => $umeta['n3_phone']]);
		                	?>
                        </div></div></div>
                        </div>
                        <div class="tab-pane fade active show" id="other-information" role="tabpanel" aria-labelledby="custom-nav-contact-tab">
                            <?php do_action('_before_student_profile_more_info', ['student_id' => $umeta['id']]); ?>

                            <div class="offset-md-2 col-md-8">
                                <div class="card">
                                    <div class="card-body">
                                        <div class="mx-auto d-block">
                                            <?php do_action('get_image_uploader', ['width' => 200, 'height' => 200, 'boundaryheight' => 210, 'boundarywidth' => 210, 'url' => get_user_image($umeta), 'image-name' => 'profile_picture']) ?>
                                        </div>
                                        <h5 class="text-sm-center mt-2 mb-1">
                                            <?php echo $umeta['surname'].' '.$umeta['other_names'] ?>
                                        </h5>
                                        <div class="location text-sm-center"><i class="fa fa-map-marker"></i>&nbsp;
                                            <?php echo $umeta['address'] ?>
                                        </div>
                                    </div>
                                    <?php do_action("profile_state", $umeta); ?>
                                    <hr>
                                    <div class="card-text text-sm-center">
                                        <a href="#"><i class="fa fa-facebook pr-1"></i></a>
                                        <a href="#"><i class="fa fa-twitter pr-1"></i></a>
                                        <a href="#"><i class="fa fa-linkedin pr-1"></i></a>
                                        <a href="#"><i class="fa fa-pinterest pr-1"></i></a>
                                    </div>
                                    <?php 
		                                if(current_user_can('switch_user_role') && $umeta['id'] != $session->id) {
						        			// select(['label' => 'Role', 'id' => 'role'], $system_roles, $user_meta['role']);
						        			?>
                                    <?php if ($umeta['status'] == 'active'): ?>
                                    <a href="our-students?action=<?php echo base64_encode('withdraw_student') ?>&id=<?php echo $umeta['id'] ?>&token=<?php echo $token; ?>" class="btn btn-outline-danger"><i class="fa fa-ban"></i>&nbsp;Withdraw Student</a>
                                    <?php else: ?>
                                    <a href="our-students?action=<?php echo base64_encode('recall_student') ?>&id=<?php echo $umeta['id'] ?>&token=<?php echo $token; ?>" class="btn btn-outline-success"><i class="fa fa-share-square-o"></i>&nbsp;Recall Student</a>
                                    <?php endif ?>

                                    <?php
						        		}
		                                 ?>
                                </div>
                            </div>
                        </div>

                        <?php do_action('_after_candidate_profile_more_info', ['student' => $umeta]); ?>
                    </div>
                    <input type="hidden" name="action" id="action" value="edit_student_profile">
                    
                </div>

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


        <div class="modal" id="cropImagePop" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">Edit Photo</h4>
                    </div>
                    <div class="modal-body">
                        <div id="upload-demo" class="center-block"></div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" id="cropImageBtn" class="btn btn-primary">Crop</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
	add_page_javascript('app/assets/js/page-scripts/submit-4.js');
	add_page_javascript('app/assets/js/page-scripts/koweb.js');
}

