/
_edit.html
90 lines (79 loc) · 3 KB
/
_edit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{% extends "commerce/_layouts/cp" %}
{% set crumbs = [
{ label: 'Customers'|t('commerce'), url: url('commerce/customers') },
] %}
{% set selectedSubnavItem = 'customers' %}
{% set fullPageForm = false %}
{% import "_includes/forms" as forms %}
{% hook "cp.commerce.customers.edit" %}
{% block actionButton %}
{% if currentUser.can('commerce-editOrders') and craft.commerce.is('pro') %}
<form action="" id="new-order" method="post">
{{ csrfInput() }}
<input type="hidden" name="customerId" value="{{ customer.id }}">
<input type="hidden" name="action" value="commerce/orders/new-order">
<a href="javascript:$('#new-order').submit();" class="btn icon add" onclick="">{{ 'New Order'|t('commerce') }}</a>
</form>
{% endif %}
{% endblock %}
{% block details %}
<div class="meta read-only">
{% set customerUser = customer.getUser() ?? null %}
{% if customerUser %}
<div class="data">
<h5 class="heading">{{ 'User'|t('commerce') }}</h5>
<div class="value">
{% if currentUser.can('editUsers') %}
{{ tag('a', {
href: customerUser.getCpEditUrl(),
text: customerUser.__toString(),
}) }}
{% else %}
<span>{{ customerUser.__toString() }}</span>
{% endif %}
</div>
</div>
{% endif %}
<div class="data">
<h5 class="heading">{{ 'Total Orders'|t('commerce') }}</h5>
<div class="value">{{ craft.orders({ customerId: customer.id, isCompleted: 1, limit: null }).count() }}</div>
</div>
{% set lastOrder = craft.orders({ customerId: customer.id, isCompleted: 1, limit: 1, orderBy: 'dateOrdered DESC' }).one() ?? null %}
{% if lastOrder %}
<div class="data">
<h5 class="heading">{{ 'Last Order'|t('commerce') }}</h5>
<div class="value">
{% if currentUser.can('commerce-manageOrders') %}
{{ tag('a', {
href: lastOrder.cpEditUrl,
text: lastOrder.__toString(),
}) }}
{% else %}
{{ lastOrder.__toString() }}
{% endif %}
</div>
</div>
<div class="data">
<h5 class="heading">{{ 'Last Order Date'|t('commerce') }}</h5>
<div class="value">
{{ lastOrder ? lastOrder.dateOrdered|date('D jS M Y') : '' }}
</div>
</div>
{% endif %}
</div>
<div class="meta read-only">
<div class="data">
<h5 class="heading">{{ "Created at"|t('app') }}</h5>
<div id="date-created-value" class="value">{{ customer.dateCreated|datetime('short') }}</div>
</div>
<div class="data">
<h5 class="heading">{{ "Updated at"|t('app') }}</h5>
<div id="date-updated-value" class="value">{{ customer.dateUpdated|datetime('short') }}</div>
</div>
</div>
{% hook "cp.commerce.customers.edit.details" %}
{% endblock %}
{% block content %}
{% include 'commerce/customers/_includes/_customerTables' with { customer: customer } %}
{% hook "cp.commerce.customers.edit.content" %}
{% endblock %}