Ltc_Komfortkasse - Version 1.7.3

Version Notes

Solved a problem for non-m2e shops

Download this release

Release Info

Developer Komfortkasse
Extension Ltc_Komfortkasse
Version 1.7.3
Comparing to
See all releases


Code changes from version 1.7.2 to 1.7.3

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.7.2';
12
  const MAXLEN_SSL = 117;
13
  const LEN_MCRYPT = 16;
14
 
8
  */
9
  class Komfortkasse
10
  {
11
+ const PLUGIN_VER = '1.7.3';
12
  const MAXLEN_SSL = 117;
13
  const LEN_MCRYPT = 16;
14
 
app/code/community/Ltc/Komfortkasse/Helper/Komfortkasse_Order.php CHANGED
@@ -8,7 +8,7 @@
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.7.2-Magento1
12
  */
13
  $path = Mage::getModuleDir('', 'Ltc_Komfortkasse');
14
  global $komfortkasse_order_extension;
@@ -51,7 +51,7 @@ class Komfortkasse_Order
51
 
52
  $minDate = date('Y-m-d', time() - 31536000); // 1 Jahr
53
 
54
- $m2e = Mage::getModel('M2ePro/Order');
55
 
56
  $shopIds = Komfortkasse_Config::getRequestParameter('s');
57
  if ($shopIds)
@@ -345,7 +345,7 @@ class Komfortkasse_Order
345
  }
346
  }
347
 
348
- $m2e = Mage::getModel('M2ePro/Order');
349
  if ($m2e && $m2e->load($order->getEntityId(), 'magento_order_id')) {
350
  $ebay = Mage::getModel('M2ePro/Ebay_Order');
351
  if ($ebay->load($m2e->getId(), 'order_id')) {
@@ -616,7 +616,7 @@ class Komfortkasse_Order
616
  if ($order['payment_method'] == 'm2epropayment') {
617
  // m2e Bestellung nur relevant wenn eBay-Zahlungsart passend
618
  $mage = Mage::getModel('sales/order')->loadByIncrementId($order['number']);
619
- $m2e = Mage::getModel('M2ePro/Order');
620
  if ($m2e && $m2e->load($mage->getEntityId(), 'magento_order_id')) {
621
  $ebay = Mage::getModel('M2ePro/Ebay_Order');
622
  if ($ebay->load($m2e->getId(), 'order_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.7.3-Magento1
12
  */
13
  $path = Mage::getModuleDir('', 'Ltc_Komfortkasse');
14
  global $komfortkasse_order_extension;
51
 
52
  $minDate = date('Y-m-d', time() - 31536000); // 1 Jahr
53
 
54
+ $m2e = Mage::helper('core')->isModuleEnabled('Ess_M2ePro') ? Mage::getModel('M2ePro/Order') : null;
55
 
56
  $shopIds = Komfortkasse_Config::getRequestParameter('s');
57
  if ($shopIds)
345
  }
346
  }
347
 
348
+ $m2e = Mage::helper('core')->isModuleEnabled('Ess_M2ePro') ? Mage::getModel('M2ePro/Order') : null;
349
  if ($m2e && $m2e->load($order->getEntityId(), 'magento_order_id')) {
350
  $ebay = Mage::getModel('M2ePro/Ebay_Order');
351
  if ($ebay->load($m2e->getId(), 'order_id')) {
616
  if ($order['payment_method'] == 'm2epropayment') {
617
  // m2e Bestellung nur relevant wenn eBay-Zahlungsart passend
618
  $mage = Mage::getModel('sales/order')->loadByIncrementId($order['number']);
619
+ $m2e = Mage::helper('core')->isModuleEnabled('Ess_M2ePro') ? Mage::getModel('M2ePro/Order') : null;
620
  if ($m2e && $m2e->load($mage->getEntityId(), 'magento_order_id')) {
621
  $ebay = Mage::getModel('M2ePro/Ebay_Order');
622
  if ($ebay->load($m2e->getId(), 'order_id')) {
app/code/community/Ltc/Komfortkasse/Helper/Komfortkasse_Order.php.esouq DELETED
@@ -1,611 +0,0 @@
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.6.3-Magento1
12
- */
13
- $path = Mage::getModuleDir('', 'Ltc_Komfortkasse');
14
- global $komfortkasse_order_extension;
15
- $komfortkasse_order_extension = false;
16
- if (file_exists("{$path}/Helper/Komfortkasse_Order_Extension.php") === true) {
17
- $komfortkasse_order_extension = true;
18
- include_once "{$path}/Helper/Komfortkasse_Order_Extension.php";
19
- }
20
- class Komfortkasse_Order
21
- {
22
-
23
-
24
- private static function createInClause($arr)
25
- {
26
- if (!is_array($arr)) {
27
- $arr = explode(',', $arr);
28
- }
29
- $tmp = array ();
30
- foreach ($arr as $item) {
31
- $tmp [] = str_replace('\'', '', $item);
32
- }
33
- return '(\'' . implode('\', \'', $tmp) . '\')';
34
-
35
- }
36
-
37
-
38
- /**
39
- * Get open order IDs.
40
- *
41
- * @return string all order IDs that are "open" and relevant for transfer to kk
42
- */
43
- public static function getOpenIDs()
44
- {
45
- $ret = array ();
46
-
47
- $resource = Mage::getSingleton('core/resource');
48
- $readConnection = $resource->getConnection('core_read');
49
- $tableOrder = $resource->getTableName('sales/order');
50
- $tablePayment = $resource->getTableName('sales/order_payment');
51
-
52
- $minDate = date('Y-m-d', time() - 31536000); // 1 Jahr
53
-
54
- $m2e = Mage::getModel('M2ePro/Order');
55
-
56
- $shopIds = Komfortkasse_Config::getRequestParameter('s');
57
- if ($shopIds)
58
- $shopIds = Komfortkasse::kkdecrypt($shopIds);
59
- $store_codes = $shopIds ? explode(',', $shopIds) : array ();
60
-
61
- foreach (Mage::app()->getWebsites() as $website) {
62
- foreach ($website->getGroups() as $group) {
63
- $stores = $group->getStores();
64
- foreach ($stores as $store) {
65
- $store_code = $store->getCode();
66
- if (empty($store_codes) || in_array($store_code, $store_codes)) {
67
-
68
- $store_id = $store->getId();
69
- $store_id_order = array ();
70
- $store_id_order ['store_id'] = $store_id;
71
-
72
- if (Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_export, $store_id_order)) {
73
-
74
- $m2e_active = $m2e && Komfortkasse_Config::getConfig('payment/m2epropayment/active', $store_id_order);
75
-
76
- $query = 'SELECT o.increment_id FROM ' . $tableOrder . ' o join ' . $tablePayment . ' p on p.parent_id = o.entity_id';
77
- if ($m2e_active)
78
- $query .= ' left join ' . $resource->getTableName('M2ePro/Order') . ' m on m.magento_order_id=o.entity_id left join ' . $resource->getTableName('M2ePro/Ebay_Order') . ' e on e.order_id=m.id ';
79
-
80
- $query .= ' where o.store_id=' . $store_id . ' and created_at > ' . $minDate . ' and (';
81
- $first = true;
82
- $m2e_used = false;
83
-
84
- // PREPAYMENT
85
- $openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open, $store_id_order);
86
- $paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods, $store_id_order);
87
- if ($openOrders && $paymentMethods) {
88
- if (!$first)
89
- $query .= ' or ';
90
- $query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods);
91
-
92
- if ($m2e_active && !$m2e_used && strstr($paymentMethods, 'm2epropayment') !== false) {
93
- $query .= ' and (p.method <> \'m2epropayment\' or e.payment_details like \'%"method":"%berweisung"%\') ';
94
- $m2e_used = true;
95
- }
96
-
97
- $query .= ')';
98
- $first = false;
99
- }
100
-
101
- // COD
102
- $openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open_cod, $store_id_order);
103
- $paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods_cod, $store_id_order);
104
- if ($openOrders && $paymentMethods) {
105
- if (!$first)
106
- $query .= ' or ';
107
- $query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods);
108
-
109
- if ($m2e_active && !$m2e_used && strstr($paymentMethods, 'm2epropayment') !== false) {
110
- $query .= ' and (p.method <> \'m2epropayment\' or e.payment_details like \'%"method":"Nachnahme"%\') ';
111
- $m2e_used = true;
112
- }
113
-
114
- $query .= ')';
115
- $first = false;
116
- }
117
-
118
- // INVOICE
119
- $openOrders = Komfortkasse_Config::getConfig(Komfortkasse_Config::status_open_invoice, $store_id_order);
120
- $paymentMethods = Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods_invoice, $store_id_order);
121
- if ($openOrders && $paymentMethods) {
122
- if (!$first)
123
- $query .= ' or ';
124
- $query .= '(o.status in ' . self::createInClause($openOrders) . ' and p.method in ' . self::createInClause($paymentMethods);
125
-
126
- if ($m2e_active && !$m2e_used && strstr($paymentMethods, 'm2epropayment') !== false) {
127
- $query .= ' and (p.method <> \'m2epropayment\' or e.payment_details like \'%"method":"Rechnung"%\') ';
128
- $m2e_used = true;
129
- }
130
-
131
- $query .= ')';
132
- $first = false;
133
- }
134
-
135
- $query .= ')';
136
- if (!$first) { // nur wenn min. eine teil-query angehängt wurde
137
- $results = $readConnection->fetchAll($query);
138
- foreach ($results as $result) {
139
- $ret [] = $result ['increment_id'];
140
- }
141
- }
142
- }
143
- }
144
- }
145
- }
146
- }
147
-
148
- return $ret;
149
-
150
- }
151
-
152
- // end getOpenIDs()
153
-
154
-
155
- /**
156
- * Get refund IDS.
157
- *
158
- * @return string all refund IDs that are "open" and relevant for transfer to kk
159
- */
160
- public static function getRefundIDs()
161
- {
162
- $ret = array ();
163
-
164
- foreach (Mage::app()->getWebsites() as $website) {
165
- foreach ($website->getGroups() as $group) {
166
- $stores = $group->getStores();
167
- foreach ($stores as $store) {
168
-
169
- $store_id = $store->getId();
170
- $store_id_order = array ();
171
- $store_id_order ['store_id'] = $store_id;
172
-
173
- if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_export, $store_id_order)) {
174
- continue;
175
- }
176
-
177
- $paymentMethods = explode(',', Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods, $store_id_order));
178
- $paymentMethodsInvoice = explode(',', Komfortkasse_Config::getConfig(Komfortkasse_Config::payment_methods_invoice, $store_id_order));
179
-
180
- $cmModel = Mage::getModel("sales/order_creditmemo");
181
- $cmCollection = $cmModel->getCollection()->addFieldToFilter('store_id', $store_id);
182
-
183
- foreach ($cmCollection as $creditMemo) {
184
- if ($creditMemo->getTransactionId() == null) {
185
- $order = $creditMemo->getOrder();
186
- try {
187
- $method = $order->getPayment()->getMethodInstance()->getCode();
188
- } catch ( Exception $e ) {
189
- // payment method has been deleted
190
- $method = null;
191
- }
192
- if ($method && (in_array($method, $paymentMethods, true) === true || in_array($method, $paymentMethodsInvoice, true) === true)) {
193
- $cmId = $creditMemo->getIncrementId();
194
- $ret [] = $cmId;
195
- }
196
- }
197
- }
198
- }
199
- }
200
- }
201
-
202
- return $ret;
203
-
204
- }
205
-
206
- // end getRefundIDs()
207
-
208
-
209
- /**
210
- * Get order.
211
- *
212
- * @param string $number order number
213
- *
214
- * @return array order
215
- */
216
- public static function getOrder($number)
217
- {
218
- $order = Mage::getModel('sales/order')->loadByIncrementId($number);
219
- if (empty($number) === true || empty($order) === true || $number != $order->getIncrementId()) {
220
- return null;
221
- }
222
-
223
- $conf_general = Mage::getStoreConfig('general', $order->getStoreId());
224
-
225
- $ret = array ();
226
- $ret ['store_id'] = $order->getStoreId();
227
- $ret ['invoice_date'] = null;
228
- $ret ['number'] = $order->getIncrementId();
229
- $ret ['status'] = $order->getStatus();
230
- $ret ['date'] = date('d.m.Y', strtotime($order->getCreatedAtStoreDate()->get(Zend_Date::DATE_MEDIUM)));
231
- $ret ['email'] = $order->getCustomerEmail();
232
- $ret ['customer_number'] = $order->getCustomerId();
233
- try {
234
- $ret ['payment_method'] = $order->getPayment()->getMethodInstance()->getCode();
235
- } catch ( Exception $e ) {
236
- }
237
- $ret ['amount'] = $order->getGrandTotal();
238
- $ret ['currency_code'] = $order->getOrderCurrencyCode();
239
- $ret ['exchange_rate'] = $order->getBaseToOrderRate();
240
-
241
- // Rechnungsnummer und -datum, evtl. Rechnungsbetrag
242
- $useInvoiceAmount = Komfortkasse::getOrderType($ret) == 'INVOICE' && Komfortkasse_Config::getConfig(Komfortkasse_Config::use_invoice_total, $ret);
243
- $considerCreditnotes = $useInvoiceAmount && Komfortkasse_Config::getConfig(Komfortkasse_Config::consider_creditnotes, $ret);
244
- $creditnotesAsInvoices = Komfortkasse_Config::getConfig(Komfortkasse_Config::creditnotes_as_invoices, $ret);
245
- $lastOnly = Komfortkasse_Config::getConfig(Komfortkasse_Config::last_receipt_only, $ret);
246
- $invoiceColl = $order->getInvoiceCollection();
247
- $creditColl = $order->getCreditmemosCollection();
248
- $invAmount = 0.0;
249
-
250
- if ($lastOnly) {
251
- // nur der letzte Beleg wird übertragen
252
- $newestInvoice = null;
253
- foreach ($invoiceColl as $invoice) {
254
- if (!$invoice->isCanceled()) {
255
- if ($newestInvoice == null || $newestInvoice->getCreatedAt() < $invoice->getCreatedAt()) {
256
- $newestInvoice = $invoice;
257
- }
258
- }
259
- }
260
- $newestCredit = null;
261
- if ($creditnotesAsInvoices) {
262
- foreach ($creditColl as $credit) {
263
- if ($newestCredit == null || $newestCredit->getCreatedAt() < $credit->getCreatedAt()) {
264
- $newestCredit = $credit;
265
- }
266
- }
267
- }
268
- if ($newestCredit != null || $newestInvoice != null) {
269
- if ($newestCredit == null || ($newestInvoice != null && $newestInvoice->getCreatedAt() > $newestCredit->getCreatedAt())) {
270
- $ret ['invoice_number'] [] = $newestInvoice->getIncrementId();
271
- $ret ['invoice_date'] = date('d.m.Y', strtotime($newestInvoice->getCreatedAt()));
272
- $invAmount = $newestInvoice->getGrandTotal();
273
- } else if ($newestCredit != null) {
274
- $ret ['invoice_number'] [] = $newestCredit->getIncrementId();
275
- $ret ['invoice_date'] = date('d.m.Y', strtotime($newestCredit->getCreatedAt()));
276
- $invAmount = $newestCredit->getGrandTotal();
277
- }
278
- }
279
- } else {
280
- // alle Belege werden übertragen
281
- if ($invoiceColl->getSize() > 0 || ($creditnotesAsInvoices && $creditColl->getSize() > 0)) {
282
- foreach ($invoiceColl as $invoice) {
283
- if (!$invoice->isCanceled()) {
284
- $ret ['invoice_number'] [] = $invoice->getIncrementId();
285
- $invoiceDate = date('d.m.Y', strtotime($invoice->getCreatedAt()));
286
- if ($ret ['invoice_date'] == null || strtotime($ret ['invoice_date']) < strtotime($invoiceDate)) {
287
- $ret ['invoice_date'] = $invoiceDate;
288
- }
289
- $invAmount = $invAmount + $invoice->getGrandTotal();
290
- }
291
- }
292
- if (!$creditnotesAsInvoices && $considerCreditnotes) {
293
- foreach ($creditColl as $credit) {
294
- $invAmount = $invAmount - $credit->getGrandTotal();
295
- }
296
- }
297
- if ($creditnotesAsInvoices) {
298
- foreach ($creditColl as $credit) {
299
- $ret ['invoice_number'] [] = $credit->getIncrementId();
300
- $invoiceDate = date('d.m.Y', strtotime($credit->getCreatedAt()));
301
- if ($ret ['invoice_date'] == null || strtotime($ret ['invoice_date']) < strtotime($invoiceDate)) {
302
- $ret ['invoice_date'] = $invoiceDate;
303
- }
304
- $invAmount = $invAmount + $credit->getGrandTotal();
305
- }
306
- }
307
- }
308
- }
309
- if ($useInvoiceAmount && $invAmount > 0)
310
- $ret ['amount'] = $invAmount;
311
-
312
- $shippingAddress = $order->getShippingAddress();
313
- if ($shippingAddress) {
314
- $ret ['delivery_firstname'] = utf8_encode($shippingAddress->getFirstname());
315
- $ret ['delivery_lastname'] = utf8_encode($shippingAddress->getLastname());
316
- $ret ['delivery_company'] = utf8_encode($shippingAddress->getCompany());
317
- $ret ['delivery_street'] = utf8_encode($shippingAddress->getStreetFull());
318
- $ret ['delivery_postcode'] = utf8_encode($shippingAddress->getPostcode());
319
- $ret ['delivery_city'] = utf8_encode($shippingAddress->getCity());
320
- $ret ['delivery_countrycode'] = utf8_encode($shippingAddress->getCountryId());
321
- }
322
-
323
- $billingAddress = $order->getBillingAddress();
324
- if ($billingAddress) {
325
- $ret ['language_code'] = substr($conf_general ['locale'] ['code'], 0, 2) . '-' . $billingAddress->getCountryId();
326
- $ret ['billing_firstname'] = utf8_encode($billingAddress->getFirstname());
327
- $ret ['billing_lastname'] = utf8_encode($billingAddress->getLastname());
328
- $ret ['billing_company'] = utf8_encode($billingAddress->getCompany());
329
- $ret ['billing_street'] = utf8_encode($billingAddress->getStreetFull());
330
- $ret ['billing_postcode'] = utf8_encode($billingAddress->getPostcode());
331
- $ret ['billing_city'] = utf8_encode($billingAddress->getCity());
332
- $ret ['billing_countrycode'] = utf8_encode($billingAddress->getCountryId());
333
- } else {
334
- $ret ['language_code'] = substr($conf_general ['locale'] ['code'], 0, 2);
335
- }
336
-
337
- foreach ($order->getAllItems() as $itemId => $item) {
338
- $sku = $item->getSku();
339
- if ($sku) {
340
- $ret ['products'] [] = $sku;
341
- } else {
342
- $ret ['products'] [] = $item->getName();
343
- }
344
- }
345
-
346
- $m2e = Mage::getModel('M2ePro/Order');
347
- if ($m2e && $m2e->load($order->getEntityId(), 'magento_order_id')) {
348
- $ebay = Mage::getModel('M2ePro/Ebay_Order');
349
- if ($ebay->load($m2e->getId(), 'order_id')) {
350
- $ret ['marketplace_number'] = $ebay->getEbayOrderId();
351
- $ret ['customer_number'] = $ebay->getBuyerUserId();
352
- }
353
- }
354
-
355
- global $komfortkasse_order_extension;
356
- if ($komfortkasse_order_extension && method_exists('Komfortkasse_Order_Extension', 'extendOrder') === true) {
357
- $ret = Komfortkasse_Order_Extension::extendOrder($order, $ret);
358
- }
359
-
360
- return $ret;
361
-
362
- }
363
-
364
- // end getOrder()
365
-
366
-
367
- /**
368
- * Get refund.
369
- *
370
- * @param string $number refund number
371
- *
372
- * @return array refund
373
- */
374
- public static function getRefund($number)
375
- {
376
- $resource = Mage::getSingleton('core/resource');
377
- $id = $resource->getConnection('core_read')->fetchOne('SELECT `entity_id` FROM `' . $resource->getTableName('sales/creditmemo') . "` WHERE `increment_id` = '" . $number . "'");
378
-
379
- $creditMemo = Mage::getModel('sales/order_creditmemo')->load($id);
380
- if (empty($number) === true || empty($creditMemo) === true || $number != $creditMemo->getIncrementId()) {
381
- return null;
382
- }
383
-
384
- $ret = array ();
385
- $ret ['number'] = $creditMemo->getOrder()->getIncrementId();
386
- // Number of the Creditmemo.
387
- $ret ['customer_number'] = $creditMemo->getIncrementId();
388
- $ret ['date'] = date('d.m.Y', strtotime($creditMemo->getCreatedAt()));
389
- $ret ['amount'] = $creditMemo->getGrandTotal();
390
-
391
- return $ret;
392
-
393
- }
394
-
395
- // end getRefund()
396
-
397
-
398
- /**
399
- * Update order.
400
- *
401
- * @param array $order order
402
- * @param string $status status
403
- * @param string $callbackid callback ID
404
- *
405
- * @return void
406
- */
407
- public static function updateOrder($order, $status, $callbackid)
408
- {
409
- if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_update, $order)) {
410
- return;
411
- }
412
-
413
- // Hint: PAID and CANCELLED are supported as of now.
414
- $order = Mage::getModel('sales/order')->loadByIncrementId($order ['number']);
415
-
416
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' START', null, 'komfortkasse.log');
417
- Mage::dispatchEvent('komfortkasse_change_order_status_before', array ('order' => $order,'status' => $status,'callbackid' => $callbackid
418
- ));
419
-
420
- $stateCollection = Mage::getModel('sales/order_status')->getCollection()->joinStates();
421
- $stateCollection->addFieldToFilter('main_table.status', array ('like' => $status
422
- ));
423
- $state = $stateCollection->getFirstItem()->getState();
424
-
425
- if ($state == 'processing' || $state == 'closed' || $state == 'complete') {
426
-
427
- // If there is already an invoice, update the invoice, not the order.
428
- $invoiceColl = $order->getInvoiceCollection();
429
- if ($invoiceColl->getSize() > 0) {
430
- foreach ($order->getInvoiceCollection() as $invoice) {
431
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' invoice ' . $invoice->getIncrementId() . ' pay', null, 'komfortkasse.log');
432
- $invoice->pay();
433
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' invoice ' . $invoice->getIncrementId() . ' addComment ' . $callbackid, null, 'komfortkasse.log');
434
- $invoice->addComment($callbackid, false, false);
435
- self::mysave($invoice);
436
- }
437
- } else {
438
- $payment = $order->getPayment();
439
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' payment capture', null, 'komfortkasse.log');
440
- $payment->capture(null);
441
-
442
- if ($callbackid) {
443
- $payment->setTransactionId($callbackid);
444
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' addTransaction', null, 'komfortkasse.log');
445
- $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
446
- }
447
- }
448
- $order->save();
449
- $order = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId());
450
-
451
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' add status history ' . $status . ' / ' . $callbackid, null, 'komfortkasse.log');
452
- $history = $order->addStatusHistoryComment('' . $callbackid, $status);
453
- $order->setStatus($status);
454
- $order->save();
455
- } else if ($state == 'canceled') {
456
-
457
- if ($callbackid) {
458
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' add status history ' . $status . ' / ' . $callbackid, null, 'komfortkasse.log');
459
- $history = $order->addStatusHistoryComment('' . $callbackid, $status);
460
- }
461
- if ($order->canCancel()) {
462
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' cancel', null, 'komfortkasse.log');
463
- $order->cancel();
464
- }
465
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' set status ' . $status, null, 'komfortkasse.log');
466
- $order->setStatus($status);
467
- $order->save();
468
- } else {
469
-
470
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' add status history ' . $status . ' / ' . $callbackid, null, 'komfortkasse.log');
471
- $history = $order->addStatusHistoryComment('' . $callbackid, $status);
472
- $order->save();
473
- }
474
-
475
- Mage::dispatchEvent('komfortkasse_change_order_status_after', array ('order' => $order,'status' => $status,'callbackid' => $callbackid
476
- ));
477
-
478
- Mage::log('Komfortkasse: update order ' . $order->getIncrementId() . ' END. Status: ' . $order->getStatus, null, 'komfortkasse.log');
479
-
480
- }
481
-
482
- // end updateOrder()
483
-
484
-
485
- /**
486
- * Update order.
487
- *
488
- * @param string $refundIncrementId Increment ID of refund
489
- * @param string $status status
490
- * @param string $callbackid callback ID
491
- *
492
- * @return void
493
- */
494
- public static function updateRefund($refundIncrementId, $status, $callbackid)
495
- {
496
- $resource = Mage::getSingleton('core/resource');
497
- $id = $resource->getConnection('core_read')->fetchOne('SELECT `entity_id` FROM `' . $resource->getTableName('sales/creditmemo') . "` WHERE `increment_id` = '" . $refundIncrementId . "'");
498
-
499
- $creditMemo = Mage::getModel('sales/order_creditmemo')->load($id);
500
-
501
- $store_id = $creditMemo->getStoreId();
502
- $store_id_order = array ();
503
- $store_id_order ['store_id'] = $store_id;
504
-
505
- if (!Komfortkasse_Config::getConfig(Komfortkasse_Config::activate_update, $store_id_order)) {
506
- return;
507
- }
508
-
509
- if ($creditMemo->getTransactionId() == null) {
510
- $creditMemo->setTransactionId($callbackid);
511
- }
512
-
513
- $history = $creditMemo->addComment($status . ' [' . $callbackid . ']', false, false);
514
-
515
- $creditMemo->save();
516
-
517
- }
518
-
519
- // end updateRefund()
520
-
521
-
522
- /**
523
- * Call an object's save method
524
- *
525
- * @param unknown $object
526
- *
527
- * @return void
528
- */
529
- private static function mysave($object)
530
- {
531
- $object->save();
532
-
533
- }
534
-
535
-
536
- public static function getInvoicePdfPrepare()
537
- {
538
-
539
- }
540
-
541
-
542
- public static function getInvoicePdf($invoiceNumber, $orderNumber)
543
- {
544
- if ($invoiceNumber) {
545
-
546
- $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceNumber);
547
- $fileName = $invoiceNumber . '.pdf';
548
-
549
- if ($invoice && (!$orderNumber || $invoice->getOrderIncrementId() == $orderNumber)) {
550
-
551
- $pdfGenerated = false;
552
-
553
- // try easy pdf (www.easypdfinvoice.com)
554
- if (!$pdfGenerated) {
555
- $pdfProModel = Mage::getModel('pdfpro/order_invoice');
556
- if ($pdfProModel !== false) {
557
- $invoiceData = $pdfProModel->initInvoiceData($invoice);
558
- $result = Mage::helper('pdfpro')->initPdf(array ($invoiceData
559
- ));
560
- if ($result ['success']) {
561
- $content = $result ['content'];
562
- $pdfGenerated = true;
563
- }
564
- }
565
- }
566
-
567
- // try Magento Standard
568
- if (!$pdfGenerated) {
569
- $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf(array ($invoice
570
- ));
571
- $content = $pdf->render();
572
- }
573
- } else if (Komfortkasse_Config::getConfig(Komfortkasse_Config::creditnotes_as_invoices, self::getOrder($orderNumber))) {
574
-
575
- // try credit note
576
- $collection = Mage::getResourceModel('sales/order_creditmemo_collection')->addFieldToFilter('increment_id', $invoiceNumber);
577
- $credit = $collection->count() == 1 ? $collection->getFirstItem() : null;
578
-
579
- if ($credit && (!$orderNumber || $credit->getOrder()->getIncrementId() == $orderNumber)) {
580
-
581
- $pdfGenerated = false;
582
-
583
- // try easy pdf (www.easypdfinvoice.com)
584
- if (!$pdfGenerated) {
585
- $pdfProModel = Mage::getModel('pdfpro/order_creditmemo');
586
- if ($pdfProModel !== false) {
587
- $creditData = $pdfProModel->initCreditmemoData($credit);
588
- $result = Mage::helper('pdfpro')->initPdf(array ($creditData
589
- ));
590
- if ($result ['success']) {
591
- $content = $result ['content'];
592
- // $pdfGenerated = true;
593
- }
594
- }
595
- }
596
-
597
- // try Magento Standard
598
- if (!$pdfGenerated) {
599
- $pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf(array ($credit
600
- ));
601
- $content = $pdf->render();
602
- }
603
- }
604
- }
605
-
606
-
607
- return $content;
608
- }
609
-
610
- }
611
- }//end class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Ltc/Komfortkasse/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Ltc_Komfortkasse>
6
- <version>1.6.3</version>
7
  </Ltc_Komfortkasse>
8
  </modules>
9
  <global>
3
  <config>
4
  <modules>
5
  <Ltc_Komfortkasse>
6
+ <version>1.7.2</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.7.2</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,11 +13,11 @@ Zus&#xE4;tzlich k&#xF6;nnen automatische Zahlungserinnerungen versendet werden u
13
  &#xD;
14
  Es ist eine Anmeldung auf www.komfortkasse.eu erforderlich (kostenloses Paket verf&#xFC;gbar).&#xD;
15
  </description>
16
- <notes>performance improvements</notes>
17
  <authors><author><name>Komfortkasse</name><user>komfortkasse</user><email>integration@komfortkasse.eu</email></author></authors>
18
- <date>2016-11-10</date>
19
- <time>13:41:45</time>
20
- <contents><target name="magecommunity"><dir name="Ltc"><dir name="Komfortkasse"><dir name="Helper"><file name="Data.php" hash="42f1d168bb70725128e15daf305802ba"/><file name="Komfortkasse.php" hash="ab2894ec6276d3a7f1a639e15abdcb44"/><file name="Komfortkasse_Config.php" hash="fc3c24ab940dabaf5655de5b0d9ec14f"/><file name="Komfortkasse_Order.php" hash="c97ec577120a6f166986c7f712b5da25"/><file name="Komfortkasse_Order.php.esouq" hash="94eac48800d5f69047701b20e5631a19"/></dir><dir name="Model"><file name="Encryptionoptions.php" hash="1fbe2ffc43cc3c1489688d20f4c8af11"/><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="4964d847be82ded534fcbc1e12f214a3"/><file name="system.xml" hash="4477e69044c79edab2b70691b0236bd8"/></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Ltc_Komfortkasse</name>
4
+ <version>1.7.3</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
  &#xD;
14
  Es ist eine Anmeldung auf www.komfortkasse.eu erforderlich (kostenloses Paket verf&#xFC;gbar).&#xD;
15
  </description>
16
+ <notes>Solved a problem for non-m2e shops</notes>
17
  <authors><author><name>Komfortkasse</name><user>komfortkasse</user><email>integration@komfortkasse.eu</email></author></authors>
18
+ <date>2016-12-05</date>
19
+ <time>08:18:33</time>
20
+ <contents><target name="magecommunity"><dir name="Ltc"><dir name="Komfortkasse"><dir name="Helper"><file name="Data.php" hash="42f1d168bb70725128e15daf305802ba"/><file name="Komfortkasse.php" hash="54393bd4105e1641765b6892ef66096f"/><file name="Komfortkasse_Config.php" hash="fc3c24ab940dabaf5655de5b0d9ec14f"/><file name="Komfortkasse_Order.php" hash="102b6e08880ee03ebbb06b8bd1f58eea"/></dir><dir name="Model"><file name="Encryptionoptions.php" hash="1fbe2ffc43cc3c1489688d20f4c8af11"/><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="8aeca5ae134645e9f939261c9135d129"/><file name="system.xml" hash="4477e69044c79edab2b70691b0236bd8"/></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>