|
1
|
|
|
/* |
|
2
|
|
|
{block name="backend/order/model/attribute/fields" append} |
|
3
|
|
|
{ name: 'swagKlarnaInvoiceNumber', type: 'string', useNull: true }, |
|
4
|
|
|
{ name: 'swagKlarnaStatus', type: 'string', useNull: true }, |
|
5
|
|
|
{/block} |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/* |
|
9
|
|
|
{block name="backend/order/model/position/fields" append} |
|
10
|
|
|
{ name: 'shipped', type:'int' }, |
|
11
|
|
|
{/block} |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
/* |
|
15
|
|
|
{block name="backend/order/model/position_attribute/fields" append} |
|
16
|
|
|
{ name: 'swagKlarnaInvoiceNumber', type: 'string', useNull: true }, |
|
17
|
|
|
{/block} |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
//{block name="backend/order/view/list/list" append} |
|
21
|
|
|
|
|
22
|
|
|
Ext.define('Shopware.apps.Order.view.list.List-Klarna', { |
|
|
|
|
|
|
23
|
|
|
override: 'Shopware.apps.Order.view.list.List', |
|
24
|
|
|
paymentColumn: function (value, meta, record) { |
|
25
|
|
|
var me = this, |
|
26
|
|
|
result = me.callOverridden(arguments); |
|
27
|
|
|
if (record.getPayment().first() |
|
28
|
|
|
&& record.getPayment().first().get('name').indexOf('klarna_') === 0) { |
|
29
|
|
|
meta.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell'; |
|
|
|
|
|
|
30
|
|
|
return '<img src="{link file="backend/_resources/klarna/icon.png"}" data-qtip="' + result + '" />'; |
|
31
|
|
|
} else { |
|
32
|
|
|
return result; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
}); |
|
36
|
|
|
//{/block} |
|
37
|
|
|
|
|
38
|
|
|
//{block name="backend/order/view/batch/form" append} |
|
39
|
|
|
Ext.define('Shopware.apps.Order.view.batch.Form-Klarna', { |
|
40
|
|
|
override: 'Shopware.apps.Order.view.batch.Form', |
|
41
|
|
|
createSettingsContainer: function () { |
|
42
|
|
|
var me = this, |
|
43
|
|
|
container = me.callOverridden(arguments); |
|
44
|
|
|
container.insert(0, [{ |
|
45
|
|
|
name: 'klarnaAction', |
|
46
|
|
|
triggerAction: 'all', |
|
47
|
|
|
fieldLabel: 'Klarna-Zahlungen', |
|
48
|
|
|
forceSelection: true, |
|
49
|
|
|
value: 0, |
|
50
|
|
|
store: [ |
|
51
|
|
|
[0, 'keine Aktion'], |
|
52
|
|
|
[1, 'Aktivieren'], |
|
53
|
|
|
[2, 'Abbrechen / Stornieren'] |
|
54
|
|
|
], |
|
55
|
|
|
listeners: { |
|
56
|
|
|
change: function (field, value) { |
|
57
|
|
|
var form = field.up('form'), |
|
58
|
|
|
documentField = form.down('[name=documentType]'); |
|
59
|
|
|
documentField.store.load(); |
|
60
|
|
|
switch (value) { |
|
61
|
|
|
case 0: |
|
62
|
|
|
documentField.enable(); |
|
63
|
|
|
break; |
|
64
|
|
|
case 1: |
|
65
|
|
|
documentField.disable().setValue(1); |
|
66
|
|
|
break; |
|
67
|
|
|
case 2: |
|
68
|
|
|
documentField.disable().setValue(4); |
|
69
|
|
|
break; |
|
70
|
|
|
default: |
|
71
|
|
|
break; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
}]); |
|
76
|
|
|
return container; |
|
77
|
|
|
} |
|
78
|
|
|
}); |
|
79
|
|
|
//{/block} |
|
80
|
|
|
|
|
81
|
|
|
//{block name="backend/order/controller/batch" append} |
|
82
|
|
|
Ext.define('Shopware.apps.Order.controller.Batch-Klarna', { |
|
|
|
|
|
|
83
|
|
|
override: 'Shopware.apps.Order.controller.Batch', |
|
84
|
|
|
|
|
85
|
|
|
onProcessChanges: function (form) { |
|
86
|
|
|
var me = this, |
|
87
|
|
|
orders = form.records, |
|
|
|
|
|
|
88
|
|
|
documentField = form.down('[name=documentType]'), |
|
89
|
|
|
values = form.getValues(); |
|
90
|
|
|
|
|
91
|
|
|
me.klarnaAction = values.klarnaAction; |
|
92
|
|
|
if (!Ext.isEmpty(me.klarnaAction) && me.klarnaAction != 0) { |
|
|
|
|
|
|
93
|
|
|
documentField.enable(); |
|
94
|
|
|
me.callOverridden(arguments); |
|
95
|
|
|
documentField.disable(); |
|
96
|
|
|
} else { |
|
97
|
|
|
me.callOverridden(arguments); |
|
98
|
|
|
} |
|
99
|
|
|
}, |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param store |
|
|
|
|
|
|
103
|
|
|
* @param progressBar Only in shopware < 5.0.2 |
|
|
|
|
|
|
104
|
|
|
* @param orders |
|
|
|
|
|
|
105
|
|
|
* @param index |
|
|
|
|
|
|
106
|
|
|
* @param resultStore |
|
|
|
|
|
|
107
|
|
|
*/ |
|
108
|
|
|
queueProcess: function () { |
|
109
|
|
|
var me = this, |
|
110
|
|
|
url, |
|
111
|
|
|
store = arguments[0], |
|
112
|
|
|
orders = arguments[4] ? arguments[2] : arguments[1], |
|
113
|
|
|
index = arguments[4] ? arguments[3] : arguments[2], |
|
114
|
|
|
order = orders[index]; |
|
115
|
|
|
|
|
116
|
|
|
if (order && me.klarnaAction) { |
|
117
|
|
|
store.getProxy().extraParams.docType = 0; |
|
118
|
|
|
switch (me.klarnaAction) { |
|
119
|
|
|
case 1: |
|
120
|
|
|
url = '{url controller=paymentKlarna action=activate}'; |
|
121
|
|
|
break; |
|
122
|
|
|
case 2: |
|
123
|
|
|
url = '{url controller=paymentKlarna action=cancel}'; |
|
124
|
|
|
break; |
|
125
|
|
|
default: |
|
126
|
|
|
break; |
|
127
|
|
|
} |
|
128
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
129
|
|
|
url: url, |
|
|
|
|
|
|
130
|
|
|
async: false, |
|
131
|
|
|
params: { |
|
132
|
|
|
orderId: order.getId() |
|
133
|
|
|
}, |
|
134
|
|
|
success: function (response, o) { |
|
|
|
|
|
|
135
|
|
|
var operation = Ext.decode(response.responseText); |
|
|
|
|
|
|
136
|
|
|
if (!operation.success) { |
|
137
|
|
|
Ext.Msg.alert('Bestellung: ' + order.get('number'), 'Fehler: ' + operation.message); |
|
138
|
|
|
} |
|
139
|
|
|
}, |
|
140
|
|
|
failure: function () { |
|
141
|
|
|
} |
|
142
|
|
|
}); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
me.callOverridden(arguments); |
|
146
|
|
|
} |
|
147
|
|
|
}); |
|
148
|
|
|
//{/block} |
|
149
|
|
|
|
|
150
|
|
|
//{block name="backend/order/controller/detail" append} |
|
151
|
|
|
Ext.define('Shopware.apps.Order.controller.Detail-Klarna', { |
|
|
|
|
|
|
152
|
|
|
override: 'Shopware.apps.Order.controller.Detail', |
|
153
|
|
|
|
|
154
|
|
|
init: function () { |
|
155
|
|
|
var me = this; |
|
156
|
|
|
|
|
157
|
|
|
me.control({ |
|
158
|
|
|
'order-klarna-panel button': { |
|
159
|
|
|
click: me.onButtonClick |
|
160
|
|
|
}, |
|
161
|
|
|
'order-klarna-panel grid': { |
|
162
|
|
|
selectionchange: me.onSelectionChange |
|
163
|
|
|
} |
|
164
|
|
|
}); |
|
165
|
|
|
|
|
166
|
|
|
me.callOverridden(arguments); |
|
167
|
|
|
}, |
|
168
|
|
|
onShowDetail: function (order, rec) { |
|
169
|
|
|
var me = this, |
|
170
|
|
|
status, |
|
171
|
|
|
payment = order.getPayment().first(); |
|
172
|
|
|
if(typeof order.getAttributes !== 'function') { |
|
173
|
|
|
var orderId = order.getId(); |
|
174
|
|
|
var tableName = 's_order_attributes'; |
|
175
|
|
|
var response; |
|
176
|
|
|
order.getAttribute = |
|
177
|
|
|
function (orderID, tableName){ |
|
178
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
179
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
180
|
|
|
async: false, |
|
181
|
|
|
params: { |
|
182
|
|
|
_foreignKey: orderID, |
|
183
|
|
|
_table: tableName |
|
184
|
|
|
}, |
|
185
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
186
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
187
|
|
|
|
|
188
|
|
|
} |
|
189
|
|
|
}); |
|
190
|
|
|
return response; |
|
191
|
|
|
}; |
|
192
|
|
|
|
|
193
|
|
|
response = order.getAttribute(orderId, tableName); |
|
194
|
|
|
|
|
195
|
|
|
status = response.data.__attribute_swag_klarna_invoice_number; |
|
196
|
|
|
|
|
197
|
|
|
} else{ |
|
198
|
|
|
var attribute = order.getAttributes().first(); |
|
199
|
|
|
status = attribute.get('swagKlarnaStatus'); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
if (rec === true || payment.get('name').indexOf('klarna_') !== 0 || (status && !order.get('invoiceShipping'))) { |
|
203
|
|
|
me.callOverridden(arguments); |
|
204
|
|
|
return; |
|
205
|
|
|
} |
|
206
|
|
|
var params = { |
|
207
|
|
|
orderId: order.getId() |
|
208
|
|
|
}, |
|
209
|
|
|
url = '{url controller=paymentKlarna action=autoUpdate}', |
|
210
|
|
|
result = me.doRequest(url, params); |
|
|
|
|
|
|
211
|
|
|
me.subApplication.getStore('Order').load({ |
|
212
|
|
|
callback: function (records) { |
|
213
|
|
|
Ext.iterate(records, function (record) { |
|
|
|
|
|
|
214
|
|
|
if (record.getId() == order.getId()) { |
|
215
|
|
|
me.onShowDetail(record, true); |
|
216
|
|
|
} |
|
217
|
|
|
}); |
|
218
|
|
|
} |
|
219
|
|
|
}); |
|
220
|
|
|
}, |
|
221
|
|
|
onSelectionChange: function (sm, selections) { |
|
222
|
|
|
var panel = sm.panel, |
|
223
|
|
|
order = panel.record, |
|
224
|
|
|
activateButton = panel.down('button[action=activate]'), |
|
225
|
|
|
refundButton = panel.down('button[action=refund]'), |
|
226
|
|
|
hasCancelSelection = false, |
|
227
|
|
|
hasActivateSelection = false; |
|
228
|
|
|
Ext.iterate(selections, function (selection) { |
|
|
|
|
|
|
229
|
|
|
if (selection.get('shipped') > 0 && selection.get('statusId') != 2) { |
|
230
|
|
|
hasCancelSelection = true; |
|
231
|
|
|
} |
|
232
|
|
|
}); |
|
233
|
|
|
Ext.iterate(selections, function (selection) { |
|
|
|
|
|
|
234
|
|
|
if (selection.get('statusId') == 2 || selection.get('statusId') == 3) { |
|
235
|
|
|
return; |
|
236
|
|
|
} |
|
237
|
|
|
hasActivateSelection = true; |
|
238
|
|
|
}); |
|
239
|
|
|
if (!hasActivateSelection) { |
|
240
|
|
|
activateButton.disable(); |
|
241
|
|
|
} else { |
|
242
|
|
|
activateButton.enable(); |
|
243
|
|
|
} |
|
244
|
|
|
if (!hasCancelSelection) { |
|
245
|
|
|
refundButton.disable(); |
|
246
|
|
|
} else { |
|
247
|
|
|
refundButton.enable(); |
|
248
|
|
|
} |
|
249
|
|
|
var status; |
|
250
|
|
|
if(typeof order.getAttributes !== 'function') { |
|
251
|
|
|
var orderId = order.getId(); |
|
252
|
|
|
var tableName = 's_order_attributes'; |
|
253
|
|
|
var response; |
|
254
|
|
|
order.getAttribute = |
|
255
|
|
|
function (orderID, tableName){ |
|
256
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
257
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
258
|
|
|
async: false, |
|
259
|
|
|
params: { |
|
260
|
|
|
_foreignKey: orderID, |
|
261
|
|
|
_table: tableName |
|
262
|
|
|
}, |
|
263
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
264
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
265
|
|
|
|
|
266
|
|
|
} |
|
267
|
|
|
}); |
|
268
|
|
|
return response; |
|
269
|
|
|
}; |
|
270
|
|
|
|
|
271
|
|
|
response = order.getAttribute(orderId, tableName); |
|
272
|
|
|
status = response.data.__attribute_swag_klarna_status; |
|
273
|
|
|
hasInvoice = response.data.__attribute_swag_klarna_invoice_number; |
|
|
|
|
|
|
274
|
|
|
} else{ |
|
275
|
|
|
var attribute = order.getAttributes().first(); |
|
276
|
|
|
hasInvoice = !!attribute.get('swagKlarnaInvoiceNumber'); |
|
277
|
|
|
status = attribute.get('swagKlarnaStatus'); |
|
278
|
|
|
} |
|
279
|
|
|
if (status == 'activate' || status == 'cancel' || status == 'credit' || status == 'pending'){ |
|
280
|
|
|
activateButton.disable(); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
}, |
|
284
|
|
|
onButtonClick: function (button) { |
|
285
|
|
|
var me = this, |
|
286
|
|
|
grid = button.up('grid'), |
|
287
|
|
|
window = button.up('window'), |
|
288
|
|
|
panel = button.up('order-klarna-panel'), |
|
289
|
|
|
order = panel.record, |
|
290
|
|
|
records = grid.getSelectionModel().getSelection(), |
|
291
|
|
|
url, msg, prompt = false, params = { |
|
292
|
|
|
orderId: order.getId() |
|
293
|
|
|
}, |
|
294
|
|
|
newRow; |
|
295
|
|
|
|
|
296
|
|
|
switch (button.action) { |
|
297
|
|
|
case 'add': |
|
298
|
|
|
var article = grid.down('[name=article]').returnRecord; |
|
299
|
|
|
if (article) { |
|
300
|
|
|
newRow = { |
|
301
|
|
|
articleId: article.get('id'), |
|
302
|
|
|
articleNumber: article.get('number'), |
|
303
|
|
|
articleName: article.get('name'), |
|
304
|
|
|
inStock: article.get('inStock'), |
|
305
|
|
|
quantity: 1 |
|
306
|
|
|
}; |
|
307
|
|
|
|
|
308
|
|
|
records = []; |
|
309
|
|
|
grid.store.each(function (record) { |
|
310
|
|
|
records.push(record.data); |
|
311
|
|
|
}); |
|
312
|
|
|
records.push(newRow); |
|
313
|
|
|
params['positions'] = Ext.JSON.encode(records); |
|
|
|
|
|
|
314
|
|
|
|
|
315
|
|
|
break; |
|
316
|
|
|
} |
|
317
|
|
|
return; |
|
318
|
|
|
case 'updateOrder': |
|
319
|
|
|
records = []; |
|
320
|
|
|
grid.store.each(function (record) { |
|
321
|
|
|
records.push(record.data); |
|
322
|
|
|
}); |
|
323
|
|
|
params['positions'] = Ext.JSON.encode(records); |
|
|
|
|
|
|
324
|
|
|
break; |
|
325
|
|
|
case 'refund': |
|
326
|
|
|
case 'activate': |
|
327
|
|
|
Ext.iterate(records, function (record, index) { |
|
|
|
|
|
|
328
|
|
|
params['positions[' + record.getId() + ']'] = record.get('selection') || record.get('quantity'); |
|
329
|
|
|
}); |
|
330
|
|
|
break; |
|
331
|
|
|
default: |
|
332
|
|
|
break; |
|
333
|
|
|
} |
|
334
|
|
|
switch (button.action) { |
|
|
|
|
|
|
335
|
|
|
case 'cancelOrder': |
|
336
|
|
|
url = '{url controller=paymentKlarna action=cancel}'; |
|
337
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
338
|
|
|
break; |
|
339
|
|
|
case 'updateOrder': |
|
340
|
|
|
case 'add': |
|
341
|
|
|
url = '{url controller=paymentKlarna action=update}'; |
|
342
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
343
|
|
|
break; |
|
344
|
|
|
case 'creditOrder': |
|
345
|
|
|
url = '{url controller=paymentKlarna action=credit}'; |
|
346
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
347
|
|
|
break; |
|
348
|
|
|
case 'activateOrder': |
|
349
|
|
|
url = '{url controller=paymentKlarna action=activate}'; |
|
350
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
351
|
|
|
break; |
|
352
|
|
|
case 'refund': |
|
353
|
|
|
url = '{url controller=paymentKlarna action=refund}'; |
|
354
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
355
|
|
|
break; |
|
356
|
|
|
case 'activate': |
|
357
|
|
|
url = '{url controller=paymentKlarna action=activate}'; |
|
358
|
|
|
msg = 'Wollen Sie wirklich diese Aktion durchführen?'; |
|
359
|
|
|
break; |
|
360
|
|
|
case 'discount': |
|
361
|
|
|
url = '{url controller=paymentKlarna action=discount}'; |
|
362
|
|
|
msg = 'Bitte geben Sie den Betrag ein:'; |
|
363
|
|
|
prompt = true; |
|
364
|
|
|
break; |
|
365
|
|
|
} |
|
366
|
|
|
Ext.Msg.show({ |
|
|
|
|
|
|
367
|
|
|
prompt: prompt, |
|
368
|
|
|
title: button.text, |
|
369
|
|
|
msg: msg, |
|
|
|
|
|
|
370
|
|
|
buttons: Ext.Msg.OKCANCEL, |
|
371
|
|
|
callback: function (btn, text) { |
|
372
|
|
|
if (btn != 'ok') { |
|
373
|
|
|
return; |
|
374
|
|
|
} |
|
375
|
|
|
if (text) { |
|
376
|
|
|
params['value'] = text; |
|
377
|
|
|
} |
|
378
|
|
|
var result = me.doRequest(url, params); |
|
|
|
|
|
|
379
|
|
|
if (result.success) { |
|
380
|
|
|
Shopware.Notification.createGrowlMessage(button.text, 'Die Aktion wurde erfolgreich ausgeführt.', panel.title); |
|
|
|
|
|
|
381
|
|
|
} else { |
|
382
|
|
|
Shopware.Notification.createStickyGrowlMessage({ |
|
383
|
|
|
title: button.text, |
|
384
|
|
|
text: 'Es ist ein Fehler aufgetreten:<br> ' + result.message |
|
385
|
|
|
}, panel.title); |
|
386
|
|
|
} |
|
387
|
|
|
me.subApplication.getStore('Order').load({ |
|
388
|
|
|
callback: function (records) { |
|
389
|
|
|
Ext.iterate(records, function (record) { |
|
|
|
|
|
|
390
|
|
|
if (record.getId() == order.getId()) { |
|
391
|
|
|
me.onUpdateDetailPage(record, window); |
|
392
|
|
|
} |
|
393
|
|
|
}); |
|
394
|
|
|
} |
|
395
|
|
|
}); |
|
396
|
|
|
} |
|
397
|
|
|
}); |
|
398
|
|
|
}, |
|
399
|
|
|
doRequest: function (url, params) { |
|
400
|
|
|
var me = this, |
|
|
|
|
|
|
401
|
|
|
result; |
|
402
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
403
|
|
|
url: url, |
|
404
|
|
|
params: params, |
|
405
|
|
|
async: false, |
|
406
|
|
|
success: function (response) { |
|
407
|
|
|
result = Ext.decode(response.responseText); |
|
|
|
|
|
|
408
|
|
|
}, |
|
409
|
|
|
failure: function (response) { |
|
410
|
|
|
console.log(response); |
|
|
|
|
|
|
411
|
|
|
} |
|
412
|
|
|
}); |
|
413
|
|
|
return result; |
|
414
|
|
|
}, |
|
415
|
|
|
onUpdateDetailPage: function (order, window) { |
|
416
|
|
|
var me = this, |
|
417
|
|
|
klarnaPanel = window.down('order-klarna-panel'), |
|
418
|
|
|
klarnaGrid = window.down('order-klarna-panel grid'), |
|
419
|
|
|
positionPanel = window.down('order-position-panel'), |
|
420
|
|
|
positionGrid = window.down('order-position-panel grid'), |
|
421
|
|
|
documentPanel = window.down('order-document-panel'), |
|
422
|
|
|
documentGrid = window.down('order-document-panel grid'); |
|
423
|
|
|
me.callOverridden(arguments); |
|
424
|
|
|
klarnaPanel.record = order; |
|
425
|
|
|
klarnaGrid.reconfigure(order.getPositions()); |
|
426
|
|
|
positionPanel.record = order; |
|
427
|
|
|
positionGrid.reconfigure(order.getPositions()); |
|
428
|
|
|
documentPanel.record = order; |
|
429
|
|
|
documentGrid.reconfigure(order.getReceipt()); |
|
430
|
|
|
me.onUpdateButtons(order, window); |
|
431
|
|
|
}, |
|
432
|
|
|
onUpdateButtons: function (order, window) { |
|
433
|
|
|
var me = this, |
|
|
|
|
|
|
434
|
|
|
// attribute = order.getAttributes().first(), |
|
435
|
|
|
positions = order.getPositions(), |
|
436
|
|
|
// hasInvoice = !!attribute.get('swagKlarnaInvoiceNumber'), |
|
437
|
|
|
// status = attribute.get('swagKlarnaStatus'), |
|
438
|
|
|
discountButton = window.down('button[action=discount]'), |
|
439
|
|
|
addButton = window.down('button[action=add]'), |
|
440
|
|
|
activateButton = window.down('button[action=activateOrder]'), |
|
441
|
|
|
cancelButton = window.down('button[action=cancelOrder]'), |
|
442
|
|
|
creditButton = window.down('button[action=creditOrder]'), |
|
443
|
|
|
updateButton = window.down('button[action=updateOrder]'), |
|
444
|
|
|
searchField = window.down('articlesearch'), |
|
445
|
|
|
hasActivatedPositions = false; |
|
446
|
|
|
|
|
447
|
|
|
var hasInvoice; |
|
448
|
|
|
var status; |
|
449
|
|
|
if(typeof order.getAttributes !== 'function') { |
|
450
|
|
|
var orderId = order.getId(); |
|
451
|
|
|
var tableName = 's_order_attributes'; |
|
452
|
|
|
var response; |
|
453
|
|
|
order.getAttribute = |
|
454
|
|
|
function (orderID, tableName){ |
|
455
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
456
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
457
|
|
|
async: false, |
|
458
|
|
|
params: { |
|
459
|
|
|
_foreignKey: orderID, |
|
460
|
|
|
_table: tableName |
|
461
|
|
|
}, |
|
462
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
463
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
464
|
|
|
|
|
465
|
|
|
} |
|
466
|
|
|
}); |
|
467
|
|
|
return response; |
|
468
|
|
|
}; |
|
469
|
|
|
|
|
470
|
|
|
response = order.getAttribute(orderId, tableName); |
|
471
|
|
|
status = response.data.__attribute_swag_klarna_status; |
|
472
|
|
|
hasInvoice = response.data.__attribute_swag_klarna_invoice_number; |
|
473
|
|
|
} else{ |
|
474
|
|
|
var attribute = order.getAttributes().first(); |
|
475
|
|
|
hasInvoice = !!attribute.get('swagKlarnaInvoiceNumber'); |
|
476
|
|
|
status = attribute.get('swagKlarnaStatus'); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
|
|
|
|
480
|
|
|
positions.each(function(item) { |
|
481
|
|
|
if (item.get('statusId') === 3) { |
|
482
|
|
|
hasActivatedPositions = true; |
|
483
|
|
|
} |
|
484
|
|
|
}); |
|
485
|
|
|
|
|
486
|
|
|
if (status == 'activate' || status == 'cancel' || status == 'credit' || status == 'pending') { |
|
487
|
|
|
activateButton.disable(); |
|
488
|
|
|
addButton.disable(); |
|
489
|
|
|
cancelButton.disable(); |
|
490
|
|
|
updateButton.disable(); |
|
491
|
|
|
searchField.setDisabled(true); |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
if (hasActivatedPositions) { |
|
495
|
|
|
discountButton.enable(); |
|
496
|
|
|
} |
|
497
|
|
|
|
|
498
|
|
|
if (status == 'activate') { |
|
499
|
|
|
if (hasInvoice) { |
|
500
|
|
|
discountButton.enable(); |
|
501
|
|
|
} |
|
502
|
|
|
creditButton.enable(); |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
if (status == 'cancel' || status == 'credit') { |
|
506
|
|
|
creditButton.disable(); |
|
507
|
|
|
discountButton.disable(); |
|
508
|
|
|
} |
|
509
|
|
|
} |
|
510
|
|
|
}); |
|
511
|
|
|
//{/block} |
|
512
|
|
|
|
|
513
|
|
|
//{block name="backend/order/view/detail/window" append} |
|
514
|
|
|
Ext.define('Shopware.apps.Order.view.detail.Window-Klarna', { |
|
|
|
|
|
|
515
|
|
|
override: 'Shopware.apps.Order.view.detail.Window', |
|
516
|
|
|
|
|
517
|
|
|
createTabPanel: function () { |
|
518
|
|
|
var me = this, |
|
519
|
|
|
panel = me.callOverridden(arguments), |
|
520
|
|
|
payment = me.record.getPayment().first(); |
|
521
|
|
|
if (payment.get('name').indexOf('klarna_') === 0) { |
|
522
|
|
|
panel.add({ |
|
523
|
|
|
xtype: 'order-klarna-panel', |
|
524
|
|
|
title: 'Klarna', |
|
525
|
|
|
record: me.record, |
|
526
|
|
|
taxStore: me.taxStore, |
|
527
|
|
|
statusStore: me.statusStore |
|
528
|
|
|
}); |
|
529
|
|
|
panel.down('order-position-panel').disable(); |
|
530
|
|
|
} |
|
531
|
|
|
return panel; |
|
532
|
|
|
} |
|
533
|
|
|
}); |
|
534
|
|
|
|
|
535
|
|
|
Ext.define('Shopware.apps.Order.view.detail.Klarna', { |
|
|
|
|
|
|
536
|
|
|
extend: 'Ext.container.Container', |
|
537
|
|
|
alias: 'widget.order-klarna-panel', |
|
538
|
|
|
cls: Ext.baseCSSPrefix + 'klarna-panel', |
|
539
|
|
|
layout: 'fit', |
|
540
|
|
|
style: { |
|
541
|
|
|
background: '#fff' |
|
542
|
|
|
}, |
|
543
|
|
|
bodyPadding: 10, |
|
544
|
|
|
title: 'Klarna', |
|
545
|
|
|
initComponent: function () { |
|
546
|
|
|
var me = this; |
|
547
|
|
|
me.items = [me.getGrid()]; |
|
548
|
|
|
me.callParent(arguments) |
|
549
|
|
|
}, |
|
550
|
|
|
getGrid: function () { |
|
551
|
|
|
var me = this; |
|
552
|
|
|
|
|
553
|
|
|
me.rowEditor = Ext.create('Ext.grid.plugin.CellEditing', { |
|
|
|
|
|
|
554
|
|
|
clicksToEdit: 1 |
|
555
|
|
|
}); |
|
556
|
|
|
|
|
557
|
|
|
me.orderPositionGrid = Ext.create('Shopware.apps.Order.view.list.Position', { |
|
558
|
|
|
store: me.record.getPositions(), |
|
559
|
|
|
taxStore: me.taxStore, |
|
560
|
|
|
statusStore: me.statusStore, |
|
561
|
|
|
plugins: [me.rowEditor], |
|
562
|
|
|
style: { |
|
563
|
|
|
borderTop: '1px solid #A4B5C0' |
|
564
|
|
|
}, |
|
565
|
|
|
dockedItems: me.getGridDockedItems(), |
|
566
|
|
|
selModel: me.getSelectionModel(), |
|
567
|
|
|
getColumns: function () { |
|
568
|
|
|
return me.getGridColumns(this); |
|
569
|
|
|
} |
|
570
|
|
|
}); |
|
571
|
|
|
|
|
572
|
|
|
return me.orderPositionGrid; |
|
573
|
|
|
}, |
|
574
|
|
|
getSelectionModel: function () { |
|
575
|
|
|
return Ext.create('Ext.selection.CheckboxModel', { |
|
|
|
|
|
|
576
|
|
|
panel: this |
|
577
|
|
|
}); |
|
578
|
|
|
}, |
|
579
|
|
|
getGridDockedItems: function () { |
|
580
|
|
|
var me = this; |
|
581
|
|
|
return [{ |
|
582
|
|
|
xtype: 'toolbar', |
|
583
|
|
|
ui: 'shopware-ui', |
|
584
|
|
|
dock: 'top', |
|
585
|
|
|
border: false, |
|
586
|
|
|
items: me.getTopBar() |
|
587
|
|
|
}, { |
|
588
|
|
|
xtype: 'toolbar', |
|
589
|
|
|
ui: 'shopware-ui', |
|
590
|
|
|
dock: 'top', |
|
591
|
|
|
border: false, |
|
592
|
|
|
items: me.getSecondBar() |
|
593
|
|
|
}]; |
|
594
|
|
|
}, |
|
595
|
|
|
getTopBar: function () { |
|
596
|
|
|
var me = this; |
|
597
|
|
|
var status; |
|
598
|
|
|
if(typeof me.record.getAttributes !== 'function') { |
|
599
|
|
|
var orderId = me.record.getId(); |
|
600
|
|
|
var tableName = 's_order_attributes'; |
|
601
|
|
|
var response; |
|
602
|
|
|
me.record.getAttribute = |
|
603
|
|
|
function (orderID, tableName){ |
|
604
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
605
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
606
|
|
|
async: false, |
|
607
|
|
|
params: { |
|
608
|
|
|
_foreignKey: orderID, |
|
609
|
|
|
_table: tableName |
|
610
|
|
|
}, |
|
611
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
612
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
613
|
|
|
|
|
614
|
|
|
} |
|
615
|
|
|
}); |
|
616
|
|
|
return response; |
|
617
|
|
|
}; |
|
618
|
|
|
|
|
619
|
|
|
response = me.record.getAttribute(orderId, tableName); |
|
620
|
|
|
status = response.data.__attribute_swag_klarna_status; |
|
621
|
|
|
} else{ |
|
622
|
|
|
var attribute = me.record.getAttributes().first(); |
|
623
|
|
|
status = attribute.get('swagKlarnaStatus'); |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
var items = []; |
|
627
|
|
|
items.push({ |
|
628
|
|
|
iconCls: 'sprite-tick-circle-frame', |
|
629
|
|
|
text: 'Bestellung aktivieren', |
|
630
|
|
|
disabled: status == 'activate' || status == 'cancel' || status == 'credit' || status == 'pending' || status == 'denied' || status == null, |
|
631
|
|
|
action: 'activateOrder' |
|
632
|
|
|
}); |
|
633
|
|
|
items.push({ |
|
634
|
|
|
iconCls: 'sprite-minus-circle-frame', |
|
635
|
|
|
text: 'Bestellung stornieren', |
|
636
|
|
|
disabled: status == 'activate' || status == 'cancel' || status == 'credit', |
|
637
|
|
|
action: 'cancelOrder' |
|
638
|
|
|
}); |
|
639
|
|
|
items.push({ |
|
640
|
|
|
iconCls: 'sprite-minus-circle-frame', |
|
641
|
|
|
text: 'Bestellung retournieren', |
|
642
|
|
|
disabled: status != 'activate', |
|
643
|
|
|
action: 'creditOrder' |
|
644
|
|
|
}); |
|
645
|
|
|
items.push({ |
|
646
|
|
|
iconCls: 'sprite-tick-circle-frame', |
|
647
|
|
|
text: 'Auswahl aktivieren', |
|
648
|
|
|
disabled: true, |
|
649
|
|
|
action: 'activate' |
|
650
|
|
|
}); |
|
651
|
|
|
items.push({ |
|
652
|
|
|
iconCls: 'sprite-minus-circle-frame', |
|
653
|
|
|
text: 'Auswahl retournieren', |
|
654
|
|
|
disabled: true, |
|
655
|
|
|
action: 'refund' |
|
656
|
|
|
}); |
|
657
|
|
|
return items; |
|
658
|
|
|
}, |
|
659
|
|
|
getSecondBar: function () { |
|
660
|
|
|
var me = this, |
|
661
|
|
|
// attribute = me.record.getAttributes().first(), |
|
662
|
|
|
positions = me.record.getPositions(), |
|
663
|
|
|
//status = attribute.get('swagKlarnaStatus'), |
|
664
|
|
|
hasActivatedPositions = false; |
|
665
|
|
|
var status; |
|
666
|
|
|
|
|
667
|
|
|
if(typeof me.record.getAttributes !== 'function') { |
|
668
|
|
|
var orderId = me.record.getId(); |
|
669
|
|
|
var tableName = 's_order_attributes'; |
|
670
|
|
|
var response; |
|
671
|
|
|
me.record.getAttribute = |
|
672
|
|
|
function (orderID, tableName){ |
|
673
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
674
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
675
|
|
|
async: false, |
|
676
|
|
|
params: { |
|
677
|
|
|
_foreignKey: orderID, |
|
678
|
|
|
_table: tableName |
|
679
|
|
|
}, |
|
680
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
681
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
682
|
|
|
|
|
683
|
|
|
} |
|
684
|
|
|
}); |
|
685
|
|
|
return response; |
|
686
|
|
|
}; |
|
687
|
|
|
|
|
688
|
|
|
response = me.record.getAttribute(orderId, tableName); |
|
689
|
|
|
status = response.data.__attribute_swag_klarna_status; |
|
690
|
|
|
} else{ |
|
691
|
|
|
var attribute = me.record.getAttributes().first(); |
|
692
|
|
|
status = attribute.get('swagKlarnaStatus'); |
|
693
|
|
|
} |
|
694
|
|
|
|
|
695
|
|
|
positions.each(function(item) { |
|
696
|
|
|
if (item.get('statusId') === 3) { |
|
697
|
|
|
hasActivatedPositions = true; |
|
698
|
|
|
} |
|
699
|
|
|
}); |
|
700
|
|
|
|
|
701
|
|
|
var items = []; |
|
702
|
|
|
items.push({ |
|
703
|
|
|
iconCls: 'sprite-plus-circle-frame', |
|
704
|
|
|
text: 'Gutschrift hinzufügen', |
|
705
|
|
|
disabled: !hasActivatedPositions || status == 'credit' || status == 'cancel', |
|
706
|
|
|
action: 'discount' |
|
707
|
|
|
}); |
|
708
|
|
|
items.push({ |
|
709
|
|
|
xtype: 'articlesearch', |
|
710
|
|
|
name: 'article', |
|
711
|
|
|
disabled: status == 'activate' || status == 'credit' || status == 'cancel' |
|
712
|
|
|
}); |
|
713
|
|
|
items.push({ |
|
714
|
|
|
iconCls: 'sprite-plus-circle-frame', |
|
715
|
|
|
text: 'Artikel hinzufügen', |
|
716
|
|
|
disabled: status == 'activate' || status == 'credit' || status == 'cancel', |
|
717
|
|
|
action: 'add' |
|
718
|
|
|
}); |
|
719
|
|
|
items.push({ |
|
720
|
|
|
iconCls: 'sprite-arrow-circle', |
|
721
|
|
|
text: 'Bestellung aktualisieren', |
|
722
|
|
|
disabled: status == 'activate' || status == 'credit' || status == 'cancel', |
|
723
|
|
|
action: 'updateOrder' |
|
724
|
|
|
}); |
|
725
|
|
|
return items; |
|
726
|
|
|
}, |
|
727
|
|
|
getGridColumns: function (grid) { |
|
728
|
|
|
var me = this; |
|
729
|
|
|
return [{ |
|
730
|
|
|
header: grid.snippets.articleNumber, |
|
731
|
|
|
dataIndex: 'articleNumber', |
|
732
|
|
|
flex: 2 |
|
733
|
|
|
}, { |
|
734
|
|
|
header: grid.snippets.articleName, |
|
735
|
|
|
dataIndex: 'articleName', |
|
736
|
|
|
flex: 2, |
|
737
|
|
|
editor: { |
|
738
|
|
|
xtype: 'textfield' |
|
739
|
|
|
} |
|
740
|
|
|
}, { |
|
741
|
|
|
header: grid.snippets.quantity, |
|
742
|
|
|
dataIndex: 'quantity', |
|
743
|
|
|
flex: 1, |
|
744
|
|
|
editor: { |
|
745
|
|
|
xtype: 'numberfield', |
|
746
|
|
|
allowBlank: false, |
|
747
|
|
|
minValue: 0 |
|
748
|
|
|
} |
|
749
|
|
|
}, { |
|
750
|
|
|
header: grid.snippets.price, |
|
751
|
|
|
dataIndex: 'price', |
|
752
|
|
|
flex: 1, |
|
753
|
|
|
renderer: grid.priceColumn, |
|
754
|
|
|
editor: { |
|
755
|
|
|
xtype: 'numberfield', |
|
756
|
|
|
allowBlank: false, |
|
757
|
|
|
decimalPrecision: 2 |
|
758
|
|
|
} |
|
759
|
|
|
}, { |
|
760
|
|
|
header: grid.snippets.total, |
|
761
|
|
|
dataIndex: 'total', |
|
762
|
|
|
flex: 1, |
|
763
|
|
|
renderer: grid.totalColumn |
|
764
|
|
|
}, { |
|
765
|
|
|
header: 'Rechnung', |
|
766
|
|
|
dataIndex: 'id', |
|
767
|
|
|
flex: 2, |
|
768
|
|
|
renderer: me.invoiceRenderer |
|
769
|
|
|
}, { |
|
770
|
|
|
header: grid.snippets.status, |
|
771
|
|
|
dataIndex: 'statusId', |
|
772
|
|
|
flex: 2, |
|
773
|
|
|
renderer: grid.statusRenderer, |
|
774
|
|
|
editor: { |
|
775
|
|
|
allowBlank: false, |
|
776
|
|
|
editable: false, |
|
777
|
|
|
xtype: 'combobox', |
|
778
|
|
|
queryMode: 'local', |
|
779
|
|
|
store: grid.statusStore, |
|
780
|
|
|
displayField: 'description', |
|
781
|
|
|
valueField: 'id' |
|
782
|
|
|
} |
|
783
|
|
|
}, { |
|
784
|
|
|
header: grid.snippets.tax, |
|
785
|
|
|
dataIndex: 'taxId', |
|
786
|
|
|
flex: 1, |
|
787
|
|
|
renderer: grid.taxRenderer, |
|
788
|
|
|
editor: { |
|
789
|
|
|
xtype: 'combobox', |
|
790
|
|
|
editable: false, |
|
791
|
|
|
queryMode: 'local', |
|
792
|
|
|
allowBlank: false, |
|
793
|
|
|
store: grid.taxStore, |
|
794
|
|
|
displayField: 'name', |
|
795
|
|
|
valueField: 'id' |
|
796
|
|
|
} |
|
797
|
|
|
}, { |
|
798
|
|
|
header: grid.snippets.inStock, |
|
799
|
|
|
dataIndex: 'inStock', |
|
800
|
|
|
flex: 1 |
|
801
|
|
|
}, { |
|
802
|
|
|
header: 'Verschickt', |
|
803
|
|
|
dataIndex: 'shipped', |
|
804
|
|
|
flex: 1 |
|
805
|
|
|
}, { |
|
806
|
|
|
header: 'Auswahl', |
|
807
|
|
|
dataIndex: 'selection', |
|
808
|
|
|
flex: 1, |
|
809
|
|
|
editor: { |
|
810
|
|
|
xtype: 'numberfield', |
|
811
|
|
|
allowBlank: false, |
|
812
|
|
|
minValue: 0 |
|
813
|
|
|
} |
|
814
|
|
|
}, { |
|
815
|
|
|
xtype: 'actioncolumn', |
|
816
|
|
|
width: 90, |
|
817
|
|
|
items: [{ |
|
818
|
|
|
iconCls: 'sprite-blue-document-pdf-text', |
|
819
|
|
|
action: 'invoice', |
|
820
|
|
|
tooltip: 'Rechnung öffnen', |
|
821
|
|
|
handler: me.handleInvoiceAction, |
|
822
|
|
|
getClass: me.getInvoiceClass |
|
823
|
|
|
},{ |
|
824
|
|
|
iconCls: 'sprite-blue-document-template', |
|
825
|
|
|
action: 'shipping', |
|
826
|
|
|
tooltip: 'Lieferschein öffnen', |
|
827
|
|
|
handler: me.handleInvoiceAction, |
|
828
|
|
|
getClass: me.getInvoiceClass |
|
829
|
|
|
},{ |
|
830
|
|
|
iconCls: 'sprite-inbox', |
|
831
|
|
|
action: 'openArticle', |
|
832
|
|
|
tooltip: grid.snippets.openArticle, |
|
833
|
|
|
handler: function (view, rowIndex, colIndex, item) { |
|
|
|
|
|
|
834
|
|
|
var store = view.getStore(), |
|
835
|
|
|
record = store.getAt(rowIndex); |
|
836
|
|
|
grid.fireEvent('openArticle', record); |
|
837
|
|
|
}, |
|
838
|
|
|
getClass: function (value, metadata, record) { |
|
839
|
|
|
if (!record.get('articleId')) { |
|
|
|
|
|
|
840
|
|
|
return 'x-hidden'; |
|
841
|
|
|
} |
|
842
|
|
|
} |
|
843
|
|
|
}] |
|
844
|
|
|
}]; |
|
845
|
|
|
|
|
846
|
|
|
}, |
|
847
|
|
|
getInvoiceClass: function(value, metaData, record) { |
|
|
|
|
|
|
848
|
|
|
var invoiceNumber; |
|
849
|
|
|
if(typeof record.getAttributes !== 'function') { |
|
850
|
|
|
var orderId = record.getId(); |
|
851
|
|
|
var tableName = 's_order_details_attributes'; |
|
852
|
|
|
var response; |
|
853
|
|
|
record.getAttribute = |
|
854
|
|
|
function (orderID, tableName){ |
|
855
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
856
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
857
|
|
|
async: false, |
|
858
|
|
|
params: { |
|
859
|
|
|
_foreignKey: orderID, |
|
860
|
|
|
_table: tableName |
|
861
|
|
|
}, |
|
862
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
863
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
864
|
|
|
|
|
865
|
|
|
} |
|
866
|
|
|
}); |
|
867
|
|
|
return response; |
|
868
|
|
|
}; |
|
869
|
|
|
response = record.getAttribute(orderId, tableName); |
|
870
|
|
|
invoiceNumber = response.data.__attribute_swag_klarna_invoice_number; |
|
871
|
|
|
if (!invoiceNumber){ |
|
|
|
|
|
|
872
|
|
|
return 'x-hidden'; |
|
873
|
|
|
} |
|
874
|
|
|
} else{ |
|
875
|
|
|
if (!record.raw.attribute || !record.raw.attribute.swagKlarnaInvoiceNumber) { |
|
|
|
|
|
|
876
|
|
|
return 'x-hidden'; |
|
877
|
|
|
} |
|
878
|
|
|
} |
|
879
|
|
|
}, |
|
880
|
|
|
handleInvoiceAction: function (view, rowIndex, colIndex, item) { |
|
881
|
|
|
var store = view.getStore(), |
|
882
|
|
|
record = store.getAt(rowIndex), |
|
883
|
|
|
orderId = record.getId(), |
|
884
|
|
|
invoiceNumber = ''; |
|
885
|
|
|
|
|
886
|
|
|
if (typeof record.getAttributes === 'function') { |
|
887
|
|
|
if (!record.raw || !record.raw.attribute) { |
|
888
|
|
|
return; |
|
889
|
|
|
} |
|
890
|
|
|
invoiceNumber = record.raw.attribute.swagKlarnaInvoiceNumber; |
|
891
|
|
|
} |
|
892
|
|
|
|
|
893
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
894
|
|
|
url: '{url controller=PaymentKlarna action=getInvoiceSecret}', |
|
895
|
|
|
params: { |
|
896
|
|
|
orderId: orderId, |
|
897
|
|
|
invoiceNo: invoiceNumber |
|
898
|
|
|
}, |
|
899
|
|
|
success: function(response) { |
|
900
|
|
|
var data = Ext.JSON.decode(response.responseText); |
|
|
|
|
|
|
901
|
|
|
if (data['success']) { |
|
902
|
|
|
invoiceNumber = data['invoiceNo']; |
|
903
|
|
|
var sub = data['testDrive'] ? 'testdrive.' : ''; |
|
904
|
|
|
var link = 'https://online.' + sub + 'klarna.com/'; |
|
905
|
|
|
link += (item.action == 'invoice') ? 'invoices/' : 'packslips/'; |
|
906
|
|
|
link += invoiceNumber + '.pdf'; |
|
907
|
|
|
link += (item.action == 'invoice') ? '?secret=' + data['secret'] : ''; |
|
908
|
|
|
window.open(link); |
|
909
|
|
|
} |
|
910
|
|
|
} |
|
911
|
|
|
}); |
|
912
|
|
|
}, |
|
913
|
|
|
invoiceRenderer: function(value, metaData, record) { |
|
|
|
|
|
|
914
|
|
|
var invoiceNumber; |
|
915
|
|
|
if(typeof record.getAttributes !== 'function') { |
|
916
|
|
|
var orderId = record.getId(); |
|
917
|
|
|
var tableName = 's_order_details_attributes'; |
|
918
|
|
|
var response; |
|
919
|
|
|
record.getAttribute = |
|
920
|
|
|
function (orderID, tableName){ |
|
921
|
|
|
Ext.Ajax.request({ |
|
|
|
|
|
|
922
|
|
|
url: '{url controller=AttributeData action=loadData}', |
|
923
|
|
|
async: false, |
|
924
|
|
|
params: { |
|
925
|
|
|
_foreignKey: orderID, |
|
926
|
|
|
_table: tableName |
|
927
|
|
|
}, |
|
928
|
|
|
success: function(responseData, request) { |
|
|
|
|
|
|
929
|
|
|
response = Ext.JSON.decode(responseData.responseText); |
|
|
|
|
|
|
930
|
|
|
|
|
931
|
|
|
} |
|
932
|
|
|
}); |
|
933
|
|
|
return response; |
|
934
|
|
|
}; |
|
935
|
|
|
response = record.getAttribute(orderId, tableName); |
|
936
|
|
|
invoiceNumber = response.data.__attribute_swag_klarna_invoice_number; |
|
937
|
|
|
} else{ |
|
938
|
|
|
if (!record.raw || !record.raw.attribute) { |
|
939
|
|
|
return; |
|
940
|
|
|
} |
|
941
|
|
|
invoiceNumber = record.raw.attribute.swagKlarnaInvoiceNumber; |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
|
|
945
|
|
|
if (!invoiceNumber) { |
|
946
|
|
|
console.log("invoiceRenderer: record.raw.attribute.swagKlarnaInvoiceNumber is undefined") |
|
|
|
|
|
|
947
|
|
|
return; |
|
948
|
|
|
} |
|
949
|
|
|
return invoiceNumber; |
|
950
|
|
|
} |
|
951
|
|
|
}); |
|
952
|
|
|
//{/block} |
|
953
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.