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