fixes #549: fill missing arrival dates and prevent setting arrival by admin-user instead of admin-arrive

This commit is contained in:
msquare 2018-12-27 19:08:35 +01:00
parent 689735ad51
commit db26412e6c
4 changed files with 33 additions and 5 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
use Engelsystem\Models\User\State;
class FixMissingArrivalDates extends Migration
{
/**
* Run the migration
*/
public function up()
{
$states = State::whereArrived(true)->whereArrivalDate(null)->get();
foreach($states as $state) {
$state->arrival_date = $state->user->personalData->planned_arrival_date;
$state->save();
}
}
/**
* Down is not possible and not needed since this is a bugfix.
*/
public function down()
{}
}

View File

@ -5,7 +5,6 @@ use Engelsystem\Database\DB;
use Engelsystem\Models\User\PasswordReset;
use Engelsystem\Models\User\User;
use Engelsystem\ValidationResult;
use Illuminate\Database\Query\JoinClause;
/**
* User model

View File

@ -75,7 +75,12 @@ function admin_user()
// Gekommen?
$html .= ' <tr><td>Gekommen</td><td>' . "\n";
$html .= html_options('eGekommen', $options, $user_source->state->arrived) . '</td></tr>' . "\n";
if($user_source->state->arrived) {
$html .= _('Yes');
} else {
$html .= _('No');
}
$html .= '</td></tr>' . "\n";
// Aktiv?
$html .= ' <tr><td>Aktiv</td><td>' . "\n";
@ -263,7 +268,6 @@ function admin_user()
$user_source->contact->mobile = $request->postData('eHandy');
$user_source->contact->dect = $request->postData('eDECT');
$user_source->contact->save();
$user_source->state->arrived = $request->postData('eGekommen');
$user_source->state->active = $request->postData('eAktiv');
$user_source->state->force_active = $force_active;
$user_source->state->got_shirt = $request->postData('eTshirt');
@ -271,7 +275,6 @@ function admin_user()
engelsystem_log(
'Updated user: ' . $request->postData('eNick') . ', ' . $request->postData('eSize')
. ', arrived: ' . $request->postData('eVorname')
. ', active: ' . $request->postData('eAktiv')
. ', tshirt: ' . $request->postData('eTshirt')
);

View File

@ -32,7 +32,6 @@ class PersonalData extends HasUserModel
'first_name',
'last_name',
'shirt_size',
'arrival_date',
'planned_arrival_date',
'planned_departure_date',
];