further switching to db exceptions instead of return false
This commit is contained in:
parent
5794c4cab8
commit
a0af8d4624
|
@ -350,9 +350,6 @@ function shifts_json_export_all_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts_source = Shifts();
|
$shifts_source = Shifts();
|
||||||
if ($shifts_source === false) {
|
|
||||||
engelsystem_error('Unable to load shifts.');
|
|
||||||
}
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
raw_output(json_encode($shifts_source));
|
raw_output(json_encode($shifts_source));
|
||||||
|
|
|
@ -143,9 +143,6 @@ function shifttype_controller()
|
||||||
function shifttypes_list_controller()
|
function shifttypes_list_controller()
|
||||||
{
|
{
|
||||||
$shifttypes = ShiftTypes();
|
$shifttypes = ShiftTypes();
|
||||||
if ($shifttypes === false) {
|
|
||||||
engelsystem_error('Unable to load shifttypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
shifttypes_title(),
|
shifttypes_title(),
|
||||||
|
|
|
@ -259,10 +259,6 @@ function users_list_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = Users($order_by);
|
$users = Users($order_by);
|
||||||
if ($users === false) {
|
|
||||||
engelsystem_error('Unable to load users.');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
$user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ function AngelType_validate_name($name, $angeltype)
|
||||||
*/
|
*/
|
||||||
function AngelTypes_with_user($user)
|
function AngelTypes_with_user($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*,
|
SELECT `AngelTypes`.*,
|
||||||
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
`UserAngelTypes`.`confirm_user_id`,
|
`UserAngelTypes`.`confirm_user_id`,
|
||||||
|
@ -222,11 +222,6 @@ function AngelTypes_with_user($user)
|
||||||
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
|
||||||
AND `UserAngelTypes`.`user_id` = ?
|
AND `UserAngelTypes`.`user_id` = ?
|
||||||
ORDER BY `name`', [$user['UID']]);
|
ORDER BY `name`', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,15 +231,10 @@ function AngelTypes_with_user($user)
|
||||||
*/
|
*/
|
||||||
function AngelTypes()
|
function AngelTypes()
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `AngelTypes`
|
FROM `AngelTypes`
|
||||||
ORDER BY `name`');
|
ORDER BY `name`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,10 +245,6 @@ function AngelTypes()
|
||||||
function AngelType_ids()
|
function AngelType_ids()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
$result = DB::select('SELECT `id` FROM `AngelTypes`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltypes.');
|
|
||||||
}
|
|
||||||
return select_array($result, 'id', 'id');
|
return select_array($result, 'id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,10 +261,6 @@ function AngelType($angeltype_id)
|
||||||
[$angeltype_id]
|
[$angeltype_id]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angelType_source)) {
|
if (empty($angelType_source)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,6 @@ use Engelsystem\Database\DB;
|
||||||
function EventConfig()
|
function EventConfig()
|
||||||
{
|
{
|
||||||
$event_config = DB::select('SELECT * FROM `EventConfig` LIMIT 1');
|
$event_config = DB::select('SELECT * FROM `EventConfig` LIMIT 1');
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load event config.');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($event_config)) {
|
if (empty($event_config)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -71,9 +71,6 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
ORDER BY `room_id` DESC',
|
ORDER BY `room_id` DESC',
|
||||||
[$shiftId]
|
[$shiftId]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use settings from room
|
// Use settings from room
|
||||||
if (count($needed_angeltypes_source) == 0) {
|
if (count($needed_angeltypes_source) == 0) {
|
||||||
|
@ -86,9 +83,6 @@ function NeededAngelTypes_by_shift($shiftId)
|
||||||
AND `count` > 0
|
AND `count` > 0
|
||||||
ORDER BY `room_id` DESC
|
ORDER BY `room_id` DESC
|
||||||
', [$shiftId]);
|
', [$shiftId]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift_entries = ShiftEntries_by_shift($shiftId);
|
$shift_entries = ShiftEntries_by_shift($shiftId);
|
||||||
|
|
|
@ -66,10 +66,6 @@ function Room($room_id, $onlyVisible = true)
|
||||||
[$room_id]
|
[$room_id]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($room_source)) {
|
if (empty($room_source)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,17 +125,16 @@ function ShiftEntry_update($shift_entry)
|
||||||
* Get a shift entry.
|
* Get a shift entry.
|
||||||
*
|
*
|
||||||
* @param int $shift_entry_id
|
* @param int $shift_entry_id
|
||||||
* @return array|false|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
function ShiftEntry($shift_entry_id)
|
function ShiftEntry($shift_entry_id)
|
||||||
{
|
{
|
||||||
$shift_entry = DB::select('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
$shift_entry = DB::select('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (empty($shift_entry)) {
|
if (empty($shift_entry)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $shift_entry[0];
|
return $shift_entry[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +208,7 @@ function ShiftEntries_finished_by_user($user)
|
||||||
*/
|
*/
|
||||||
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `ShiftEntry`
|
FROM `ShiftEntry`
|
||||||
WHERE `SID` = ?
|
WHERE `SID` = ?
|
||||||
|
@ -220,10 +219,6 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
|
||||||
$angeltype_id,
|
$angeltype_id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift entries.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,27 +71,20 @@ function ShiftType_create($name, $angeltype_id, $description)
|
||||||
function ShiftType($shifttype_id)
|
function ShiftType($shifttype_id)
|
||||||
{
|
{
|
||||||
$shifttype = DB::select('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
$shifttype = DB::select('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift type.');
|
|
||||||
}
|
|
||||||
if (empty($shifttype)) {
|
if (empty($shifttype)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_shift($shifttype);
|
return array_shift($shifttype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all shift types.
|
* Get all shift types.
|
||||||
*
|
*
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function ShiftTypes()
|
function ShiftTypes()
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
return DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,7 @@ use Engelsystem\ShiftSignupState;
|
||||||
*/
|
*/
|
||||||
function Shifts_by_room($room)
|
function Shifts_by_room($room)
|
||||||
{
|
{
|
||||||
$result = DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
|
return DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shifts.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +45,8 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
|
||||||
|
|
||||||
ORDER BY `start`';
|
ORDER BY `start`';
|
||||||
$result = DB::select(
|
|
||||||
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -58,10 +55,6 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shifts by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +93,8 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||||
AND `start` BETWEEN ? AND ?
|
AND `start` BETWEEN ? AND ?
|
||||||
AND NOT `Shifts`.`PSID` IS NULL';
|
AND NOT `Shifts`.`PSID` IS NULL';
|
||||||
$result = DB::select(
|
|
||||||
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
|
@ -109,10 +103,6 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,12 +150,11 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load needed angeltypes by filter.');
|
|
||||||
}
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,17 +182,13 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||||
AND `start` BETWEEN ? AND ?
|
AND `start` BETWEEN ? AND ?
|
||||||
ORDER BY `Shifts`.`start`';
|
ORDER BY `Shifts`.`start`';
|
||||||
$result = DB::select(
|
return DB::select(
|
||||||
$sql,
|
$sql,
|
||||||
[
|
[
|
||||||
$shiftsFilter->getStartTime(),
|
$shiftsFilter->getStartTime(),
|
||||||
$shiftsFilter->getEndTime(),
|
$shiftsFilter->getEndTime(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift entries by filter.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -469,12 +454,9 @@ function Shift_update($shift)
|
||||||
function Shift_update_by_psid($shift)
|
function Shift_update_by_psid($shift)
|
||||||
{
|
{
|
||||||
$shift_source = DB::select('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
|
$shift_source = DB::select('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($shift_source)) {
|
if (empty($shift_source)) {
|
||||||
return null;
|
throw new Exception('Shift not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift['SID'] = $shift_source[0]['SID'];
|
$shift['SID'] = $shift_source[0]['SID'];
|
||||||
|
@ -485,7 +467,7 @@ function Shift_update_by_psid($shift)
|
||||||
* Create a new shift.
|
* Create a new shift.
|
||||||
*
|
*
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
* @return int|false shift id or false
|
* @return int ID of the new created shift
|
||||||
*/
|
*/
|
||||||
function Shift_create($shift)
|
function Shift_create($shift)
|
||||||
{
|
{
|
||||||
|
@ -516,9 +498,7 @@ function Shift_create($shift)
|
||||||
time(),
|
time(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return DB::getPdo()->lastInsertId();
|
return DB::getPdo()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +511,7 @@ function Shift_create($shift)
|
||||||
*/
|
*/
|
||||||
function Shifts_by_user($user, $include_freeload_comments = false)
|
function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
|
SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
|
||||||
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
|
||||||
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
|
' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
|
||||||
|
@ -547,10 +527,6 @@ function Shifts_by_user($user, $include_freeload_comments = false)
|
||||||
$user['UID']
|
$user['UID']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load users shifts.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -567,10 +543,6 @@ function Shift($shift_id)
|
||||||
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
|
||||||
WHERE `SID`=?', [$shift_id]);
|
WHERE `SID`=?', [$shift_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load shift.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($shifts_source)) {
|
if (empty($shifts_source)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -601,7 +573,7 @@ function Shift($shift_id)
|
||||||
/**
|
/**
|
||||||
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
* Returns all shifts with needed angeltypes and count of subscribed jobs.
|
||||||
*
|
*
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Shifts()
|
function Shifts()
|
||||||
{
|
{
|
||||||
|
@ -612,10 +584,6 @@ function Shifts()
|
||||||
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
|
||||||
');
|
');
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($shifts_source as &$shift) {
|
foreach ($shifts_source as &$shift) {
|
||||||
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
|
||||||
$shift['angeltypes'] = $needed_angeltypes;
|
$shift['angeltypes'] = $needed_angeltypes;
|
||||||
|
|
|
@ -27,23 +27,16 @@ function UserAngelType_exists($user, $angeltype)
|
||||||
* List users angeltypes.
|
* List users angeltypes.
|
||||||
*
|
*
|
||||||
* @param array $user
|
* @param array $user
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function User_angeltypes($user)
|
function User_angeltypes($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
|
||||||
FROM `UserAngelTypes`
|
FROM `UserAngelTypes`
|
||||||
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
|
||||||
WHERE `UserAngelTypes`.`user_id`=?
|
WHERE `UserAngelTypes`.`user_id`=?
|
||||||
', [$user['UID']]);
|
', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltypes.');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +47,7 @@ function User_angeltypes($user)
|
||||||
*/
|
*/
|
||||||
function User_unconfirmed_AngelTypes($user)
|
function User_unconfirmed_AngelTypes($user)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
`UserAngelTypes`.*,
|
`UserAngelTypes`.*,
|
||||||
`AngelTypes`.`name`,
|
`AngelTypes`.`name`,
|
||||||
|
@ -69,12 +62,6 @@ function User_unconfirmed_AngelTypes($user)
|
||||||
GROUP BY `UserAngelTypes`.`angeltype_id`
|
GROUP BY `UserAngelTypes`.`angeltype_id`
|
||||||
ORDER BY `AngelTypes`.`name`
|
ORDER BY `AngelTypes`.`name`
|
||||||
', [$user['UID']]);
|
', [$user['UID']]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltypes.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,10 +203,6 @@ function UserAngelType($user_angeltype_id)
|
||||||
WHERE `id`=?
|
WHERE `id`=?
|
||||||
LIMIT 1', [$user_angeltype_id]);
|
LIMIT 1', [$user_angeltype_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angeltype)) {
|
if (empty($angeltype)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -249,10 +232,6 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user angeltype.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($angeltype)) {
|
if (empty($angeltype)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ function UserDriverLicense_valid($user_driver_license)
|
||||||
* Get a users driver license information
|
* Get a users driver license information
|
||||||
*
|
*
|
||||||
* @param int $user_id The users id
|
* @param int $user_id The users id
|
||||||
* @return array|false|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
function UserDriverLicense($user_id)
|
function UserDriverLicense($user_id)
|
||||||
{
|
{
|
||||||
|
@ -50,11 +50,6 @@ function UserDriverLicense($user_id)
|
||||||
FROM `UserDriverLicenses`
|
FROM `UserDriverLicenses`
|
||||||
WHERE `user_id`=?', [$user_id]);
|
WHERE `user_id`=?', [$user_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user driver license.');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_driver_license)) {
|
if (empty($user_driver_license)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,23 +184,17 @@ function User_sortable_columns()
|
||||||
* Get all users, ordered by Nick by default or by given param.
|
* Get all users, ordered by Nick by default or by given param.
|
||||||
*
|
*
|
||||||
* @param string $order_by
|
* @param string $order_by
|
||||||
* @return array|false
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Users($order_by = 'Nick')
|
function Users($order_by = 'Nick')
|
||||||
{
|
{
|
||||||
$result = DB::select(sprintf('
|
return DB::select(sprintf('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `User`
|
FROM `User`
|
||||||
ORDER BY `%s` ASC
|
ORDER BY `%s` ASC
|
||||||
',
|
',
|
||||||
trim(DB::getPdo()->quote($order_by), '\'')
|
trim(DB::getPdo()->quote($order_by), '\'')
|
||||||
));
|
));
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,7 +218,7 @@ function User_is_freeloader($user)
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype_inverted($angeltype)
|
function Users_by_angeltype_inverted($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT `User`.*
|
SELECT `User`.*
|
||||||
FROM `User`
|
FROM `User`
|
||||||
LEFT JOIN `UserAngelTypes`
|
LEFT JOIN `UserAngelTypes`
|
||||||
|
@ -236,10 +230,6 @@ function Users_by_angeltype_inverted($angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load users.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,7 +240,7 @@ function Users_by_angeltype_inverted($angeltype)
|
||||||
*/
|
*/
|
||||||
function Users_by_angeltype($angeltype)
|
function Users_by_angeltype($angeltype)
|
||||||
{
|
{
|
||||||
$result = DB::select('
|
return DB::select('
|
||||||
SELECT
|
SELECT
|
||||||
`User`.*,
|
`User`.*,
|
||||||
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
`UserAngelTypes`.`id` AS `user_angeltype_id`,
|
||||||
|
@ -267,10 +257,6 @@ function Users_by_angeltype($angeltype)
|
||||||
$angeltype['id']
|
$angeltype['id']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load members.');
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,10 +383,6 @@ function User($user_id)
|
||||||
{
|
{
|
||||||
$user_source = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
$user_source = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user_source)) {
|
if (empty($user_source)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -413,16 +395,12 @@ function User($user_id)
|
||||||
*
|
*
|
||||||
* @param string $api_key
|
* @param string $api_key
|
||||||
* User api key
|
* User api key
|
||||||
* @return array|null Matching user, null on error
|
* @return array|null Matching user, null if not found
|
||||||
*/
|
*/
|
||||||
function User_by_api_key($api_key)
|
function User_by_api_key($api_key)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
|
$user = DB::select('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to find user by api key.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -440,10 +418,6 @@ function User_by_email($email)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
|
$user = DB::select('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -461,10 +435,6 @@ function User_by_password_recovery_token($token)
|
||||||
{
|
{
|
||||||
$user = DB::select('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
|
$user = DB::select('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
|
||||||
|
|
||||||
if (DB::getStm()->errorCode() != '00000') {
|
|
||||||
engelsystem_error('Unable to load user.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,6 @@ function admin_import()
|
||||||
$add_minutes_end = 15;
|
$add_minutes_end = 15;
|
||||||
|
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
|
||||||
engelsystem_error('Unable to load shifttypes.');
|
|
||||||
}
|
|
||||||
$shifttypes = [];
|
$shifttypes = [];
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
|
@ -265,17 +262,11 @@ function admin_import()
|
||||||
$add_minutes_end
|
$add_minutes_end
|
||||||
);
|
);
|
||||||
foreach ($events_new as $event) {
|
foreach ($events_new as $event) {
|
||||||
$result = Shift_create($event);
|
Shift_create($event);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to create shift.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events_updated as $event) {
|
foreach ($events_updated as $event) {
|
||||||
$result = Shift_update_by_psid($event);
|
Shift_update_by_psid($event);
|
||||||
if ($result === false) {
|
|
||||||
engelsystem_error('Unable to update shift.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events_deleted as $event) {
|
foreach ($events_deleted as $event) {
|
||||||
|
|
|
@ -50,9 +50,6 @@ function admin_rooms()
|
||||||
|
|
||||||
if (test_request_int('id')) {
|
if (test_request_int('id')) {
|
||||||
$room = Room($request->input('id'), false);
|
$room = Room($request->input('id'), false);
|
||||||
if ($room === false) {
|
|
||||||
engelsystem_error('Unable to load room.');
|
|
||||||
}
|
|
||||||
if ($room == null) {
|
if ($room == null) {
|
||||||
redirect(page_link_to('admin_rooms'));
|
redirect(page_link_to('admin_rooms'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,6 @@ function admin_shifts()
|
||||||
|
|
||||||
// Load shift types
|
// Load shift types
|
||||||
$shifttypes_source = ShiftTypes();
|
$shifttypes_source = ShiftTypes();
|
||||||
if ($shifttypes_source === false) {
|
|
||||||
engelsystem_error('Unable to load shift types.');
|
|
||||||
}
|
|
||||||
$shifttypes = [];
|
$shifttypes = [];
|
||||||
foreach ($shifttypes_source as $shifttype) {
|
foreach ($shifttypes_source as $shifttype) {
|
||||||
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
$shifttypes[$shifttype['id']] = $shifttype['name'];
|
||||||
|
@ -319,9 +316,6 @@ function admin_shifts()
|
||||||
$shift['URL'] = null;
|
$shift['URL'] = null;
|
||||||
$shift['PSID'] = null;
|
$shift['PSID'] = null;
|
||||||
$shift_id = Shift_create($shift);
|
$shift_id = Shift_create($shift);
|
||||||
if ($shift_id === false) {
|
|
||||||
engelsystem_error('Unable to create shift.');
|
|
||||||
}
|
|
||||||
|
|
||||||
engelsystem_log(
|
engelsystem_log(
|
||||||
'Shift created: ' . $shifttypes[$shift['shifttype_id']]
|
'Shift created: ' . $shifttypes[$shift['shifttype_id']]
|
||||||
|
|
|
@ -38,15 +38,14 @@ class ShiftCalendarLane
|
||||||
* Returns true on success.
|
* Returns true on success.
|
||||||
*
|
*
|
||||||
* @param array $shift The shift to add
|
* @param array $shift The shift to add
|
||||||
* @return boolean true on success
|
|
||||||
*/
|
*/
|
||||||
public function addShift($shift)
|
public function addShift($shift)
|
||||||
{
|
{
|
||||||
if ($this->shiftFits($shift)) {
|
if ($this->shiftFits($shift)) {
|
||||||
$this->shifts[] = $shift;
|
$this->shifts[] = $shift;
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
return false;
|
throw new Exception('Unable to add shift to shift calendar lane.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Engelsystem;
|
namespace Engelsystem;
|
||||||
|
|
||||||
class ShiftCalendarRenderer
|
class ShiftCalendarRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 15m * 60s/m = 900s
|
* 15m * 60s/m = 900s
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +67,8 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Assigns the shifts to different lanes per room if they collide
|
* Assigns the shifts to different lanes per room if they collide
|
||||||
*
|
*
|
||||||
* @param array[] $shifts The shifts to assign
|
* @param array[] $shifts
|
||||||
|
* The shifts to assign
|
||||||
*
|
*
|
||||||
* @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
* @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
|
||||||
*/
|
*/
|
||||||
|
@ -82,7 +83,7 @@ class ShiftCalendarRenderer
|
||||||
'RID' => $room_id,
|
'RID' => $room_id,
|
||||||
'Name' => $shift['room_name']
|
'Name' => $shift['room_name']
|
||||||
]);
|
]);
|
||||||
if (!isset($lanes[$room_id])) {
|
if (! isset($lanes[$room_id])) {
|
||||||
// initialize room with one lane
|
// initialize room with one lane
|
||||||
$lanes[$room_id] = [
|
$lanes[$room_id] = [
|
||||||
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
|
||||||
|
@ -92,17 +93,16 @@ class ShiftCalendarRenderer
|
||||||
$shift_added = false;
|
$shift_added = false;
|
||||||
foreach ($lanes[$room_id] as $lane) {
|
foreach ($lanes[$room_id] as $lane) {
|
||||||
/** @var ShiftCalendarLane $lane */
|
/** @var ShiftCalendarLane $lane */
|
||||||
$shift_added = $lane->addShift($shift);
|
try {
|
||||||
if ($shift_added == true) {
|
$lane->addShift($shift);
|
||||||
|
} catch (Exception $e) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If all lanes for this room are busy, create a new lane and add shift to it
|
// If all lanes for this room are busy, create a new lane and add shift to it
|
||||||
if ($shift_added == false) {
|
if ($shift_added == false) {
|
||||||
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
|
||||||
if (!$newLane->addShift($shift)) {
|
$newLane->addShift($shift);
|
||||||
engelsystem_error('Unable to add shift to new lane.');
|
|
||||||
}
|
|
||||||
$lanes[$room_id][] = $newLane;
|
$lanes[$room_id][] = $newLane;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getFirstBlockStartTime()
|
public function getFirstBlockStartTime()
|
||||||
|
@ -119,6 +120,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getLastBlockEndTime()
|
public function getLastBlockEndTime()
|
||||||
|
@ -127,6 +129,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getBlocksPerSlot()
|
public function getBlocksPerSlot()
|
||||||
|
@ -173,7 +176,8 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Renders a single lane
|
* Renders a single lane
|
||||||
*
|
*
|
||||||
* @param ShiftCalendarLane $lane The lane to render
|
* @param ShiftCalendarLane $lane
|
||||||
|
* The lane to render
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function renderLane(ShiftCalendarLane $lane)
|
private function renderLane(ShiftCalendarLane $lane)
|
||||||
|
@ -190,12 +194,7 @@ class ShiftCalendarRenderer
|
||||||
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($shift_height, $shift_html) = $shift_renderer->render(
|
list ($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
|
||||||
$shift,
|
|
||||||
$this->needed_angeltypes[$shift['SID']],
|
|
||||||
$this->shift_entries[$shift['SID']],
|
|
||||||
$user
|
|
||||||
);
|
|
||||||
$html .= $shift_html;
|
$html .= $shift_html;
|
||||||
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
|
||||||
}
|
}
|
||||||
|
@ -214,21 +213,23 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* Renders a tick/block for given time
|
* Renders a tick/block for given time
|
||||||
*
|
*
|
||||||
* @param int $time unix timestamp
|
* @param int $time
|
||||||
* @param boolean $label Should time labels be generated?
|
* unix timestamp
|
||||||
|
* @param boolean $label
|
||||||
|
* Should time labels be generated?
|
||||||
* @return string rendered tick html
|
* @return string rendered tick html
|
||||||
*/
|
*/
|
||||||
private function renderTick($time, $label = false)
|
private function renderTick($time, $label = false)
|
||||||
{
|
{
|
||||||
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
|
||||||
if (!$label) {
|
if (! $label) {
|
||||||
return div('tick day');
|
return div('tick day');
|
||||||
}
|
}
|
||||||
return div('tick day', [
|
return div('tick day', [
|
||||||
date('m-d<b\r />H:i', $time)
|
date('m-d<b\r />H:i', $time)
|
||||||
]);
|
]);
|
||||||
} elseif ($time % (60 * 60) == 0) {
|
} elseif ($time % (60 * 60) == 0) {
|
||||||
if (!$label) {
|
if (! $label) {
|
||||||
return div('tick hour');
|
return div('tick hour');
|
||||||
}
|
}
|
||||||
return div('tick hour', [
|
return div('tick hour', [
|
||||||
|
@ -250,7 +251,7 @@ class ShiftCalendarRenderer
|
||||||
_('Time')
|
_('Time')
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
|
for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
|
||||||
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
$thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
|
||||||
$time_slot[] = $this->renderTick($thistime, true);
|
$time_slot[] = $this->renderTick($thistime, true);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +259,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array[] $shifts
|
* @param array[] $shifts
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +275,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param array[] $shifts
|
* @param array[] $shifts
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -288,6 +291,7 @@ class ShiftCalendarRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function calcBlocksPerSlot()
|
private function calcBlocksPerSlot()
|
||||||
|
|
Loading…
Reference in New Issue