1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
6
|
|
|
* @package MShop |
7
|
|
|
* @subpackage Customer |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\MShop\Customer\Manager; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Customer class implementation for Friends of Symfony user bundle. |
16
|
|
|
* |
17
|
|
|
* @package MShop |
18
|
|
|
* @subpackage Customer |
19
|
|
|
*/ |
20
|
|
|
class Laravel |
21
|
|
|
extends \Aimeos\MShop\Customer\Manager\Standard |
22
|
|
|
{ |
23
|
|
|
private $searchConfig = array( |
24
|
|
|
// customer.siteid is only for informational purpuse, not for filtering |
25
|
|
|
'customer.id' => array( |
26
|
|
|
'label' => 'Customer ID', |
27
|
|
|
'code' => 'customer.id', |
28
|
|
|
'internalcode' => 'lvu."id"', |
29
|
|
|
'type' => 'integer', |
30
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
31
|
|
|
'public' => false, |
32
|
|
|
), |
33
|
|
|
'customer.code' => array( |
34
|
|
|
'label' => 'Customer username', |
35
|
|
|
'code' => 'customer.code', |
36
|
|
|
'internalcode' => 'lvu."name"', |
37
|
|
|
'type' => 'string', |
38
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR |
39
|
|
|
), |
40
|
|
|
'customer.label' => array( |
41
|
|
|
'label' => 'Customer label', |
42
|
|
|
'code' => 'customer.label', |
43
|
|
|
'internalcode' => 'lvu."label"', |
44
|
|
|
'type' => 'string', |
45
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR |
46
|
|
|
), |
47
|
|
|
'customer.salutation' => array( |
48
|
|
|
'label' => 'Customer salutation', |
49
|
|
|
'code' => 'customer.salutation', |
50
|
|
|
'internalcode' => 'lvu."salutation"', |
51
|
|
|
'type' => 'string', |
52
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
53
|
|
|
), |
54
|
|
|
'customer.company'=> array( |
55
|
|
|
'label' => 'Customer company', |
56
|
|
|
'code' => 'customer.company', |
57
|
|
|
'internalcode' => 'lvu."company"', |
58
|
|
|
'type' => 'string', |
59
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
60
|
|
|
), |
61
|
|
|
'customer.vatid'=> array( |
62
|
|
|
'label' => 'Customer VAT ID', |
63
|
|
|
'code' => 'customer.vatid', |
64
|
|
|
'internalcode' => 'lvu."vatid"', |
65
|
|
|
'type' => 'string', |
66
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
67
|
|
|
), |
68
|
|
|
'customer.title' => array( |
69
|
|
|
'label' => 'Customer title', |
70
|
|
|
'code' => 'customer.title', |
71
|
|
|
'internalcode' => 'lvu."title"', |
72
|
|
|
'type' => 'string', |
73
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
74
|
|
|
), |
75
|
|
|
'customer.firstname' => array( |
76
|
|
|
'label' => 'Customer firstname', |
77
|
|
|
'code' => 'customer.firstname', |
78
|
|
|
'internalcode' => 'lvu."firstname"', |
79
|
|
|
'type' => 'string', |
80
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
81
|
|
|
), |
82
|
|
|
'customer.lastname' => array( |
83
|
|
|
'label' => 'Customer lastname', |
84
|
|
|
'code' => 'customer.lastname', |
85
|
|
|
'internalcode' => 'lvu."lastname"', |
86
|
|
|
'type' => 'string', |
87
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
88
|
|
|
), |
89
|
|
|
'customer.address1' => array( |
90
|
|
|
'label' => 'Customer address part one', |
91
|
|
|
'code' => 'customer.address1', |
92
|
|
|
'internalcode' => 'lvu."address1"', |
93
|
|
|
'type' => 'string', |
94
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
95
|
|
|
), |
96
|
|
|
'customer.address2' => array( |
97
|
|
|
'label' => 'Customer address part two', |
98
|
|
|
'code' => 'customer.address2', |
99
|
|
|
'internalcode' => 'lvu."address2"', |
100
|
|
|
'type' => 'string', |
101
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
102
|
|
|
), |
103
|
|
|
'customer.address3' => array( |
104
|
|
|
'label' => 'Customer address part three', |
105
|
|
|
'code' => 'customer.address3', |
106
|
|
|
'internalcode' => 'lvu."address3"', |
107
|
|
|
'type' => 'string', |
108
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
109
|
|
|
), |
110
|
|
|
'customer.postal' => array( |
111
|
|
|
'label' => 'Customer postal', |
112
|
|
|
'code' => 'customer.postal', |
113
|
|
|
'internalcode' => 'lvu."postal"', |
114
|
|
|
'type' => 'string', |
115
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
116
|
|
|
), |
117
|
|
|
'customer.city' => array( |
118
|
|
|
'label' => 'Customer city', |
119
|
|
|
'code' => 'customer.city', |
120
|
|
|
'internalcode' => 'lvu."city"', |
121
|
|
|
'type' => 'string', |
122
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
123
|
|
|
), |
124
|
|
|
'customer.state' => array( |
125
|
|
|
'label' => 'Customer state', |
126
|
|
|
'code' => 'customer.state', |
127
|
|
|
'internalcode' => 'lvu."state"', |
128
|
|
|
'type' => 'string', |
129
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
130
|
|
|
), |
131
|
|
|
'customer.languageid' => array( |
132
|
|
|
'label' => 'Customer language', |
133
|
|
|
'code' => 'customer.languageid', |
134
|
|
|
'internalcode' => 'lvu."langid"', |
135
|
|
|
'type' => 'string', |
136
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
137
|
|
|
), |
138
|
|
|
'customer.countryid' => array( |
139
|
|
|
'label' => 'Customer country', |
140
|
|
|
'code' => 'customer.countryid', |
141
|
|
|
'internalcode' => 'lvu."countryid"', |
142
|
|
|
'type' => 'string', |
143
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
144
|
|
|
), |
145
|
|
|
'customer.telephone' => array( |
146
|
|
|
'label' => 'Customer telephone', |
147
|
|
|
'code' => 'customer.telephone', |
148
|
|
|
'internalcode' => 'lvu."telephone"', |
149
|
|
|
'type' => 'string', |
150
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
151
|
|
|
), |
152
|
|
|
'customer.email' => array( |
153
|
|
|
'label' => 'Customer email', |
154
|
|
|
'code' => 'customer.email', |
155
|
|
|
'internalcode' => 'lvu."email"', |
156
|
|
|
'type' => 'string', |
157
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
158
|
|
|
), |
159
|
|
|
'customer.telefax' => array( |
160
|
|
|
'label' => 'Customer telefax', |
161
|
|
|
'code' => 'customer.telefax', |
162
|
|
|
'internalcode' => 'lvu."telefax"', |
163
|
|
|
'type' => 'string', |
164
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
165
|
|
|
), |
166
|
|
|
'customer.website' => array( |
167
|
|
|
'label' => 'Customer website', |
168
|
|
|
'code' => 'customer.website', |
169
|
|
|
'internalcode' => 'lvu."website"', |
170
|
|
|
'type' => 'string', |
171
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
172
|
|
|
), |
173
|
|
|
'customer.longitude' => array( |
174
|
|
|
'label' => 'Customer longitude', |
175
|
|
|
'code' => 'customer.longitude', |
176
|
|
|
'internalcode' => 'lvu."longitude"', |
177
|
|
|
'type' => 'float', |
178
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
179
|
|
|
), |
180
|
|
|
'customer.latitude' => array( |
181
|
|
|
'label' => 'Customer latitude', |
182
|
|
|
'code' => 'customer.latitude', |
183
|
|
|
'internalcode' => 'lvu."latitude"', |
184
|
|
|
'type' => 'float', |
185
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
186
|
|
|
), |
187
|
|
|
'customer.birthday' => array( |
188
|
|
|
'label' => 'Customer birthday', |
189
|
|
|
'code' => 'customer.birthday', |
190
|
|
|
'internalcode' => 'lvu."birthday"', |
191
|
|
|
'type' => 'string', |
192
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
193
|
|
|
), |
194
|
|
|
'customer.password'=> array( |
195
|
|
|
'label' => 'Customer password', |
196
|
|
|
'code' => 'customer.password', |
197
|
|
|
'internalcode' => 'lvu."password"', |
198
|
|
|
'type' => 'string', |
199
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
200
|
|
|
), |
201
|
|
|
'customer.status'=> array( |
202
|
|
|
'label' => 'Customer status', |
203
|
|
|
'code' => 'customer.status', |
204
|
|
|
'internalcode' => 'lvu."status"', |
205
|
|
|
'type' => 'integer', |
206
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT |
207
|
|
|
), |
208
|
|
|
'customer.dateverified'=> array( |
209
|
|
|
'label' => 'Customer verification date', |
210
|
|
|
'code' => 'customer.dateverified', |
211
|
|
|
'internalcode' => 'lvu."vdate"', |
212
|
|
|
'type' => 'date', |
213
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
214
|
|
|
), |
215
|
|
|
'customer.ctime'=> array( |
216
|
|
|
'label' => 'Customer creation time', |
217
|
|
|
'code' => 'customer.ctime', |
218
|
|
|
'internalcode' => 'lvu."created_at"', |
219
|
|
|
'type' => 'datetime', |
220
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
221
|
|
|
), |
222
|
|
|
'customer.mtime'=> array( |
223
|
|
|
'label' => 'Customer modification time', |
224
|
|
|
'code' => 'customer.mtime', |
225
|
|
|
'internalcode' => 'lvu."updated_at"', |
226
|
|
|
'type' => 'datetime', |
227
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
228
|
|
|
), |
229
|
|
|
'customer.editor'=> array( |
230
|
|
|
'label'=>'Customer editor', |
231
|
|
|
'code'=>'customer.editor', |
232
|
|
|
'internalcode' => 'lvu."editor"', |
233
|
|
|
'type'=> 'string', |
234
|
|
|
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
235
|
|
|
), |
236
|
|
|
'customer:has' => array( |
237
|
|
|
'code' => 'customer:has()', |
238
|
|
|
'internalcode' => '( |
239
|
|
|
SELECT lvuli_has."id" FROM users_list AS lvuli_has |
240
|
|
|
WHERE lvu."id" = lvuli_has."parentid" AND :site |
241
|
|
|
AND lvuli_has."domain" = $1 AND lvuli_has."type" = $2 AND lvuli_has."refid" = $3 |
242
|
|
|
)', |
243
|
|
|
'label' => 'Customer has list item, parameter(<domain>,<list type>,<reference ID>)', |
244
|
|
|
'type' => 'null', |
245
|
|
|
'internaltype' => 'null', |
246
|
|
|
'public' => false, |
247
|
|
|
), |
248
|
|
|
'customer:prop' => array( |
249
|
|
|
'code' => 'customer:prop()', |
250
|
|
|
'internalcode' => '( |
251
|
|
|
SELECT lvupr_prop."id" FROM users_property AS lvupr_prop |
252
|
|
|
WHERE lvu."id" = lvupr_prop."parentid" AND :site |
253
|
|
|
AND lvupr_prop."type" = $1 AND lvupr_prop."value" = $3 |
254
|
|
|
AND ( lvupr_prop."langid" = $2 OR lvupr_prop."langid" IS NULL ) |
255
|
|
|
)', |
256
|
|
|
'label' => 'Customer has property item, parameter(<property type>,<language code>,<property value>)', |
257
|
|
|
'type' => 'null', |
258
|
|
|
'internaltype' => 'null', |
259
|
|
|
'public' => false, |
260
|
|
|
), |
261
|
|
|
); |
262
|
|
|
|
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Initializes the object. |
266
|
|
|
* |
267
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object |
268
|
|
|
*/ |
269
|
|
|
public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
270
|
|
|
{ |
271
|
|
|
parent::__construct( $context ); |
272
|
|
|
|
273
|
|
|
$locale = $context->getLocale(); |
274
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
275
|
|
|
$level = $context->getConfig()->get( 'mshop/customer/manager/sitemode', $level ); |
276
|
|
|
|
277
|
|
|
$siteIds = [$locale->getSiteId()]; |
278
|
|
|
|
279
|
|
|
if( $level & \Aimeos\MShop\Locale\Manager\Base::SITE_PATH ) { |
280
|
|
|
$siteIds = array_merge( $siteIds, $locale->getSitePath() ); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
if( $level & \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE ) { |
284
|
|
|
$siteIds = array_merge( $siteIds, $locale->getSiteSubTree() ); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
$this->replaceSiteMarker( $this->searchConfig['customer:has'], 'lvuli_has."siteid"', $siteIds, ':site' ); |
288
|
|
|
$this->replaceSiteMarker( $this->searchConfig['customer:prop'], 'lvupr_prop."siteid"', $siteIds, ':site' ); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Removes old entries from the storage. |
294
|
|
|
* |
295
|
|
|
* @param array $siteids List of IDs for sites whose entries should be deleted |
296
|
|
|
*/ |
297
|
|
|
public function cleanup( array $siteids ) |
298
|
|
|
{ |
299
|
|
|
$path = 'mshop/customer/manager/submanagers'; |
300
|
|
|
$default = ['address', 'group', 'lists', 'property']; |
301
|
|
|
|
302
|
|
|
foreach( $this->getContext()->getConfig()->get( $path, $default ) as $domain ) { |
303
|
|
|
$this->getObject()->getSubManager( $domain )->cleanup( $siteids ); |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Removes multiple items specified by ids in the array. |
310
|
|
|
* |
311
|
|
|
* @param array $ids List of IDs |
312
|
|
|
*/ |
313
|
|
|
public function deleteItems( array $ids ) |
314
|
|
|
{ |
315
|
|
|
$path = 'mshop/customer/manager/laravel/delete'; |
316
|
|
|
$this->deleteItemsBase( $ids, $path, false ); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Returns the list attributes that can be used for searching. |
322
|
|
|
* |
323
|
|
|
* @param boolean $withsub Return also attributes of sub-managers if true |
324
|
|
|
* @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface |
325
|
|
|
*/ |
326
|
|
|
public function getSearchAttributes( $withsub = true ) |
327
|
|
|
{ |
328
|
|
|
$path = 'mshop/customer/manager/submanagers'; |
329
|
|
|
$default = ['address', 'group', 'lists', 'property']; |
330
|
|
|
|
331
|
|
|
return $this->getSearchAttributesBase( $this->searchConfig, $path, $default, $withsub ); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* Saves a customer item object. |
337
|
|
|
* |
338
|
|
|
* @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
339
|
|
|
* @param boolean $fetch True if the new ID should be returned in the item |
340
|
|
|
* @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID |
341
|
|
|
*/ |
342
|
|
|
public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true ) |
343
|
|
|
{ |
344
|
|
|
self::checkClass( '\\Aimeos\\MShop\\Customer\\Item\\Iface', $item ); |
345
|
|
|
|
346
|
|
|
if( !$item->isModified() ) |
347
|
|
|
{ |
348
|
|
|
$item = $this->savePropertyItems( $item, 'customer' ); |
349
|
|
|
$item = $this->saveAddressItems( $item, 'customer' ); |
|
|
|
|
350
|
|
|
return $this->saveListItems( $item, 'customer' ); |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
$context = $this->getContext(); |
354
|
|
|
$dbm = $context->getDatabaseManager(); |
355
|
|
|
$dbname = $this->getResourceName(); |
356
|
|
|
$conn = $dbm->acquire( $dbname ); |
357
|
|
|
|
358
|
|
|
try |
359
|
|
|
{ |
360
|
|
|
$id = $item->getId(); |
361
|
|
|
$date = date( 'Y-m-d H:i:s' ); |
362
|
|
|
$billingAddress = $item->getPaymentAddress(); |
|
|
|
|
363
|
|
|
|
364
|
|
|
if( $id === null ) |
365
|
|
|
{ |
366
|
|
|
/** mshop/customer/manager/laravel/insert |
367
|
|
|
* Inserts a new customer record into the database table |
368
|
|
|
* |
369
|
|
|
* Items with no ID yet (i.e. the ID is NULL) will be created in |
370
|
|
|
* the database and the newly created ID retrieved afterwards |
371
|
|
|
* using the "newid" SQL statement. |
372
|
|
|
* |
373
|
|
|
* The SQL statement must be a string suitable for being used as |
374
|
|
|
* prepared statement. It must include question marks for binding |
375
|
|
|
* the values from the customer item to the statement before they are |
376
|
|
|
* sent to the database server. The number of question marks must |
377
|
|
|
* be the same as the number of columns listed in the INSERT |
378
|
|
|
* statement. The order of the columns must correspond to the |
379
|
|
|
* order in the saveItems() method, so the correct values are |
380
|
|
|
* bound to the columns. |
381
|
|
|
* |
382
|
|
|
* The SQL statement should conform to the ANSI standard to be |
383
|
|
|
* compatible with most relational database systems. This also |
384
|
|
|
* includes using double quotes for table and column names. |
385
|
|
|
* |
386
|
|
|
* @param string SQL statement for inserting records |
387
|
|
|
* @since 2015.01 |
388
|
|
|
* @category Developer |
389
|
|
|
* @see mshop/customer/manager/laravel/update |
390
|
|
|
* @see mshop/customer/manager/laravel/newid |
391
|
|
|
* @see mshop/customer/manager/laravel/delete |
392
|
|
|
* @see mshop/customer/manager/laravel/search |
393
|
|
|
* @see mshop/customer/manager/laravel/count |
394
|
|
|
*/ |
395
|
|
|
$path = 'mshop/customer/manager/laravel/insert'; |
396
|
|
|
} |
397
|
|
|
else |
398
|
|
|
{ |
399
|
|
|
/** mshop/customer/manager/laravel/update |
400
|
|
|
* Updates an existing customer record in the database |
401
|
|
|
* |
402
|
|
|
* Items which already have an ID (i.e. the ID is not NULL) will |
403
|
|
|
* be updated in the database. |
404
|
|
|
* |
405
|
|
|
* The SQL statement must be a string suitable for being used as |
406
|
|
|
* prepared statement. It must include question marks for binding |
407
|
|
|
* the values from the customer item to the statement before they are |
408
|
|
|
* sent to the database server. The order of the columns must |
409
|
|
|
* correspond to the order in the saveItems() method, so the |
410
|
|
|
* correct values are bound to the columns. |
411
|
|
|
* |
412
|
|
|
* The SQL statement should conform to the ANSI standard to be |
413
|
|
|
* compatible with most relational database systems. This also |
414
|
|
|
* includes using double quotes for table and column names. |
415
|
|
|
* |
416
|
|
|
* @param string SQL statement for updating records |
417
|
|
|
* @since 2015.01 |
418
|
|
|
* @category Developer |
419
|
|
|
* @see mshop/customer/manager/laravel/insert |
420
|
|
|
* @see mshop/customer/manager/laravel/newid |
421
|
|
|
* @see mshop/customer/manager/laravel/delete |
422
|
|
|
* @see mshop/customer/manager/laravel/search |
423
|
|
|
* @see mshop/customer/manager/laravel/count |
424
|
|
|
*/ |
425
|
|
|
$path = 'mshop/customer/manager/laravel/update'; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
$stmt = $this->getCachedStatement( $conn, $path ); |
429
|
|
|
|
430
|
|
|
$stmt->bind( 1, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
431
|
|
|
$stmt->bind( 2, $item->getCode() ); |
|
|
|
|
432
|
|
|
$stmt->bind( 3, $billingAddress->getCompany() ); |
433
|
|
|
$stmt->bind( 4, $billingAddress->getVatID() ); |
434
|
|
|
$stmt->bind( 5, $billingAddress->getSalutation() ); |
435
|
|
|
$stmt->bind( 6, $billingAddress->getTitle() ); |
436
|
|
|
$stmt->bind( 7, $billingAddress->getFirstname() ); |
437
|
|
|
$stmt->bind( 8, $billingAddress->getLastname() ); |
438
|
|
|
$stmt->bind( 9, $billingAddress->getAddress1() ); |
439
|
|
|
$stmt->bind( 10, $billingAddress->getAddress2() ); |
440
|
|
|
$stmt->bind( 11, $billingAddress->getAddress3() ); |
441
|
|
|
$stmt->bind( 12, $billingAddress->getPostal() ); |
442
|
|
|
$stmt->bind( 13, $billingAddress->getCity() ); |
443
|
|
|
$stmt->bind( 14, $billingAddress->getState() ); |
444
|
|
|
$stmt->bind( 15, $billingAddress->getCountryId() ); |
445
|
|
|
$stmt->bind( 16, $billingAddress->getLanguageId() ); |
446
|
|
|
$stmt->bind( 17, $billingAddress->getTelephone() ); |
447
|
|
|
$stmt->bind( 18, $billingAddress->getTelefax() ); |
448
|
|
|
$stmt->bind( 19, $billingAddress->getWebsite() ); |
449
|
|
|
$stmt->bind( 20, $billingAddress->getEmail() ); |
450
|
|
|
$stmt->bind( 21, $billingAddress->getLongitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT ); |
451
|
|
|
$stmt->bind( 22, $billingAddress->getLatitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT ); |
452
|
|
|
$stmt->bind( 23, $item->getLabel() ); |
|
|
|
|
453
|
|
|
$stmt->bind( 24, $item->getBirthday() ); |
|
|
|
|
454
|
|
|
$stmt->bind( 25, $item->getStatus(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
|
|
|
|
455
|
|
|
$stmt->bind( 26, $item->getDateVerified() ); |
|
|
|
|
456
|
|
|
$stmt->bind( 27, $item->getPassword() ); |
|
|
|
|
457
|
|
|
$stmt->bind( 28, $date ); // Modification time |
458
|
|
|
$stmt->bind( 29, $context->getEditor() ); |
459
|
|
|
|
460
|
|
|
if( $id !== null ) { |
461
|
|
|
$stmt->bind( 30, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
462
|
|
|
$item->setId( $id ); |
463
|
|
|
} else { |
464
|
|
|
$stmt->bind( 30, $date ); // Creation time |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
$stmt->execute()->finish(); |
468
|
|
|
|
469
|
|
|
if( $id === null && $fetch === true ) |
470
|
|
|
{ |
471
|
|
|
/** mshop/customer/manager/laravel/newid |
472
|
|
|
* Retrieves the ID generated by the database when inserting a new record |
473
|
|
|
* |
474
|
|
|
* As soon as a new record is inserted into the database table, |
475
|
|
|
* the database server generates a new and unique identifier for |
476
|
|
|
* that record. This ID can be used for retrieving, updating and |
477
|
|
|
* deleting that specific record from the table again. |
478
|
|
|
* |
479
|
|
|
* For MySQL: |
480
|
|
|
* SELECT LAST_INSERT_ID() |
481
|
|
|
* For PostgreSQL: |
482
|
|
|
* SELECT currval('seq_mcus_id') |
483
|
|
|
* For SQL Server: |
484
|
|
|
* SELECT SCOPE_IDENTITY() |
485
|
|
|
* For Oracle: |
486
|
|
|
* SELECT "seq_mcus_id".CURRVAL FROM DUAL |
487
|
|
|
* |
488
|
|
|
* There's no way to retrive the new ID by a SQL statements that |
489
|
|
|
* fits for most database servers as they implement their own |
490
|
|
|
* specific way. |
491
|
|
|
* |
492
|
|
|
* @param string SQL statement for retrieving the last inserted record ID |
493
|
|
|
* @since 2015.01 |
494
|
|
|
* @category Developer |
495
|
|
|
* @see mshop/customer/manager/laravel/insert |
496
|
|
|
* @see mshop/customer/manager/laravel/update |
497
|
|
|
* @see mshop/customer/manager/laravel/delete |
498
|
|
|
* @see mshop/customer/manager/laravel/search |
499
|
|
|
* @see mshop/customer/manager/laravel/count |
500
|
|
|
*/ |
501
|
|
|
$path = 'mshop/customer/manager/laravel/newid'; |
502
|
|
|
$item->setId( $this->newId( $conn, $path ) ); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
$dbm->release( $conn, $dbname ); |
506
|
|
|
} |
507
|
|
|
catch( \Exception $e ) |
508
|
|
|
{ |
509
|
|
|
$dbm->release( $conn, $dbname ); |
510
|
|
|
throw $e; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
$this->addGroups( $item ); |
514
|
|
|
|
515
|
|
|
$item = $this->savePropertyItems( $item, 'customer' ); |
516
|
|
|
$item = $this->saveAddressItems( $item, 'customer' ); |
517
|
|
|
return $this->saveListItems( $item, 'customer' ); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* Returns the item objects matched by the given search criteria. |
523
|
|
|
* |
524
|
|
|
* @param \Aimeos\MW\Criteria\Iface $search Search criteria object |
525
|
|
|
* @param integer &$total Number of items that are available in total |
526
|
|
|
* @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface |
527
|
|
|
* @throws \Aimeos\MShop\Customer\Exception If creating items failed |
528
|
|
|
*/ |
529
|
|
|
public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null ) |
530
|
|
|
{ |
531
|
|
|
$dbm = $this->getContext()->getDatabaseManager(); |
532
|
|
|
$dbname = $this->getResourceName(); |
533
|
|
|
$conn = $dbm->acquire( $dbname ); |
534
|
|
|
$map = []; |
535
|
|
|
|
536
|
|
|
try |
537
|
|
|
{ |
538
|
|
|
$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
539
|
|
|
$cfgPathSearch = 'mshop/customer/manager/laravel/search'; |
540
|
|
|
$cfgPathCount = 'mshop/customer/manager/laravel/count'; |
541
|
|
|
$required = array( 'customer' ); |
542
|
|
|
|
543
|
|
|
$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level ); |
544
|
|
|
while( ( $row = $results->fetch() ) !== false ) { |
545
|
|
|
$map[ $row['customer.id'] ] = $row; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
$dbm->release( $conn, $dbname ); |
549
|
|
|
} |
550
|
|
|
catch( \Exception $e ) |
551
|
|
|
{ |
552
|
|
|
$dbm->release( $conn, $dbname ); |
553
|
|
|
throw $e; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
$addrItems = []; |
557
|
|
|
if( in_array( 'customer/address', $ref, true ) ) { |
558
|
|
|
$addrItems = $this->getAddressItems( array_keys( $map ), 'customer' ); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
$propItems = []; |
562
|
|
|
if( in_array( 'customer/property', $ref, true ) ) { |
563
|
|
|
$propItems = $this->getPropertyItems( array_keys( $map ), 'customer' ); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
return $this->buildItems( $map, $ref, 'customer', $addrItems, $propItems ); |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Returns a new manager for customer extensions |
572
|
|
|
* |
573
|
|
|
* @param string $manager Name of the sub manager type in lower case |
574
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
575
|
|
|
* @return mixed Manager for different extensions, e.g stock, tags, locations, etc. |
576
|
|
|
*/ |
577
|
|
|
public function getSubManager( $manager, $name = null ) |
578
|
|
|
{ |
579
|
|
|
return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Laravel' : $name ) ); |
580
|
|
|
} |
581
|
|
|
} |
582
|
|
|
|