diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index a1801de6..c8b6932a 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -316,7 +316,7 @@ function shift_next_controller() $upcoming_shifts = ShiftEntries_upcoming_for_user($user); - if (empty($upcoming_shifts)) { + if (!empty($upcoming_shifts)) { redirect(shift_link($upcoming_shifts[0])); } diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php index 491a70b2..3098c8ce 100644 --- a/includes/controller/user_driver_licenses_controller.php +++ b/includes/controller/user_driver_licenses_controller.php @@ -123,7 +123,7 @@ function user_driver_license_edit_controller() if (UserDriverLicense_valid($user_driver_license)) { 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 { UserDriverLicenses_update($user_driver_license); } @@ -133,7 +133,7 @@ function user_driver_license_edit_controller() } else { 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']); engelsystem_log('Driver license information removed.'); success(_('Your driver license information has been removed.')); diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index faa37d59..e2a05c44 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -11,7 +11,7 @@ use Engelsystem\ShiftSignupState; function Shifts_by_room($room) { $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.'); } return $result; @@ -23,7 +23,6 @@ function Shifts_by_room($room) */ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { - //@TODO $sql = 'SELECT * FROM ( SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name` FROM `Shifts` @@ -31,7 +30,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` 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`.`count` > 0 AND `Shifts`.`PSID` IS NULL @@ -44,13 +43,21 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID` 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`.`count` > 0 AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts ORDER BY `start`'; - $result = DB::select($sql); + $result = DB::select( + $sql, + [ + $shiftsFilter->getStartTime(), + $shiftsFilter->getEndTime(), + $shiftsFilter->getStartTime(), + $shiftsFilter->getEndTime(), + ] + ); if (DB::getStm()->errorCode() != '00000') { engelsystem_error('Unable to load shifts by filter.'); } @@ -63,7 +70,6 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) */ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { - //@TODO $sql = ' SELECT `NeededAngelTypes`.*, @@ -76,7 +82,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id` WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') - AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' + AND `start` BETWEEN ? AND ? AND `Shifts`.`PSID` IS NULL UNION @@ -92,9 +98,17 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID` JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id` 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'; - $result = DB::select($sql); + $result = DB::select( + $sql, + [ + $shiftsFilter->getStartTime(), + $shiftsFilter->getEndTime(), + $shiftsFilter->getStartTime(), + $shiftsFilter->getEndTime(), + ] + ); if (DB::getStm()->errorCode() != '00000') { 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) { - // @TODO $sql = ' SELECT `User`.`Nick`, @@ -178,9 +191,15 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID` JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') - AND `start` BETWEEN ' . $shiftsFilter->getStartTime() . ' AND ' . $shiftsFilter->getEndTime() . ' + AND `start` BETWEEN ? AND ? ORDER BY `Shifts`.`start`'; - $result = DB::select($sql); + $result = DB::select( + $sql, + [ + $shiftsFilter->getStartTime(), + $shiftsFilter->getEndTime(), + ] + ); if (DB::getStm()->errorCode() != '00000') { engelsystem_error('Unable to load shift entries by filter.'); } diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 60349676..8f833087 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -45,7 +45,7 @@ function admin_user() . 'Wenn T-Shirt ein \'Ja\' enthält, bedeutet dies, dass der Engel ' . 'bereits sein T-Shirt erhalten hat.

' . "\n"; - $html .= '
' . "\n"; + $html .= '' . "\n"; $html .= '' . "\n"; $html .= '' . "\n"; $html .= '
' . "\n";