Moved arrival_date to state
This commit is contained in:
parent
4e09ee3eb2
commit
57932be428
|
@ -42,7 +42,6 @@ class CreateUsersTables extends Migration
|
||||||
$table->string('shirt_size', 4)->nullable();
|
$table->string('shirt_size', 4)->nullable();
|
||||||
|
|
||||||
$table->date('planned_arrival_date')->nullable();
|
$table->date('planned_arrival_date')->nullable();
|
||||||
$table->dateTime('arrival_date')->nullable();
|
|
||||||
$table->date('planned_departure_date')->nullable();
|
$table->date('planned_departure_date')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,6 +66,7 @@ class CreateUsersTables extends Migration
|
||||||
$this->referencesUser($table);
|
$this->referencesUser($table);
|
||||||
|
|
||||||
$table->boolean('arrived')->default(false);
|
$table->boolean('arrived')->default(false);
|
||||||
|
$table->dateTime('arrival_date')->nullable();
|
||||||
$table->boolean('active')->default(false);
|
$table->boolean('active')->default(false);
|
||||||
$table->boolean('force_active')->default(false);
|
$table->boolean('force_active')->default(false);
|
||||||
$table->boolean('got_shirt')->default(false);
|
$table->boolean('got_shirt')->default(false);
|
||||||
|
@ -114,7 +114,6 @@ class CreateUsersTables extends Migration
|
||||||
'last_name' => $data->Name ?: null,
|
'last_name' => $data->Name ?: null,
|
||||||
'shirt_size' => $data->Size ?: null,
|
'shirt_size' => $data->Size ?: null,
|
||||||
'planned_arrival_date' => $data->planned_arrival_date ? Carbon::createFromTimestamp($data->planned_arrival_date) : null,
|
'planned_arrival_date' => $data->planned_arrival_date ? Carbon::createFromTimestamp($data->planned_arrival_date) : null,
|
||||||
'arrival_date' => $data->arrival_date ? Carbon::createFromTimestamp($data->arrival_date) : null,
|
|
||||||
'planned_departure_date' => $data->planned_departure_date ? Carbon::createFromTimestamp($data->planned_departure_date) : null,
|
'planned_departure_date' => $data->planned_departure_date ? Carbon::createFromTimestamp($data->planned_departure_date) : null,
|
||||||
]);
|
]);
|
||||||
$personalData->user()
|
$personalData->user()
|
||||||
|
@ -133,6 +132,7 @@ class CreateUsersTables extends Migration
|
||||||
|
|
||||||
$state = new State([
|
$state = new State([
|
||||||
'arrived' => $data->Gekommen,
|
'arrived' => $data->Gekommen,
|
||||||
|
'arrival_date' => $data->arrival_date ? Carbon::createFromTimestamp($data->arrival_date) : null,
|
||||||
'active' => $data->Aktiv,
|
'active' => $data->Aktiv,
|
||||||
'force_active' => $data->force_active,
|
'force_active' => $data->force_active,
|
||||||
'got_shirt' => $data->Tshirt,
|
'got_shirt' => $data->Tshirt,
|
||||||
|
@ -242,7 +242,7 @@ class CreateUsersTables extends Migration
|
||||||
'CreateDate' => $user->created_at ? $user->created_at->toDateTimeString() : null,
|
'CreateDate' => $user->created_at ? $user->created_at->toDateTimeString() : null,
|
||||||
'api_key' => $user->api_key,
|
'api_key' => $user->api_key,
|
||||||
'got_voucher' => $state->got_voucher,
|
'got_voucher' => $state->got_voucher,
|
||||||
'arrival_date' => $personal->arrival_date ? $personal->arrival_date->getTimestamp() : null,
|
'arrival_date' => $state->arrival_date ? $state->arrival_date->getTimestamp() : null,
|
||||||
'planned_arrival_date' => $personal->planned_arrival_date ? $personal->planned_arrival_date->getTimestamp() : null,
|
'planned_arrival_date' => $personal->planned_arrival_date ? $personal->planned_arrival_date->getTimestamp() : null,
|
||||||
'planned_departure_date' => $personal->planned_departure_date ? $personal->planned_departure_date->getTimestamp() : null,
|
'planned_departure_date' => $personal->planned_departure_date ? $personal->planned_departure_date->getTimestamp() : null,
|
||||||
'email_by_human_allowed' => $settings->email_human,
|
'email_by_human_allowed' => $settings->email_human,
|
||||||
|
|
|
@ -29,9 +29,8 @@ function admin_arrive()
|
||||||
$user_source = User::find($user_id);
|
$user_source = User::find($user_id);
|
||||||
if ($user_source) {
|
if ($user_source) {
|
||||||
$user_source->state->arrived = false;
|
$user_source->state->arrived = false;
|
||||||
|
$user_source->state->arrival_date = null;
|
||||||
$user_source->state->save();
|
$user_source->state->save();
|
||||||
$user_source->personalData->arrival_date = null;
|
|
||||||
$user_source->personalData->save();
|
|
||||||
|
|
||||||
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
|
engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
|
||||||
success(__('Reset done. Angel has not arrived.'));
|
success(__('Reset done. Angel has not arrived.'));
|
||||||
|
@ -44,8 +43,7 @@ function admin_arrive()
|
||||||
$user_source = User::find($user_id);
|
$user_source = User::find($user_id);
|
||||||
if ($user_source) {
|
if ($user_source) {
|
||||||
$user_source->state->arrived = true;
|
$user_source->state->arrived = true;
|
||||||
$user_source->state->save();
|
$user_source->state->arrival_date = new Carbon\Carbon();
|
||||||
$user_source->personalData->arrival_date = new Carbon\Carbon();
|
|
||||||
$user_source->personalData->save();
|
$user_source->personalData->save();
|
||||||
|
|
||||||
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
|
engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
|
||||||
|
@ -89,7 +87,7 @@ function admin_arrive()
|
||||||
$usr['rendered_planned_departure_date'] = '-';
|
$usr['rendered_planned_departure_date'] = '-';
|
||||||
}
|
}
|
||||||
$usr['rendered_planned_arrival_date'] = $usr->personalData->planned_arrival_date->format('Y-m-d');
|
$usr['rendered_planned_arrival_date'] = $usr->personalData->planned_arrival_date->format('Y-m-d');
|
||||||
$usr['rendered_arrival_date'] = $usr->personalData->arrival_date ? $usr->personalData->arrival_date->format('Y-m-d') : '-';
|
$usr['rendered_arrival_date'] = $usr->state->arrival_date ? $usr->state->arrival_date->format('Y-m-d') : '-';
|
||||||
$usr['arrived'] = $usr->state->arrived ? __('yes') : '';
|
$usr['arrived'] = $usr->state->arrived ? __('yes') : '';
|
||||||
$usr['actions'] = $usr->state->arrived == 1
|
$usr['actions'] = $usr->state->arrived == 1
|
||||||
? '<a href="' . page_link_to(
|
? '<a href="' . page_link_to(
|
||||||
|
@ -101,8 +99,8 @@ function admin_arrive()
|
||||||
['arrived' => $usr->id, 'search' => $search]
|
['arrived' => $usr->id, 'search' => $search]
|
||||||
) . '">' . __('arrived') . '</a>';
|
) . '">' . __('arrived') . '</a>';
|
||||||
|
|
||||||
if ($usr->personalData->arrival_date) {
|
if ($usr->state->arrival_date) {
|
||||||
$day = $usr->personalData->arrival_date->format('Y-m-d');
|
$day = $usr->state->arrival_date->format('Y-m-d');
|
||||||
if (!isset($arrival_count_at_day[$day])) {
|
if (!isset($arrival_count_at_day[$day])) {
|
||||||
$arrival_count_at_day[$day] = 0;
|
$arrival_count_at_day[$day] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
||||||
|
|
||||||
if ($request->has('planned_departure_date')) {
|
if ($request->has('planned_departure_date')) {
|
||||||
$tmp = parse_date('Y-m-d H:i', $request->input('planned_departure_date') . ' 00:00');
|
$tmp = parse_date('Y-m-d H:i', $request->input('planned_departure_date') . ' 00:00');
|
||||||
$result = User_validate_planned_departure_date($user_source->personalData->arrival_date->getTimestamp(), $tmp);
|
$result = User_validate_planned_departure_date($user_source->state->arrival_date->getTimestamp(), $tmp);
|
||||||
$user_source->personalData->planned_departure_date = Carbon::createFromTimestamp($result->getValue());
|
$user_source->personalData->planned_departure_date = Carbon::createFromTimestamp($result->getValue());
|
||||||
if (!$result->isValid()) {
|
if (!$result->isValid()) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
|
|
@ -25,6 +25,7 @@ function User_settings_view(
|
||||||
$tshirt_sizes
|
$tshirt_sizes
|
||||||
) {
|
) {
|
||||||
$personalData = $user_source->personalData;
|
$personalData = $user_source->personalData;
|
||||||
|
$state = $user_source->state;
|
||||||
return page_with_title(settings_title(), [
|
return page_with_title(settings_title(), [
|
||||||
msg(),
|
msg(),
|
||||||
div('row', [
|
div('row', [
|
||||||
|
@ -38,7 +39,7 @@ function User_settings_view(
|
||||||
form_date(
|
form_date(
|
||||||
'planned_arrival_date',
|
'planned_arrival_date',
|
||||||
__('Planned date of arrival') . ' ' . entry_required(),
|
__('Planned date of arrival') . ' ' . entry_required(),
|
||||||
$personalData->arrival_date ? $personalData->arrival_date->getTimestamp() : '',
|
$state->arrival_date ? $state->arrival_date->getTimestamp() : '',
|
||||||
$buildup_start_date,
|
$buildup_start_date,
|
||||||
$teardown_end_date
|
$teardown_end_date
|
||||||
),
|
),
|
||||||
|
@ -726,7 +727,7 @@ function User_view_state_admin($freeloader, $user_source)
|
||||||
$state[] = '<span class="text-success">' . glyph('home')
|
$state[] = '<span class="text-success">' . glyph('home')
|
||||||
. sprintf(
|
. sprintf(
|
||||||
__('Arrived at %s'),
|
__('Arrived at %s'),
|
||||||
$user_source->personalData->arrival_date ? $user_source->personalData->arrival_date->format('Y-m-d') : ''
|
$user_source->state->arrival_date ? $user_source->state->arrival_date->format('Y-m-d') : ''
|
||||||
)
|
)
|
||||||
. '</span>';
|
. '</span>';
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,12 @@ namespace Engelsystem\Models\User;
|
||||||
* @property string $first_name
|
* @property string $first_name
|
||||||
* @property string $last_name
|
* @property string $last_name
|
||||||
* @property string $shirt_size
|
* @property string $shirt_size
|
||||||
* @property \Carbon\Carbon $arrival_date
|
|
||||||
* @property \Carbon\Carbon $planned_arrival_date
|
* @property \Carbon\Carbon $planned_arrival_date
|
||||||
* @property \Carbon\Carbon $planned_departure_date
|
* @property \Carbon\Carbon $planned_departure_date
|
||||||
*
|
*
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereFirstName($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereFirstName($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereLastName($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereLastName($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereShirtSize($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereShirtSize($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData whereArrivalDate($value)
|
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData wherePlannedArrivalDate($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData wherePlannedArrivalDate($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData wherePlannedDepartureDate($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\PersonalData wherePlannedDepartureDate($value)
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +22,6 @@ class PersonalData extends HasUserModel
|
||||||
|
|
||||||
/** @var array The attributes that should be mutated to dates */
|
/** @var array The attributes that should be mutated to dates */
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'arrival_date',
|
|
||||||
'planned_arrival_date',
|
'planned_arrival_date',
|
||||||
'planned_departure_date',
|
'planned_departure_date',
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
namespace Engelsystem\Models\User;
|
namespace Engelsystem\Models\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property bool $arrived
|
* @property bool $arrived
|
||||||
* @property bool $active
|
* @property \Carbon\Carbon $arrival_date
|
||||||
* @property bool $force_active
|
* @property bool $active
|
||||||
* @property bool $got_shirt
|
* @property bool $force_active
|
||||||
* @property int $got_voucher
|
* @property bool $got_shirt
|
||||||
|
* @property int $got_voucher
|
||||||
*
|
*
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereArrived($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereArrived($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereArrivalDate($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereActive($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereActive($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereForceActive($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereForceActive($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereGotShirt($value)
|
* @method static \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\State[] whereGotShirt($value)
|
||||||
|
@ -24,6 +26,7 @@ class State extends HasUserModel
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id',
|
'user_id',
|
||||||
'arrived',
|
'arrived',
|
||||||
|
'arrival_date',
|
||||||
'active',
|
'active',
|
||||||
'force_active',
|
'force_active',
|
||||||
'got_shirt',
|
'got_shirt',
|
||||||
|
|
Loading…
Reference in New Issue