Fixes and improvements

main
Igor Scheller 8 years ago
parent 3de0cc840f
commit 781f830678

@ -316,7 +316,7 @@ function shift_next_controller()
$upcoming_shifts = ShiftEntries_upcoming_for_user($user); $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
if (empty($upcoming_shifts)) { if (!empty($upcoming_shifts)) {
redirect(shift_link($upcoming_shifts[0])); redirect(shift_link($upcoming_shifts[0]));
} }

@ -123,7 +123,7 @@ function user_driver_license_edit_controller()
if (UserDriverLicense_valid($user_driver_license)) { if (UserDriverLicense_valid($user_driver_license)) {
if ($user_driver_license['user_id'] == null) { if ($user_driver_license['user_id'] == null) {
$user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source['UID']); $user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
} else { } else {
UserDriverLicenses_update($user_driver_license); UserDriverLicenses_update($user_driver_license);
} }
@ -133,7 +133,7 @@ function user_driver_license_edit_controller()
} else { } else {
error(_('Please select at least one driving license.')); error(_('Please select at least one driving license.'));
} }
} elseif ($user_driver_license['id'] != null) { } elseif ($user_driver_license['user_id'] != null) {
UserDriverLicenses_delete($user_source['UID']); UserDriverLicenses_delete($user_source['UID']);
engelsystem_log('Driver license information removed.'); engelsystem_log('Driver license information removed.');
success(_('Your driver license information has been removed.')); success(_('Your driver license information has been removed.'));

@ -11,7 +11,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']]); $result = DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
if (empty($result)) { if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to load shifts.'); engelsystem_error('Unable to load shifts.');
} }
return $result; return $result;
@ -23,7 +23,6 @@ function Shifts_by_room($room)
*/ */
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
//@TODO
$sql = 'SELECT * FROM ( $sql = 'SELECT * FROM (
SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name` SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts` FROM `Shifts`
@ -31,7 +30,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id` JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ') AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0 AND `NeededAngelTypes`.`count` > 0
AND `Shifts`.`PSID` IS NULL AND `Shifts`.`PSID` IS NULL
@ -44,13 +43,21 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id` JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' AND `start` BETWEEN ? AND ?
AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ') AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0 AND `NeededAngelTypes`.`count` > 0
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($sql); $result = DB::select(
$sql,
[
$shiftsFilter->getStartTime(),
$shiftsFilter->getEndTime(),
$shiftsFilter->getStartTime(),
$shiftsFilter->getEndTime(),
]
);
if (DB::getStm()->errorCode() != '00000') { if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to load shifts by filter.'); engelsystem_error('Unable to load shifts by filter.');
} }
@ -63,7 +70,6 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
*/ */
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
//@TODO
$sql = ' $sql = '
SELECT SELECT
`NeededAngelTypes`.*, `NeededAngelTypes`.*,
@ -76,7 +82,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id` JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' AND `start` BETWEEN ? AND ?
AND `Shifts`.`PSID` IS NULL AND `Shifts`.`PSID` IS NULL
UNION UNION
@ -92,9 +98,17 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id` JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' AND `start` BETWEEN ? AND ?
AND NOT `Shifts`.`PSID` IS NULL'; AND NOT `Shifts`.`PSID` IS NULL';
$result = DB::select($sql); $result = DB::select(
$sql,
[
$shiftsFilter->getStartTime(),
$shiftsFilter->getEndTime(),
$shiftsFilter->getStartTime(),
$shiftsFilter->getEndTime(),
]
);
if (DB::getStm()->errorCode() != '00000') { if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to load needed angeltypes by filter.'); engelsystem_error('Unable to load needed angeltypes by filter.');
} }
@ -161,7 +175,6 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
*/ */
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
// @TODO
$sql = ' $sql = '
SELECT SELECT
`User`.`Nick`, `User`.`Nick`,
@ -178,9 +191,15 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID` JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' AND `start` BETWEEN ? AND ?
ORDER BY `Shifts`.`start`'; ORDER BY `Shifts`.`start`';
$result = DB::select($sql); $result = DB::select(
$sql,
[
$shiftsFilter->getStartTime(),
$shiftsFilter->getEndTime(),
]
);
if (DB::getStm()->errorCode() != '00000') { if (DB::getStm()->errorCode() != '00000') {
engelsystem_error('Unable to load shift entries by filter.'); engelsystem_error('Unable to load shift entries by filter.');
} }

@ -45,7 +45,7 @@ function admin_user()
. 'Wenn T-Shirt ein \'Ja\' enthält, bedeutet dies, dass der Engel ' . 'Wenn T-Shirt ein \'Ja\' enthält, bedeutet dies, dass der Engel '
. 'bereits sein T-Shirt erhalten hat.<br /><br />' . "\n"; . 'bereits sein T-Shirt erhalten hat.<br /><br />' . "\n";
$html .= '<form action="' . page_link_to('admin_user') . '&action=save&id=$user_id" method="post">' . "\n"; $html .= '<form action="' . page_link_to('admin_user') . '&action=save&id=' . $user_id . '" method="post">' . "\n";
$html .= '<table border="0">' . "\n"; $html .= '<table border="0">' . "\n";
$html .= '<input type="hidden" name="Type" value="Normal">' . "\n"; $html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
$html .= '<tr><td>' . "\n"; $html .= '<tr><td>' . "\n";

Loading…
Cancel
Save