Shifts creation: Simplify log message, fix "room angels" validation

This commit is contained in:
Igor Scheller 2023-12-24 02:27:10 +01:00 committed by msquare
parent 6d4f059b3a
commit d803591a91
1 changed files with 21 additions and 8 deletions

View File

@ -184,15 +184,23 @@ function admin_shifts()
error(sprintf(__('Please check the needed angels for team %s.'), $type->name)); error(sprintf(__('Please check the needed angels for team %s.'), $type->name));
} }
} }
if (array_sum($needed_angel_types) == 0) {
$valid = false;
error(__('There are 0 angels needed. Please enter the amounts of needed angels.'));
}
} else { } else {
$valid = false; $valid = false;
error(__('Please select a mode for needed angels.')); error(__('Please select a mode for needed angels.'));
} }
if (
$angelmode == 'manually' && array_sum($needed_angel_types) == 0
|| $angelmode == 'location' && !NeededAngelType::whereLocationId($lid)
->where('count', '>', '0')
->count()
|| $angelmode == 'shift_type' && !NeededAngelType::whereShiftTypeId($shifttype_id)
->where('count', '>', '0')
->count()
) {
$valid = false;
error(__('There are 0 angels needed. Please enter the amounts of needed angels.'));
}
} else { } else {
$valid = false; $valid = false;
error(__('Please select needed angels.')); error(__('Please select needed angels.'));
@ -427,13 +435,18 @@ function admin_shifts()
$needed_angel_types_info[] = $angel_type_source->name . ': ' . $count; $needed_angel_types_info[] = $angel_type_source->name . ': ' . $count;
} }
} }
engelsystem_log('Shift created: ' . $shifttypes[$shift->shift_type_id]
engelsystem_log(
'Shift created: ' . $shifttypes[$shift->shift_type_id]
. ' (' . $shift->id . ')'
. ' with title ' . $shift->title . ' with title ' . $shift->title
. ' with description ' . $shift->description . ' and description ' . $shift->description
. ' from ' . $shift->start->format('Y-m-d H:i') . ' from ' . $shift->start->format('Y-m-d H:i')
. ' to ' . $shift->end->format('Y-m-d H:i') . ' to ' . $shift->end->format('Y-m-d H:i')
. ' in ' . $shift->location->name
. ' with angel types: ' . join(', ', $needed_angel_types_info)
. ', transaction: ' . $transactionId . ', transaction: ' . $transactionId
. '; needed angel types: ' . join(', ', $needed_angel_types_info)); );
} }
success('Shifts created.'); success('Shifts created.');