Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ETA Button with notifications, flash feedback and localization #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion assets/css/kds.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
max-width: 320px;
}

}
}
input[type="text"] {
width: 320px;
}
42 changes: 42 additions & 0 deletions controllers/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
use Admin\Models\Staffs_model;
use Admin\Models\Statuses_model;
use Carbon\Carbon;
use DateTime;
use Igniter\Flame\Exception\ApplicationException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use Illuminate\Http\RedirectResponse;
use Thoughtco\KitchenDisplay\Models\Views as KitchenViews;

/**
Expand Down Expand Up @@ -279,4 +281,44 @@ public function view($route, $viewId)

}

public function contact(): RedirectResponse
{
$orderId = Request::get('orderId', -1);
$eta = Request::get('eta', '45');

// get newest order
/** @var Orders_model $order */
$order = Orders_model::where('order_id', $orderId)->first();
$order->updateOrderStatus(
$order->status_id,
[
'comment' => sprintf(lang('lang:thoughtco.kitchendisplay::default.eta'), $eta),
'notify' => false,
]
);

// check if ETA is valid
$etaDateTime = (new DateTime())->modify('+' . $eta . ' minutes');
$orderDateTime = DateTime::createFromFormat('Y-m-d H:i:s', $order->order_date->format('Y-m-d') . ' ' . $order->order_time);
// flash()->info($orderDateTime->format('Y-m-d H:i:s'));
if (! $order->order_time_is_asap && $etaDateTime < $orderDateTime)
{
flash()->warning(lang('lang:thoughtco.kitchendisplay::default.eta_too_low'))->now();
return back();
}

// send mail to customer
$mailView = 'admin::_mail.order_update ';
$order->mailSend($mailView, 'customer');

// flash success message in kitchen display

$order->order_date = $etaDateTime->format('Y-m-d');
$order->order_time = $etaDateTime->format('H:i');
$order->save();
flash()->success(sprintf(lang('lang:thoughtco.kitchendisplay::default.eta_success'), $eta))->now();

return back();
}

}
8 changes: 8 additions & 0 deletions language/de/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'eta' => 'Die geschätzte Wartezeit für Ihre Bestellung beträgt %d Minuten.',
'eta_too_low' => 'Die Wartezeit ist niedriger als vom Kunden angegeben! Wurde die Wunschzeit beachtet?',
'eta_success' => 'Successfully set ETA to %d minutes',
'btn_eta' => 'Wartezeit erfolgreich auf %d Minuten angegeben',
];
5 changes: 5 additions & 0 deletions language/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'label_card_status' => 'Show status',
'label_card_items' => 'Show menu items',
'label_card_assign' => 'Show assign',
'label_card_eta' => 'Show ETA combo box',
'label_card_print' => 'Show print',

'option_blank' => 'Blank',
Expand Down Expand Up @@ -81,4 +82,8 @@
'value_delivery' => 'Delivery only',
'value_collection' => 'Collection only',

'eta' => 'The estimated time of arrival for your order is %d minutes',
'eta_too_low' => 'The ETA is earlier than the time requested. Did you take the reservation time into account?',
'eta_success' => 'Successfully set ETA to %d minutes',
'btn_eta' => 'Send ETA'
];
6 changes: 6 additions & 0 deletions models/config/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@
'type' => 'switch',
'default' => FALSE,
],
'display[eta]' => [
'tab' => 'lang:thoughtco.kitchendisplay::default.tab_cards',
'label' => 'thoughtco.kitchendisplay::default.label_card_eta',
'type' => 'switch',
'default' => FALSE,
]
]
]
],
Expand Down
16 changes: 14 additions & 2 deletions views/summary/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@
@if($viewSettings->display['card_status'])
<h6 class="label label-default mt-2" style="background-color:{!! $order->status_color !!}!important">{{ $order->status_name }}</h6>
@endif

@if(array_key_exists('eta', $viewSettings->display) && $viewSettings->display['eta'])
<form action="{{ admin_url('thoughtco/kitchendisplay/summary/contact') }}" method="GET">
<input type="hidden" name="orderId" value="{{ $order->id }}" />
<select name="eta" id="eta">
<option value="15">15 min</option>
<option value="30">30 min</option>
<option value="45">45 min</option>
<option value="60">60 min</option>
<option value="90">90 min</option>
</select>
<button type="submit" class="btn btn-primary">@lang('thoughtco.kitchendisplay::default.btn_eta')</button>
</form>
@endif
@if($viewSettings->display['card_items'])
<div>
@foreach ($order->dishes as $dish)
Expand All @@ -67,7 +79,7 @@
@endif
</div>
@endif

@if($order->print != '')
<div class="mt-4">
@if (count($order->print) > 1)
Expand Down