HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/selfanalyse/wp-content/plugins/psychometrics/psy_counselor_profile.php
<?php
$pid = get_query_var('pid');
if (isset($pid)) {
    $pageurl = $pid;
} else {
    $pageurl = "";
}
// echo $pageurl ;

// ini_set('display_errors',1);
// ini_set('display_startup_errors',1);
// error_reporting(E_ALL);

$Url = explode('/', $_SERVER["REQUEST_URI"]);

$permalink = $Url[2];
$page = $Url[1];

$completeLink = $page . '/' . $permalink;

//looged in used id
global $current_user;
global $wpdb;
$user_id = $current_user->ID;

global $wpdb;
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
$PSY_TEST_GEN_TEST_TAKEN = $wpdb->prefix . PSY_TEST_GEN_TEST_TAKEN;


//get counselor details
$getCounselors = $wpdb->get_row("SELECT c.counselor_id, c.counselor_name, c.counselor_title, c.url_slug, c.full_image, c.short_desc, c.full_desc from $PSY_COUNSELORS as c where c.status='1' and c.url_slug='$permalink'");

$counselor_id = $getCounselors->counselor_id;

//check if test taken
$checktest = $wpdb->get_var("SELECT count(test_taken_id) FROM $PSY_TEST_GEN_TEST_TAKEN where status='Y' and user_id='$user_id'");

//include file for calendar
include '/var/www/selfanalyse/wp-content/plugins/psychometrics/api/psy_calendar_format.php';

?>
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script>
<style>
    .calendar {
        width: 52% !important;
    }

    .loading_image {
        display: block;
        position: fixed;
        z-index: 1000;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        background: rgba(255, 255, 255, .8) url('/wp-content/plugins/psychometrics/images/loading_image.gif') 50% 50% no-repeat;
    }
</style>

<!-- PROFILE SECTION  -->

<section class="counselor-header-profile-section">
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-sm-6 col-xs-12">
                <img src="/counselor/profile-image/<?php echo $getCounselors->full_image ?>" alt="<?php echo $getCounselors->counselor_name ?>">
            </div>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <h6><?php echo $getCounselors->counselor_title ?></h6>
                <h1><?php echo $getCounselors->counselor_name ?></h1>
                <?php echo $getCounselors->short_desc ?>
            </div>
        </div>
    </div>
</section>

<!-- END PROFILE SECTION  -->

<!-- BIOGRAPHY SECTION  -->

<section class="counselor-about-page-section">
    <div class="container">
        <div class="row">
            <div class="col-md-9 col-sm-9 col-xs-12">
                <h4>About <?php echo $getCounselors->counselor_name ?></h4>
                <p><?php echo $getCounselors->full_desc ?></p>

                <?php if (is_user_logged_in()) { ?>
                    <?php if ($checktest > 0) { ?>
                        <button><a data-toggle="modal" data-target="#login-modal">Book Appointment</a></button>
                    <?php } else { ?>
                        <button><a id="takeTest">Book Appointment</a></button>
                    <?php } ?>
                <?php } else { ?>
                    <button><a id="beforLogin">Book Appointment</a></button>
                <?php } ?>
            </div>

            <div class="col-md-3 col-sm-3 col-xs-12">
                <img src="/wp-content/themes/psychometrics/images/book-appoinment.webp" alt="">
            </div>
        </div>
    </div>
</section>

<!-- END BIOGRAPHY SECTION  -->


<!-- Book and appointment MODAL  -->

<div class="modal fade counselor-profile-modal" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
    <div class="modal-dialog loginmodal-dialog">
        <div id="book-loading"></div>
        <div class="row counselor-profile-modal-box m-0">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <h4>Book Appoinment <i class="fas fa-times" data-dismiss="modal" aria-label="Close"></i></h4>
            </div>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="month-box">
                    <?php echo get_calender_full($year = date('Y'), $month = date('m'), $counselor_id); ?>
                </div>
            </div>
            <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="month-box">
                    <?php echo get_calender_full($year = date('Y'), $month = date('m', strtotime('first day of +1 month')), $counselor_id); ?>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12"></div>
            <div class="col-md-12 col-sm-12 col-xs-12" id="data-show"></div>
            <div id="user_slot"></div>
        </div>
    </div>
</div>
<!-- END Book and appointment MODAL  -->

<script type="text/javascript">
    jQuery(document).ready(function() {
        var msg_login = localStorage.getItem('msg_login')
        if (msg_login != null) {
            toastr.success(msg_login)
            localStorage.removeItem('msg_login')
        }
    })
    jQuery(document).on('click', '#beforLogin', function() {
        localStorage.setItem('link', '/<?php echo $completeLink ?>')
        window.location.href = '/login'
    });
    jQuery(document).on('click', '#takeTest', function() {
        var msg = "You haven't take any Psychometrics test, Please take one from Dashboard then try to book appointment"
        localStorage.setItem('test_msg', msg)
        toastr.info(msg)
        window.location.href = '/dashboard'
    });

    //book appointment
    function bookApp(bookDate, counselor) {
        jQuery("#book-loading").addClass("loading_image");
        var siteBaseUrl = "<?php echo get_site_url()  ?>/";
        var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_counselor_slots.php";
        jQuery.ajax(url, {
            type: 'POST',
            data: {
                book_date: bookDate,
                counselor: counselor,
                type: 'counselor'
            },
            success: function(data) {
                jQuery("#data-show").html(data);
                var container = jQuery('#login-modal'),
                    scrollTo = jQuery('#data-show');

                container.scrollTop(
                    scrollTo.offset().top - container.offset().top + container.scrollTop()
                );
                jQuery("#book-loading").removeClass("loading_image");
            },
            error: function(jqXhr, textStatus, errorMessage) {}
        });
    }
    /***validate user slot */
    jQuery(document).on('click', '#book_slot', function() {
        jQuery("#book-loading").addClass("loading_image");
        var c_id = jQuery("#c_id").val();
        var timeAllow = jQuery("#timeAllow").val();
        var time_slot_hr = jQuery("#time_slot_hr").val();
        var time_slot_min = jQuery("#time_slot_min").val();
        var end_time = jQuery("#end_slot_dur").val();
        var s_booked_on = jQuery("#s_booked_on").val();
        if (timeAllow < 10) {
            alert("Please select time duration between 10 to 30 min");
            jQuery("#timeAllow").focus();
            jQuery("#book-loading").removeClass("loading_image");
        } else if (timeAllow > 30) {
            alert("Please select time duration between 10 to 30 min");
            jQuery("#timeAllow").focus();
            jQuery("#book-loading").removeClass("loading_image");
        } else if (jQuery("#time_slot_hr").val() == '0') {
            alert("Please select hour");
            jQuery("#time_slot_hr").focus();
            jQuery("#book-loading").removeClass("loading_image");
        } else if (jQuery("#time_slot_min").val() == '0') {
            alert("Please select hour");
            jQuery("#time_slot_min").focus();
            jQuery("#book-loading").removeClass("loading_image");
        } else {
            var r = confirm("Are you sure to book this slot ?");
            if (r == true) {
                var siteBaseUrl = "<?php echo get_site_url()  ?>/";
                var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_counselor_slot_by_user.php";
                var arr = {
                    "type": 'user-slot-book',
                    "c_id": c_id,
                    "timeAllow": timeAllow,
                    "time_slot_hr": time_slot_hr,
                    "time_slot_min": time_slot_min,
                    "end_time": end_time,
                    "s_booked_on": s_booked_on
                };

                jQuery.ajax(url, {
                    type: 'POST',
                    data: JSON.stringify(arr),
                    contentType: 'application/json; charset=utf-8',
                    dataType: 'json',
                    success: function(data) {

                        if (data.status == 1) {
                            var ref_id = data.ref_id;
                            jQuery("#user_slot").html(
                                '<form id="checkoutSlot" method="post" action="' + siteBaseUrl + 'checkout"><input type="hidden" name="ref_id" value="' + ref_id + '"><input type="hidden" name="txn_type" value="C"></form>'
                            );
                            jQuery("#checkoutSlot").submit();
                        } else if (data.status == 0) {
                            toastr.error(data.message);
                            jQuery("#book-loading").removeClass("loading_image");
                        }


                    },
                    error: function(jqXhr, textStatus, errorMessage) {}
                });
            } else {
                jQuery("#book-loading").removeClass("loading_image");
                return false;
            }
        }
    });

    //appointment by user manually
    function bookAppUser(bookDate, counselor) {
        jQuery("#book-loading").addClass("loading_image");
        var siteBaseUrl = "<?php echo get_site_url()  ?>/";
        var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_counselor_slots.php";
        jQuery.ajax(url, {
            type: 'POST',
            data: {
                book_date: bookDate,
                counselor: counselor,
                type: 'user'
            },
            success: function(data) {
                jQuery("#data-show").html(data);
                var container = jQuery('#login-modal'),
                    scrollTo = jQuery('#data-show');

                container.scrollTop(
                    scrollTo.offset().top - container.offset().top + container.scrollTop()
                );
                jQuery("#book-loading").removeClass("loading_image");
            },
            error: function(jqXhr, textStatus, errorMessage) {}
        });
    }
    jQuery(document).on('change', '#time_slot_min', function() {
        var hour = jQuery('#time_slot_hr').val();
        var minutes = jQuery('#time_slot_min').val();
        var slot_time = jQuery('#timeAllow').val();

        if (slot_time == 0) {
            alert("Enter Time Slot First! ");
        } else if (hour == 0) {
            alert("Select Time Slot Hour to precise your booking ! ");
        } else if (minutes == '') {
            alert("Select Time Slot Minutes to precise your booking !");
        } else {

            var dt = new Date();
            var time = hour + ":" + minutes;
            var end_timeAllow = '<input type="text" name="end_slot_dur" id="end_slot_dur" class="form-control endTime" value="' + moment.utc(time, 'hh:mm').add(slot_time, 'minutes').format('hh:mm') + '" readonly />';

            if (this.value != "0") {
                jQuery('#ic').show();
                jQuery('#end_time').show();
                jQuery('#end_time').html(end_timeAllow);
            } else {
                jQuery('#ic').hide();
            }
        }
    });
</script>