<?php

require_once 'private/LMS_Engine.php';
$engine = new LMS_Engine();
$msg = "";
if (isset($_POST) && isset($_POST['update_profile'])) {
    if ($engine->is_librarian($_POST['cr_user_name'], $_POST['cr_user_pass'])) {
        if (strlen($_POST['nw_full_name']) > 3 && strlen($_POST['nw_user_name']) > 3 && strlen($_POST['nw_user_pass']) > 3) {
            if (!$engine->is_librarian($_POST['nw_user_name'], $_POST['nw_user_pass'])) {
                $con = $engine->add_new_librarian($_POST['nw_full_name'], $_POST['nw_user_name'], $_POST['nw_user_pass']);
                if ($con) {
                    $user_id = $engine->get_user_id_by($_POST['cr_user_name'], $_POST['cr_user_pass']);
                    $engine->remove_user_by($user_id);
                    $engine->add_new_librarian($_POST['nw_full_name'], $_POST['nw_user_name'], $_POST['nw_user_name']);
                    $msg = "Your profile is successfully updated!";
                } else {
                    $msg = "The system cannot update your profile! please notify to the Admin";
                }
            } else {
                $msg = "Your new user name and password are not valid. please use another one";
            }
        } else {
            $msg = "Your new user name and password character length is so short. please use 4 characters and more";
        }
    } else {
        $msg = "Your current user name and password are not valid";
    }
}
?>
<div class="container" id="main">
    <div  class="row" id="contact">
<?php

require_once 'private/LMS_Engine.php';
$engine = new LMS_Engine();
if (isset($_POST)) {
    if (isset($_POST['Add_New_Teacher'])) {
        if (strlen($_POST['Full_Name']) > 2 && strlen($_POST['User_Name']) > 2 && strlen($_POST['User_Pass']) > 2) {
            $engine->add_new_teacher($_POST['Full_Name'], $_POST['User_Name'], $_POST['User_Pass'], $_POST['Department']);
        } else {
        }
    } elseif (isset($_POST['Remove_Teacher']) and $_POST['Remove_Teacher'] == "Remove") {
        $engine->remove_user_by($_POST['User_ID']);
    }
}
if (isset($_GET['page_num'])) {
    $page_num = $_GET['page_num'];
} else {
    $page_num = 0;
}
?>
?>
<div class="container" id="main"><br>
    <h3><strong>Registered School Teachers</strong> </h3><hr>
    <div  class="row" id="contact">
        <div class="col-md-3 col-lg-8"  >
            <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
            <div class="table table-responsive ">
                <table class="table table-bordered ">
                    <thead>
                    <tr style="background: #ececec">
                        <th>Full Name</th>