Skip to content

Commit

Permalink
nota su altre prenotazioni da ritirare nella giornata. ref #289
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Nov 9, 2024
1 parent b7d3266 commit 2f18b0e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/app/BookedProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function getValue($type)

public function getFinalUnitPrice()
{
if ($this->delivered) {
if ($this->delivered > 0) {
return $this->final_price / $this->delivered;
}
else {
Expand Down
2 changes: 2 additions & 0 deletions code/app/Printers/Concerns/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function formatShipping($order, $fields, $status, $shipping_place, $extra
'products' => [],
'totals' => [],
'notes' => !empty($booking->notes) ? [$booking->notes] : [],

'others' => $booking->user->morePendingBookings($order->aggregate),
];

foreach($booking->products_with_friends as $booked) {
Expand Down
27 changes: 27 additions & 0 deletions code/app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,33 @@ public function initialWelcome()
}
}

/*
Genera la notifica relativa ad altre prenotazioni (oltre a quella
dell'aggregato specificato) che devono essere ritirate dall'utente nel
corso della giornata. Viene aggiunta nel pannello delle consegne e nel
Dettaglio Consegne PDF
*/
public function morePendingBookings($aggregate)
{
$other_bookings = $this->bookings()->where('status', 'pending')->whereHas('order', function($query) use ($aggregate) {
$query->where('aggregate_id', '!=', $aggregate->id)->where('shipping', $aggregate->shipping);
})->get();

if ($other_bookings->isEmpty() == false) {
$notice = _i('Questa persona oggi deve ritirare anche altre prenotazioni:');
$notice .= '<ul>';

foreach ($other_bookings as $ob) {
$notice .= '<li>' . $ob->order->printableName() . '</li>';
}

$notice .= '</ul>';
return $notice;
}

return null;
}

/************************************************************ SluggableID */

public function getSlugID()
Expand Down
13 changes: 3 additions & 10 deletions code/resources/views/delivery/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
$master_summary = $aggregate->reduxData();
$currency_symbol = defaultCurrency()->symbol;
$other_bookings = $user->bookings()->where('status', 'pending')->whereHas('order', function($query) use ($aggregate) {
$query->where('aggregate_id', '!=', $aggregate->id)->where('shipping', $aggregate->shipping);
})->get();
$other_bookings = $user->morePendingBookings($aggregate);
/*
In fase di consegna, aggrego sempre tutte le quantità
Expand Down Expand Up @@ -47,16 +45,11 @@
</div>
</div>

@if($other_bookings->count())
@if($other_bookings)
<div class="row mt-1">
<div class="col">
<div class="alert alert-info">
{{ _i('Questa persona oggi deve ritirare anche altre prenotazioni:') }}
<ul>
@foreach($other_bookings as $ob)
<li>{{ $ob->order->printableName() }}</li>
@endforeach
</ul>
{!! $other_bookings !!}
</div>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions code/resources/views/documents/order_shipping_pdf.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
padding: 4px 0;
width: 100%;
}
ul {
margin: 0;
}
li {
margin: 0;
}
</style>
</head>

Expand Down Expand Up @@ -139,6 +147,10 @@
?>
</div>

@if($d->others)
<div class="extended">{!! $d->others !!}</div>
@endif

<div class="main-wrapper">
@foreach($d->products as $product)
<div class="row">
Expand Down

0 comments on commit 2f18b0e

Please sign in to comment.