Skip to content

Commit 1398368

Browse files
committed
Improve admin order details design
Signed-off-by: Sam Poyigi <[email protected]>
1 parent 155e27c commit 1398368

File tree

9 files changed

+183
-185
lines changed

9 files changed

+183
-185
lines changed

app/admin/controllers/Orders.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,6 @@ public function invoice($context, $recordId = null)
109109
$this->suppressLayout = TRUE;
110110
}
111111

112-
public function formExtendFieldsBefore($form)
113-
{
114-
if (!array_key_exists('invoice_number', $form->tabs['fields']))
115-
return;
116-
117-
if (!$form->model->hasInvoice()) {
118-
array_pull($form->tabs['fields']['invoice_number'], 'addonRight');
119-
}
120-
else {
121-
$form->tabs['fields']['invoice_number']['addonRight']['attributes']['href'] = admin_url('orders/invoice/'.$form->model->getKey());
122-
}
123-
}
124-
125112
public function formExtendQuery($query)
126113
{
127114
$query->with([

app/admin/language/en/lang.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@
776776
'text_invoice_date' => 'Invoice Date',
777777
'text_order_date' => 'Order Date',
778778
'text_deliver_to' => 'Deliver to',
779+
'text_asap' => 'ASAP',
779780
'text_invoice_thank_you' => 'Thank you for your order',
780781
'text_collection_order_type' => 'This is a pick-up order',
781782
'text_no_payment' => 'No payment method selected',
@@ -799,6 +800,7 @@
799800
'column_notify' => 'Customer Notified',
800801
'column_name_option' => 'Name/Options',
801802
'column_price' => 'Price',
803+
'column_quantity' => 'Qty',
802804

803805
'label_order_id' => 'Order ID',
804806
'label_customer_name' => 'Customer Name',
@@ -808,9 +810,10 @@
808810
'label_time_is_asap' => 'Order Time Is Asap',
809811
'label_order_time' => 'Delivery/Pick-up Time',
810812
'label_order_date' => 'Delivery/Pick-up Date',
813+
'label_order_date_time' => 'Delivery/Pick-up Date Time',
811814
'label_date_added' => 'Date Added',
812815
'label_order_total' => 'Order Total',
813-
'label_comment' => 'Order Comment',
816+
'label_comment' => 'Notes',
814817
'label_date_modified' => 'Date Modified',
815818
'label_user_agent' => 'User Agent',
816819
'label_ip_address' => 'IP Address',

app/admin/models/config/orders_model.php

Lines changed: 14 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
'disabled' => TRUE,
191191
'path' => 'orders/form/info',
192192
'span' => 'left',
193+
'cssClass' => 'left',
193194
'context' => ['edit', 'preview'],
194195
],
195196
'status_id' => [
@@ -202,127 +203,25 @@
202203
$config['form']['tabs'] = [
203204
'defaultTab' => 'lang:admin::lang.orders.text_tab_general',
204205
'fields' => [
205-
'order_type_name' => [
206-
'label' => 'lang:admin::lang.orders.label_order_type',
207-
'type' => 'text',
208-
'span' => 'left',
209-
'cssClass' => 'flex-width',
210-
'disabled' => TRUE,
211-
'context' => ['edit', 'preview'],
212-
],
213-
'order_time_is_asap' => [
214-
'label' => 'lang:admin::lang.orders.label_time_is_asap',
215-
'type' => 'switch',
216-
'span' => 'left',
217-
'cssClass' => 'flex-width',
218-
'on' => 'lang:admin::lang.text_yes',
219-
'off' => 'lang:admin::lang.text_no',
220-
'disabled' => TRUE,
221-
'context' => ['edit', 'preview'],
222-
],
223-
'location[location_name]' => [
224-
'label' => 'lang:admin::lang.orders.text_restaurant',
225-
'type' => 'location',
226-
'disabled' => TRUE,
227-
'span' => 'right',
228-
'placeholder' => 'lang:admin::lang.text_please_select',
229-
],
230-
'order_date' => [
231-
'label' => 'lang:admin::lang.orders.label_order_date',
232-
'type' => 'datepicker',
233-
'disabled' => TRUE,
234-
'mode' => 'date',
235-
'span' => 'left',
236-
'cssClass' => 'flex-width',
237-
],
238-
'order_time' => [
239-
'label' => 'lang:admin::lang.orders.label_order_time',
240-
'type' => 'datepicker',
241-
'disabled' => TRUE,
242-
'mode' => 'time',
243-
'span' => 'left',
244-
'cssClass' => 'flex-width',
206+
'order_menus' => [
207+
'type' => 'partial',
208+
'path' => 'orders/form/order_menus',
245209
],
246-
'customer[full_name]' => [
210+
'customer' => [
247211
'label' => 'lang:admin::lang.orders.text_customer',
248-
'type' => 'customer',
249-
'disabled' => TRUE,
250-
'span' => 'right',
251-
],
252-
'delivery_address' => [
253-
'label' => 'lang:admin::lang.orders.label_delivery_address',
254-
'span' => 'left',
255-
'valueFrom' => 'formatted_address',
256-
'disabled' => TRUE,
257-
],
258-
'telephone' => [
259-
'label' => 'lang:admin::lang.orders.label_telephone',
260-
'type' => 'text',
261-
'disabled' => TRUE,
262-
'span' => 'right',
263-
'context' => ['edit', 'preview'],
264-
],
265-
'payment_method[name]' => [
266-
'label' => 'lang:admin::lang.orders.label_payment_method',
267-
'span' => 'left',
268-
'type' => 'text',
269-
'disabled' => TRUE,
270-
],
271-
'invoice_number' => [
272-
'label' => 'lang:admin::lang.orders.label_invoice',
273-
'type' => 'addon',
274-
'disabled' => TRUE,
275-
'span' => 'right',
276-
'context' => ['edit', 'preview'],
277-
'addonRight' => [
278-
'tag' => 'a',
279-
'label' => 'admin::lang.orders.button_print_invoice',
280-
'attributes' => [
281-
'class' => 'btn btn-outline-default',
282-
'target' => '_blank',
283-
],
284-
],
285-
],
286-
'comment' => [
287-
'label' => 'lang:admin::lang.orders.label_comment',
288-
'type' => 'textarea',
289-
'disabled' => TRUE,
290-
],
291-
'created_at' => [
292-
'label' => 'lang:admin::lang.orders.label_date_added',
293-
'type' => 'datepicker',
294-
'mode' => 'date',
295-
'disabled' => TRUE,
296-
'span' => 'left',
297-
'context' => ['edit', 'preview'],
298-
],
299-
'ip_address' => [
300-
'label' => 'lang:admin::lang.orders.label_ip_address',
301-
'type' => 'text',
302-
'disabled' => TRUE,
303-
'span' => 'right',
304-
'context' => ['edit', 'preview'],
305-
],
306-
'updated_at' => [
307-
'label' => 'lang:admin::lang.orders.label_date_modified',
308-
'type' => 'datepicker',
309-
'mode' => 'date',
310-
'span' => 'left',
311-
'disabled' => TRUE,
312-
'context' => ['edit', 'preview'],
212+
'type' => 'partial',
213+
'path' => 'orders/form/field_customer',
313214
],
314-
'user_agent' => [
315-
'label' => 'lang:admin::lang.orders.label_user_agent',
316-
'disabled' => TRUE,
317-
'type' => 'text',
318-
'span' => 'right',
319-
'context' => ['edit', 'preview'],
215+
'location' => [
216+
'label' => 'lang:admin::lang.orders.text_restaurant',
217+
'type' => 'partial',
218+
'path' => 'orders/form/field_location',
320219
],
321-
'order_menus' => [
322-
'tab' => 'lang:admin::lang.orders.text_tab_menu',
220+
'order_details' => [
323221
'type' => 'partial',
324-
'path' => 'orders/form/order_menus',
222+
'path' => 'orders/form/order_details',
325223
],
224+
326225
'status_history' => [
327226
'tab' => 'lang:admin::lang.orders.text_status_history',
328227
'type' => 'datatable',
Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
@php $fieldValue = sprintf('%s (%s)', $formModel->customer_name, $formModel->email) @endphp
2-
@if($this->previewMode)
3-
<p class="form-control-static">{{ $fieldValue ?: '&nbsp;' }}</p>
4-
@else
5-
<input
6-
type="text"
7-
name="{{ $field->getName() }}"
8-
id="{{ $field->getId() }}"
9-
value="{{ $fieldValue }}"
10-
placeholder="{{ $field->placeholder }}"
11-
class="form-control"
12-
autocomplete="off"
13-
{!! $field->hasAttribute('maxlength') ? '' : 'maxlength="255"' !!}
14-
{!! $field->getAttributes() !!}
15-
/>
1+
<div class="card-body">
2+
<h5 class="card-title">@lang($field->label)</h5>
3+
<div class="py-2 lead">
4+
@if ($formModel->customer)
5+
<a href="{{ admin_url('customers/preview/'.$formModel->customer_id) }}">{{ $formModel->customer_name }}</a>
6+
@else
7+
{{ $formModel->customer_name }}
8+
@endif
9+
</div>
10+
<div class="py-2">
11+
<i class="fa fa-envelope fa-fw text-muted"></i>&nbsp;&nbsp;
12+
{{ $formModel->email }}
13+
</div>
14+
<div class="py-2">
15+
<i class="fa fa-phone fa-fw text-muted"></i>&nbsp;&nbsp;
16+
{{ $formModel->telephone }}
17+
</div>
18+
</div>
19+
@if ($formModel->isDeliveryType())
20+
<div class="card-body border-top">
21+
<h5 class="card-title">@lang('admin::lang.orders.label_delivery_address')</h5>
22+
<div class="py-2">
23+
{!! format_address($formModel->address->toArray()) !!}
24+
</div>
25+
</div>
1626
@endif
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
@php
2-
$location = $formModel->location;
3-
$fieldValue = sprintf('%s (%s)', $location->location_name, format_address($location->getAddress(), false));
4-
@endphp
5-
@if($this->previewMode)
6-
<p class="form-control-static">{{ $fieldValue ?: '&nbsp;' }}</p>
7-
@else
8-
<input
9-
type="text"
10-
name="{{ $field->getName() }}"
11-
id="{{ $field->getId() }}"
12-
value="{{ $fieldValue }}"
13-
placeholder="{{ $field->placeholder }}"
14-
class="form-control"
15-
autocomplete="off"
16-
{!! $field->hasAttribute('maxlength') ? '' : 'maxlength="255"' !!}
17-
{!! $field->getAttributes() !!}
18-
/>
19-
@endif
1+
<div class="py-2">
2+
<p class="lead">{{ $formModel->location->location_name }}</p>
3+
{!! format_address($formModel->location->getAddress()) !!}
4+
</div>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@php
2+
$activeTab = $activeTab ? $activeTab : '#'.$tabs->section.'tab-1';
3+
@endphp
4+
<div class="tab-heading">
5+
<ul class="form-nav nav nav-tabs">
6+
@foreach ($tabs as $name => $fields)
7+
<li class="nav-item">
8+
<a
9+
class="nav-link{{ (('#'.$tabs->section.'tab-'.$loop->iteration) == $activeTab) ? ' active' : '' }}"
10+
href="{{ '#'.$tabs->section.'tab-'.$loop->iteration }}"
11+
data-toggle="tab"
12+
>@lang($name)</a>
13+
</li>
14+
@endforeach
15+
</ul>
16+
</div>
17+
18+
<div class="tab-content">
19+
@foreach ($tabs as $name => $fields)
20+
<div
21+
class="tab-pane {{ (('#'.$tabs->section.'tab-'.$loop->iteration) == $activeTab) ? 'active' : '' }}"
22+
id="{{ $tabs->section.'tab-'.$loop->iteration }}">
23+
<div class="form-fields">
24+
@if ($loop->iteration == 1)
25+
<div class="row w-100">
26+
<div class="col-md-9">
27+
@isset($fields['order_menus'])
28+
<div class="card bg-light shadow-sm mb-2 p-2">
29+
{!! $this->renderFieldElement($fields['order_menus']) !!}
30+
</div>
31+
@endisset
32+
@isset($fields['order_details'])
33+
<div class="card bg-light shadow-sm mb-2 p-2">
34+
{!! $this->renderFieldElement($fields['order_details']) !!}
35+
</div>
36+
@endisset
37+
</div>
38+
<div class="col-md-3 px-md-0">
39+
@if($formModel->comment)
40+
<div class="card bg-light shadow-sm mb-2">
41+
<div class="card-body">
42+
<h5 class="card-title">@lang('admin::lang.orders.label_comment')</h5>
43+
<p class="mb-0">{{ $formModel->comment }}</p>
44+
</div>
45+
</div>
46+
@endif
47+
<div class="card bg-light shadow-sm mb-2">
48+
@isset($fields['customer'])
49+
{!! $this->renderFieldElement($fields['customer']) !!}
50+
@endisset
51+
</div>
52+
@isset($fields['location'])
53+
<div class="card bg-light shadow-sm mb-2">
54+
<div class="card-body">
55+
<h5 class="card-title">@lang($fields['location']->label)</h5>
56+
{!! $this->renderFieldElement($fields['location']) !!}
57+
</div>
58+
</div>
59+
@endisset
60+
</div>
61+
</div>
62+
@else
63+
{!! $this->makePartial('form/form_fields', ['fields' => $fields]) !!}
64+
@endif
65+
</div>
66+
</div>
67+
@endforeach
68+
</div>

app/admin/views/orders/form/info.blade.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
</div>
88
<div class="mr-3 flex-fill text-center">
99
<label class="control-label">
10-
@lang('admin::lang.orders.label_total_items')
10+
@lang('admin::lang.orders.label_order_type')
1111
</label>
12-
<h3>{{ $formModel->total_items }}</h3>
12+
<h3>{{ $formModel->order_type_name }}</h3>
1313
</div>
14-
<div class="flex-fill text-center">
14+
<div class="mr-3 flex-fill text-center">
1515
<label class="control-label">
16-
@lang('admin::lang.orders.label_order_total')
16+
@lang('admin::lang.orders.label_order_date_time')
1717
</label>
18-
<h3>{{ currency_format($formModel->order_total) }}</h3>
18+
<h3>
19+
{{ $formModel->order_date_time->isoFormat(lang('system::lang.moment.date_time_format_short')) }}
20+
@if ($formModel->order_time_is_asap)
21+
<span class="small text-muted">(@lang('admin::lang.orders.text_asap'))</span>
22+
@endif
23+
</h3>
1924
</div>
2025
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<div class="table-responsive">
2+
<table class="table table-borderless mb-0">
3+
<tbody>
4+
<tr>
5+
<td class="text-muted">@lang('admin::lang.orders.label_payment_method')</td>
6+
<td class="text-right">{{ $formModel->payment_method->name }}</td>
7+
</tr>
8+
<tr>
9+
<td class="text-muted">@lang('admin::lang.orders.label_invoice')</td>
10+
<td class="text-right">
11+
@if ($formModel->hasInvoice())
12+
<a
13+
class="font-weight-bold"
14+
href="{{ admin_url('orders/invoice/'.$formModel->order_id) }}"
15+
target="_blank"
16+
>{{ $formModel->invoice_number }}</a>
17+
@else
18+
{{ $formModel->invoice_number }}
19+
@endif
20+
</td>
21+
</tr>
22+
<tr>
23+
<td class="text-muted">@lang('admin::lang.orders.label_date_added')</td>
24+
<td class="text-right">{{ $formModel->created_at->isoFormat(lang('system::lang.moment.date_time_format_short')) }}</td>
25+
</tr>
26+
<tr>
27+
<td class="text-muted">@lang('admin::lang.orders.label_date_modified')</td>
28+
<td class="text-right">{{ $formModel->updated_at->isoFormat(lang('system::lang.moment.date_time_format_short')) }}</td>
29+
</tr>
30+
<tr>
31+
<td class="text-muted">@lang('admin::lang.orders.label_ip_address')</td>
32+
<td class="text-right">{{ $formModel->ip_address }}</td>
33+
</tr>
34+
<tr>
35+
<td class="text-muted">@lang('admin::lang.orders.label_user_agent')</td>
36+
<td class="text-right">{{ $formModel->user_agent }}</td>
37+
</tr>
38+
</tbody>
39+
</table>
40+
</div>

0 commit comments

Comments
 (0)