<?php
/**
 * Created by PhpStorm.
 * User: sunusi
 * Date: 2019-02-05
 * Time: 23:56
 */

if (isset($URL[1])) {
    if (!empty($URL[1])) {
        $userId = $URL[1];
        //detecting patient details
        $adminUser = $query->getOne("
          SELECT udut_users.*,
                 udut_users_roles.*,
                 udut_users_privileges.*
          FROM udut_users 
          JOIN udut_users_roles
          ON udut_users.userId = udut_users_roles.userId
          JOIN udut_users_privileges
          ON udut_users_roles.roleId = udut_users_privileges.roleId
          WHERE udut_users.userId = '${userId}'
        ");
    } else {
        require path() . "home";
    }
}


if (isset($_POST['s'])) {
    if (!empty($_POST['s'])) {
        $search = $_POST['s'];
        //detecting patient details
        $adminUser = $query->getOne("
          SELECT udut_users.*,
                 udut_users_roles.*,
                 udut_users_privileges.*
          FROM udut_users 
          JOIN udut_users_roles
          ON udut_users.userId = udut_users_roles.userId
          JOIN udut_users_privileges
          ON udut_users_roles.roleId = udut_users_privileges.roleId
          WHERE udut_users.userFullname like '%${search}%' OR udut_users.userEmail like '%${search}%'
        ");
    } else {
        require path() . "search-patient";
    }
}

