Skip to content

Commit

Permalink
Merge pull request #56 from SolidCharity/TP-202010-separate_names
Browse files Browse the repository at this point in the history
add option to enter firstname separate from surname
  • Loading branch information
tpokorra authored Oct 19, 2020
2 parents 3e07974 + 76a30cc commit 0408832
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function index(Request $request)
$churchname = $tenant->name;
$collect_contact_details_checked = ($tenant->collect_contact_details?"checked":"");
$option_to_report_contact_details_checked = ($tenant->option_to_report_contact_details?"checked":"");
$option_for_separate_firstname_checked = ($tenant->option_for_separate_firstname?"checked":"");
$text_for_signup_for_closed_event = $tenant->text_for_signup_for_closed_event;
if ($text_for_signup_for_closed_event == 'error_registration_closed') {
$text_for_signup_for_closed_event = __('messages.error_registration_closed');
Expand All @@ -56,6 +57,7 @@ public function index(Request $request)
return view('admin', ['services' => $services,
'participants' => $participants, 'link_visitors' => $visitor_link, 'churchname' => $churchname,
'collect_contact_details_checked' => $collect_contact_details_checked,
'option_for_separate_firstname_checked' => $option_for_separate_firstname_checked,
'option_to_report_contact_details_checked' => $option_to_report_contact_details_checked,
'text_for_signup_for_closed_event' => $text_for_signup_for_closed_event,
]);
Expand Down Expand Up @@ -171,6 +173,27 @@ public function updateOptionToReportContactDetails(Request $request)
return redirect('/admin');
}

/// update the flag to allow the option for a separate firstname for this tenant
public function updateOptionForSeparateFirstname(Request $request)
{
$tenant_id = Auth::user()->tenant_id;

$data = $request->validate([
'option_for_separate_firstname' => 'boolean',
]);

if (empty($data['option_for_separate_firstname'])) {
$data = array('option_for_separate_firstname' => '0');
}

$tenant = \App\Tenant::
where('id',$tenant_id)->first();
$tenant->option_for_separate_firstname = $data['option_for_separate_firstname'];
$tenant->save();

return redirect('/admin');
}

/// update the text that is displayed if someone tries to signup for an event with closed registration
public function updateTextForSignupForClosedEvent(Request $request)
{
Expand Down
7 changes: 7 additions & 0 deletions app/Http/Controllers/FrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function index(Request $request)
$display['registered'] = array();
$display['collect_contact_details'] = $tenant->collect_contact_details;
$display['option_to_report_contact_details'] = $tenant->option_to_report_contact_details;
$display['option_for_separate_firstname'] = $tenant->option_for_separate_firstname;

$registered_service = "";
if (isset($_COOKIE['where2ormore_registration']) && !empty($_COOKIE['where2ormore_registration']))
Expand Down Expand Up @@ -143,6 +144,7 @@ public function store(Request $request)
{
$data = $request->validate([
'name' => 'required|max:255',
'firstname' => 'max:255',
'service_id' => 'required|integer',
'uuid' => 'required|uuid',
'count_adults' => 'required|integer',
Expand All @@ -152,6 +154,11 @@ public function store(Request $request)
'report_details' => 'integer',
]);

if (array_key_exists('firstname', $data))
{
$data['name'] = $data['firstname']." ".$data['name'];
}

if (isset($_COOKIE['where2ormore_registration']) && !empty($_COOKIE['where2ormore_registration']))
{
// reuse existing cookie
Expand Down
33 changes: 33 additions & 0 deletions database/migrations/2020_10_19_193655_separate_names.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class SeparateNames extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tenants', function ($table) {
$table->boolean('option_for_separate_firstname')->default(false);
});
Schema::table('participants', function ($table) {
$table->string('firstname')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
3 changes: 3 additions & 0 deletions resources/lang/de/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
return [
'pagetitle' => 'Gottesdienst Planer',
'my_name' => 'Mein Name',
'my_firstname' => 'Mein Vorname',
'my_surname' => 'Mein Nachname',
'my_address' => 'Meine Anschrift',
'my_phone' => 'Meine Telefonnummer',
'report_details' => 'Meine Daten dürfen auf der gedruckten Teilnehmerliste erscheinen',
'collect_contact_details' => 'Adresse und Telefonnummer der Besucher erfassen',
'option_for_separate_firstname' => 'Vorname und Nachname getrennt erfassen',
'option_to_report_contact_details' => 'Besucher dürfen entscheiden, ob sie nicht auf dem Bericht enthalten sein wollen',
'text_for_signup_for_closed_event' => 'Zeige diesen Text, falls die Anmeldung bereits geschlossen ist',
'service' => 'Gottesdienst',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
return [
'pagetitle' => 'Service Planner',
'my_name' => 'My name',
'my_firstname' => 'My first name',
'my_surname' => 'My surname',
'my_address' => 'My address',
'my_phone' => 'My phone number',
'report_details' => 'Include my details on the official participants list',
'collect_contact_details' => 'Collect the address and phone number of visitors',
'option_for_separate_firstname' => 'Firstname and Surname must be entered separately',
'option_to_report_contact_details' => 'Give visitors the option to opt-out of being included on the report',
'text_for_signup_for_closed_event' => 'Show this message if the application is closed already',
'service' => 'Service',
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/nl/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
return [
'pagetitle' => 'Dienstplanner',
'my_name' => 'My name',
'my_firstname' => 'My first name',
'my_surname' => 'My surname',
'my_address' => 'My address',
'my_phone' => 'My phone number',
'report_details' => 'Include my details on the official participants list',
'collect_contact_details' => 'Collect the address and phone number of visitors',
'option_for_separate_firstname' => 'Firstname and Surname must be entered separately',
'option_to_report_contact_details' => 'Give visitors the option to opt-out of being included on the report',
'text_for_signup_for_closed_event' => 'Show this message if the application is closed already',
'service' => 'Dienst',
Expand Down
13 changes: 13 additions & 0 deletions resources/views/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@
</form>
</tr>
<tr>
<form method="post" action="{{ route('updateOptionForSeparateFirstname') }}">
@method('PATCH')
@csrf
<td style="width:70%" colspan="2">
<input type="checkbox" name="option_for_separate_firstname" id="option_for_separate_firstname" value="1" {{$option_for_separate_firstname_checked}}>
<label for="option_for_separate_firstname">@lang('messages.option_for_separate_firstname')</label>
</td>
<td>
<button type="submit" class="btn btn-primary">@lang('messages.save')</button>
</td>
</form>
</tr>
<tr>
<form method="post" action="{{ route('updateOptionToReportContactDetails') }}">
@method('PATCH')
@csrf
Expand Down
7 changes: 7 additions & 0 deletions resources/views/frontend.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,15 @@
</div>
<fieldset class="field">
<!-- Here i added this Label tag so i can apply the styles to the text also -->
@if ($option_for_separate_firstname)
<label class="name-input" for="firstname" id="firstname">@lang('messages.my_firstname'):</label>
<input class="name-input" type="text" id="firstname" name="firstname" required value="{{old('firstname')}}"><br/>
<label class="name-input" for="name" id="name">@lang('messages.my_surname'):</label>
<input class="name-input" type="text" id="name" name="name" required value="{{old('name')}}"><br/>
@else
<label class="name-input" for="name" id="name">@lang('messages.my_name'):</label>
<input class="name-input" type="text" id="name" name="name" required value="{{old('name')}}"><br/>
@endif
@if ($collect_contact_details)
<label class="name-input" for="address">@lang('messages.my_address'):</label>
<input class="name-input" type="text" id="address" name="address" required value="{{old('address')}}"><br/>
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function ($service_id = null) {
Route::patch('tenants2', 'AdminController@updateCollectContactDetails')->name('updateCollectContactDetails');
Route::patch('tenants3', 'AdminController@updateOptionToReportContactDetails')->name('updateOptionToReportContactDetails');
Route::patch('tenants4', 'AdminController@updateTextForSignupForClosedEvent')->name('updateTextForSignupForClosedEvent');
Route::patch('tenants5', 'AdminController@updateOptionForSeparateFirstname')->name('updateOptionForSeparateFirstname');
Route::delete('participants2', 'FrontendController@cancelregistration')->name('cancelregistration');

# only allow register if there is no user yet
Expand Down

0 comments on commit 0408832

Please sign in to comment.