1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2020 |
6
|
|
|
* @package Admin |
7
|
|
|
* @subpackage JQAdm |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JQAdm\Dashboard\Order\Latest; |
12
|
|
|
|
13
|
|
|
sprintf( 'latest' ); // for translation |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Default implementation of dashboard latest order JQAdm client. |
18
|
|
|
* |
19
|
|
|
* @package Admin |
20
|
|
|
* @subpackage JQAdm |
21
|
|
|
*/ |
22
|
|
|
class Standard |
23
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base |
24
|
|
|
implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
25
|
|
|
{ |
26
|
|
|
/** admin/jqadm/dashboard/order/latest/name |
27
|
|
|
* Name of the order latest subpart used by the JQAdm dashboard implementation |
28
|
|
|
* |
29
|
|
|
* Use "Myname" if your class is named "\Aimeos\Admin\Jqadm\Dashboard\Order\Latest\Myname". |
30
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
31
|
|
|
* |
32
|
|
|
* @param string Last part of the JQAdm class name |
33
|
|
|
* @since 2018.01 |
34
|
|
|
* @category Developer |
35
|
|
|
*/ |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns a list of resource according to the conditions |
40
|
|
|
* |
41
|
|
|
* @return string Output to display |
42
|
|
|
*/ |
43
|
|
|
public function search() : ?string |
44
|
|
|
{ |
45
|
|
|
$view = $this->getView(); |
46
|
|
|
$manager = \Aimeos\MShop::create( $this->getContext(), 'order' ); |
47
|
|
|
|
48
|
|
|
$search = $manager->createSearch()->setSlice( 0, 10 ); |
49
|
|
|
$search->setConditions( $search->compare( '!=', 'order.base.product.siteid', '' ) ); |
50
|
|
|
$search->setSortations( [$search->sort( '-', 'order.ctime' ), $search->sort( '-', 'order.id' )] ); |
51
|
|
|
|
52
|
|
|
$view->orderlatestItems = $manager->searchItems( $search, ['order/base', 'order/base/address', 'order/base/service'] ); |
53
|
|
|
$view->orderlatestBody = ''; |
54
|
|
|
|
55
|
|
|
foreach( $this->getSubClients() as $client ) { |
56
|
|
|
$view->orderlatestBody .= $client->search(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** admin/jqadm/dashboard/order/latest/template-item |
60
|
|
|
* Relative path to the HTML body template of the latest orders subpart for the dashboard. |
61
|
|
|
* |
62
|
|
|
* The template file contains the HTML code and processing instructions |
63
|
|
|
* to generate the result shown in the body of the frontend. The |
64
|
|
|
* configuration string is the path to the template file relative |
65
|
|
|
* to the templates directory (usually in admin/jqadm/templates). |
66
|
|
|
* |
67
|
|
|
* You can overwrite the template file configuration in extensions and |
68
|
|
|
* provide alternative templates. These alternative templates should be |
69
|
|
|
* named like the default one but with the string "default" replaced by |
70
|
|
|
* an unique name. You may use the name of your project for this. If |
71
|
|
|
* you've implemented an alternative client class as well, "default" |
72
|
|
|
* should be replaced by the name of the new class. |
73
|
|
|
* |
74
|
|
|
* @param string Relative path to the template creating the HTML code |
75
|
|
|
* @since 2016.04 |
76
|
|
|
* @category Developer |
77
|
|
|
*/ |
78
|
|
|
$tplconf = 'admin/jqadm/dashboard/order/latest/template-item'; |
79
|
|
|
$default = 'dashboard/item-order-latest-standard'; |
80
|
|
|
|
81
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the sub-client given by its name. |
87
|
|
|
* |
88
|
|
|
* @param string $type Name of the client type |
89
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
90
|
|
|
* @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
91
|
|
|
*/ |
92
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
93
|
|
|
{ |
94
|
|
|
/** admin/jqadm/dashboard/order/latest/decorators/excludes |
95
|
|
|
* Excludes decorators added by the "common" option from the dashboard JQAdm client |
96
|
|
|
* |
97
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
98
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
99
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
100
|
|
|
* modify what is returned to the caller. |
101
|
|
|
* |
102
|
|
|
* This option allows you to remove a decorator added via |
103
|
|
|
* "admin/jqadm/common/decorators/default" before they are wrapped |
104
|
|
|
* around the JQAdm client. |
105
|
|
|
* |
106
|
|
|
* admin/jqadm/dashboard/order/latest/decorators/excludes = array( 'decorator1' ) |
107
|
|
|
* |
108
|
|
|
* This would remove the decorator named "decorator1" from the list of |
109
|
|
|
* common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via |
110
|
|
|
* "admin/jqadm/common/decorators/default" to the JQAdm client. |
111
|
|
|
* |
112
|
|
|
* @param array List of decorator names |
113
|
|
|
* @since 2016.07 |
114
|
|
|
* @category Developer |
115
|
|
|
* @see admin/jqadm/common/decorators/default |
116
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/global |
117
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/local |
118
|
|
|
*/ |
119
|
|
|
|
120
|
|
|
/** admin/jqadm/dashboard/order/latest/decorators/global |
121
|
|
|
* Adds a list of globally available decorators only to the dashboard JQAdm client |
122
|
|
|
* |
123
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
124
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
125
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
126
|
|
|
* modify what is returned to the caller. |
127
|
|
|
* |
128
|
|
|
* This option allows you to wrap global decorators |
129
|
|
|
* ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client. |
130
|
|
|
* |
131
|
|
|
* admin/jqadm/dashboard/order/latest/decorators/global = array( 'decorator1' ) |
132
|
|
|
* |
133
|
|
|
* This would add the decorator named "decorator1" defined by |
134
|
|
|
* "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client. |
135
|
|
|
* |
136
|
|
|
* @param array List of decorator names |
137
|
|
|
* @since 2016.07 |
138
|
|
|
* @category Developer |
139
|
|
|
* @see admin/jqadm/common/decorators/default |
140
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/excludes |
141
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/local |
142
|
|
|
*/ |
143
|
|
|
|
144
|
|
|
/** admin/jqadm/dashboard/order/latest/decorators/local |
145
|
|
|
* Adds a list of local decorators only to the dashboard JQAdm client |
146
|
|
|
* |
147
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
148
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
149
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
150
|
|
|
* modify what is returned to the caller. |
151
|
|
|
* |
152
|
|
|
* This option allows you to wrap local decorators |
153
|
|
|
* ("\Aimeos\Admin\JQAdm\Dashboard\Decorator\*") around the JQAdm client. |
154
|
|
|
* |
155
|
|
|
* admin/jqadm/dashboard/order/latest/decorators/local = array( 'decorator2' ) |
156
|
|
|
* |
157
|
|
|
* This would add the decorator named "decorator2" defined by |
158
|
|
|
* "\Aimeos\Admin\JQAdm\Dashboard\Decorator\Decorator2" only to the JQAdm client. |
159
|
|
|
* |
160
|
|
|
* @param array List of decorator names |
161
|
|
|
* @since 2016.07 |
162
|
|
|
* @category Developer |
163
|
|
|
* @see admin/jqadm/common/decorators/default |
164
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/excludes |
165
|
|
|
* @see admin/jqadm/dashboard/order/latest/decorators/global |
166
|
|
|
*/ |
167
|
|
|
return $this->createSubClient( 'dashboard/order/latest/' . $type, $name ); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Returns the list of sub-client names configured for the client. |
173
|
|
|
* |
174
|
|
|
* @return array List of JQAdm client names |
175
|
|
|
*/ |
176
|
|
|
protected function getSubClientNames() : array |
177
|
|
|
{ |
178
|
|
|
/** admin/jqadm/dashboard/order/latest/standard/subparts |
179
|
|
|
* List of JQAdm sub-clients rendered within the dashboard latest section |
180
|
|
|
* |
181
|
|
|
* The output of the frontend is composed of the code generated by the JQAdm |
182
|
|
|
* clients. Each JQAdm client can consist of serveral (or none) sub-clients |
183
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
184
|
|
|
* sub-clients can contain JQAdm clients themselves and therefore a |
185
|
|
|
* hierarchical tree of JQAdm clients is composed. Each JQAdm client creates |
186
|
|
|
* the output that is placed inside the container of its parent. |
187
|
|
|
* |
188
|
|
|
* At first, always the JQAdm code generated by the parent is printed, then |
189
|
|
|
* the JQAdm code of its sub-clients. The order of the JQAdm sub-clients |
190
|
|
|
* determines the order of the output of these sub-clients inside the parent |
191
|
|
|
* container. If the configured list of clients is |
192
|
|
|
* |
193
|
|
|
* array( "subclient1", "subclient2" ) |
194
|
|
|
* |
195
|
|
|
* you can easily change the order of the output by reordering the subparts: |
196
|
|
|
* |
197
|
|
|
* admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" ) |
198
|
|
|
* |
199
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
200
|
|
|
* |
201
|
|
|
* admin/jqadm/<clients>/subparts = array( "subclient1" ) |
202
|
|
|
* |
203
|
|
|
* As the clients only generates structural JQAdm, the layout defined via CSS |
204
|
|
|
* should support adding, removing or reordering content by a fluid like |
205
|
|
|
* design. |
206
|
|
|
* |
207
|
|
|
* @param array List of sub-client names |
208
|
|
|
* @since 2016.07 |
209
|
|
|
* @category Developer |
210
|
|
|
*/ |
211
|
|
|
return $this->getContext()->getConfig()->get( 'admin/jqadm/dashboard/order/latest/standard/subparts', [] ); |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
|