File: /var/www/selfanalyse/wp-content/plugins/psychometrics/psy_profile_dashboard.php
<?php
if (is_user_logged_in()) {
?>
<!-- DASHBOARD SECTION -->
<section class="dashboard-section">
<div class="container">
<div class="row dashboard-page-section-box">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="dashboard-bg-img"></div>
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<?php include("psy_profile_sidebar.php"); ?>
</div>
<div class="col-md-9 col-sm-9 col-xs-12">
<!-----Include menus of profile header ----->
<?php include 'psy_profile_menus.php'; ?>
<?php
$checkPlan = $wpdb->get_var("SELECT count(subscription_id) FROM $PSY_SUBSCRIPTION where user_id='$user_id' and status='1'");
if ($checkPlan == 0) {
$getPlans = $wpdb->get_results("SELECT plan_id,plan_name,ref_url_slug,plan_price,plan_short_desc,plan_image FROM $PSY_PLANS where status='1' Order by display_order");
foreach ($getPlans as $p) {
?>
<div class="col-md-12 col-sm-12 col-xs-12 plan-dashboard">
<!-- <div class="col-md-1 col-sm-1 col-xs-12">
<img class="dashboard-detail-img" src="<?php echo ROOT_LINK . 'wp-content/themes/psychometrics/images/' . $p->plan_image; ?>" alt="">
</div> -->
<div class="col-md-9 col-sm-9 col-xs-12">
<div class="dashboard-detail-box">
<a href="/psychometric-test/#<?php echo $p->ref_url_slug; ?>">
<h4><?php echo $p->plan_name ?></h4>
<p><?php echo $p->plan_short_desc ?></p>
</a>
</div>
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<form action="<?php echo ROOT_LINK . 'checkout' ?>" method="post">
<input type="hidden" name="ref_id" value="<?php echo $p->plan_id; ?>">
<input type="hidden" name="txn_type" value="P">
<button type="submit" class="dashboard-detail-buynowbtn">Buy Now Rs.<?php echo $p->plan_price; ?></button>
</form>
</div>
</div>
<?php } ?>
<?php } else {
$curDate = date('Y-m-d H:i:s');
//get exams by user wise
$getPlaExams = $wpdb->get_results("SELECT ps.subscription_id,ps.test_type,ps.purchase_date,ps.plan_id,e.category_name,ps.active_date FROM $PSY_SUBSCRIPTION as ps LEFT JOIN $PSY_EXAMS as e on e.exam_category_id=ps.exam_id where ps.user_id='$user_id' and ps.status='1' and ps.active_status='1' order by ps.subscription_id desc limit 3");
//foreach for user exams
foreach ($getPlaExams as $e) {
//page url by test type
$test_type = $e->test_type;
if ($test_type == 'APT') {
$testLink = 'aptitude-test/';
$videoConfirm = "type='button' onclick='videoConfirm($e->subscription_id)' data-toggle='modal' data-target='#step1-confirm'";
} else if ($test_type == 'PER') {
$testLink = 'personality-test/';
$videoConfirm = "type='submit'";
} else if ($test_type == 'INT') {
$testLink = 'interest-test/';
$videoConfirm = "type='submit'";
} else {
$e_plan_id = $e->plan_id;
$getLink = $wpdb->get_row("SELECT test_url FROM $PSY_PLANS where plan_id='$e_plan_id'");
$testLink = $getLink->test_url . '/';
$videoConfirm = "type='submit'";
}
# plan expiry
$date1 = $e->active_date;
$date2 = date('Y-m-d H:i:s');;
$datetime1 = new DateTime($date1);
$datetime2 = new DateTime($date2);
$dteDiff = $datetime2->diff($datetime1);
$todayDate = date("Y-m-d");
$expireDays = $dteDiff->format('%a');
$activeOn = str_replace('-', '/', date('Y-m-d H:i:s', strtotime($date1)));
$expiredDate = date('d M,Y', strtotime($activeOn . '+15 days'));
//check if user already taken test
$checkTest = $wpdb->get_row("SELECT count(test_taken_id) as count_test,test_taken_id,start_date,status FROM $PSY_TEST_GEN_TEST_TAKEN where reference_id='$e->subscription_id' and user_id='$user_id'");
//check if test taken then show 24 hour message
$dateAttempt = date('d F, Y', strtotime($checkTest->start_date));
$testDate = date('Y-m-d H:i:s', strtotime($checkTest->start_date));
$date1 = str_replace('-', '/', $testDate);
$tomorrow = date('Y-m-d H:i:s', strtotime($date1 . '+1 days'));
$takenTest = $checkTest->status;
if ($takenTest == '') {
$view = 'new';
$testID = 0;
$btnName = 'Start Test';
} else if ($takenTest == 'N') {
$view = 'old';
$testID = $checkTest->test_taken_id;
$btnName = 'Resume Test';
} else {
$view = 'complete';
$btnName = '';
}
?>
<div class="start-test-box">
<div class="start-test-details-box">
<h4><?php echo $e->category_name ?></h4>
<h6><span> <?php echo date('d M, Y', strtotime($e->purchase_date)) ?> </span></h6>
</div>
<?php if ($view == 'new' || $view == 'old') { ?>
<div class="start-test-start-box">
<?php if ($testStatus == 1) {
if ($expireDays < 15 || $view == 'old') {
?>
<form id="testForm<?php echo $e->subscription_id ?>" action="<?php echo ROOT_LINK . $testLink ?>" method="POST">
<input type="hidden" name="sID" value="<?php echo $e->subscription_id ?>">
<input type="hidden" name="class_id" value="<?php echo $class_id ?>">
<input type="hidden" name="view" value="<?php echo $view ?>">
<input type="hidden" name="pending_test_id" value="<?php echo $testID ?>">
<input <?php echo $videoConfirm; ?> name="start_test" value="<?php echo $btnName; ?>" class="start-test-btn">
</form><?php } else { ?>
<input type="button" class="start-test-btn" value="Your plan was Expired on <?php echo $expiredDate; ?>" />
<?php }
} else { ?>
<button type="button" class="start-test-btn" id="testStatus">Start Test</button>
<?php } ?>
</div>
<?php } else {
if ($curDate >= $tomorrow) {
?>
<a href="<?php echo ROOT_LINK . $testLink . 'test-report?testId=' . $checkTest->test_taken_id ?>" class="start-test-btn">View Report</a>
<?php } //if test taken and time complete 24 hour
else { ?>
<div class="col-md-6">
<h6>Thank you for taking the test
Your reports will be ready within 24 hrs on your dashboard after our experts have created your profile. You will be intimated through email.</h6>
</div>
<?php } // else shoe msg of 24 hour
?>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
</section>
<!-- END DASHBOARD SECTION -->
<!----Start Test Video---------->
<div class="modal fade start-video-modal" id="step1-confirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog socialmodal-dialog">
<div class="loginmodal-container sociallink-box">
<div class="section-description-content">
<h2>Watch these videos before taking Aptitude test:</h2>
</div>
<input type="hidden" name="btn_id" id="catch_id">
<div class="row m-0">
<div class="col-md-6 col-sm-6 col-xs-12">
<iframe width="400" height="250" src="https://www.youtube.com/embed/eKOzP1AdAcE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<iframe width="400" height="250" src="https://www.youtube.com/embed/BFpfh_IXWy8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="row m-0">
<div class="col-md-6 col-sm-6 col-xs-12">
<iframe width="400" height="250" src="https://www.youtube.com/embed/HZiMf0iO23s" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<iframe width="400" height="250" src="https://www.youtube.com/embed/i9uBAmDyekU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="col-md-2 col-sm-2 col-xs-12">
</div>
</div>
<div class="row m-0">
<div class="col-md-12 col-sm-12 col-xs-12 text-center">
<p>
<a href="https://www.youtube.com/channel/UC_Y9Si7E4Xjt9hjYhGuo_gQ" target="_blank">
<i class="fa fa-arrow-right"></i> More videos on career development</a>
</p>
<p class="lead">
<input type="checkbox" name="watched" id="watched" value="Y"> I have watched all the videos. Proceed with test.
</p>
<p class="lead">
<button type="button" class="" id="startTestConfirm">Start Test</button>
or <a href="javascript:void(0);" data-dismiss="modal">
<< Back</a>
</p>
</div>
</div>
</div>
</div>
</div>
<!----Start Test Video ENd------>
<script type="text/javascript">
jQuery(document).ready(function() {
var msg = localStorage.getItem('test_msg')
if (msg != null) {
toastr.info(msg)
localStorage.removeItem('test_msg')
}
var msg_login = localStorage.getItem('msg_login')
if (msg_login != null) {
toastr.success(msg_login)
localStorage.removeItem('msg_login')
}
})
jQuery(document).on('click', '#testStatus', function() {
toastr.options = {
"closeButton": true,
"debug": false,
"positionClass": "toast-bottom-full-width",
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "10000",
"extendedTimeOut": "10000000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "slideDown",
"hideMethod": "hide"
};
toastr.error("To start test you have to fill your details, for example: Date of birth,State and Class <button type='button' class='btn btn-sm btn-info' id='toast'>Click Here</button>")
});
jQuery(document).on('click', '#toast', function() {
window.location.href = '/profile'
});
/**function for opening video modal */
function videoConfirm(id) {
jQuery("#catch_id").val(id);
}
/***start test on modal btn click */
jQuery(document).on('click', '#startTestConfirm', function() {
if (jQuery("input[name='watched']").is(':checked')) {
var from_id = jQuery("#catch_id").val();
jQuery("#testForm" + from_id).submit();
} else {
alert("It seems, that you haven't watched our videos");
}
});
</script>
<?php
} else {
?>
<script>
window.location.href = '/login'
</script>
<?php
}
?>