top.window.location = '../../index.php'";
exit;
}
require_once __DIR__ . "/" . "../../includes/include_basics_only.php";
require_once __DIR__ . "/" . "../../includes/classes/ConnectPDO.php";
use includes\classes\ConnectPDO;
$conn = ConnectPDO::getInstance();
$post = $_POST;
if (!isset($post['user']) || $post['user'] == '') {
$data['']['error'] = TRANS('MSG_SOMETHING_GOT_WRONG');
echo json_encode($data);
return false;
}
/* Se for somente abertura, somente recebe as informações do próprio usuário */
if ($_SESSION['s_nivel'] == 3 && $post['user'] != $_SESSION['s_uid']) {
$author_department = getUserDepartment($conn, $_SESSION['s_uid']);
$requester_department = getUserDepartment($conn, $post['user']);
if (empty($author_department) || $author_department != $requester_department) {
$post['user'] = $_SESSION['s_uid'];
}
// $post['user'] = $_SESSION['s_uid'];
}
$userInfo = [];
$userInfo = getUserInfo($conn, (int)$post['user']);
unset($userInfo['password']);
unset($userInfo['hash']);
$userClient = (!empty($userInfo) && !empty($userInfo['user_client']) ? $userInfo['user_client'] : "");
$userDepartment = (!empty($userInfo) && !empty($userInfo['user_department']) ? $userInfo['user_department'] : "");
$unitInfo = [];
$units = [];
if (!empty($userDepartment)) {
/* Buscando a unidade com base no departamento do usuário */
$departmentInfo = getDepartments($conn, null, $userDepartment);
if (!empty($departmentInfo) && !empty($departmentInfo['loc_unit'])) {
$unitInfo = getUnits($conn, null , $departmentInfo['loc_unit']);
}
}
$unit = (!empty($unitInfo) && !empty($unitInfo['inst_cod']) ? $unitInfo : []);
$unitByDepartment = (!empty($unit) ? " (" . $unitInfo['inst_nome'] . ")" : "");
if (empty($unit)) {
/* Buscar pelo cliente do usuário então */
if (!empty($userClient)) {
$units = getUnits($conn, null , null, $userClient);
}
if (count($units) == 1) {
$unit = $units[0];
}
}
$info['unit'] = $unit;
$info['user'] = $userInfo;
$html = "";
$html .= TRANS('USER_INFO') . "