Version Notes
Bugfixes and performance improvements
Download this release
Release Info
Developer | Komfortkasse |
Extension | Ltc_Komfortkasse |
Version | 1.4.4 |
Comparing to | |
See all releases |
Code changes from version 1.4.3.1 to 1.4.4
app/code/community/Ltc/Komfortkasse/Helper/Komfortkasse.php
CHANGED
@@ -8,7 +8,7 @@ require_once 'Komfortkasse_Order.php';
|
|
8 |
*/
|
9 |
class Komfortkasse
|
10 |
{
|
11 |
-
const PLUGIN_VER = '1.4.
|
12 |
const MAXLEN_SSL = 117;
|
13 |
const LEN_MCRYPT = 16;
|
14 |
|
@@ -353,6 +353,26 @@ class Komfortkasse
|
|
353 |
|
354 |
// end update()
|
355 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
/**
|
358 |
* Notify order.
|
@@ -367,15 +387,14 @@ class Komfortkasse
|
|
367 |
return;
|
368 |
}
|
369 |
|
370 |
-
// See if order is relevant.
|
371 |
-
$openids = Komfortkasse_Order::getOpenIDs();
|
372 |
-
if (in_array($id, $openids) === false) {
|
373 |
-
return;
|
374 |
-
}
|
375 |
-
|
376 |
$order = Komfortkasse_Order::getOrder($id);
|
377 |
$order['type'] = self::getOrderType($order['payment_method']);
|
378 |
|
|
|
|
|
|
|
|
|
|
|
379 |
$queryRaw = http_build_query($order);
|
380 |
|
381 |
$queryEnc = Komfortkasse::kkencrypt($queryRaw);
|
8 |
*/
|
9 |
class Komfortkasse
|
10 |
{
|
11 |
+
const PLUGIN_VER = '1.4.4';
|
12 |
const MAXLEN_SSL = 117;
|
13 |
const LEN_MCRYPT = 16;
|
14 |
|
353 |
|
354 |
// end update()
|
355 |
|
356 |
+
private static function isOpen($order)
|
357 |
+
{
|
358 |
+
$methods = '';
|
359 |
+
$status = '';
|
360 |
+
switch ($order ['type']) {
|
361 |
+
case 'PREPAYMENT' :
|
362 |
+
$status = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open, $order);
|
363 |
+
break;
|
364 |
+
case 'INVOICE' :
|
365 |
+
$status = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open, $order);
|
366 |
+
break;
|
367 |
+
case 'COD' :
|
368 |
+
$status = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open, $order);
|
369 |
+
break;
|
370 |
+
default:
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
|
374 |
+
return in_array($order['status'], explode(',', $status));
|
375 |
+
}
|
376 |
|
377 |
/**
|
378 |
* Notify order.
|
387 |
return;
|
388 |
}
|
389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
$order = Komfortkasse_Order::getOrder($id);
|
391 |
$order['type'] = self::getOrderType($order['payment_method']);
|
392 |
|
393 |
+
// See if order is relevant.
|
394 |
+
if (!self::isOpen($order)) {
|
395 |
+
return;
|
396 |
+
}
|
397 |
+
|
398 |
$queryRaw = http_build_query($order);
|
399 |
|
400 |
$queryEnc = Komfortkasse::kkencrypt($queryRaw);
|
app/code/community/Ltc/Komfortkasse/Helper/Komfortkasse_Order.php
CHANGED
@@ -1,497 +1,444 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Komfortkasse Order Class
|
6 |
-
* in KK, an Order is an Array providing the following members:
|
7 |
-
* number, date, email, customer_number, payment_method, amount, currency_code, exchange_rate, language_code, invoice_number, store_id
|
8 |
-
* status: data type according to the shop system
|
9 |
-
* delivery_ and billing_: _firstname, _lastname, _company, _street, _postcode, _city, _countrycode
|
10 |
-
* products: an Array of item numbers
|
11 |
-
* @version 1.4.
|
12 |
-
*/
|
13 |
-
$path = Mage::getModuleDir('', 'Ltc_Komfortkasse');
|
14 |
-
$order_extension = false;
|
15 |
-
if (file_exists("{$path}/Helper/Komfortkasse_Order_Extension.php") === true) {
|
16 |
-
$order_extension = true;
|
17 |
-
include_once "{$path}/Helper/Komfortkasse_Order_Extension.php";
|
18 |
-
}
|
19 |
-
class Komfortkasse_Order
|
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 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
try {
|
141 |
-
$method = $order->getPayment()->getMethodInstance()->getCode();
|
142 |
-
} catch (Exception $e) {
|
143 |
-
// payment method has been deleted
|
144 |
-
$method = null;
|
145 |
-
}
|
146 |
-
if ($method && in_array($method, $paymentMethods, true) === true) {
|
147 |
-
$
|
148 |
-
$ret [] = $
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
*
|
166 |
-
*
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
$
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
if (
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
)
|
402 |
-
|
403 |
-
}
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
/**
|
446 |
-
* Call an object's save method
|
447 |
-
*
|
448 |
-
* @param unknown $object
|
449 |
-
*
|
450 |
-
* @return void
|
451 |
-
*/
|
452 |
-
private static function mysave($object)
|
453 |
-
{
|
454 |
-
$object->save();
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
|
459 |
-
public static function getInvoicePdfPrepare()
|
460 |
-
{
|
461 |
-
|
462 |
-
}
|
463 |
-
|
464 |
-
|
465 |
-
public static function getInvoicePdf($invoiceNumber)
|
466 |
-
{
|
467 |
-
if ($invoiceNumber && $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceNumber)) {
|
468 |
-
$fileName = $invoiceNumber . '.pdf';
|
469 |
-
|
470 |
-
$pdfGenerated = false;
|
471 |
-
|
472 |
-
// try easy pdf (www.easypdfinvoice.com)
|
473 |
-
if (!$pdfGenerated) {
|
474 |
-
$pdfProModel = Mage::getModel('pdfpro/order_invoice');
|
475 |
-
if ($pdfProModel !== false) {
|
476 |
-
$invoiceData = $pdfProModel->initInvoiceData($invoice);
|
477 |
-
$result = Mage::helper('pdfpro')->initPdf(array ($invoiceData
|
478 |
-
));
|
479 |
-
if ($result ['success']) {
|
480 |
-
$content = $result ['content'];
|
481 |
-
$pdfGenerated = true;
|
482 |
-
}
|
483 |
-
}
|
484 |
-
}
|
485 |
-
|
486 |
-
// try Magento Standard
|
487 |
-
if (!$pdfGenerated) {
|
488 |
-
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array ($invoice
|
489 |
-
));
|
490 |
-
$content = $pdf->render();
|
491 |
-
}
|
492 |
-
|
493 |
-
return $content;
|
494 |
-
}
|
495 |
-
|
496 |
-
}
|
497 |
}//end class
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Komfortkasse Order Class
|
6 |
+
* in KK, an Order is an Array providing the following members:
|
7 |
+
* number, date, email, customer_number, payment_method, amount, currency_code, exchange_rate, language_code, invoice_number, store_id
|
8 |
+
* status: data type according to the shop system
|
9 |
+
* delivery_ and billing_: _firstname, _lastname, _company, _street, _postcode, _city, _countrycode
|
10 |
+
* products: an Array of item numbers
|
11 |
+
* @version 1.4.4-Magento1
|
12 |
+
*/
|
13 |
+
$path = Mage::getModuleDir('', 'Ltc_Komfortkasse');
|
14 |
+
$order_extension = false;
|
15 |
+
if (file_exists("{$path}/Helper/Komfortkasse_Order_Extension.php") === true) {
|
16 |
+
$order_extension = true;
|
17 |
+
include_once "{$path}/Helper/Komfortkasse_Order_Extension.php";
|
18 |
+
}
|
19 |
+
class Komfortkasse_Order
|
20 |
+
{
|
21 |
+
|
22 |
+
private static function createInClause($arr)
|
23 |
+
{
|
24 |
+
if (!is_array($arr)) {
|
25 |
+
$arr = explode(',', $arr);
|
26 |
+
}
|
27 |
+
$tmp = array ();
|
28 |
+
foreach ($arr as $item) {
|
29 |
+
$tmp [] = str_replace('\'', '', $item);
|
30 |
+
}
|
31 |
+
return '(\'' . implode('\', \'', $tmp) . '\')';
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get open order IDs.
|
37 |
+
*
|
38 |
+
* @return string all order IDs that are "open" and relevant for transfer to kk
|
39 |
+
*/
|
40 |
+
public static function getOpenIDs()
|
41 |
+
{
|
42 |
+
$ret = array ();
|
43 |
+
|
44 |
+
$resource = Mage::getSingleton('core/resource');
|
45 |
+
$readConnection = $resource->getConnection('core_read');
|
46 |
+
$tableOrder = $resource->getTableName('sales/order');
|
47 |
+
$tablePayment = $resource->getTableName('sales/order_payment');
|
48 |
+
|
49 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
50 |
+
foreach ($website->getGroups() as $group) {
|
51 |
+
$stores = $group->getStores();
|
52 |
+
foreach ($stores as $store) {
|
53 |
+
$store_id = $store->getId();
|
54 |
+
$store_id_order = array ();
|
55 |
+
$store_id_order ['store_id'] = $store_id;
|
56 |
+
|
57 |
+
if (Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_export, $store_id_order)) {
|
58 |
+
|
59 |
+
$query = 'SELECT o.increment_id FROM ' . $tableOrder . ' o join ' . $tablePayment . ' p on p.parent_id = o.entity_id where o.store_id=' . $store_id . ' and (';
|
60 |
+
$first = true;
|
61 |
+
|
62 |
+
// PREPAYMENT
|
63 |
+
$openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open, $store_id_order);
|
64 |
+
$paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods, $store_id_order);
|
65 |
+
if ($openOrders && $paymentMethods) {
|
66 |
+
if (!$first)
|
67 |
+
$query .= ' or ';
|
68 |
+
$query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods) . ')';
|
69 |
+
$first = false;
|
70 |
+
}
|
71 |
+
|
72 |
+
// COD
|
73 |
+
$openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open_cod, $store_id_order);
|
74 |
+
$paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods_cod, $store_id_order);
|
75 |
+
if ($openOrders && $paymentMethods) {
|
76 |
+
if (!$first)
|
77 |
+
$query .= ' or ';
|
78 |
+
$query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods) . ')';
|
79 |
+
$first = false;
|
80 |
+
}
|
81 |
+
|
82 |
+
// INVOICE
|
83 |
+
$openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open_invoice, $store_id_order);
|
84 |
+
$paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods_invoice, $store_id_order);
|
85 |
+
if ($openOrders && $paymentMethods) {
|
86 |
+
if (!$first)
|
87 |
+
$query .= ' or ';
|
88 |
+
$query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods) . ')';
|
89 |
+
$first = false;
|
90 |
+
}
|
91 |
+
|
92 |
+
$query .= ')';
|
93 |
+
|
94 |
+
$results = $readConnection->fetchAll($query);
|
95 |
+
foreach ($results as $result) {
|
96 |
+
$ret[] = $result['increment_id'];
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
return $ret;
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
// end getOpenIDs()
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Get refund IDS.
|
112 |
+
*
|
113 |
+
* @return string all refund IDs that are "open" and relevant for transfer to kk
|
114 |
+
*/
|
115 |
+
public static function getRefundIDs()
|
116 |
+
{
|
117 |
+
$ret = array ();
|
118 |
+
|
119 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
120 |
+
foreach ($website->getGroups() as $group) {
|
121 |
+
$stores = $group->getStores();
|
122 |
+
foreach ($stores as $store) {
|
123 |
+
|
124 |
+
$store_id = $store->getId();
|
125 |
+
$store_id_order = array ();
|
126 |
+
$store_id_order ['store_id'] = $store_id;
|
127 |
+
|
128 |
+
if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_export, $store_id_order)) {
|
129 |
+
continue;
|
130 |
+
}
|
131 |
+
|
132 |
+
$paymentMethods = explode(',', Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods, $store_id_order));
|
133 |
+
|
134 |
+
$cmModel = Mage::getModel("sales/order_creditmemo");
|
135 |
+
$cmCollection = $cmModel->getCollection()->addFieldToFilter('store_id', $store_id);
|
136 |
+
|
137 |
+
foreach ($cmCollection as $creditMemo) {
|
138 |
+
if ($creditMemo->getTransactionId() == null) {
|
139 |
+
$order = $creditMemo->getOrder();
|
140 |
+
try {
|
141 |
+
$method = $order->getPayment()->getMethodInstance()->getCode();
|
142 |
+
} catch ( Exception $e ) {
|
143 |
+
// payment method has been deleted
|
144 |
+
$method = null;
|
145 |
+
}
|
146 |
+
if ($method && in_array($method, $paymentMethods, true) === true) {
|
147 |
+
$cmId = $creditMemo->getIncrementId();
|
148 |
+
$ret [] = $cmId;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
return $ret;
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
// end getRefundIDs()
|
161 |
+
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Get order.
|
165 |
+
*
|
166 |
+
* @param string $number order number
|
167 |
+
*
|
168 |
+
* @return array order
|
169 |
+
*/
|
170 |
+
public static function getOrder($number)
|
171 |
+
{
|
172 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($number);
|
173 |
+
if (empty($number) === true || empty($order) === true || $number != $order->getIncrementId()) {
|
174 |
+
return null;
|
175 |
+
}
|
176 |
+
|
177 |
+
$conf_general = Mage::getStoreConfig('general', $order->getStoreId());
|
178 |
+
|
179 |
+
$ret = array ();
|
180 |
+
$ret ['number'] = $order->getIncrementId();
|
181 |
+
$ret ['status'] = $order->getStatus();
|
182 |
+
$ret ['date'] = date('d.m.Y', strtotime($order->getCreatedAtStoreDate()->get(Zend_Date::DATE_MEDIUM)));
|
183 |
+
$ret ['email'] = $order->getCustomerEmail();
|
184 |
+
$ret ['customer_number'] = $order->getCustomerId();
|
185 |
+
try {
|
186 |
+
$ret ['payment_method'] = $order->getPayment()->getMethodInstance()->getCode();
|
187 |
+
} catch ( Exception $e ) {
|
188 |
+
}
|
189 |
+
$ret ['amount'] = $order->getGrandTotal();
|
190 |
+
$ret ['currency_code'] = $order->getOrderCurrencyCode();
|
191 |
+
$ret ['exchange_rate'] = $order->getBaseToOrderRate();
|
192 |
+
|
193 |
+
// Rechnungsnummer und -datum
|
194 |
+
$invoiceColl = $order->getInvoiceCollection();
|
195 |
+
if ($invoiceColl->getSize() > 0) {
|
196 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
197 |
+
$ret ['invoice_number'] [] = $invoice->getIncrementId();
|
198 |
+
$invoiceDate = date('d.m.Y', strtotime($invoice->getCreatedAt()));
|
199 |
+
if ($ret ['invoice_date'] == null || strtotime($ret ['invoice_date']) < strtotime($invoiceDate)) {
|
200 |
+
$ret ['invoice_date'] = $invoiceDate;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
$shippingAddress = $order->getShippingAddress();
|
206 |
+
if ($shippingAddress) {
|
207 |
+
$ret ['delivery_firstname'] = utf8_encode($shippingAddress->getFirstname());
|
208 |
+
$ret ['delivery_lastname'] = utf8_encode($shippingAddress->getLastname());
|
209 |
+
$ret ['delivery_company'] = utf8_encode($shippingAddress->getCompany());
|
210 |
+
$ret ['delivery_street'] = utf8_encode($shippingAddress->getStreetFull());
|
211 |
+
$ret ['delivery_postcode'] = utf8_encode($shippingAddress->getPostcode());
|
212 |
+
$ret ['delivery_city'] = utf8_encode($shippingAddress->getCity());
|
213 |
+
$ret ['delivery_countrycode'] = utf8_encode($shippingAddress->getCountryId());
|
214 |
+
}
|
215 |
+
|
216 |
+
$billingAddress = $order->getBillingAddress();
|
217 |
+
if ($billingAddress) {
|
218 |
+
$ret ['language_code'] = substr($conf_general ['locale'] ['code'], 0, 2) . '-' . $billingAddress->getCountryId();
|
219 |
+
$ret ['billing_firstname'] = utf8_encode($billingAddress->getFirstname());
|
220 |
+
$ret ['billing_lastname'] = utf8_encode($billingAddress->getLastname());
|
221 |
+
$ret ['billing_company'] = utf8_encode($billingAddress->getCompany());
|
222 |
+
$ret ['billing_street'] = utf8_encode($billingAddress->getStreetFull());
|
223 |
+
$ret ['billing_postcode'] = utf8_encode($billingAddress->getPostcode());
|
224 |
+
$ret ['billing_city'] = utf8_encode($billingAddress->getCity());
|
225 |
+
$ret ['billing_countrycode'] = utf8_encode($billingAddress->getCountryId());
|
226 |
+
} else {
|
227 |
+
$ret ['language_code'] = substr($conf_general ['locale'] ['code'], 0, 2);
|
228 |
+
}
|
229 |
+
|
230 |
+
foreach ($order->getAllItems() as $itemId => $item) {
|
231 |
+
$sku = $item->getSku();
|
232 |
+
if ($sku) {
|
233 |
+
$ret ['products'] [] = $sku;
|
234 |
+
} else {
|
235 |
+
$ret ['products'] [] = $item->getName();
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
$ret ['store_id'] = $order->getStoreId();
|
240 |
+
|
241 |
+
if ($order_extension && method_exists('Komfortkasse_Order_Extension', 'extendOrder') === true) {
|
242 |
+
$ret = Komfortkasse_Order_Extension::extendOrder($order, $ret);
|
243 |
+
}
|
244 |
+
|
245 |
+
return $ret;
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
// end getOrder()
|
250 |
+
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Get refund.
|
254 |
+
*
|
255 |
+
* @param string $number refund number
|
256 |
+
*
|
257 |
+
* @return array refund
|
258 |
+
*/
|
259 |
+
public static function getRefund($number)
|
260 |
+
{
|
261 |
+
$resource = Mage::getSingleton('core/resource');
|
262 |
+
$id = $resource->getConnection('core_read')->fetchOne('SELECT `entity_id` FROM `' . $resource->getTableName('sales/creditmemo') . "` WHERE `increment_id` = '" . $number . "'");
|
263 |
+
|
264 |
+
$creditMemo = Mage::getModel('sales/order_creditmemo')->load($id);
|
265 |
+
if (empty($number) === true || empty($creditMemo) === true || $number != $creditMemo->getIncrementId()) {
|
266 |
+
return null;
|
267 |
+
}
|
268 |
+
|
269 |
+
$ret = array ();
|
270 |
+
$ret ['number'] = $creditMemo->getOrder()->getIncrementId();
|
271 |
+
// Number of the Creditmemo.
|
272 |
+
$ret ['customer_number'] = $creditMemo->getIncrementId();
|
273 |
+
$ret ['date'] = date('d.m.Y', strtotime($creditMemo->getCreatedAt()));
|
274 |
+
$ret ['amount'] = $creditMemo->getGrandTotal();
|
275 |
+
|
276 |
+
return $ret;
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
// end getRefund()
|
281 |
+
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Update order.
|
285 |
+
*
|
286 |
+
* @param array $order order
|
287 |
+
* @param string $status status
|
288 |
+
* @param string $callbackid callback ID
|
289 |
+
*
|
290 |
+
* @return void
|
291 |
+
*/
|
292 |
+
public static function updateOrder($order, $status, $callbackid)
|
293 |
+
{
|
294 |
+
if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_update, $order)) {
|
295 |
+
return;
|
296 |
+
}
|
297 |
+
|
298 |
+
// Hint: PAID and CANCELLED are supported as of now.
|
299 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order ['number']);
|
300 |
+
|
301 |
+
Mage::dispatchEvent('komfortkasse_change_order_status_before', array ('order' => $order,'status' => $status,'callbackid' => $callbackid
|
302 |
+
));
|
303 |
+
|
304 |
+
$stateCollection = Mage::getModel('sales/order_status')->getCollection()->joinStates();
|
305 |
+
$stateCollection->addFieldToFilter('main_table.status', array ('like' => $status
|
306 |
+
));
|
307 |
+
$state = $stateCollection->getFirstItem()->getState();
|
308 |
+
|
309 |
+
if ($state == 'processing' || $state == 'closed' || $state == 'complete') {
|
310 |
+
|
311 |
+
// If there is already an invoice, update the invoice, not the order.
|
312 |
+
$invoiceColl = $order->getInvoiceCollection();
|
313 |
+
if ($invoiceColl->getSize() > 0) {
|
314 |
+
foreach ($order->getInvoiceCollection() as $invoice) {
|
315 |
+
$invoice->pay();
|
316 |
+
$invoice->addComment($callbackid, false, false);
|
317 |
+
self::mysave($invoice);
|
318 |
+
}
|
319 |
+
} else {
|
320 |
+
$payment = $order->getPayment();
|
321 |
+
$payment->capture(null);
|
322 |
+
|
323 |
+
if ($callbackid) {
|
324 |
+
$payment->setTransactionId($callbackid);
|
325 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
$history = $order->addStatusHistoryComment('' . $callbackid, $status);
|
330 |
+
$order->save();
|
331 |
+
} else if ($state == 'canceled') {
|
332 |
+
|
333 |
+
if ($callbackid) {
|
334 |
+
$history = $order->addStatusHistoryComment('' . $callbackid, $status);
|
335 |
+
}
|
336 |
+
if ($order->canCancel()) {
|
337 |
+
$order->cancel();
|
338 |
+
}
|
339 |
+
$order->setStatus($status);
|
340 |
+
$order->save();
|
341 |
+
} else {
|
342 |
+
|
343 |
+
$history = $order->addStatusHistoryComment('' . $callbackid, $status);
|
344 |
+
$order->save();
|
345 |
+
}
|
346 |
+
|
347 |
+
Mage::dispatchEvent('komfortkasse_change_order_status_after', array ('order' => $order,'status' => $status,'callbackid' => $callbackid
|
348 |
+
));
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
// end updateOrder()
|
353 |
+
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Update order.
|
357 |
+
*
|
358 |
+
* @param string $refundIncrementId Increment ID of refund
|
359 |
+
* @param string $status status
|
360 |
+
* @param string $callbackid callback ID
|
361 |
+
*
|
362 |
+
* @return void
|
363 |
+
*/
|
364 |
+
public static function updateRefund($refundIncrementId, $status, $callbackid)
|
365 |
+
{
|
366 |
+
$resource = Mage::getSingleton('core/resource');
|
367 |
+
$id = $resource->getConnection('core_read')->fetchOne('SELECT `entity_id` FROM `' . $resource->getTableName('sales/creditmemo') . "` WHERE `increment_id` = '" . $refundIncrementId . "'");
|
368 |
+
|
369 |
+
$creditMemo = Mage::getModel('sales/order_creditmemo')->load($id);
|
370 |
+
|
371 |
+
$store_id = $creditMemo->getStoreId();
|
372 |
+
$store_id_order = array ();
|
373 |
+
$store_id_order ['store_id'] = $store_id;
|
374 |
+
|
375 |
+
if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_update, $store_id_order)) {
|
376 |
+
return;
|
377 |
+
}
|
378 |
+
|
379 |
+
if ($creditMemo->getTransactionId() == null) {
|
380 |
+
$creditMemo->setTransactionId($callbackid);
|
381 |
+
}
|
382 |
+
|
383 |
+
$history = $creditMemo->addComment($status . ' [' . $callbackid . ']', false, false);
|
384 |
+
|
385 |
+
$creditMemo->save();
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
// end updateRefund()
|
390 |
+
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Call an object's save method
|
394 |
+
*
|
395 |
+
* @param unknown $object
|
396 |
+
*
|
397 |
+
* @return void
|
398 |
+
*/
|
399 |
+
private static function mysave($object)
|
400 |
+
{
|
401 |
+
$object->save();
|
402 |
+
|
403 |
+
}
|
404 |
+
|
405 |
+
|
406 |
+
public static function getInvoicePdfPrepare()
|
407 |
+
{
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
|
412 |
+
public static function getInvoicePdf($invoiceNumber)
|
413 |
+
{
|
414 |
+
if ($invoiceNumber && $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceNumber)) {
|
415 |
+
$fileName = $invoiceNumber . '.pdf';
|
416 |
+
|
417 |
+
$pdfGenerated = false;
|
418 |
+
|
419 |
+
// try easy pdf (www.easypdfinvoice.com)
|
420 |
+
if (!$pdfGenerated) {
|
421 |
+
$pdfProModel = Mage::getModel('pdfpro/order_invoice');
|
422 |
+
if ($pdfProModel !== false) {
|
423 |
+
$invoiceData = $pdfProModel->initInvoiceData($invoice);
|
424 |
+
$result = Mage::helper('pdfpro')->initPdf(array ($invoiceData
|
425 |
+
));
|
426 |
+
if ($result ['success']) {
|
427 |
+
$content = $result ['content'];
|
428 |
+
$pdfGenerated = true;
|
429 |
+
}
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
// try Magento Standard
|
434 |
+
if (!$pdfGenerated) {
|
435 |
+
$pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array ($invoice
|
436 |
+
));
|
437 |
+
$content = $pdf->render();
|
438 |
+
}
|
439 |
+
|
440 |
+
return $content;
|
441 |
+
}
|
442 |
+
|
443 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
}//end class
|
app/code/community/Ltc/Komfortkasse/Model/Observer.php
CHANGED
@@ -2,13 +2,21 @@
|
|
2 |
|
3 |
/**
|
4 |
* Komfortkasse
|
5 |
-
*
|
6 |
*
|
7 |
-
* @version 1.
|
8 |
class Ltc_Komfortkasse_Model_Observer
|
9 |
{
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
{
|
13 |
$id = $observer->getOrder()->getIncrementId();
|
14 |
if ($id) {
|
@@ -19,7 +27,14 @@ class Ltc_Komfortkasse_Model_Observer
|
|
19 |
}//end getRegName()
|
20 |
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
{
|
24 |
$regName = self::getRegName($observer);
|
25 |
if ($regName) {
|
@@ -29,8 +44,14 @@ class Ltc_Komfortkasse_Model_Observer
|
|
29 |
}//end noteNewOrder()
|
30 |
|
31 |
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
{
|
35 |
$regName = self::getRegName($observer);
|
36 |
if ($regName && !Mage::registry($regName)) {
|
@@ -40,7 +61,14 @@ class Ltc_Komfortkasse_Model_Observer
|
|
40 |
}//end noteOrderStatus()
|
41 |
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
{
|
45 |
$regName = self::getRegName($observer);
|
46 |
$orderStatus = Mage::registry($regName);
|
2 |
|
3 |
/**
|
4 |
* Komfortkasse
|
5 |
+
* Magento Plugin - Observer Class
|
6 |
*
|
7 |
+
* @version 1.2.1.8-Magento */
|
8 |
class Ltc_Komfortkasse_Model_Observer
|
9 |
{
|
10 |
|
11 |
+
|
12 |
+
/**
|
13 |
+
* getRegName
|
14 |
+
*
|
15 |
+
* @param Varien_Event_Observer $observer Observer
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
private function getRegName(Varien_Event_Observer $observer)
|
20 |
{
|
21 |
$id = $observer->getOrder()->getIncrementId();
|
22 |
if ($id) {
|
27 |
}//end getRegName()
|
28 |
|
29 |
|
30 |
+
/**
|
31 |
+
* noteNewOrder
|
32 |
+
*
|
33 |
+
* @param Varien_Event_Observer $observer Observer
|
34 |
+
*
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
public function noteNewOrder(Varien_Event_Observer $observer)
|
38 |
{
|
39 |
$regName = self::getRegName($observer);
|
40 |
if ($regName) {
|
44 |
}//end noteNewOrder()
|
45 |
|
46 |
|
47 |
+
/**
|
48 |
+
* noteOrderStatus
|
49 |
+
*
|
50 |
+
* @param Varien_Event_Observer $observer Observer
|
51 |
+
*
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function noteOrderStatus(Varien_Event_Observer $observer)
|
55 |
{
|
56 |
$regName = self::getRegName($observer);
|
57 |
if ($regName && !Mage::registry($regName)) {
|
61 |
}//end noteOrderStatus()
|
62 |
|
63 |
|
64 |
+
/**
|
65 |
+
* checkOrderStatus
|
66 |
+
*
|
67 |
+
* @param Varien_Event_Observer $observer Observer
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function checkOrderStatus(Varien_Event_Observer $observer)
|
72 |
{
|
73 |
$regName = self::getRegName($observer);
|
74 |
$orderStatus = Mage::registry($regName);
|
app/code/community/Ltc/Komfortkasse/etc/config.xml
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<config>
|
4 |
<modules>
|
5 |
<Ltc_Komfortkasse>
|
6 |
-
<version>1.4.
|
7 |
</Ltc_Komfortkasse>
|
8 |
</modules>
|
9 |
<global>
|
3 |
<config>
|
4 |
<modules>
|
5 |
<Ltc_Komfortkasse>
|
6 |
+
<version>1.4.4</version>
|
7 |
</Ltc_Komfortkasse>
|
8 |
</modules>
|
9 |
<global>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Ltc_Komfortkasse</name>
|
4 |
-
<version>1.4.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://creativecommons.org/licenses/by-nd/4.0/">CC BY-ND 4.0</license>
|
7 |
<channel>community</channel>
|
@@ -13,11 +13,11 @@ Zusätzlich können automatische Zahlungserinnerungen versendet werden u
|
|
13 |

|
14 |
Es ist eine Anmeldung auf www.komfortkasse.eu erforderlich (kostenloses Paket verfügbar).
|
15 |
</description>
|
16 |
-
<notes>
|
17 |
<authors><author><name>Komfortkasse</name><user>komfortkasse</user><email>integration@komfortkasse.eu</email></author></authors>
|
18 |
-
<date>2016-02-
|
19 |
-
<time>07:
|
20 |
-
<contents><target name="magecommunity"><dir name="Ltc"><dir name="Komfortkasse"><dir name="Helper"><file name="Data.php" hash="ec7f9f8fb6ea400a740ed2c127eb71bc"/><file name="Komfortkasse.php" hash="
|
21 |
<compatible/>
|
22 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Ltc_Komfortkasse</name>
|
4 |
+
<version>1.4.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://creativecommons.org/licenses/by-nd/4.0/">CC BY-ND 4.0</license>
|
7 |
<channel>community</channel>
|
13 |

|
14 |
Es ist eine Anmeldung auf www.komfortkasse.eu erforderlich (kostenloses Paket verfügbar).
|
15 |
</description>
|
16 |
+
<notes>Bugfixes and performance improvements</notes>
|
17 |
<authors><author><name>Komfortkasse</name><user>komfortkasse</user><email>integration@komfortkasse.eu</email></author></authors>
|
18 |
+
<date>2016-02-23</date>
|
19 |
+
<time>07:26:32</time>
|
20 |
+
<contents><target name="magecommunity"><dir name="Ltc"><dir name="Komfortkasse"><dir name="Helper"><file name="Data.php" hash="ec7f9f8fb6ea400a740ed2c127eb71bc"/><file name="Komfortkasse.php" hash="b87bacf0341fda90a98ca63b7b7faf01"/><file name="Komfortkasse_Config.php" hash="44cf103f0ddef60890cd6c221262b7e5"/><file name="Komfortkasse_Order.php" hash="5f0e709f14b8127b371cb605b6ad999a"/></dir><dir name="Model"><file name="Observer.php" hash="5b616b6d3651df44f8297c732dc478bb"/></dir><dir name="controllers"><file name="MainController.php" hash="b983fe60b2bbfa3aa1d57850cc6c045b"/></dir><dir name="etc"><file name="config.xml" hash="62882f4d9d6ae107d9067ba28d90b27a"/><file name="system.xml" hash="c069f07b4f846e62bc5dd922c81e375b"/></dir></dir></dir><dir name="Mage"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="KomfortkasseEncryptionOptions.php" hash="fea880dd3e60c13ede05be53511a6d93"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ltc_Komfortkasse.xml" hash="433066ef75047d9468dcea87888283d2"/></dir></target></contents>
|
21 |
<compatible/>
|
22 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|