<?php

$user_object = new Hmgtuser();
$role = 'patient';
$id = 0;
$patient_type = 'outpatient';
$obj_bloodbank = new Hmgtbloodbank();
$active_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'outpatientlist';
?>
<script type="text/javascript">
$(document).ready(function() {
	$('#out_patient_form').validationEngine();
	jQuery('#outpatient_list').DataTable({
		"order": [[ 1, "asc" ]],
		"aoColumns":[
	                  {"bSortable": false},
	                  {"bSortable": true},
	                  {"bSortable": true},
	                  {"bSortable": true},
	                  {"bVisible": true},
	                  {"bVisible": true},
	                  {"bSortable": false}
	               ]

		});
	$('#birth_date').datepicker({
		  changeMonth: true,
	        changeYear: true,
	        yearRange:'-65:+0',	
	        onChangeMonthYear: function(year, month, inst) {
	            $(this).val(month + "/" + year);
<?php

$role = 'nurse';
$user_object = new Hmgtuser();
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'nurselist';
?>
<!-- POP up code -->
<div class="popup-bg" style="min-height:1631px !important">
    <div class="overlay-content">
    <div class="modal-content">
    <div class="category_list">
     </div>
     
    </div>
    </div> 
    
</div>
<!-- End POP-UP Code -->

<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
?>
</h3>
	</div>
	<?php 
if (isset($_POST['save_nurse'])) {
                            <br>
                            <button type="button" class="btn btn-success" id="newpatient">New Patient</button>
                            <br>
                            <label class="control-label" id="PhoneNumberLabel" for="inputPatient">Patient Phone
                                Number:</label>

                            <div class="controls">
                                <input type="text" class="form-control pull-left" name="patientNumber"
                                       id="patientNumber" tyle="margin: 0 auto;" data-provide="typeahead" data-items="4"
                                       data-source="[&quot;Value 1&quot;,&quot;Value 2&quot;,&quot;Value 3&quot;]">
                            </div>
                            <label class="control-label" for="inputPatient">Doctor:</label>

                            <div class="controls">
                                <?php 
$obj_users = new Hmgtuser();
$doctors = $obj_users->get_user_by_type('doctor');
hmgt_render_doctors_options($doctors, 'doctor', $selected);
?>
                            </div>
                            <label class="control-label" id="datepickerfromlabel" for="inputPatient" style="display:none;">
                                From:</label>
                            <input type="text" id="datepickerfrom" style="display:none;" class="form-control" value="2016-01-13 12:00:00">
                            <label class="control-label" id="datepickertolabel" for="inputPatient" style="display:none;">
                                To:</label>
                            <input type="text" id="datepickerto" style="display:none;" class="form-control" value="2016-01-13 12:00:00">
                           <label class="control-label" for="inputPatient">Session Type:</label>
                            <div class="controls">
                                <?php 
$obj_sessions = new Hmgt_session();
$sessions = $obj_sessions->get_all_session();
function hmgt_add_category()
{
    global $wpdb;
    $model = $_REQUEST['model'];
    $array_var = array();
    $data['category_name'] = $_REQUEST['medicine_cat_name'];
    if ($model == 'medicine') {
        $obj_medicine = new Hmgtmedicine();
        $obj_medicine->hmgt_add_medicinecategory($data);
        $id = $wpdb->insert_id;
    }
    if ($model == 'department') {
        $user_object = new Hmgtuser();
        $user_object->add_staff_department($data);
        $id = $wpdb->insert_id;
    }
    if ($model == 'bedtype') {
        $bed_type = new Hmgtbedmanage();
        $bed_type->hmgt_add_bedtype($data);
        $id = $wpdb->insert_id;
    }
    if ($model == 'specialization') {
        $user_object = new Hmgtuser();
        $user_object->add_doctor_specilize($data);
        $id = $wpdb->insert_id;
    }
    if ($model == 'operation') {
        $operation_type = new Hmgt_operation();
        $operation_type->hmgt_add_operationtype($data);
        $id = $wpdb->insert_id;
    }
    if ($model == 'report_type') {
        $report_type = new Hmgt_dignosis();
        $report_type->hmgt_add_report_type($data);
        $id = $wpdb->insert_id;
    }
    $row1 = '<tr id="cat-' . $id . '"><td>' . $_REQUEST['medicine_cat_name'] . '</td><td><a class="btn-delete-cat badge badge-delete" href="#" id=' . $id . '>X</a></td></tr>';
    $option = "<option value='{$id}'>" . $_REQUEST['medicine_cat_name'] . "</option>";
    $array_var[] = $row1;
    $array_var[] = $option;
    echo json_encode($array_var);
    die;
}
<?php

$role = 'doctor';
$user_object = new Hmgtuser();
?>
	<?php 
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'doctorlist';
?>
<!-- POP up code -->
<div class="popup-bg">
    <div class="overlay-content">
    <div class="modal-content">
    <div class="category_list">
     </div>
     
    </div>
    </div> 
    
</div>
<!-- End POP-UP Code -->
	
	
	

<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
		</div>
	<?php 
}
if ($active_tab == 'adddoctor') {
    $edit = 0;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $edit = 1;
        $doctor_id = $_REQUEST['docotor_id'];
        $user_info = get_userdata($doctor_id);
    }
    ?>

	     <div class="panel-body">
      <?php 
    //This is Dashboard at admin side
    $user_object = new Hmgtuser();
    $doctor_id = 0;
    if (isset($_REQUEST['docotor_id'])) {
        $doctor_id = $_REQUEST['docotor_id'];
    }
    $role = 'doctor';
    ?>
	<script type="text/javascript">
$(document).ready(function() {
	$('#doctor_form').validationEngine();
	$('#birth_date').datepicker({
		  changeMonth: true,
	        changeYear: true,
	        yearRange:'-65:+0',
	        onChangeMonthYear: function(year, month, inst) {
	            $(this).val(month + "/" + year);
<?php

$role = 'laboratorist';
$user_object = new Hmgtuser();
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'laboratoristlist';
?>


<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
?>
</h3>
	</div>
	<?php 
if (isset($_POST['save_laboratorist'])) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $result = $user_object->hmgt_add_user($_POST);
        if ($result) {
            wp_redirect(admin_url() . 'admin.php?page=hmgt_laboratorist&tab=laboratoristlist&message=2');
        }
    } else {
        if (!email_exists($_POST['email']) && !username_exists($_POST['username'])) {
            $result = $user_object->hmgt_add_user($_POST);
            if ($result) {
                wp_redirect(admin_url() . 'admin.php?page=hmgt_laboratorist&tab=laboratoristlist&message=1');
            }
<?php

$role = 'accountant';
$user_object = new Hmgtuser();
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'accountantlist';
?>


<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
?>
</h3>
	</div>
	<?php 
if (isset($_POST['save_accountant'])) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $result = $user_object->hmgt_add_user($_POST);
        if ($result) {
            wp_redirect(admin_url() . 'admin.php?page=hmgt_accountant&tab=accountantlist&message=2');
        }
    } else {
        if (!email_exists($_POST['email']) && !username_exists($_POST['username'])) {
            $result = $user_object->hmgt_add_user($_POST);
            if ($result) {
                wp_redirect(admin_url() . 'admin.php?page=hmgt_accountant&tab=accountantlist&message=1');
            }
<?php

$role = 'pharmacist';
$user_object = new Hmgtuser();
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'pharmacistlist';
?>


<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
?>
</h3>
	</div>
	<?php 
if (isset($_POST['save_pharmacist'])) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $result = $user_object->hmgt_add_user($_POST);
        if ($result) {
            wp_redirect(admin_url() . 'admin.php?page=hmgt_pharmacist&tab=pharmacistlist&message=2');
        }
    } else {
        if (!email_exists($_POST['email']) && !username_exists($_POST['username'])) {
            $result = $user_object->hmgt_add_user($_POST);
            if ($result) {
                wp_redirect(admin_url() . 'admin.php?page=hmgt_pharmacist&tab=pharmacistlist&message=1');
            }
<?php

//$school_obj = new School_Management ( get_current_user_id () );
$user_object = new Hmgtuser();
$user = wp_get_current_user();
$user_data = get_userdata($user->ID);
require_once ABSPATH . 'wp-includes/class-phpass.php';
$wp_hasher = new PasswordHash(8, true);
if (isset($_POST['save_change'])) {
    $referrer = $_SERVER['HTTP_REFERER'];
    $success = 0;
    if ($wp_hasher->CheckPassword($_REQUEST['current_pass'], $user_data->user_pass)) {
        if (isset($_REQUEST['new_pass']) == $_REQUEST['conform_pass']) {
            wp_set_password($_REQUEST['new_pass'], $user->ID);
            $success = 1;
        } else {
            wp_redirect($referrer . '&sucess=2');
        }
    } else {
        wp_redirect($referrer . '&sucess=3');
    }
    if ($success == 1) {
        wp_cache_delete($user->ID, 'users');
        wp_cache_delete($user_data->user_login, 'userlogins');
        wp_logout();
        if (wp_signon(array('user_login' => $user_data->user_login, 'user_password' => $_REQUEST['new_pass']), false)) {
            $referrer = $_SERVER['HTTP_REFERER'];
            wp_redirect($referrer . '&sucess=1');
        }
        ob_start();
    } else {
<?php

$role = 'receptionist';
$user_object = new Hmgtuser();
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'receptionistlist';
?>
<!-- POP up code -->
<div class="popup-bg" style="min-height:1631px !important">
    <div class="overlay-content">
    <div class="modal-content">
    <div class="category_list">
     </div>
     
    </div>
    </div> 
    
</div>
<!-- End POP-UP Code -->

<div class="page-inner" style="min-height:1631px !important">
<div class="page-title">
		<h3><img src="<?php 
echo get_option('hmgt_hospital_logo');
?>
" class="img-circle head_logo" width="40" height="40" /><?php 
echo get_option('hmgt_hospital_name');
?>
</h3>
	</div>
	<?php 
if (isset($_POST['save_receptionist'])) {