User: Bugfixes & code cleanup
This commit is contained in:
parent
d7aea575ff
commit
a2aaba9cab
|
@ -102,7 +102,7 @@ class CreateUsersTables extends Migration
|
|||
$user->save();
|
||||
|
||||
$contact = new Contact([
|
||||
'dect' => ($data->DECT && $data->DECT != '-') ? $data->DECT : null,
|
||||
'dect' => $data->DECT ? $data->DECT : null,
|
||||
'mobile' => $data->Handy ?: ($data->Telefon ?: null),
|
||||
]);
|
||||
$contact->user()
|
||||
|
@ -170,7 +170,7 @@ class CreateUsersTables extends Migration
|
|||
public function down()
|
||||
{
|
||||
$this->schema->create('User', function (Blueprint $table) {
|
||||
$table->increments('UID');
|
||||
$table->integer('UID', true, false);
|
||||
|
||||
$table->string('Nick', 23)->unique()->default('');
|
||||
$table->string('Name', 23)->nullable();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Engelsystem\Migrations;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use stdClass;
|
||||
|
||||
trait ChangesReferences
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use Engelsystem\ShiftSignupState;
|
|||
function shift_entries_controller()
|
||||
{
|
||||
$user = auth()->user();
|
||||
if ($user) {
|
||||
if (!$user) {
|
||||
redirect(page_link_to('login'));
|
||||
}
|
||||
|
||||
|
@ -75,10 +75,9 @@ function shift_entry_create_controller()
|
|||
*/
|
||||
function shift_entry_create_controller_admin($shift, $angeltype)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$signup_user = auth()->user();
|
||||
$request = request();
|
||||
|
||||
$signup_user = $user;
|
||||
if ($request->has('user_id')) {
|
||||
$signup_user = User::find($request->input('user_id'));
|
||||
}
|
||||
|
@ -113,8 +112,8 @@ function shift_entry_create_controller_admin($shift, $angeltype)
|
|||
|
||||
$users = User::all();
|
||||
$users_select = [];
|
||||
foreach ($users as $u) {
|
||||
$users_select[$u->id] = $u->name;
|
||||
foreach ($users as $user) {
|
||||
$users_select[$user->id] = $user->name;
|
||||
}
|
||||
|
||||
$angeltypes_select = [];
|
||||
|
|
|
@ -332,13 +332,12 @@ function shifts_controller()
|
|||
function shift_next_controller()
|
||||
{
|
||||
global $privileges;
|
||||
$user = auth()->user();
|
||||
|
||||
if (!in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('/'));
|
||||
}
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user->id);
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user(auth()->user()->id);
|
||||
|
||||
if (!empty($upcoming_shifts)) {
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
|
|
|
@ -9,9 +9,7 @@ use Engelsystem\Models\User\User;
|
|||
*/
|
||||
function user_angeltypes_unconfirmed_hint()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user->id);
|
||||
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes(auth()->user()->id);
|
||||
if (count($unconfirmed_user_angeltypes) == 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -76,9 +76,8 @@ function user_driver_license_edit_link($user = null)
|
|||
*/
|
||||
function user_driver_license_load_user()
|
||||
{
|
||||
$user = auth()->user();
|
||||
$request = request();
|
||||
$user_source = $user;
|
||||
$user_source = auth()->user();
|
||||
|
||||
if ($request->has('user_id')) {
|
||||
$user_source = User::find($request->input('user_id'));
|
||||
|
|
|
@ -9,12 +9,10 @@ use Engelsystem\Models\User\User;
|
|||
*/
|
||||
function user_worklog_delete_controller()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$request = request();
|
||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||
if (empty($userWorkLog)) {
|
||||
redirect(user_link($user->id));
|
||||
redirect(user_link(auth()->user()->id));
|
||||
}
|
||||
$user_source = User::find($userWorkLog['user_id']);
|
||||
|
||||
|
@ -38,12 +36,10 @@ function user_worklog_delete_controller()
|
|||
*/
|
||||
function user_worklog_edit_controller()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$request = request();
|
||||
$userWorkLog = UserWorkLog($request->input('user_worklog_id'));
|
||||
if (empty($userWorkLog)) {
|
||||
redirect(user_link($user->id));
|
||||
redirect(user_link(auth()->user()->id));
|
||||
}
|
||||
$user_source = User::find($userWorkLog['user_id']);
|
||||
|
||||
|
@ -110,12 +106,10 @@ function user_worklog_from_request($userWorkLog)
|
|||
*/
|
||||
function user_worklog_add_controller()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$request = request();
|
||||
$user_source = User::find($request->input('user_id'));
|
||||
if (!$user_source) {
|
||||
redirect(user_link($user->id));
|
||||
redirect(user_link(auth()->user()->id));
|
||||
}
|
||||
|
||||
$userWorkLog = UserWorkLog_new($user_source->id);
|
||||
|
|
|
@ -167,7 +167,7 @@ function user_edit_vouchers_controller()
|
|||
|
||||
if ($valid) {
|
||||
$user_source->state->got_voucher = $vouchers;
|
||||
$user->state->save();
|
||||
$user_source->state->save();
|
||||
|
||||
success(__('Saved the number of vouchers.'));
|
||||
engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
|
||||
|
@ -268,26 +268,30 @@ function users_list_controller()
|
|||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$order_by = 'Nick';
|
||||
$order_by = 'name';
|
||||
if ($request->has('OrderBy') && in_array($request->input('OrderBy'), [
|
||||
'Nick',
|
||||
'Name',
|
||||
'Vorname',
|
||||
'DECT',
|
||||
'name',
|
||||
'last_name',
|
||||
'first_name',
|
||||
'dect',
|
||||
'email',
|
||||
'Size',
|
||||
'Gekommen',
|
||||
'Aktiv',
|
||||
'shirt_size',
|
||||
'arrived',
|
||||
'active',
|
||||
'force_active',
|
||||
'Tshirt',
|
||||
'lastLogIn'
|
||||
'got_shirt',
|
||||
'last_login_at',
|
||||
])) {
|
||||
$order_by = $request->input('OrderBy');
|
||||
}
|
||||
|
||||
/** @var User[] $users */
|
||||
$users = User::query()
|
||||
->leftJoin('users_contact', 'users.id', '=', 'users_contact.user_id')
|
||||
->leftJoin('users_personal_data', 'users.id', '=', 'users_personal_data.user_id')
|
||||
->leftJoin('users_state', 'users.id', '=', 'users_state.user_id')
|
||||
->orderBy($order_by)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
foreach ($users as $user) {
|
||||
$user->setAttribute('freeloads', count(ShiftEntries_freeloaded_by_user($user->id)));
|
||||
|
|
|
@ -4,7 +4,7 @@ use Engelsystem\Mail\EngelsystemMailer;
|
|||
use Engelsystem\Models\User\User;
|
||||
|
||||
/**
|
||||
* @param array|User $recipientUser
|
||||
* @param User $recipientUser
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
* @param bool $notIfItsMe
|
||||
|
@ -12,21 +12,7 @@ use Engelsystem\Models\User\User;
|
|||
*/
|
||||
function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe = false)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
|
||||
if ($recipientUser instanceof User) {
|
||||
$id = $user->id;
|
||||
$lang = $user->settings->language;
|
||||
$email = $user->contact->email ? $user->contact->email : $user->email;
|
||||
$username = $user->name;
|
||||
} else {
|
||||
$id = $recipientUser['UID'];
|
||||
$lang = $recipientUser['Sprache'];
|
||||
$email = $recipientUser['email'];
|
||||
$username = $recipientUser['Nick'];
|
||||
}
|
||||
|
||||
if ($notIfItsMe && $user->id == $id) {
|
||||
if ($notIfItsMe && Auth()->user()->id == $recipientUser->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -36,12 +22,12 @@ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe
|
|||
/** @var EngelsystemMailer $mailer */
|
||||
$mailer = app('mailer');
|
||||
|
||||
$translator->setLocale($lang);
|
||||
$translator->setLocale($recipientUser->settings->language);
|
||||
$status = $mailer->sendView(
|
||||
$email,
|
||||
$recipientUser->contact->email ? $recipientUser->contact->email : $recipientUser->email,
|
||||
$title,
|
||||
'emails/mail',
|
||||
['username' => $username, 'message' => $message]
|
||||
['username' => $recipientUser->name, 'message' => $message]
|
||||
);
|
||||
$translator->setLocale($locale);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ function mail_shift_change($old_shift, $new_shift)
|
|||
$message .= $new_room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user = User::find($user->id);
|
||||
$user = (new User())->forceFill($user);
|
||||
if ($user->settings->email_shiftinfo) {
|
||||
engelsystem_email_to_user(
|
||||
$user,
|
||||
|
@ -92,7 +92,7 @@ function mail_shift_delete($shift)
|
|||
$message .= $room['Name'] . "\n";
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user = User::find($user->id);
|
||||
$user = (new User())->forceFill($user);
|
||||
if ($user->settings->email_shiftinfo) {
|
||||
engelsystem_email_to_user($user, __('Your Shift was deleted'), $message, true);
|
||||
}
|
||||
|
|
|
@ -233,9 +233,9 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
|||
*/
|
||||
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
||||
{
|
||||
$sql = '
|
||||
$sql = sprintf('
|
||||
SELECT
|
||||
users.*
|
||||
users.*,
|
||||
`ShiftEntry`.`UID`,
|
||||
`ShiftEntry`.`TID`,
|
||||
`ShiftEntry`.`SID`,
|
||||
|
@ -244,9 +244,12 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
|||
FROM `Shifts`
|
||||
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
|
||||
WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
|
||||
WHERE `Shifts`.`RID` IN (%s)
|
||||
AND `start` BETWEEN ? AND ?
|
||||
ORDER BY `Shifts`.`start`';
|
||||
ORDER BY `Shifts`.`start`
|
||||
',
|
||||
implode(',', $shiftsFilter->getRooms())
|
||||
);
|
||||
return DB::select(
|
||||
$sql,
|
||||
[
|
||||
|
@ -575,7 +578,6 @@ function Shift_update_by_psid($shift)
|
|||
*/
|
||||
function Shift_create($shift)
|
||||
{
|
||||
$user = auth()->user();
|
||||
DB::insert('
|
||||
INSERT INTO `Shifts` (
|
||||
`shifttype_id`,
|
||||
|
@ -599,7 +601,7 @@ function Shift_create($shift)
|
|||
$shift['title'],
|
||||
$shift['URL'],
|
||||
$shift['PSID'],
|
||||
$user->id,
|
||||
auth()->user()->id,
|
||||
time(),
|
||||
time(),
|
||||
]
|
||||
|
|
|
@ -73,16 +73,16 @@ function User_is_freeloader($user)
|
|||
function Users_by_angeltype_inverted($angeltype)
|
||||
{
|
||||
return User::query()
|
||||
->leftJoin('UserAngelTypes', 'users.id', '=', 'UserAngelTypes.user_id')
|
||||
->select('users.*')
|
||||
->leftJoin('UserAngelTypes', function ($query) use ($angeltype) {
|
||||
/** @var JoinClause $query */
|
||||
$query
|
||||
->on('users.id', '=', 'UserAngelTypes.user_id')
|
||||
->on('UserAngelTypes.angeltype_id', '=', $angeltype['id']);
|
||||
->where('UserAngelTypes.angeltype_id', '=', $angeltype['id']);
|
||||
})
|
||||
->whereNull('UserAngelTypes.id')
|
||||
->orderBy('users.name')
|
||||
->get('users.*');
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,17 +94,17 @@ function Users_by_angeltype_inverted($angeltype)
|
|||
function Users_by_angeltype($angeltype)
|
||||
{
|
||||
return User::query()
|
||||
->select('users.*',
|
||||
'UserAngelTypes.id AS user_angeltype_id',
|
||||
'UserAngelTypes.confirm_user_id',
|
||||
'UserAngelTypes.supporter',
|
||||
'UserDriverLicenses.user_id AS wants_to_drive',
|
||||
'UserDriverLicenses.*'
|
||||
)
|
||||
->join('UserAngelTypes', 'users.id', '=', 'UserAngelTypes.user_id')
|
||||
->leftJoin('UserDriverLicenses', 'users.id', '=', 'UserDriverLicenses.user_id')
|
||||
->where('UserAngelTypes.angeltype_id', '=', $angeltype['id'])
|
||||
->get([
|
||||
'users.*',
|
||||
'`UserAngelTypes`.`id` AS `user_angeltype_id`',
|
||||
'`UserAngelTypes`.`confirm_user_id`',
|
||||
'`UserAngelTypes`.`supporter`',
|
||||
'(`UserDriverLicenses`.`user_id` IS NOT NULL) AS `wants_to_drive`',
|
||||
'`UserDriverLicenses`.*',
|
||||
]);
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +226,7 @@ function User_reset_api_key($user, $log = true)
|
|||
function User_generate_password_recovery_token($user)
|
||||
{
|
||||
$reset = PasswordReset::findOrNew($user->id);
|
||||
$reset->user_id = $user->id;
|
||||
$reset->token = md5($user->name . time() . rand());
|
||||
$reset->save();
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use Engelsystem\Models\User\State;
|
||||
use Engelsystem\Models\User\User;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -23,8 +25,7 @@ function admin_active()
|
|||
$msg = '';
|
||||
$search = '';
|
||||
$forced_count = State::whereForceActive(true)->count();
|
||||
$count = $forced_count;
|
||||
$limit = '';
|
||||
$count = null;
|
||||
$set_active = '';
|
||||
|
||||
if ($request->has('search')) {
|
||||
|
@ -34,8 +35,6 @@ function admin_active()
|
|||
$show_all_shifts = $request->has('show_all_shifts');
|
||||
|
||||
if ($request->has('set_active')) {
|
||||
$valid = true;
|
||||
|
||||
if ($request->has('count') && preg_match('/^\d+$/', $request->input('count'))) {
|
||||
$count = strip_request_item('count');
|
||||
if ($count < $forced_count) {
|
||||
|
@ -46,41 +45,43 @@ function admin_active()
|
|||
redirect(page_link_to('admin_active'));
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$msg .= error(__('Please enter a number of angels to be marked as active.'), true);
|
||||
$msg .= error(__('Please enter a number of angels to be marked as active.'));
|
||||
redirect(page_link_to('admin_active'));
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$limit = ' LIMIT ' . $count;
|
||||
}
|
||||
if ($request->has('ack')) {
|
||||
State::query()
|
||||
->where('got_shirt', '=', false)
|
||||
->where('got_shirt', '=', false)
|
||||
->update(['active' => false]);
|
||||
|
||||
/** @var User[] $users */
|
||||
$users = User::query()->raw(sprintf('
|
||||
SELECT
|
||||
`users`.*,
|
||||
COUNT(`ShiftEntry`.`id`) AS `shift_count`,
|
||||
$query = User::query()
|
||||
->selectRaw(
|
||||
sprintf(
|
||||
'
|
||||
users.*,
|
||||
COUNT(ShiftEntry.id) AS shift_count,
|
||||
(%s + (
|
||||
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
|
||||
AND `work_timestamp` < %s
|
||||
AND `work_timestamp` < ?
|
||||
)) AS `shift_length`
|
||||
FROM `users`
|
||||
LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
|
||||
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
|
||||
LEFT JOIN `users_state` ON `users`.`id` = `users_state`.`user_id`
|
||||
WHERE `users_state`.`arrived` = 1
|
||||
AND `users_state`.`force_active` = 0
|
||||
GROUP BY `users`.`id`
|
||||
ORDER BY `force_active` DESC, `shift_length` DESC
|
||||
%s
|
||||
',
|
||||
$shift_sum_formula,
|
||||
time(),
|
||||
$limit
|
||||
));
|
||||
$shift_sum_formula
|
||||
),
|
||||
[time()]
|
||||
)
|
||||
->leftJoin('ShiftEntry', 'users.id', '=', 'ShiftEntry.UID')
|
||||
->leftJoin('Shifts', 'ShiftEntry.SID', '=', 'Shifts.SID')
|
||||
->leftJoin('users_state', 'users.id', '=', 'users_state.user_id')
|
||||
->where('users_state.arrived', '=', true)
|
||||
->where('users_state.force_active', '=', false)
|
||||
->groupBy('users.id')
|
||||
->orderByDesc('force_active')
|
||||
->orderByDesc('shift_length')
|
||||
->orderByDesc('name')
|
||||
->limit($count);
|
||||
|
||||
$users = $query->get();
|
||||
$user_nicks = [];
|
||||
foreach ($users as $usr) {
|
||||
$usr->state->active = true;
|
||||
|
@ -88,10 +89,9 @@ function admin_active()
|
|||
$user_nicks[] = User_Nick_render($usr);
|
||||
}
|
||||
|
||||
State::whereForceActive(true)->update(['active' => 'true']);
|
||||
State::whereForceActive(true)->update(['active' => true]);
|
||||
engelsystem_log('These angels are active now: ' . join(', ', $user_nicks));
|
||||
|
||||
$limit = '';
|
||||
$msg = success(__('Marked angels.'), true);
|
||||
} else {
|
||||
$set_active = '<a href="' . page_link_to('admin_active', ['search' => $search]) . '">« '
|
||||
|
@ -120,7 +120,7 @@ function admin_active()
|
|||
} elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
|
||||
$user_id = $request->input('not_active');
|
||||
$user_source = User::find($user_id);
|
||||
if (!$user_source) {
|
||||
if ($user_source) {
|
||||
$user_source->state->active = false;
|
||||
$user_source->state->save();
|
||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
|
||||
|
@ -131,7 +131,7 @@ function admin_active()
|
|||
} elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
|
||||
$user_id = $request->input('tshirt');
|
||||
$user_source = User::find($user_id);
|
||||
if (!$user_source) {
|
||||
if ($user_source) {
|
||||
$user_source->state->got_shirt = true;
|
||||
$user_source->state->save();
|
||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
|
||||
|
@ -142,7 +142,7 @@ function admin_active()
|
|||
} elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
|
||||
$user_id = $request->input('not_tshirt');
|
||||
$user_source = User::find($user_id);
|
||||
if (!$user_source) {
|
||||
if ($user_source) {
|
||||
$user_source->state->got_shirt = false;
|
||||
$user_source->state->save();
|
||||
engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
|
||||
|
@ -152,28 +152,45 @@ function admin_active()
|
|||
}
|
||||
}
|
||||
|
||||
$users = User::query()->raw(sprintf('
|
||||
SELECT
|
||||
`users`.*,
|
||||
COUNT(`ShiftEntry`.`id`) AS `shift_count`,
|
||||
$query = User::query()
|
||||
->selectRaw(
|
||||
sprintf(
|
||||
'
|
||||
users.*,
|
||||
COUNT(ShiftEntry.id) AS shift_count,
|
||||
(%s + (
|
||||
SELECT COALESCE(SUM(`work_hours`) * 3600, 0) FROM `UserWorkLog` WHERE `user_id`=`users`.`id`
|
||||
AND `work_timestamp` < %s
|
||||
AND `work_timestamp` < ?
|
||||
)) AS `shift_length`
|
||||
FROM `users`
|
||||
LEFT JOIN `users_state` ON `users`.`id` = `users_state`.`user_id`
|
||||
LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
|
||||
LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` '
|
||||
. ($show_all_shifts ? '' : 'AND (`Shifts`.`end` < ' . time() . " OR `Shifts`.`end` IS NULL)") . '
|
||||
WHERE `users_state`.`arrived` = 1
|
||||
GROUP BY `users`.`id`
|
||||
ORDER BY `users_state`.`force_active` DESC, `shift_length` DESC
|
||||
%s
|
||||
',
|
||||
$shift_sum_formula,
|
||||
time(),
|
||||
$limit
|
||||
));
|
||||
$shift_sum_formula
|
||||
),
|
||||
[time()]
|
||||
)
|
||||
->leftJoin('ShiftEntry', 'users.id', '=', 'ShiftEntry.UID')
|
||||
->leftJoin('Shifts', function ($join) use ($show_all_shifts) {
|
||||
/** @var JoinClause $join */
|
||||
$join->on('ShiftEntry.SID', '=', 'Shifts.SID');
|
||||
if ($show_all_shifts) {
|
||||
$join->where(function ($query) {
|
||||
/** @var Builder $query */
|
||||
$query->where('Shifts.end', '<', time())
|
||||
->orWhereNull('Shifts.end');
|
||||
});
|
||||
}
|
||||
})
|
||||
->leftJoin('users_state', 'users.id', '=', 'users_state.user_id')
|
||||
->where('users_state.arrived', '=', true)
|
||||
->groupBy('users.id')
|
||||
->orderByDesc('force_active')
|
||||
->orderByDesc('shift_length')
|
||||
->orderByDesc('name');
|
||||
|
||||
if (!is_null($count)) {
|
||||
$query->limit($count);
|
||||
}
|
||||
|
||||
$users = $query->get();
|
||||
$matched_users = [];
|
||||
if ($search == '') {
|
||||
$tokens = [];
|
||||
|
@ -202,6 +219,7 @@ function admin_active()
|
|||
$userData['active'] = glyph_bool($usr->state->active == 1);
|
||||
$userData['force_active'] = glyph_bool($usr->state->force_active == 1);
|
||||
$userData['tshirt'] = glyph_bool($usr->state->got_shirt == 1);
|
||||
$userData['shift_count'] = $usr['shift_count'];
|
||||
|
||||
$actions = [];
|
||||
if (!$usr->state->active) {
|
||||
|
@ -262,6 +280,7 @@ function admin_active()
|
|||
foreach (array_keys($tshirt_sizes) as $size) {
|
||||
$gc = State::query()
|
||||
->leftJoin('users_settings', 'users_state.user_id', '=', 'users_settings.user_id')
|
||||
->leftJoin('users_personal_data', 'users_state.user_id', '=', 'users_personal_data.user_id')
|
||||
->where('users_state.got_shirt', '=', true)
|
||||
->where('users_personal_data.shirt_size', '=', $size)
|
||||
->count();
|
||||
|
@ -283,7 +302,7 @@ function admin_active()
|
|||
form_submit('submit', __('Search'))
|
||||
], page_link_to('admin_active')),
|
||||
$set_active == '' ? form([
|
||||
form_text('count', __('How much angels should be active?'), $count),
|
||||
form_text('count', __('How much angels should be active?'), $count ? $count : $forced_count),
|
||||
form_submit('set_active', __('Preview'))
|
||||
]) : $set_active,
|
||||
$msg . msg(),
|
||||
|
|
|
@ -44,7 +44,7 @@ function admin_arrive()
|
|||
if ($user_source) {
|
||||
$user_source->state->arrived = true;
|
||||
$user_source->state->arrival_date = new Carbon\Carbon();
|
||||
$user_source->personalData->save();
|
||||
$user_source->state->save();
|
||||
|
||||
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
|
||||
success(__('Angel has been marked as arrived.'));
|
||||
|
@ -170,7 +170,7 @@ function admin_arrive()
|
|||
form_submit('submit', __('Search'))
|
||||
]),
|
||||
table([
|
||||
'nick' => __('Nickname'),
|
||||
'name' => __('Nickname'),
|
||||
'rendered_planned_arrival_date' => __('Planned arrival'),
|
||||
'arrived' => __('Arrived?'),
|
||||
'rendered_arrival_date' => __('Arrival date'),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Engelsystem\Database\DB;
|
||||
use Engelsystem\Models\User\User;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
@ -24,18 +25,6 @@ function admin_free()
|
|||
$search = strip_request_item('search');
|
||||
}
|
||||
|
||||
$angelTypeSearch = '';
|
||||
$angelType = $request->input('angeltype', '');
|
||||
if (!empty($angelType)) {
|
||||
$angelTypeSearch = ' INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '
|
||||
. DB::getPdo()->quote($angelType)
|
||||
. ' AND `UserAngelTypes`.`user_id` = `users`.`id`';
|
||||
if ($request->has('confirmed_only')) {
|
||||
$angelTypeSearch .= ' AND `UserAngelTypes`.`confirm_user_id`';
|
||||
}
|
||||
$angelTypeSearch .= ') ';
|
||||
}
|
||||
|
||||
$angel_types_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
|
||||
$angel_types = [
|
||||
'' => 'alle Typen'
|
||||
|
@ -44,27 +33,34 @@ function admin_free()
|
|||
$angel_types[$angel_type['id']] = $angel_type['name'];
|
||||
}
|
||||
|
||||
/** @var User[] $users */
|
||||
$users = User::query()->raw(sprintf('
|
||||
SELECT `users`.*
|
||||
FROM `users`
|
||||
%s
|
||||
LEFT JOIN `ShiftEntry` ON `users`.`id` = `ShiftEntry`.`UID`
|
||||
LEFT JOIN `users_state` ON `users`.`id` = `users_state`.`user_id`
|
||||
LEFT JOIN `Shifts`
|
||||
ON (
|
||||
`ShiftEntry`.`SID` = `Shifts`.`SID`
|
||||
AND `Shifts`.`start` < %u
|
||||
AND `Shifts`.`end` > %u
|
||||
)
|
||||
WHERE `users_state`.`arrived` = 1
|
||||
AND `Shifts`.`SID` IS NULL
|
||||
GROUP BY `users`.`id`
|
||||
ORDER BY `users`
|
||||
', $angelTypeSearch, time(), time()
|
||||
)
|
||||
);
|
||||
$angelType = $request->input('angeltype', '');
|
||||
$query = User::query()
|
||||
->select('users.*')
|
||||
->leftJoin('ShiftEntry', 'users.id', 'ShiftEntry.UID')
|
||||
->leftJoin('users_state', 'users.id', 'users_state.user_id')
|
||||
->leftJoin('Shifts', function ($join) {
|
||||
/** @var JoinClause $join */
|
||||
$join->on('ShiftEntry.SID', '=', 'Shifts.SID')
|
||||
->where('Shifts.start', '<', time())
|
||||
->where('Shifts.end', '>', time());
|
||||
})
|
||||
->where('users_state.arrived', '=', 1)
|
||||
->whereNull('Shifts.SID')
|
||||
->groupBy('users.id');
|
||||
|
||||
if (!empty($angelType)) {
|
||||
$query->join('UserAngelTypes', function ($join) use ($angelType, $request, $query) {
|
||||
/** @var JoinClause $join */
|
||||
$join->on('UserAngelTypes.user_id', '=', 'users.id')
|
||||
->where('UserAngelTypes.angeltype_id', '=', $angelType);
|
||||
|
||||
if ($request->has('confirmed_only')) {
|
||||
$join->whereNotNull('UserAngelTypes.confirm_user_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$users = $query->get();
|
||||
$free_users_table = [];
|
||||
if ($search == '') {
|
||||
$tokens = [];
|
||||
|
|
|
@ -60,8 +60,13 @@ function admin_user()
|
|||
$html .= " <tr><td>email</td><td>" . '<input type="email" size="40" name="eemail" value="' . $user_source->email . '" class="form-control"></td></tr>' . "\n";
|
||||
}
|
||||
$html .= ' <tr><td>Size</td><td>'
|
||||
. html_select_key('size', 'eSize', $tshirt_sizes, $user_source->personalData->shirt_size,
|
||||
__('Please select...')) . '</td></tr>' . "\n";
|
||||
. html_select_key(
|
||||
'size',
|
||||
'eSize',
|
||||
$tshirt_sizes, $user_source->personalData->shirt_size,
|
||||
__('Please select...')
|
||||
)
|
||||
. '</td></tr>' . "\n";
|
||||
|
||||
$options = [
|
||||
'1' => __('Yes'),
|
||||
|
@ -84,7 +89,7 @@ function admin_user()
|
|||
|
||||
// T-Shirt bekommen?
|
||||
$html .= ' <tr><td>T-Shirt</td><td>' . "\n";
|
||||
$html .= html_options('eTshirt', $options, $user_source->personalData->shirt_size) . '</td></tr>' . "\n";
|
||||
$html .= html_options('eTshirt', $options, $user_source->state->got_shirt) . '</td></tr>' . "\n";
|
||||
|
||||
$html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>';
|
||||
|
||||
|
@ -244,7 +249,7 @@ function admin_user()
|
|||
if (in_array('admin_active', $privileges)) {
|
||||
$force_active = $request->input('force_active');
|
||||
}
|
||||
if($user_source->settings->email_human){
|
||||
if ($user_source->settings->email_human) {
|
||||
$user_source->email = $request->postData('eemail');
|
||||
}
|
||||
$user_source->name = User_validate_Nick($request->postData('eNick'));
|
||||
|
|
|
@ -57,7 +57,11 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
|||
|
||||
if ($request->has('planned_departure_date')) {
|
||||
$tmp = parse_date('Y-m-d H:i', $request->input('planned_departure_date') . ' 00:00');
|
||||
$result = User_validate_planned_departure_date($user_source->state->arrival_date->getTimestamp(), $tmp);
|
||||
$plannedArrivalDate = $user_source->personalData->planned_arrival_date;
|
||||
$result = User_validate_planned_departure_date(
|
||||
$plannedArrivalDate ? $plannedArrivalDate->getTimestamp() : 0,
|
||||
$tmp
|
||||
);
|
||||
$user_source->personalData->planned_departure_date = Carbon::createFromTimestamp($result->getValue());
|
||||
if (!$result->isValid()) {
|
||||
$valid = false;
|
||||
|
@ -66,7 +70,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
|||
}
|
||||
|
||||
// Trivia
|
||||
$user_source->name = strip_request_item('lastname', $user_source['Name']);
|
||||
$user_source->personalData->last_name = strip_request_item('lastname', $user_source['Name']);
|
||||
$user_source->personalData->first_name = strip_request_item('prename', $user_source['Vorname']);
|
||||
if (strlen(strip_request_item('dect')) <= 5) {
|
||||
$user_source->contact->dect = strip_request_item('dect', $user_source['DECT']);
|
||||
|
|
|
@ -203,6 +203,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
|
|||
$members_unconfirmed = [];
|
||||
foreach ($members as $member) {
|
||||
$member->name = User_Nick_render($member);
|
||||
$member['dect'] = $member->contact->dect;
|
||||
if ($angeltype['requires_driver_license']) {
|
||||
$member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
|
||||
$member['has_car'] = glyph_bool($member['has_car']);
|
||||
|
@ -294,8 +295,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
|||
{
|
||||
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
|
||||
return [
|
||||
'Nick' => __('Nick'),
|
||||
'DECT' => __('DECT'),
|
||||
'name' => __('Nick'),
|
||||
'dect' => __('DECT'),
|
||||
'wants_to_drive' => __('Driver'),
|
||||
'has_car' => __('Has car'),
|
||||
'has_license_car' => __('Car'),
|
||||
|
@ -307,8 +308,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
|
|||
];
|
||||
}
|
||||
return [
|
||||
'Nick' => __('Nick'),
|
||||
'DECT' => __('DECT'),
|
||||
'name' => __('Nick'),
|
||||
'dect' => __('DECT'),
|
||||
'actions' => ''
|
||||
];
|
||||
}
|
||||
|
@ -420,16 +421,16 @@ function AngelType_view_info(
|
|||
|
||||
if (count($members_confirmed) > 0) {
|
||||
$members_confirmed[] = [
|
||||
'Nick' => __('Sum'),
|
||||
'DECT' => count($members_confirmed),
|
||||
'name' => __('Sum'),
|
||||
'dect' => count($members_confirmed),
|
||||
'actions' => ''
|
||||
];
|
||||
}
|
||||
|
||||
if (count($members_unconfirmed) > 0) {
|
||||
$members_unconfirmed[] = [
|
||||
'Nick' => __('Sum'),
|
||||
'DECT' => count($members_unconfirmed),
|
||||
'name' => __('Sum'),
|
||||
'dect' => count($members_unconfirmed),
|
||||
'actions' => ''
|
||||
];
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ function public_dashboard_view($stats, $free_shifts)
|
|||
];
|
||||
foreach ($free_shifts as $i => $shift) {
|
||||
$shift_panels[] = public_dashboard_shift_render($shift);
|
||||
if($i % 4 == 3) {
|
||||
if ($i % 4 == 3) {
|
||||
$shift_panels[] = '</div><div class="row">';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,10 +76,8 @@ function Shift_editor_info_render($shift)
|
|||
*/
|
||||
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (empty($user_angeltype)) {
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype);
|
||||
$user_angeltype = UserAngelType_by_User_and_AngelType(auth()->user()->id, $angeltype);
|
||||
}
|
||||
|
||||
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
|
||||
|
@ -105,7 +103,6 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
|
|||
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
|
||||
{
|
||||
global $privileges;
|
||||
$user = auth()->user();
|
||||
|
||||
$shift_admin = in_array('admin_shifts', $privileges);
|
||||
$user_shift_admin = in_array('user_shifts_admin', $privileges);
|
||||
|
@ -143,7 +140,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
|
|||
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '',
|
||||
];
|
||||
}
|
||||
$buttons[] = button(user_link($user->id), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
|
||||
$buttons[] = button(user_link(auth()->user()->id), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
|
||||
$content[] = buttons($buttons);
|
||||
|
||||
$content[] = Shift_view_header($shift, $room);
|
||||
|
|
|
@ -25,7 +25,6 @@ function User_settings_view(
|
|||
$tshirt_sizes
|
||||
) {
|
||||
$personalData = $user_source->personalData;
|
||||
$state = $user_source->state;
|
||||
return page_with_title(settings_title(), [
|
||||
msg(),
|
||||
div('row', [
|
||||
|
@ -34,12 +33,12 @@ function User_settings_view(
|
|||
form_info('', __('Here you can change your user details.')),
|
||||
form_info(entry_required() . ' = ' . __('Entry required!')),
|
||||
form_text('nick', __('Nick'), $user_source->name, true),
|
||||
form_text('lastname', __('Last name'), $user_source->personalData->last_name),
|
||||
form_text('prename', __('First name'), $user_source->personalData->first_name),
|
||||
form_text('lastname', __('Last name'), $personalData->last_name),
|
||||
form_text('prename', __('First name'), $personalData->first_name),
|
||||
form_date(
|
||||
'planned_arrival_date',
|
||||
__('Planned date of arrival') . ' ' . entry_required(),
|
||||
$state->arrival_date ? $state->arrival_date->getTimestamp() : '',
|
||||
$personalData->planned_arrival_date ? $personalData->planned_arrival_date->getTimestamp() : '',
|
||||
$buildup_start_date,
|
||||
$teardown_end_date
|
||||
),
|
||||
|
@ -52,7 +51,7 @@ function User_settings_view(
|
|||
),
|
||||
form_text('dect', __('DECT'), $user_source->contact->dect),
|
||||
form_text('mobile', __('Mobile'), $user_source->contact->mobile),
|
||||
form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->contact->email),
|
||||
form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email),
|
||||
form_checkbox(
|
||||
'email_shiftinfo',
|
||||
__(
|
||||
|
@ -70,7 +69,7 @@ function User_settings_view(
|
|||
'tshirt_size',
|
||||
__('Shirt size'),
|
||||
$tshirt_sizes,
|
||||
$user_source->personalData->shirt_size,
|
||||
$personalData->shirt_size,
|
||||
__('Please select...')
|
||||
) : '',
|
||||
form_info('', __('Please visit the angeltypes page to manage your angeltypes.')),
|
||||
|
@ -215,31 +214,31 @@ function Users_view(
|
|||
$usersList = [];
|
||||
foreach ($users as $user) {
|
||||
$u = [];
|
||||
$u['Nick'] = User_Nick_render($user);
|
||||
$u['Vorname'] = $user->personalData->first_name;
|
||||
$u['Name'] = $user->personalData->last_name;
|
||||
$u['DECT'] = $user->contact->dect;
|
||||
$u['Gekommen'] = glyph_bool($user->state->arrived);
|
||||
$u['got_voucher'] = glyph_bool($user->state->got_voucher);
|
||||
$u['name'] = User_Nick_render($user);
|
||||
$u['first_name'] = $user->personalData->first_name;
|
||||
$u['last_name'] = $user->personalData->last_name;
|
||||
$u['dect'] = $user->contact->dect;
|
||||
$u['arrived'] = glyph_bool($user->state->arrived);
|
||||
$u['got_voucher'] = $user->state->got_voucher;
|
||||
$u['freeloads'] = $user->getAttribute('freeloads');
|
||||
$u['Aktiv'] = glyph_bool($user->state->active);
|
||||
$u['active'] = glyph_bool($user->state->active);
|
||||
$u['force_active'] = glyph_bool($user->state->force_active);
|
||||
$u['Tshirt'] = glyph_bool($user->state->got_shirt);
|
||||
$u['Size'] = $user->personalData->shirt_size;
|
||||
$u['lastLogIn'] = $user->last_login_at ? $user->last_login_at->format(__('m/d/Y h:i a')) : '';
|
||||
$u['got_shirt'] = glyph_bool($user->state->got_shirt);
|
||||
$u['shirt_size'] = $user->personalData->shirt_size;
|
||||
$u['last_login_at'] = $user->last_login_at ? $user->last_login_at->format(__('m/d/Y h:i a')) : '';
|
||||
$u['actions'] = table_buttons([
|
||||
button_glyph(page_link_to('admin_user', ['id' => $user->id]), 'edit', 'btn-xs')
|
||||
]);
|
||||
$usersList[] = $u;
|
||||
}
|
||||
$usersList[] = [
|
||||
'Nick' => '<strong>' . __('Sum') . '</strong>',
|
||||
'Gekommen' => $arrived_count,
|
||||
'name' => '<strong>' . __('Sum') . '</strong>',
|
||||
'arrived' => $arrived_count,
|
||||
'got_voucher' => $voucher_count,
|
||||
'Aktiv' => $active_count,
|
||||
'active' => $active_count,
|
||||
'force_active' => $force_active_count,
|
||||
'freeloads' => $freeloads_count,
|
||||
'Tshirt' => $tshirts_count,
|
||||
'got_shirt' => $tshirts_count,
|
||||
'actions' => '<strong>' . count($usersList) . '</strong>'
|
||||
];
|
||||
|
||||
|
@ -249,18 +248,18 @@ function Users_view(
|
|||
button(page_link_to('register'), glyph('plus') . __('New user'))
|
||||
]),
|
||||
table([
|
||||
'Nick' => Users_table_header_link('Nick', __('Nick'), $order_by),
|
||||
'Vorname' => Users_table_header_link('Vorname', __('Prename'), $order_by),
|
||||
'Name' => Users_table_header_link('Name', __('Name'), $order_by),
|
||||
'DECT' => Users_table_header_link('DECT', __('DECT'), $order_by),
|
||||
'Gekommen' => Users_table_header_link('Gekommen', __('Arrived'), $order_by),
|
||||
'name' => Users_table_header_link('name', __('Nick'), $order_by),
|
||||
'first_name' => Users_table_header_link('first_name', __('Prename'), $order_by),
|
||||
'last_name' => Users_table_header_link('last_name', __('Name'), $order_by),
|
||||
'dect' => Users_table_header_link('dect', __('DECT'), $order_by),
|
||||
'arrived' => Users_table_header_link('arrived', __('Arrived'), $order_by),
|
||||
'got_voucher' => Users_table_header_link('got_voucher', __('Voucher'), $order_by),
|
||||
'freeloads' => __('Freeloads'),
|
||||
'Aktiv' => Users_table_header_link('Aktiv', __('Active'), $order_by),
|
||||
'active' => Users_table_header_link('active', __('Active'), $order_by),
|
||||
'force_active' => Users_table_header_link('force_active', __('Forced'), $order_by),
|
||||
'Tshirt' => Users_table_header_link('Tshirt', __('T-Shirt'), $order_by),
|
||||
'Size' => Users_table_header_link('Size', __('Size'), $order_by),
|
||||
'lastLogIn' => Users_table_header_link('lastLogIn', __('Last login'), $order_by),
|
||||
'got_shirt' => Users_table_header_link('got_shirt', __('T-Shirt'), $order_by),
|
||||
'shirt_size' => Users_table_header_link('shirt_size', __('Size'), $order_by),
|
||||
'last_login_at' => Users_table_header_link('last_login_at', __('Last login'), $order_by),
|
||||
'actions' => ''
|
||||
], $usersList)
|
||||
]);
|
||||
|
@ -282,24 +281,16 @@ function Users_table_header_link($column, $label, $order_by)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param User|array $user
|
||||
* @param User $user
|
||||
* @return string|false
|
||||
*/
|
||||
function User_shift_state_render($user)
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$id = $user->id;
|
||||
$arrived = $user->state->arrived;
|
||||
} else {
|
||||
$arrived = $user['Gekommen'];
|
||||
$id = $user['UID'];
|
||||
}
|
||||
|
||||
if (!$arrived) {
|
||||
if (!$user->state->arrived) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($id);
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user->id);
|
||||
if (empty($upcoming_shifts)) {
|
||||
return '<span class="text-success">' . __('Free') . '</span>';
|
||||
}
|
||||
|
@ -735,7 +726,7 @@ function User_view_state_admin($freeloader, $user_source)
|
|||
} elseif ($user_source->state->active) {
|
||||
$state[] = '<span class="text-success">' . __('Active') . '</span>';
|
||||
}
|
||||
if ($user_source->personalData->shirt_size) {
|
||||
if ($user_source->state->got_shirt) {
|
||||
$state[] = '<span class="text-success">' . __('T-Shirt') . '</span>';
|
||||
}
|
||||
} else {
|
||||
|
@ -844,20 +835,14 @@ function User_groups_render($user_groups)
|
|||
*/
|
||||
function User_Nick_render($user)
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$id = $user->id;
|
||||
$name = $user->name;
|
||||
$arrived = $user->state->arrived;
|
||||
} else {
|
||||
$id = $user['UID'];
|
||||
$name = $user['Nick'];
|
||||
$arrived = $user['Gekommen'];
|
||||
if (is_array($user)) {
|
||||
$user = (new User())->forceFill($user);
|
||||
}
|
||||
|
||||
return render_profile_link(
|
||||
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($name) . '</a>',
|
||||
$id,
|
||||
($arrived ? '' : 'text-muted')
|
||||
'<span class="icon-icon_angel"></span> ' . htmlspecialchars($user->name) . '</a>',
|
||||
$user->id,
|
||||
($user->state->arrived ? '' : 'text-muted')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -917,9 +902,7 @@ function render_user_freeloader_hint()
|
|||
*/
|
||||
function render_user_arrived_hint()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (!$user->state->arrived) {
|
||||
if (!auth()->user()->state->arrived) {
|
||||
/** @var Carbon $buildup */
|
||||
$buildup = config('buildup_start');
|
||||
if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
|
||||
|
@ -935,9 +918,7 @@ function render_user_arrived_hint()
|
|||
*/
|
||||
function render_user_tshirt_hint()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (config('enable_tshirt_size') && !$user->personalData->shirt_size) {
|
||||
if (config('enable_tshirt_size') && !auth()->user()->personalData->shirt_size) {
|
||||
$text = __('You need to specify a tshirt size in your settings!');
|
||||
return render_profile_link($text, null, 'alert-link');
|
||||
}
|
||||
|
@ -951,7 +932,6 @@ function render_user_tshirt_hint()
|
|||
function render_user_dect_hint()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->state->arrived && !$user->contact->dect) {
|
||||
$text = __('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
|
||||
return render_profile_link($text, null, 'alert-link');
|
||||
|
|
|
@ -22,6 +22,11 @@ class State extends HasUserModel
|
|||
/** @var string The table associated with the model */
|
||||
protected $table = 'users_state';
|
||||
|
||||
/** @var array The attributes that should be mutated to dates */
|
||||
protected $dates = [
|
||||
'arrival_date',
|
||||
];
|
||||
|
||||
/** The attributes that are mass assignable */
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
|
|
Loading…
Reference in New Issue