Skip to content

Commit

Permalink
email per amici promossi a utenti. closes #234
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Nov 25, 2023
1 parent 726efae commit 95fc65b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions code/app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function revisioned(Request $request, $id)

public function promote(Request $request, $id)
{
return $this->easyExecute(function() use ($id) {
$subject = $this->service->promoteFriend($id);
return $this->easyExecute(function() use ($id, $request) {
$subject = $this->service->promoteFriend($request->all(), $id);
return $this->commonSuccessResponse($subject);
});
}
Expand Down
2 changes: 1 addition & 1 deletion code/app/Models/Concerns/ContactableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait ContactableTrait
{
public function contacts(): MorphMany
{
return $this->morphMany('App\Contact', 'target');
return $this->morphMany(Contact::class, 'target');
}

public function updateContacts($request)
Expand Down
7 changes: 6 additions & 1 deletion code/app/Services/UsersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function revisioned($id, $approved)
DB::commit();
}

public function promoteFriend($id)
public function promoteFriend($request, $id)
{
$admin = $this->ensureAuth(['users.admin' => 'gas']);

Expand All @@ -299,6 +299,11 @@ public function promoteFriend($id)
$user->parent_id = null;
$user->save();

$email = $request['email'] ?? null;
if ($email) {
$user->addContact('email', $email);
}

return $user;
}

Expand Down
16 changes: 16 additions & 0 deletions code/resources/views/commons/columns.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="btn-group order-columns-selector">
<button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown">
<i class="bi-layout-three-columns"></i>&nbsp;{{ _i('Colonne') }} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
@foreach($display_columns as $identifier => $metadata)
<li>
<div class="checkbox dropdown-item">
<label>
<input type="checkbox" value="{{ $identifier }}" {{ in_array($identifier, $columns) ? 'checked' : '' }}> {{ $metadata->label }}
</label>
</div>
</li>
@endforeach
</ul>
</div>
22 changes: 6 additions & 16 deletions code/resources/views/order/summary.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,12 @@
</ul>
</div>

<div class="btn-group order-columns-selector">
<button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown">
<i class="bi-layout-three-columns"></i>&nbsp;{{ _i('Colonne') }} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
@foreach($display_columns as $identifier => $metadata)
<li>
<div class="checkbox dropdown-item">
<label>
<input type="checkbox" value="{{ $identifier }}" {{ in_array($identifier, $columns) ? 'checked' : '' }}> {{ $metadata->label }}
</label>
</div>
</li>
@endforeach
</ul>
</div>&nbsp;
@include('commons.columns', [
'columns' => $columns,
'display_columns' => $display_columns,
])

&nbsp;

@include('commons.iconslegend', [
'class' => App\Product::class,
Expand Down
20 changes: 4 additions & 16 deletions code/resources/views/order/summary_ro.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,10 @@
<input type="text" class="form-control table-text-filter" data-table-target="#{{ $table_identifier }}" placeholder="{{ _i('Filtra') }}">
</div>

<div class="btn-group order-columns-selector">
<button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown">
<i class="bi-layout-three-columns"></i>&nbsp;{{ _i('Colonne') }} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
@foreach($display_columns as $identifier => $metadata)
<li>
<div class="checkbox dropdown-item">
<label>
<input type="checkbox" value="{{ $identifier }}" {{ in_array($identifier, $columns) ? 'checked' : '' }}> {{ $metadata->label }}
</label>
</div>
</li>
@endforeach
</ul>
</div>
@include('commons.columns', [
'columns' => $columns,
'display_columns' => $display_columns,
])
</div>
</div>

Expand Down
7 changes: 6 additions & 1 deletion code/resources/views/user/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$friend_admin_buttons = [
[
'label' => _i('Modifica Amico'),
'classes' => ['float-start', 'prevent-default'],
'classes' => ['float-start', 'prevent-default', 'me-2'],
'attributes' => ['data-bs-toggle' => 'modal', 'data-bs-target' => '#change_friend_' . $user->id]
]
];
Expand Down Expand Up @@ -165,6 +165,11 @@
<p>
{{ _i('Cliccando "Salva", questo utente diventerà un utente regolare. Gli sarà assegnato il ruolo %s, avrà una propria contabilità, e non potrà più essere amministrato da %s. Sarà preservato lo storico delle sue prenotazioni, ma tutti i suoi pagamenti pregressi resteranno addebitati a %s.', roleByIdentifier('user')->name, $user->parent->printableName(), $user->parent->printableName()) }}
</p>

@if(blank($user->email))
<hr>
<x-larastrap::email :label="_i('E-Mail')" name="email" :help="_i('È necessario specificare almeno un indirizzo email di contatto del nuovo utente')" required />
@endif
</x-larastrap::mform>
</x-larastrap::accordionitem>
<x-larastrap::accordionitem :label="_i('Cambia assegnazione')" active="false">
Expand Down

0 comments on commit 95fc65b

Please sign in to comment.