00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00032 include_once './payment/classes/class.ilPaymentShoppingCart.php';
00033 include_once './payment/classes/class.ilPaymentShoppingCartGUI.php';
00034 include_once './payment/classes/class.ilPaymentCoupons.php';
00035 include_once './payment/classes/class.ilBMFSettings.php';
00036 #include_once dirname(__FILE__)."/../bmf/lib/ePayment/cfg_epayment.inc.php";
00037 include_once dirname(__FILE__)."/../bmf/lib/SOAP/class.ilBMFClient.php";
00038
00039 class ilPurchaseBMFGUI
00040 {
00041 var $ctrl;
00042 var $tpl;
00043
00044 var $user_obj;
00045 var $coupon_obj = null;
00046 var $error;
00047 var $shoppingCart;
00048
00049 var $soapClient;
00050
00051 function ilPurchaseBMFGUI(&$user_obj)
00052 {
00053 global $ilias,$ilDB,$lng,$tpl,$rbacsystem;
00054 $this->ilias =& $ilias;
00055 $this->db =& $ilDB;
00056 $this->lng =& $lng;
00057
00058 global $ilCtrl;
00059
00060 $this->ctrl =& $ilCtrl;
00061 $this->tpl =& $tpl;
00062
00063
00064 $this->user_obj =& $user_obj;
00065
00066 $this->coupon_obj = new ilPaymentCoupons($this->user_obj);
00067
00068 if (!is_array($_SESSION["bmf"]["personal_data"]))
00069 {
00070 $_SESSION["bmf"]["personal_data"]["vorname"] = $this->user_obj->getFirstname();
00071 $_SESSION["bmf"]["personal_data"]["nachname"] = $this->user_obj->getLastname();
00072 if (strpos("_" . $this->user_obj->getStreet(), " ") > 0)
00073 {
00074 $houseNo = substr($this->user_obj->getStreet(), strrpos($this->user_obj->getStreet(), " ")+1);
00075 $street = substr($this->user_obj->getStreet(), 0, strlen($this->user_obj->getStreet())-(strlen($houseNo)+1));
00076 $_SESSION["bmf"]["personal_data"]["strasse"] = $street;
00077 $_SESSION["bmf"]["personal_data"]["hausNr"] = $houseNo;
00078 }
00079 else
00080 {
00081 $_SESSION["bmf"]["personal_data"]["strasse"] = $this->user_obj->getStreet();
00082 $_SESSION["bmf"]["personal_data"]["hausNr"] = "";
00083 }
00084 $_SESSION["bmf"]["personal_data"]["postfach"] = "";
00085 $_SESSION["bmf"]["personal_data"]["PLZ"] = $this->user_obj->getZipcode();
00086 $_SESSION["bmf"]["personal_data"]["ort"] = $this->user_obj->getCity();
00087 $_SESSION["bmf"]["personal_data"]["land"] = $this->__getCountryCode($this->user_obj->getCountry());
00088 $_SESSION["bmf"]["personal_data"]["EMailAdresse"] = $this->user_obj->getEmail();
00089 $_SESSION["bmf"]["personal_data"]["sprache"] = $this->user_obj->getLanguage();
00090 }
00091
00092 if (!is_array($_SESSION["coupons"]["bmf"]))
00093 {
00094 $_SESSION["coupons"]["bmf"] = array();
00095 }
00096
00097 $this->__loadTemplate();
00098
00099 $this->error = "";
00100
00101 $this->lng->loadLanguageModule("payment");
00102 }
00103
00104 function cancel()
00105 {
00106 ilUtil::redirect("./payment.php");
00107 }
00108
00109 function showPersonalData()
00110 {
00111
00112
00113
00114 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00115
00116 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00117 {
00118
00119 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00120 $this->tpl->touchBlock("stop_floating");
00121 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00122
00123 }
00124 else
00125 {
00126
00127 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_personal_data.html','payment');
00128 #$this->tpl = new ilTemplate('tpl.pay_bmf_personal_data.html', true, true, 'payment');
00129
00130 $this->tpl->setVariable("PERSONAL_DATA_FORMACTION",$this->ctrl->getFormAction($this));
00131
00132
00133 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays_b.gif'));
00134 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
00135 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step1'));
00136 $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_personal_data'));
00137 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_personal_data'));
00138 $this->tpl->touchBlock("stop_floating");
00139 $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
00140
00141
00142 $this->tpl->setVariable("TXT_FIRSTNAME",$this->lng->txt('firstname'));
00143 $this->tpl->setVariable("TXT_LASTNAME",$this->lng->txt('lastname'));
00144 $this->tpl->setVariable("TXT_STREET",$this->lng->txt('street'));
00145 $this->tpl->setVariable("TXT_HOUSE_NUMBER",$this->lng->txt('pay_bmf_house_number'));
00146 $this->tpl->setVariable("TXT_OR",$this->lng->txt('pay_bmf_or'));
00147 $this->tpl->setVariable("TXT_PO_BOX",$this->lng->txt('pay_bmf_po_box'));
00148 $this->tpl->setVariable("TXT_ZIPCODE",$this->lng->txt('zipcode'));
00149 $this->tpl->setVariable("TXT_CITY",$this->lng->txt('city'));
00150 $this->tpl->setVariable("TXT_COUNTRY",$this->lng->txt('country'));
00151 $this->tpl->setVariable("TXT_EMAIL",$this->lng->txt('email'));
00152
00153 $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('next')));
00154 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
00155
00156
00157
00158 $this->error != "" && isset($_POST['country']) ? $this->__showCountries($this->tpl, $_POST['country']) : $this->__showCountries($this->tpl, $_SESSION['bmf']['personal_data']['land']);
00159
00160
00161
00162
00163
00164
00165
00166
00167 $this->tpl->setVariable("FIRSTNAME", $this->user_obj->getFirstname());
00168 $this->tpl->setVariable("LASTNAME", $this->user_obj->getLastname());
00169 $this->tpl->setVariable("STREET",
00170 $this->error != "" && isset($_POST['street'])
00171 ? ilUtil::prepareFormOutput($_POST['street'],true)
00172 : ilUtil::prepareFormOutput($_SESSION['bmf']["personal_data"]['strasse'],true));
00173 $this->tpl->setVariable("HOUSE_NUMBER",
00174 $this->error != "" && isset($_POST['house_number'])
00175 ? ilUtil::prepareFormOutput($_POST['house_number'],true)
00176 : ilUtil::prepareFormOutput($_SESSION['bmf']["personal_data"]['hausNr'],true));
00177 $this->tpl->setVariable("PO_BOX",
00178 $this->error != "" && isset($_POST['po_box'])
00179 ? ilUtil::prepareFormOutput($_POST['po_box'],true)
00180 : ilUtil::prepareFormOutput($_SESSION['bmf']["personal_data"]['postfach'],true));
00181 $this->tpl->setVariable("ZIPCODE",
00182 $this->error != "" && isset($_POST['zipcode'])
00183 ? ilUtil::prepareFormOutput($_POST['zipcode'],true)
00184 : ilUtil::prepareFormOutput($_SESSION['bmf']["personal_data"]['PLZ'],true));
00185 $this->tpl->setVariable("CITY",
00186 $this->error != "" && isset($_POST['city'])
00187 ? ilUtil::prepareFormOutput($_POST['city'],true)
00188 : ilUtil::prepareFormOutput($_SESSION['bmf']["personal_data"]['ort'],true));
00189
00190
00191
00192
00193 $this->tpl->setVariable("EMAIL", $this->user_obj->getEmail());
00194
00195 }
00196 }
00197
00198 function getPersonalData()
00199 {
00200
00201
00202 if ($_SESSION["bmf"]["personal_data"]["vorname"] == "" ||
00203 $_SESSION["bmf"]["personal_data"]["nachname"] == "" ||
00204 $_POST["zipcode"] == "" ||
00205 $_POST["city"] == "" ||
00206 $_POST["country"] == "" ||
00207
00208 $_SESSION["bmf"]["personal_data"]["EMailAdresse"] == "")
00209 {
00210 $this->error = $this->lng->txt('pay_bmf_personal_data_not_valid');
00211 ilUtil::sendInfo($this->error);
00212 $this->showPersonalData();
00213 return;
00214 }
00215 if (($_POST["street"] == "" && $_POST["house_number"] == "" && $_POST["po_box"] == "") ||
00216 (($_POST["street"] != "" || $_POST["house_number"] != "") && $_POST["po_box"] != "") ||
00217 ($_POST["street"] != "" && $_POST["house_number"] == "") ||
00218 ($_POST["street"] == "" && $_POST["house_number"] != ""))
00219 {
00220 $this->error = $this->lng->txt('pay_bmf_street_or_pobox');
00221 ilUtil::sendInfo($this->error);
00222 $this->showPersonalData();
00223 return;
00224 }
00225
00226
00227
00228 $_SESSION["bmf"]["personal_data"]["vorname"] = $this->user_obj->getFirstname();
00229 $_SESSION["bmf"]["personal_data"]["nachname"] = $this->user_obj->getLastname();
00230 $_SESSION["bmf"]["personal_data"]["strasse"] = $_POST["street"];
00231 $_SESSION["bmf"]["personal_data"]["hausNr"] = $_POST["house_number"];
00232 $_SESSION["bmf"]["personal_data"]["postfach"] = $_POST["po_box"];
00233 $_SESSION["bmf"]["personal_data"]["PLZ"] = $_POST["zipcode"];
00234 $_SESSION["bmf"]["personal_data"]["ort"] = $_POST["city"];
00235 $_SESSION["bmf"]["personal_data"]["land"] = $_POST["country"];
00236
00237 $_SESSION["bmf"]["personal_data"]["EmailAdresse"] = $this->user_obj->getEmail();
00238 $_SESSION["bmf"]["personal_data"]["sprache"] = $this->user_obj->getLanguage();
00239
00240 if ($_SESSION["bmf"]["personal_data"]["land"] != "DE")
00241 {
00242 if ($_SESSION["bmf"]["payment_type"] == "debit_entry")
00243 {
00244 $_SESSION["bmf"]["payment_type"] = "";
00245 }
00246 }
00247
00248 $this->error = "";
00249 $this->showPaymentType();
00250 }
00251
00252 function showPaymentType()
00253 {
00254
00255
00256
00257 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00258
00259 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00260 {
00261
00262 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00263 $this->tpl->touchBlock("stop_floating");
00264 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00265
00266 }
00267 else
00268 {
00269
00270 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_payment_type.html','payment');
00271 #$this->tpl = new ilTemplate('tpl.pay_bmf_payment_type.html', true, true, 'payment');
00272
00273 $this->tpl->setVariable("PAYMENT_TYPE_FORMACTION",$this->ctrl->getFormAction($this));
00274
00275
00276 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays_b.gif'));
00277 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
00278 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step2'));
00279 $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_payment_type'));
00280 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_payment_type'));
00281 $this->tpl->touchBlock("stop_floating");
00282 $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
00283
00284
00285 if ($_SESSION["bmf"]["personal_data"]["land"] == "DE")
00286 {
00287 $this->tpl->setVariable("TXT_DEBIT_ENTRY",$this->lng->txt('pay_bmf_debit_entry'));
00288 }
00289 $this->tpl->setVariable("TXT_CREDIT_CARD",$this->lng->txt('pay_bmf_credit_card'));
00290
00291 $this->tpl->setVariable("INPUT_VALUE",ucfirst($this->lng->txt('next')));
00292 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
00293
00294
00295
00296 if ($this->error != "" &&
00297 isset($_POST["payment_type"]))
00298 {
00299 $this->tpl->setVariable("PAYMENT_TYPE_" . strtoupper($_POST["payment_type"]), " checked") ;
00300 }
00301 else
00302 {
00303 if (($_SESSION["bmf"]["personal_data"]["land"] != "DE" && $_POST["payment_type"] != "debit_entry") ||
00304 $_SESSION["bmf"]["personal_data"]["land"] == "DE")
00305 {
00306 $this->tpl->setVariable("PAYMENT_TYPE_" . strtoupper($_SESSION["bmf"]["payment_type"]), " checked") ;
00307 }
00308 }
00309
00310
00311 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00312 $this->tpl->setCurrentBlock("btn_cell");
00313 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPersonalData"));
00314 $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
00315 $this->tpl->parseCurrentBlock("btn_cell");
00316
00317 }
00318 }
00319
00320 function getPaymentType()
00321 {
00322 if (($_POST["payment_type"] != "credit_card" && $_POST["payment_type"] != "debit_entry") ||
00323 ($_SESSION["bmf"]["personal_data"]["land"] != "DE" && $_POST["payment_type"] == "debit_entry"))
00324 {
00325 $this->error = $this->lng->txt('pay_bmf_payment_type_not_valid');
00326 ilUtil::sendInfo($this->error);
00327 $this->showPaymentType();
00328 return;
00329 }
00330
00331 $_SESSION["bmf"]["payment_type"] = $_POST["payment_type"];
00332
00333 $this->error = "";
00334 if ($_SESSION["bmf"]["payment_type"] == "credit_card")
00335 {
00336 $this->showCreditCard();
00337 }
00338 else
00339 {
00340 $this->showDebitEntry();
00341 }
00342 }
00343
00344 function showDebitEntry()
00345 {
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00357
00358 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00359 {
00360
00361 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00362 $this->tpl->touchBlock("stop_floating");
00363 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00364
00365 }
00366 else
00367 {
00368
00369 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_debit_entry.html','payment');
00370 #$this->tpl = new ilTemplate('tpl.pay_bmf_debit_entry.html', true, true, 'payment');
00371
00372 $this->__showShoppingCart();
00373
00374 $this->tpl->setVariable("DEBIT_ENTRY_FORMACTION",$this->ctrl->getFormAction($this));
00375
00376
00377 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays_b.gif'));
00378 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
00379 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step3_debit_entry'));
00380 $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_debit_entry_data'));
00381 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_debit_entry'));
00382 $this->tpl->touchBlock("stop_floating");
00383 $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
00384
00385
00386 $this->tpl->setVariable("TXT_ACCOUNT_HOLDER",$this->lng->txt('pay_bmf_account_holder'));
00387 $this->tpl->setVariable("TXT_OPTIONAL",$this->lng->txt('pay_bmf_optional'));
00388 $this->tpl->setVariable("TXT_BANK_CODE",$this->lng->txt('pay_bmf_bank_code'));
00389 $this->tpl->setVariable("TXT_ACCOUNT_NUMBER",$this->lng->txt('pay_bmf_account_number'));
00390 $this->tpl->setVariable("TXT_TERMS_CONDITIONS",$this->lng->txt('pay_bmf_terms_conditions'));
00391 $this->tpl->setVariable("TXT_TERMS_CONDITIONS_READ",$this->lng->txt('pay_bmf_terms_conditions_read'));
00392 $this->tpl->setVariable("TXT_TERMS_CONDITIONS_SHOW",$this->lng->txt('pay_bmf_terms_conditions_show'));
00393 $this->tpl->setVariable("LINK_TERMS_CONDITIONS","./payment.php?view=conditions");
00394 $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt('password'));
00395 $this->tpl->setVariable("TXT_CONFIRM_ORDER",$this->lng->txt('pay_confirm_order'));
00396
00397 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_send_order'));
00398 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
00399
00400
00401
00402 $this->tpl->setVariable("ACCOUNT_HOLDER",
00403 $this->error != "" && isset($_POST['account_holder'])
00404 ? ilUtil::prepareFormOutput($_POST['account_holder'],true)
00405 : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['kontoinhaber'],true));
00406 $this->tpl->setVariable("BANK_CODE",
00407 $this->error != "" && isset($_POST['bank_code'])
00408 ? ilUtil::prepareFormOutput($_POST['bank_code'],true)
00409 : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['BLZ'],true));
00410 $this->tpl->setVariable("ACCOUNT_NUMBER",
00411 $this->error != "" && isset($_POST['account_number'])
00412 ? ilUtil::prepareFormOutput($_POST['account_number'],true)
00413 : ilUtil::prepareFormOutput($_SESSION['bmf']["debit_entry"]['kontoNr'],true));
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00427 $this->tpl->setCurrentBlock("btn_cell");
00428 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPaymentType"));
00429 $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
00430 $this->tpl->parseCurrentBlock("btn_cell");
00431
00432 }
00433 }
00434
00435 function getDebitEntry()
00436 {
00437 if ($_POST["account_holder"] == "" ||
00438 $_POST["bank_code"] == "" ||
00439 $_POST["account_number"] == "")
00440 {
00441 $this->error = $this->lng->txt('pay_bmf_debit_entry_not_valid');
00442 ilUtil::sendInfo($this->error);
00443 $this->showDebitEntry();
00444 return;
00445 }
00446 if ($_POST["terms_conditions"] != 1)
00447 {
00448 $this->error = $this->lng->txt('pay_bmf_check_terms_conditions');
00449 ilUtil::sendInfo($this->error);
00450 $this->showDebitEntry();
00451 return;
00452 }
00453 if ($_POST["password"] == "" ||
00454 md5($_POST["password"]) != $this->user_obj->getPasswd())
00455 {
00456 $this->error = $this->lng->txt('pay_bmf_password_not_valid');
00457 ilUtil::sendInfo($this->error);
00458 $this->showDebitEntry();
00459 return;
00460 }
00461
00462 $_SESSION["bmf"]["debit_entry"]["BLZ"] = $_POST["bank_code"];
00463 $_SESSION["bmf"]["debit_entry"]["kontoinhaber"] = $_POST["account_holder"];
00464 $_SESSION["bmf"]["debit_entry"]["kontoNr"] = $_POST["account_number"];
00465
00466 $this->error = "";
00467 $this->sendDebitEntry();
00468 }
00469
00470 function sendDebitEntry()
00471 {
00472 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00473
00474 $this->psc_obj->clearCouponItemsSession();
00475
00476 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00477 {
00478
00479 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00480 $this->tpl->touchBlock("stop_floating");
00481 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00482
00483 }
00484 else
00485 {
00486 $customer = new KundenstammdatenPflegeWS();
00487
00488 $newCustomer = new Kunde($this->user_obj->getId());
00489
00490 $resultCustomerObj = $customer->anlegenKunde($newCustomer);
00491
00492 $resultCustomer = $resultCustomerObj->ergebnis;
00493
00494 if (is_object($resultCustomer))
00495 {
00496 if ($resultCustomer->code < 0)
00497 {
00498 $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $resultCustomer->code . ": " . $resultCustomer->kurzText . "<br>\n" . $resultCustomer->langText;
00499 if ($resultCustomer->code == -103 ||
00500 $resultCustomer->code == -104 ||
00501 $resultCustomer->code == -107 ||
00502 ($resultCustomer->code <= -202 && $resultCustomer->code >= -208) ||
00503 $resultCustomer->code == -213)
00504 {
00505 ilUtil::sendInfo($error);
00506 $this->showPersonalData();
00507 }
00508 else
00509 {
00510 $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
00511 ilUtil::sendInfo($error);
00512 $this->showPersonalData();
00513 }
00514 }
00515 else
00516 {
00517 $payment = new LastschriftWS();
00518
00519 $debitEntry = new Lastschrift();
00520
00521 $address = new LieferAdresse();
00522
00523 $bank = new Bankverbindung();
00524
00525 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
00526
00527 $tmp_bookEntries = $sc_obj->getShoppingCart();
00528 if (!is_array($tmp_bookEntries))
00529 {
00530 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00531 }
00532 else
00533 {
00534 $totalAmount = 0;
00535 for ($i = 0; $i < count($tmp_bookEntries); $i++)
00536 {
00537 $booking = true;
00538
00539 if (!empty($_SESSION["coupons"]["bmf"]))
00540 {
00541 $price = $tmp_bookEntries[$i]["betrag"];
00542 $tmp_bookEntries[$i]["math_price"] = (float) $price;
00543
00544 foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
00545 {
00546 $this->coupon_obj->setId($coupon["pc_pk"]);
00547 $this->coupon_obj->setCurrentCoupon($coupon);
00548
00549 $tmp_pobject =& new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
00550
00551 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00552 {
00553 $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += (float) $price;
00554 $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
00555 $booking = false;
00556 }
00557
00558 unset($tmp_pobject);
00559 }
00560 }
00561
00562 if ($booking)
00563 {
00564 $tmp_bookEntries[$i]["betrag_string"] = number_format( (float) $tmp_bookEntries[$i]["betrag"] , 2, ",", ".");
00565
00566 $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
00567 $totalAmount += $tmp_bookEntries[$i]["betrag"];
00568 }
00569 else
00570 {
00571 $tmp_bookEntries[$i]["betrag_string"] = number_format( (float) $tmp_bookEntries[$i]["betrag"] , 2, ",", ".");
00572 }
00573 }
00574
00575 $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
00576
00577 if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
00578 {
00579 foreach ($coupon_discount_items as $item)
00580 {
00581 $item["betrag"] = $item["discount_price"];
00582 $bookEntries[] = new Buchung($item);
00583 $totalAmount += $item["betrag"];
00584 }
00585 }
00586
00587 $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
00588 $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
00589 }
00590
00591 # vd($address);
00592 # vd($debitEntry);
00593 # vd($bank);
00594 # vd($bookingList);
00595
00596 $resultObj = $payment->abbuchenOhneEinzugsermaechtigung($resultCustomerObj->kunde->EShopKundenNr, $address, $bank, $bookingList);
00597 $result = $resultObj->ergebnis;
00598
00599 if (is_object($result))
00600 {
00601 if ($result->code < 0)
00602 {
00603 $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
00604 $this->tpl->touchBlock("stop_floating");
00605 $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
00606 if ($result->code == -103 ||
00607 $result->code == -104 ||
00608 $result->code == -107 ||
00609 ($result->code <= -202 && $result->code >= -208) ||
00610 $result->code == -213)
00611 {
00612 ilUtil::sendInfo($error);
00613 $this->showPersonalData();
00614 }
00615 else if ($result->code == -507 ||
00616 $result->code == -510 ||
00617 $result->code == -511)
00618 {
00619 ilUtil::sendInfo($error);
00620 $this->showPaymentType();
00621 }
00622 else if ($result->code == -402 ||
00623 $result->code == -402 ||
00624 $result->code == -403 ||
00625 $result->code == -406 ||
00626 $result->code == -410 ||
00627 $result->code == -413 ||
00628 $result->code == -701 ||
00629 $result->code == -702 ||
00630 $result->code == -703)
00631 {
00632 ilUtil::sendInfo($error);
00633 $this->showDebitEntry();
00634 }
00635 else
00636 {
00637 $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
00638 ilUtil::sendInfo($error);
00639 $this->showPersonalData();
00640 }
00641
00642 }
00643 else
00644 {
00645 $resultCustomerObj->kunde->vorname = utf8_decode($resultCustomerObj->kunde->vorname);
00646 $resultCustomerObj->kunde->nachname = utf8_decode($resultCustomerObj->kunde->nachname);
00647 $resultCustomerObj->kunde->rechnungsAdresse->strasse = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->strasse);
00648 $resultCustomerObj->kunde->rechnungsAdresse->hausNr = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->hausNr);
00649 $resultCustomerObj->kunde->rechnungsAdresse->postfach = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->postfach);
00650 $resultCustomerObj->kunde->rechnungsAdresse->PLZ = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->PLZ);
00651 $resultCustomerObj->kunde->rechnungsAdresse->ort = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->ort);
00652 $resultCustomerObj->kunde->rechnungsAdresse->land = utf8_decode($resultCustomerObj->kunde->rechnungsAdresse->land);
00653
00654
00655 $this->__sendBill($resultCustomerObj->kunde, $_SESSION["bmf"]["payment_type"], $bookingList, $resultObj);
00656
00657 $this->__addBookings($resultObj,$bookingList->getTransaction());
00658 $this->__emptyShoppingCart();
00659 $this->__clearSession();
00660
00661 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00662 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
00663 $this->tpl->touchBlock("stop_floating");
00664
00665 ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
00666
00667 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_debit_entry.html','payment');
00668 #$this->tpl = new ilTemplate('tpl.pay_bmf_debit_entry.html', true, true, 'payment');
00669 if ($this->ilias->getSetting("https") != 1)
00670 {
00671 $this->tpl->setCurrentBlock("buyed_objects");
00672 #$this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", "./payment.php?baseClass=ilpaymentbuyedobjectsgui&cmd=2");
00673 $link = $this->ctrl->getLinkTargetByClass('ilpaymentbuyedobjectsgui', 'showItems');
00674
00675 $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
00676 $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
00677 $this->tpl->parseCurrentBlock("buyed_objects");
00678 }
00679 $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
00680 }
00681 }
00682 else
00683 {
00684 $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
00685 $this->tpl->touchBlock("stop_floating");
00686 ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
00687 }
00688 }
00689 }
00690 else
00691 {
00692 $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
00693 $this->tpl->touchBlock("stop_floating");
00694 ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
00695 }
00696 }
00697 }
00698
00699 function showCreditCard()
00700 {
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00712
00713 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00714 {
00715
00716 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00717 $this->tpl->touchBlock("stop_floating");
00718 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00719
00720 }
00721 else
00722 {
00723
00724 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','payment');
00725 #$this->tpl = new ilTemplate('tpl.pay_bmf_credit_card.html', true, true, 'payment');
00726 $this->__showShoppingCart();
00727
00728 $this->tpl->setVariable("CREDIT_CARD_FORMACTION",$this->ctrl->getFormAction($this));
00729
00730
00731 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_pays_b.gif'));
00732 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_usr'));
00733 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_step3_credit_card'));
00734 $this->tpl->setVariable("TITLE",$this->lng->txt('pay_bmf_credit_card_data'));
00735 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_description_credit_card'));
00736 $this->tpl->touchBlock("stop_floating");
00737 $this->tpl->setVariable("TXT_CLOSE_WINDOW",$this->lng->txt('close_window'));
00738
00739
00740 $this->tpl->setVariable("TXT_CARD_HOLDER",$this->lng->txt('pay_bmf_card_holder'));
00741 $this->tpl->setVariable("TXT_CHECK_NUMBER",$this->lng->txt('pay_bmf_check_number'));
00742 $this->tpl->setVariable("TXT_OPTIONAL",$this->lng->txt('pay_bmf_optional'));
00743 $this->tpl->setVariable("TXT_CARD_NUMBER",$this->lng->txt('pay_bmf_card_number'));
00744 $this->tpl->setVariable("TXT_VALIDITY",$this->lng->txt('pay_bmf_validity'));
00745 $this->tpl->setVariable("TXT_TERMS_CONDITIONS",$this->lng->txt('pay_bmf_terms_conditions'));
00746 $this->tpl->setVariable("TXT_TERMS_CONDITIONS_READ",$this->lng->txt('pay_bmf_terms_conditions_read'));
00747 $this->tpl->setVariable("TXT_TERMS_CONDITIONS_SHOW",$this->lng->txt('pay_bmf_terms_conditions_show'));
00748 $this->tpl->setVariable("LINK_TERMS_CONDITIONS","./payment.php?view=conditions");
00749 $this->tpl->setVariable("TXT_PASSWORD",$this->lng->txt('password'));
00750 $this->tpl->setVariable("TXT_CONFIRM_ORDER",$this->lng->txt('pay_confirm_order'));
00751
00752 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_send_order'));
00753 $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
00754
00755
00756
00757 $this->tpl->setVariable("CARD_HOLDER",
00758 $this->error != "" && isset($_POST['card_holder'])
00759 ? ilUtil::prepareFormOutput($_POST['card_holder'],true)
00760 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['karteninhaber'],true));
00761 $this->tpl->setVariable("CARD_NUMBER_BLOCK_1",
00762 $this->error != "" && isset($_POST['card_number']['block_1'])
00763 ? ilUtil::prepareFormOutput($_POST['card_number']['block_1'],true)
00764 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_1'],true));
00765 $this->tpl->setVariable("CARD_NUMBER_BLOCK_2",
00766 $this->error != "" && isset($_POST['card_number']['block_2'])
00767 ? ilUtil::prepareFormOutput($_POST['card_number']['block_2'],true)
00768 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_2'],true));
00769 $this->tpl->setVariable("CARD_NUMBER_BLOCK_3",
00770 $this->error != "" && isset($_POST['card_number']['block_3'])
00771 ? ilUtil::prepareFormOutput($_POST['card_number']['block_3'],true)
00772 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_3'],true));
00773 $this->tpl->setVariable("CARD_NUMBER_BLOCK_4",
00774 $this->error != "" && isset($_POST['card_number']['block_4'])
00775 ? ilUtil::prepareFormOutput($_POST['card_number']['block_4'],true)
00776 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kreditkartenNr']['block_4'],true));
00777 $this->tpl->setVariable("CHECK_NUMBER",
00778 $this->error != "" && isset($_POST['check_number'])
00779 ? ilUtil::prepareFormOutput($_POST['check_number'],true)
00780 : ilUtil::prepareFormOutput($_SESSION['bmf']["credit_card"]['kartenpruefnummer'],true));
00781 for ($i = 1; $i <= 12; $i++)
00782 {
00783 $this->tpl->setCurrentBlock("loop_validity_months");
00784 $this->tpl->setVariable("LOOP_VALIDITY_MONTHS", $i < 10 ? "0" . $i : $i);
00785 $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_TXT", $i < 10 ? "0" . $i : $i);
00786 if ($this->error != "" &&
00787 isset($_POST['validity']['month']))
00788 {
00789 if ($_POST['validity']['month'] == $i)
00790 {
00791 $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
00792 }
00793 }
00794 else
00795 {
00796 if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] == $i)
00797 {
00798 $this->tpl->setVariable("LOOP_VALIDITY_MONTHS_SELECTED", " selected");
00799 }
00800 }
00801 $this->tpl->parseCurrentBlock("loop_validity_months");
00802 }
00803 for ($i = date("Y"); $i <= (date("Y")+6); $i++)
00804 {
00805 $this->tpl->setCurrentBlock("loop_validity_years");
00806 $this->tpl->setVariable("LOOP_VALIDITY_YEARS", $i);
00807 $this->tpl->setVariable("LOOP_VALIDITY_YEARS_TXT", $i);
00808 if ($this->error != "" &&
00809 isset($_POST['validity']['year']))
00810 {
00811 if ($_POST['validity']['year'] == $i)
00812 {
00813 $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
00814 }
00815 }
00816 else
00817 {
00818 if ($_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] == $i)
00819 {
00820 $this->tpl->setVariable("LOOP_VALIDITY_YEARS_SELECTED", " selected");
00821 }
00822 }
00823 $this->tpl->parseCurrentBlock("loop_validity_years");
00824 }
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00838 $this->tpl->setCurrentBlock("btn_cell");
00839 $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "showPaymentType"));
00840 $this->tpl->setVariable("BTN_TXT", $this->lng->txt('pay_bmf_back'));
00841 $this->tpl->parseCurrentBlock("btn_cell");
00842
00843 }
00844 }
00845
00846 function getCreditCard()
00847 {
00848 if ($_POST["card_holder"] == "" ||
00849 $_POST["card_number"]["block_1"] == "" ||
00850 $_POST["card_number"]["block_2"] == "" ||
00851 $_POST["card_number"]["block_3"] == "" ||
00852 $_POST["card_number"]["block_4"] == "" ||
00853 $_POST["validity"]["month"] == "" ||
00854 $_POST["validity"]["year"] == "" ||
00855 $_POST["validity"]["year"]."-".$_POST["validity"]["month"] < date("Y-m"))
00856 {
00857 $this->error = $this->lng->txt('pay_bmf_credit_card_not_valid');
00858 ilUtil::sendInfo($this->error);
00859 $this->showCreditCard();
00860 return;
00861 }
00862 if ($_POST["terms_conditions"] != 1)
00863 {
00864 $this->error = $this->lng->txt('pay_bmf_check_terms_conditions');
00865 ilUtil::sendInfo($this->error);
00866 $this->showCreditCard();
00867 return;
00868 }
00869 if ($_POST["password"] == "" ||
00870 md5($_POST["password"]) != $this->user_obj->getPasswd())
00871 {
00872 $this->error = $this->lng->txt('pay_bmf_password_not_valid');
00873 ilUtil::sendInfo($this->error);
00874 $this->showCreditCard();
00875 return;
00876 }
00877
00878 $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["monat"] = $_POST["validity"]["month"];
00879 $_SESSION["bmf"]["credit_card"]["gueltigkeit"]["jahr"] = $_POST["validity"]["year"];
00880 $_SESSION["bmf"]["credit_card"]["karteninhaber"] = $_POST["card_holder"];
00881 $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_1"] = $_POST["card_number"]["block_1"];
00882 $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_2"] = $_POST["card_number"]["block_2"];
00883 $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_3"] = $_POST["card_number"]["block_3"];
00884 $_SESSION["bmf"]["credit_card"]["kreditkartenNr"]["block_4"] = $_POST["card_number"]["block_4"];
00885 $_SESSION["bmf"]["credit_card"]["kartenpruefnummer"] = $_POST["check_number"];
00886
00887 $this->error = "";
00888 $this->sendCreditCard();
00889 }
00890
00891 function sendCreditCard()
00892 {
00893 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
00894
00895 $this->psc_obj->clearCouponItemsSession();
00896
00897 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
00898 {
00899
00900 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
00901 $this->tpl->touchBlock("stop_floating");
00902 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00903
00904 }
00905 else
00906 {
00907
00908 $payment = new KreditkartenzahlungWS();
00909
00910 $customer = new Kunde($this->user_obj->getId());
00911
00912 $creditCard = new Kreditkarte();
00913
00914 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
00915
00916 $tmp_bookEntries = $sc_obj->getShoppingCart();
00917 if (!is_array($tmp_bookEntries))
00918 {
00919 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
00920 }
00921 else
00922 {
00923 $totalAmount = 0;
00924 for ($i = 0; $i < count($tmp_bookEntries); $i++)
00925 {
00926 $booking = true;
00927
00928 if (!empty($_SESSION["coupons"]["bmf"]))
00929 {
00930 $price = $tmp_bookEntries[$i]["betrag"];
00931 $tmp_bookEntries[$i]["math_price"] = (float) $price;
00932
00933 foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
00934 {
00935 $this->coupon_obj->setId($coupon["pc_pk"]);
00936 $this->coupon_obj->setCurrentCoupon($coupon);
00937
00938 $tmp_pobject =& new ilPaymentObject($this->user_obj, $tmp_bookEntries[$i]['pobject_id']);
00939
00940 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00941 {
00942 $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += (float) $price;
00943 $_SESSION["coupons"]["bmf"][$key]["items"][] = $tmp_bookEntries[$i];
00944
00945 $booking = false;
00946 }
00947
00948 unset($tmp_pobject);
00949 }
00950 }
00951
00952 if ($booking)
00953 {
00954 $tmp_bookEntries[$i]["betrag_string"] = number_format( (float) $tmp_bookEntries[$i]["betrag"] , 2, ",", ".");
00955
00956 $bookEntries[] = new Buchung($tmp_bookEntries[$i]);
00957 $totalAmount += $tmp_bookEntries[$i]["betrag"];
00958 }
00959 else
00960 {
00961 $tmp_bookEntries[$i]["betrag_string"] = number_format( (float) $tmp_bookEntries[$i]["betrag"] , 2, ",", ".");
00962 }
00963 }
00964
00965 $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
00966
00967 if (is_array($coupon_discount_items) && !empty($coupon_discount_items))
00968 {
00969 foreach ($coupon_discount_items as $item)
00970 {
00971 $item["betrag"] = $item["discount_price"];
00972 $bookEntries[] = new Buchung($item);
00973 $totalAmount += $item["discount_price"];
00974 }
00975 }
00976
00977 $values = array("betrag" => $totalAmount, "buchungen" => $bookEntries);
00978 $bookingList = new BuchungsListe($this->user_obj->getId(), $values);
00979 }
00980
00981 # vd($customer);
00982 # vd($creditCard);
00983 # vd($bookingList);
00984
00985 $resultObj = $payment->zahlenUndAnlegenKunde($customer, $creditCard, $bookingList);
00986 $result = $resultObj->ergebnis;
00987
00988 # vd($result);
00989
00990 if (is_object($result))
00991 {
00992 if ($result->code < 0)
00993 {
00994 $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
00995 $this->tpl->touchBlock("stop_floating");
00996 $error = $this->lng->txt('pay_bmf_server_error_code') . " " . $result->code . ": " . $result->kurzText . "<br>\n" . $result->langText;
00997 if ($result->code == -103 ||
00998 $result->code == -104 ||
00999 $result->code == -107 ||
01000 ($result->code <= -202 && $result->code >= -208) ||
01001 $result->code == -213)
01002 {
01003 ilUtil::sendInfo($error);
01004 $this->showPersonalData();
01005 }
01006 else if ($result->code == -507 ||
01007 $result->code == -510 ||
01008 $result->code == -511)
01009 {
01010 ilUtil::sendInfo($error);
01011 $this->showPaymentType();
01012 }
01013 else if ($result->code == -701 ||
01014 $result->code == -1701 ||
01015 $result->code == -1706 ||
01016 $result->code == -1707 ||
01017 $result->code == -1710 ||
01018 $result->code == -1711)
01019 {
01020 ilUtil::sendInfo($error);
01021 $this->showCreditCard();
01022 }
01023 else
01024 {
01025 $error .= "<br>\n" . $this->lng->txt('pay_bmf_server_error_sysadmin');
01026 ilUtil::sendInfo($error);
01027 $this->showPersonalData();
01028 }
01029
01030 }
01031 else
01032 {
01033
01034 $this->__sendBill($customer, $_SESSION["bmf"]["payment_type"], $bookingList, $resultObj);
01035
01036 $this->__addBookings($resultObj,$bookingList->getTransaction());
01037 $this->__emptyShoppingCart();
01038 $this->__clearSession();
01039
01040 $this->tpl->setVariable("HEADER",$this->lng->txt('pay_bmf_your_order'));
01041 $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('pay_bmf_thanks'));
01042 $this->tpl->touchBlock("stop_floating");
01043
01044 ilUtil::sendInfo($this->lng->txt('pay_bmf_thanks'));
01045
01046 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_bmf_credit_card.html','payment');
01047 #$this->tpl = new ilTemplate('tpl.pay_bmf_credit_card.html', true, true, 'payment');
01048 if ($this->ilias->getSetting("https") != 1)
01049 {
01050 $this->tpl->setCurrentBlock("buyed_objects");
01051 #$this->ctrl->redirectByClass("ilPaymentBuyedObjectsGUI", "ilpaymentbuyedobjectsgui");
01052 $link = $this->ctrl->getLinkTargetByClass('ilpaymentbuyedobjectsgui', 'showItems');
01053 $this->tpl->setVariable("LINK_GOTO_BUYED_OBJECTS", $link);
01054 $this->tpl->setVariable("TXT_GOTO_BUYED_OBJECTS", $this->lng->txt('pay_goto_buyed_objects'));
01055 $this->tpl->parseCurrentBlock("buyed_objects");
01056 }
01057 $this->tpl->setVariable("TXT_CLOSE_WINDOW", $this->lng->txt('close_window'));
01058 }
01059 }
01060 else
01061 {
01062 $this->tpl->setVariable("HEADER",$this->lng->txt('error'));
01063 $this->tpl->touchBlock("stop_floating");
01064 ilUtil::sendInfo($this->lng->txt('pay_bmf_server_error_communication'));
01065 }
01066
01067 }
01068
01069 }
01070
01074 function &executeCommand()
01075 {
01076 global $tree;
01077
01078 $cmd = $this->ctrl->getCmd();
01079
01080 switch ($this->ctrl->getNextClass($this))
01081 {
01082
01083 default:
01084 if(!$cmd = $this->ctrl->getCmd())
01085 {
01086 $cmd = 'showPersonalData';
01087 }
01088 $this->$cmd();
01089 break;
01090 }
01091 }
01092
01093
01094 function __sendBill($customer, $paymentType, $bookingList, $result)
01095 {
01096 include_once './classes/class.ilTemplate.php';
01097 include_once "./Services/Utilities/classes/class.ilUtil.php";
01098 include_once './payment/classes/class.ilGeneralSettings.php';
01099 include_once './payment/classes/class.ilPaymentShoppingCart.php';
01100 include_once 'Services/Mail/classes/class.ilMimeMail.php';
01101
01102 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
01103 $genSet = new ilGeneralSettings();
01104
01105 $tpl = new ilTemplate("./payment/templates/default/tpl.pay_bmf_bill.html", true, true, true);
01106
01107 $tpl->setVariable("VENDOR_ADDRESS", nl2br(utf8_decode($genSet->get("address"))));
01108 $tpl->setVariable("VENDOR_ADD_INFO", nl2br(utf8_decode($genSet->get("add_info"))));
01109 $tpl->setVariable("VENDOR_BANK_DATA", nl2br(utf8_decode($genSet->get("bank_data"))));
01110 $tpl->setVariable("TXT_BANK_DATA", utf8_decode($this->lng->txt("pay_bank_data")));
01111
01112 $tpl->setVariable("CUSTOMER_FIRSTNAME", $customer->vorname);
01113 $tpl->setVariable("CUSTOMER_LASTNAME", $customer->nachname);
01114 if ($customer->rechnungsAdresse->strasse != "" &&
01115 $customer->rechnungsAdresse->hausNr != "")
01116 {
01117 $tpl->setVariable("CUSTOMER_STREET_POBOX", $customer->rechnungsAdresse->strasse . " ". $customer->rechnungsAdresse->hausNr);
01118 }
01119 else
01120 {
01121 $tpl->setVariable("CUSTOMER_STREET_POBOX", $customer->rechnungsAdresse->postfach);
01122 }
01123 $tpl->setVariable("CUSTOMER_ZIPCODE", $customer->rechnungsAdresse->PLZ);
01124 $tpl->setVariable("CUSTOMER_CITY", $customer->rechnungsAdresse->ort);
01125 $tpl->setVariable("CUSTOMER_COUNTRY", $this->__getCountryName($customer->rechnungsAdresse->land));
01126
01127 $tpl->setVariable("BILL_NO", $result->buchungsListe->kassenzeichen);
01128 $tpl->setVariable("DATE", date("d.m.Y"));
01129
01130 $tpl->setVariable("TXT_BILL", utf8_decode($this->lng->txt("pays_bill")));
01131 $tpl->setVariable("TXT_BILL_NO", utf8_decode($this->lng->txt("pay_bill_no")));
01132 $tpl->setVariable("TXT_DATE", utf8_decode($this->lng->txt("date")));
01133
01134 $tpl->setVariable("TXT_ARTICLE", utf8_decode($this->lng->txt("pay_article")));
01135 $tpl->setVariable("TXT_PRICE", utf8_decode($this->lng->txt("price_a")));
01136
01137 $bookEntries = $sc_obj->getShoppingCart();
01138 for ($i = 0; $i < count($bookEntries); $i++)
01139 {
01140 $tmp_pobject =& new ilPaymentObject($this->user_obj, $bookEntries[$i]['pobject_id']);
01141
01142 $assigned_coupons = '';
01143 if (!empty($_SESSION["coupons"]["bmf"]))
01144 {
01145 foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
01146 {
01147 $this->coupon_obj->setId($coupon["pc_pk"]);
01148 $this->coupon_obj->setCurrentCoupon($coupon);
01149
01150 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
01151 {
01152 $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon["pcc_code"];
01153 }
01154 }
01155 }
01156
01157 $tpl->setCurrentBlock("loop");
01158 $tpl->setVariable("LOOP_OBJ_TYPE", utf8_decode($this->lng->txt($bookEntries[$i]["typ"])));
01159 $tpl->setVariable("LOOP_TITLE", $bookEntries[$i]["buchungstext"]. $assigned_coupons);
01160 $tpl->setVariable("LOOP_TXT_ENTITLED_RETRIEVE", utf8_decode($this->lng->txt("pay_entitled_retrieve")));
01161 $tpl->setVariable("LOOP_DURATION", $bookEntries[$i]["dauer"] . " " . utf8_decode($this->lng->txt("paya_months")));
01162 $tpl->setVariable("LOOP_PRICE", number_format($bookEntries[$i]["betrag"], 2, ",", ".") . " " . $genSet->get("currency_unit"));
01163 $tpl->parseCurrentBlock("loop");
01164
01165 unset($tmp_pobject);
01166 }
01167
01168 if (!empty($_SESSION["coupons"]["bmf"]))
01169 {
01170 if (count($items = $bookEntries))
01171 {
01172 $sub_total_amount = $bookingList->betrag;
01173
01174 foreach ($_SESSION["coupons"]["bmf"] as $coupon)
01175 {
01176 $this->coupon_obj->setId($coupon["pc_pk"]);
01177 $this->coupon_obj->setCurrentCoupon($coupon);
01178
01179 $total_object_price = 0.0;
01180 $current_coupon_bonus = 0.0;
01181
01182 foreach ($bookEntries as $item)
01183 {
01184 $tmp_pobject =& new ilPaymentObject($this->user_obj, $item['pobject_id']);
01185
01186 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
01187 {
01188 $total_object_price += $item["betrag"];
01189 }
01190
01191 unset($tmp_pobject);
01192 }
01193
01194 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
01195
01196 $sub_total_amount += $current_coupon_bonus;
01197
01198 $tpl->setCurrentBlock("cloop");
01199 $tpl->setVariable("TXT_COUPON", utf8_decode($this->lng->txt("paya_coupons_coupon") . " " . $coupon["pcc_code"]));
01200 $tpl->setVariable("BONUS", number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get("currency_unit"));
01201 $tpl->parseCurrentBlock();
01202 }
01203
01204 $tpl->setVariable("TXT_SUBTOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_subtotal_amount")));
01205 $tpl->setVariable("SUBTOTAL_AMOUNT", number_format($sub_total_amount, 2, ",", ".") . " " . $genSet->get("currency_unit"));
01206 }
01207 }
01208
01209 if ($bookingList->betrag < 0) $bookingList->betrag = 0.0;
01210
01211 $tpl->setVariable("TXT_TOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_total_amount")));
01212 $tpl->setVariable("TOTAL_AMOUNT", number_format($bookingList->betrag, 2, ",", ".") . " " . $genSet->get("currency_unit"));
01213 if (($vat = $sc_obj->getVat($bookingList->betrag)) > 0)
01214 {
01215 $tpl->setVariable("VAT", number_format($vat, 2, ",", ".") . " " . $genSet->get("currency_unit"));
01216 $tpl->setVariable("TXT_VAT", $genSet->get("vat_rate") . "% " . utf8_decode($this->lng->txt("pay_bmf_vat_included")));
01217 }
01218
01219 if ($paymentType == "debit_entry")
01220 {
01221 $tpl->setVariable("TXT_PAYMENT_TYPE", utf8_decode($this->lng->txt("pay_payed_debit_entry")));
01222 }
01223 else
01224 {
01225 $tpl->setVariable("TXT_PAYMENT_TYPE", utf8_decode($this->lng->txt("pay_payed_credit_card")));
01226 }
01227
01228 if (!@file_exists($genSet->get("pdf_path")))
01229 {
01230 ilUtil::makeDir($genSet->get("pdf_path"));
01231 }
01232
01233 if (@file_exists($genSet->get("pdf_path")))
01234 {
01235 ilUtil::html2pdf($tpl->get(), $genSet->get("pdf_path") . "/" . $result->buchungsListe->kassenzeichen . ".pdf");
01236 }
01237
01238 if (@file_exists($genSet->get("pdf_path") . "/" . $result->buchungsListe->kassenzeichen . ".pdf") &&
01239 $customer->EMailAdresse != "" &&
01240 $this->ilias->getSetting("admin_email") != "")
01241 {
01242 $m= new ilMimeMail;
01243 $m->From( $this->ilias->getSetting("admin_email") );
01244 $m->To( $customer->EMailAdresse );
01245 $m->Subject( $this->lng->txt("pay_message_subject") );
01246 $message = $this->lng->txt("pay_message_hello") . " " . utf8_encode($customer->vorname) . " " . utf8_encode($customer->nachname) . ",\n\n";
01247 $message .= $this->lng->txt("pay_message_thanks") . "\n\n";
01248 $message .= $this->lng->txt("pay_message_attachment") . "\n\n";
01249 $message .= $this->lng->txt("pay_message_regards") . "\n\n";
01250 $message .= strip_tags($genSet->get("address"));
01251 $m->Body( $message );
01252 $m->Attach( $genSet->get("pdf_path") . "/" . $result->buchungsListe->kassenzeichen . ".pdf", "application/pdf" ) ;
01253 $m->Send();
01254 }
01255
01256 @unlink($genSet->get("pdf_path") . "/" . $result->buchungsListe->kassenzeichen . ".html");
01257 @unlink($genSet->get("pdf_path") . "/" . $result->buchungsListe->kassenzeichen . ".pdf");
01258
01259 }
01260
01261 function __addBookings($a_result,$a_transaction)
01262 {
01263 include_once './payment/classes/class.ilPaymentBookings.php';
01264 include_once './payment/classes/class.ilPaymentShoppingCart.php';
01265 include_once './payment/classes/class.ilPaymentObject.php';
01266 include_once './payment/classes/class.ilPaymentPrices.php';
01267
01268 $booking_obj =& new ilPaymentBookings();
01269
01270 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
01271
01272 $items = $sc_obj->getEntries(PAY_METHOD_BMF);
01273
01274 $sc_obj->clearCouponItemsSession();
01275
01276 foreach($items as $entry)
01277 {
01278 $pobject =& new ilPaymentObject($this->user_obj,$entry['pobject_id']);
01279
01280 $price = ilPaymentPrices::_getPrice($entry['price_id']);
01281
01282 if (!empty($_SESSION["coupons"]["bmf"]))
01283 {
01284 $entry["math_price"] = (float) ilPaymentPrices::_getPriceFromArray($price);
01285 foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
01286 {
01287 $this->coupon_obj->setId($coupon["pc_pk"]);
01288 $this->coupon_obj->setCurrentCoupon($coupon);
01289
01290 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
01291 {
01292 $_SESSION["coupons"]["bmf"][$key]["total_objects_coupon_price"] += (float) ilPaymentPrices::_getPriceFromArray($price);
01293 $_SESSION["coupons"]["bmf"][$key]["items"][] = $entry;
01294 }
01295 }
01296 }
01297
01298 unset($pobject);
01299 }
01300
01301 $coupon_discount_items = $sc_obj->calcDiscountPrices($_SESSION["coupons"]["bmf"]);
01302
01303 $i = 0;
01304 foreach($items as $entry)
01305 {
01306 $pobject =& new ilPaymentObject($this->user_obj,$entry['pobject_id']);
01307
01308 $price = ilPaymentPrices::_getPrice($entry['price_id']);
01309
01310 if (array_key_exists($entry["pobject_id"], $coupon_discount_items))
01311 {
01312 $bonus = $coupon_discount_items[$entry["pobject_id"]]["math_price"] - $coupon_discount_items[$entry["pobject_id"]]["discount_price"];
01313 }
01314
01315 $booking_obj->setTransaction($a_transaction);
01316 $booking_obj->setPobjectId($entry['pobject_id']);
01317 $booking_obj->setCustomerId($this->user_obj->getId());
01318 $booking_obj->setVendorId($pobject->getVendorId());
01319 $booking_obj->setPayMethod($pobject->getPayMethod());
01320 $booking_obj->setOrderDate(time());
01321 $booking_obj->setDuration($price['duration']);
01322 $booking_obj->setPrice(ilPaymentPrices::_getPriceString($entry['price_id']));
01323 $booking_obj->setDiscount($bonus > 0 ? ilPaymentPrices::_getPriceStringFromAmount((-1) * $bonus) : "");
01324 $booking_obj->setPayed(1);
01325 $booking_obj->setAccess(1);
01326 $booking_obj->setVoucher($a_result->buchungsListe->buchungen[$i++]->belegNr);
01327 $booking_obj->setTransactionExtern($a_result->buchungsListe->kassenzeichen);
01328
01329 $current_booking_id = $booking_obj->add();
01330
01331 if (!empty($_SESSION["coupons"]["bmf"]) && $current_booking_id)
01332 {
01333 foreach ($_SESSION["coupons"]["bmf"] as $coupon)
01334 {
01335 $this->coupon_obj->setId($coupon["pc_pk"]);
01336 $this->coupon_obj->setCurrentCoupon($coupon);
01337
01338 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
01339 {
01340 $this->coupon_obj->addCouponForBookingId($current_booking_id);
01341 }
01342 }
01343 }
01344
01345 unset($current_booking_id);
01346 unset($pobject);
01347 }
01348
01349 if (!empty($_SESSION["coupons"]["bmf"]))
01350 {
01351 foreach ($_SESSION["coupons"]["bmf"] as $coupon)
01352 {
01353 $this->coupon_obj->setId($coupon["pc_pk"]);
01354 $this->coupon_obj->setCurrentCoupon($coupon);
01355 $this->coupon_obj->addTracking();
01356 }
01357 }
01358 }
01359
01360 function __emptyShoppingCart()
01361 {
01362 include_once './payment/classes/class.ilPaymentShoppingCart.php';
01363
01364 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
01365
01366 return $sc_obj->emptyShoppingCart();
01367 }
01368
01369 function __clearSession()
01370 {
01371 $_SESSION["coupons"]["bmf"] = "";
01372 $_SESSION["bmf"]["payment_type"] = "";
01373 $_SESSION["bmf"]["debit_entry"] = array();
01374 $_SESSION["bmf"]["credit_card"] = array();
01375 }
01376
01377 function __loadTemplate()
01378 {
01379 $this->tpl->addBlockFile("CONTENT", "content", "tpl.payb_content.html");
01380
01381 $this->__buildStylesheet();
01382 $this->__buildStatusline();
01383 }
01384
01385 function __buildStatusline()
01386 {
01387 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01388 # $this->__buildLocator();
01389 }
01390
01391 function __buildLocator()
01392 {
01393 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
01394 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
01395
01396 $this->tpl->setCurrentBlock("locator_item");
01397 $this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
01398 $this->tpl->setVariable("LINK_ITEM","../ilias.php?baseClass=ilPersonalDesktopGUI");
01399 #$this->tpl->setVariable("LINK_ITEM", "../usr_personaldesktop.php");
01400 $this->tpl->parseCurrentBlock();
01401
01402 $this->tpl->setCurrentBlock("locator_item");
01403 $this->tpl->setVariable("PREFIX",'> ');
01404 # $this->tpl->setVariable("ITEM", $this->lng->txt("pay_locator"));
01405 $this->tpl->setVariable("ITEM", "Payment");
01406 $this->tpl->setVariable("LINK_ITEM", "./payment.php");
01407 $this->tpl->parseCurrentBlock();
01408
01409
01410 ilUtil::sendInfo();
01411
01412 return true;
01413 }
01414
01415 function __buildStylesheet()
01416 {
01417 $this->tpl->setVariable("LOCATION_STYLESHEET",ilUtil::getStyleSheetLocation());
01418 }
01419
01423 function __showCountries(&$tpl, $value = "")
01424 {
01425 $countries = $this->__getCountries();
01426 foreach($countries as $code => $text)
01427 {
01428 $tpl->setCurrentBlock("loop_countries");
01429 $tpl->setVariable("LOOP_COUNTRIES", $code);
01430 $tpl->setVariable("LOOP_COUNTRIES_TXT", $text);
01431 if ($value != "" &&
01432 $value == $code)
01433 {
01434 $tpl->setVariable("LOOP_COUNTRIES_SELECTED", " selected");
01435 }
01436 $tpl->parseCurrentBlock("loop_countries");
01437 }
01438 $tpl->setVariable("TXT_PLEASE_SELECT", $this->lng->txt("pay_bmf_please_select"));
01439 return;
01440 }
01441
01442 function __getCountries()
01443 {
01444 global $lng;
01445
01446 $lng->loadLanguageModule("meta");
01447
01448 $cntcodes = array ("DE","ES","FR","GB","AT","CH","AF","AL","DZ","AS","AD","AO",
01449 "AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY",
01450 "BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","BN","BG","BF",
01451 "BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM",
01452 "CG","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","TP","EC",
01453 "EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","FX","GF","PF",
01454 "TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GN",
01455 "GW","GY","HT","HM","HN","HU","IS","IN","ID","IR","IQ","IE","IL","IT",
01456 "JM","JP","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS",
01457 "LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH",
01458 "MQ","MR","MU","YT","MX","FM","MD","MC","MN","MS","MA","MZ","MM","NA",
01459 "NR","NP","NL","AN","NC","NZ","NI","NE","NG","NU","NF","MP","NO","OM",
01460 "PK","PW","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RE","RO",
01461 "RU","RW","KN","LC","VC","WS","SM","ST","SA","CH","SN","SC","SL","SG",
01462 "SK","SI","SB","SO","ZA","GS","ES","LK","SH","PM","SD","SR","SJ","SZ",
01463 "SE","SY","TW","TJ","TZ","TH","TG","TK","TO","TT","TN","TR","TM","TC",
01464 "TV","UG","UA","AE","GB","UY","US","UM","UZ","VU","VA","VE","VN","VG",
01465 "VI","WF","EH","YE","ZR","ZM","ZW");
01466 $cntrs = array();
01467 foreach($cntcodes as $cntcode)
01468 {
01469 $cntrs[$cntcode] = $lng->txt("meta_c_".$cntcode);
01470 }
01471 asort($cntrs);
01472 return $cntrs;
01473 }
01474
01475 function __getCountryCode($value = "")
01476 {
01477 $countries = $this->__getCountries();
01478 foreach($countries as $code => $text)
01479 {
01480 if ($text == $value)
01481 {
01482 return $code;
01483 }
01484 }
01485 return;
01486 }
01487
01488 function __getCountryName($value = "")
01489 {
01490 $countries = $this->__getCountries();
01491 return $countries[$value];
01492 }
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546 function __showShoppingCart()
01547 {
01548
01549 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
01550
01551 if(!count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
01552 {
01553 ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
01554 }
01555
01556 $counter = 0;
01557 foreach($items as $item)
01558 {
01559 $tmp_pobject =& new ilPaymentObject($this->user_obj,$item['pobject_id']);
01560
01561 $tmp_obj =& ilObjectFactory::getInstanceByRefId($tmp_pobject->getRefId());
01562
01563 $price_arr = ilPaymentPrices::_getPrice($item['price_id']);
01564
01565 $assigned_coupons = '';
01566 if (!empty($_SESSION["coupons"]["bmf"]))
01567 {
01568 foreach ($_SESSION["coupons"]["bmf"] as $key => $coupon)
01569 {
01570 $this->coupon_obj->setId($coupon["pc_pk"]);
01571 $this->coupon_obj->setCurrentCoupon($coupon);
01572
01573 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
01574 {
01575 $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon["pcc_code"];
01576 }
01577 }
01578 }
01579
01580 $f_result[$counter][] = $tmp_obj->getTitle();
01581 if ($assigned_coupons != '') $f_result[$counter][count($f_result[$counter]) - 1] .= $assigned_coupons;
01582
01583 $f_result[$counter][] = $price_arr['duration'] . " " . $this->lng->txt("paya_months");
01584
01585 $f_result[$counter][] = ilPaymentPrices::_getPriceString($item['price_id']);
01586
01587 unset($tmp_obj);
01588 unset($tmp_pobject);
01589
01590 ++$counter;
01591 }
01592
01593 return $this->__showItemsTable($f_result);
01594 }
01595
01596 function &__initTableGUI()
01597 {
01598 include_once "./Services/Table/classes/class.ilTableGUI.php";
01599
01600 return new ilTableGUI(0,false);
01601 }
01602
01603 function __showItemsTable($a_result_set)
01604 {
01605 include_once './payment/classes/class.ilGeneralSettings.php';
01606
01607 $genSet = new ilGeneralSettings();
01608
01609 $tbl =& $this->__initTableGUI();
01610 $tpl =& $tbl->getTemplateObject();
01611
01612
01613 $tpl->setCurrentBlock("tbl_form_header");
01614
01615 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01616 $tpl->parseCurrentBlock();
01617
01618 $tbl->setTitle($this->lng->txt("paya_shopping_cart"),"icon_pays_b.gif",$this->lng->txt("paya_shopping_cart"));
01619 $tbl->setHeaderNames(array($this->lng->txt("title"),
01620 $this->lng->txt("duration"),
01621 $this->lng->txt("price_a")));
01622
01623 $tbl->setHeaderVars(array("title",
01624 "duration",
01625 "price"),
01626 array("cmd" => "",
01627 "cmdClass" => "ilpurchasebmfgui",
01628 "cmdNode" => $_GET["cmdNode"]));
01629
01630 $tbl->disable("footer");
01631 $tbl->disable("sort");
01632 $tbl->disable("linkbar");
01633
01634 $offset = $_GET["offset"];
01635 $order = $_GET["sort_by"];
01636 $direction = $_GET["sort_order"] ? $_GET['sort_order'] : 'desc';
01637
01638 $tbl->setOrderColumn($order,'title');
01639 $tbl->setOrderDirection($direction);
01640 $tbl->setOffset($offset);
01641 $tbl->setLimit($_GET["limit"]);
01642 $tbl->setMaxCount(count($a_result_set));
01643 # $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01644 $tbl->setData($a_result_set);
01645
01646 $sc_obj =& new ilPaymentShoppingCart($this->user_obj);
01647
01648 $totalAmount = $sc_obj->getTotalAmount();
01649 $vat = $sc_obj->getVat($totalAmount[PAY_METHOD_BMF]);
01650
01651 $tpl->setCurrentBlock("tbl_footer_linkbar");
01652 $amount .= "<table class=\"\" style=\"float: right;\">\n";
01653 if (!empty($_SESSION["coupons"]["bmf"]))
01654 {
01655 $this->psc_obj = new ilPaymentShoppingCart($this->user_obj);
01656
01657 if (count($items = $this->psc_obj->getEntries(PAY_METHOD_BMF)))
01658 {
01659 $amount .= "<tr>\n";
01660 $amount .= "<td>\n";
01661 $amount .= "<b>" . $this->lng->txt("pay_bmf_subtotal_amount") . ":";
01662 $amount .= "</td>\n";
01663 $amount .= "<td>\n";
01664 $amount .= number_format($totalAmount[PAY_METHOD_BMF], 2, ',', '.') . " " . $genSet->get("currency_unit") . "</b>";
01665 $amount .= "</td>\n";
01666 $amount .= "</tr>\n";
01667
01668 foreach ($_SESSION["coupons"]["bmf"] as $coupon)
01669 {
01670 $this->coupon_obj->setCurrentCoupon($coupon);
01671 $this->coupon_obj->setId($coupon["pc_pk"]);
01672
01673 $total_object_price = 0.0;
01674 $current_coupon_bonus = 0.0;
01675
01676 foreach ($items as $item)
01677 {
01678 $tmp_pobject =& new ilPaymentObject($this->user_obj, $item['pobject_id']);
01679
01680 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
01681 {
01682 $price_data = ilPaymentPrices::_getPrice($item['price_id']);
01683 $price = ((int) $price_data["unit_value"]) . "." . sprintf("%02d", ((int) $price_data["sub_unit_value"]));
01684
01685 $total_object_price += $price;
01686 }
01687
01688 unset($tmp_pobject);
01689 }
01690
01691 $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price);
01692 $totalAmount[PAY_METHOD_BMF] += $current_coupon_bonus * (-1);
01693
01694 $amount .= "<tr>\n";
01695 $amount .= "<td>\n";
01696 $amount .= $this->lng->txt("paya_coupons_coupon") . " " . $coupon["pcc_code"] . ":";
01697 $amount .= "</td>\n";
01698 $amount .= "<td>\n";
01699 $amount .= number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get("currency_unit");
01700 $amount .= "</td>\n";
01701 $amount .= "</tr>\n";
01702 }
01703
01704
01705 if ($totalAmount[PAY_METHOD_BMF] < 0)
01706 {
01707 $totalAmount[PAY_METHOD_BMF] = 0;
01708 $vat = 0;
01709 }
01710 else
01711 {
01712 $vat = $sc_obj->getVat($totalAmount[PAY_METHOD_BMF]);
01713 }
01714 }
01715 }
01716
01717 $amount .= "<tr>\n";
01718 $amount .= "<td>\n";
01719 $amount .= "<b>" . $this->lng->txt("pay_bmf_total_amount") . ":";
01720 $amount .= "</td>\n";
01721 $amount .= "<td>\n";
01722 $amount .= number_format($totalAmount[PAY_METHOD_BMF], 2, ',', '.') . " " . $genSet->get("currency_unit");
01723 $amount .= "</td>\n";
01724 $amount .= "</tr>\n";
01725
01726 if ($vat > 0)
01727 {
01728 $amount .= "<tr>\n";
01729 $amount .= "<td>\n";
01730 $amount .= $genSet->get("vat_rate") . "% " . $this->lng->txt("pay_bmf_vat_included") . ":";
01731 $amount .= "</td>\n";
01732 $amount .= "<td>\n";
01733 $amount .= number_format($vat, 2, ',', '.') . " " . $genSet->get("currency_unit");
01734 $amount .= "</td>\n";
01735 $amount .= "</tr>\n";
01736 }
01737
01738 $amount .= "</table>\n";
01739
01740 $tpl->setVariable("LINKBAR", $amount);
01741 $tpl->parseCurrentBlock("tbl_footer_linkbar");
01742 $tpl->setCurrentBlock('tbl_footer');
01743 $tpl->setVariable('COLUMN_COUNT',3);
01744 $tpl->parseCurrentBlock();
01745 $tbl->render();
01746
01747 $this->tpl->setVariable("ITEMS_TABLE",$tbl->tpl->get());
01748
01749 return true;
01750 }
01751
01752 }
01753
01754 class KundenstammdatenPflegeWS
01755 {
01756
01757 var $_soapClient = NULL;
01758
01759 function KundenstammdatenPflegeWS ()
01760 {
01761 $bmfSetObj = ilBMFSettings::getInstance();
01762 $bmfConfig = $bmfSetObj->getAll();
01763
01764 $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
01765 }
01766
01767 function anlegenKunde ($customer)
01768 {
01769 $bmfSetObj = ilBMFSettings::getInstance();
01770 $bmfConfig = $bmfSetObj->getAll();
01771
01772 $tmp = array(
01773 'mandantNr' => $bmfConfig["mandantNr"],
01774 'kunde' => $customer
01775 );
01776
01777 $result = $this->_soapClient->call("anlegenKunde", $tmp, "KundenstammdatenPflegeWS");
01778 return $result;
01779 }
01780
01781 };
01782
01783 class KreditkartenzahlungWS
01784 {
01785 var $_soapClient = NULL;
01786
01787 function KreditkartenzahlungWS()
01788 {
01789 $bmfSetObj = ilBMFSettings::getInstance();
01790 $bmfConfig = $bmfSetObj->getAll();
01791
01792 $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
01793 }
01794
01795 function validierenKreditkarte($creditCard)
01796 {
01797 $bmfSetObj = ilBMFSettings::getInstance();
01798 $bmfConfig = $bmfSetObj->getAll();
01799
01800 $tmp = array(
01801 'mandantNr' => $bmfConfig["mandantNr"],
01802 'kreditkarte' => $creditCard,
01803 'waehrungskennzeichen' => $bmfConfig["waehrungskennzeichen"]
01804 );
01805
01806 $result = $this->_soapClient->call("validierenKreditkarte", $tmp, "KreditkartenzahlungWS");
01807 return $result;
01808 }
01809
01810 function zahlenUndAnlegenKunde($customer, $creditCard, $bookingList)
01811 {
01812 $bmfSetObj = ilBMFSettings::getInstance();
01813 $bmfConfig = $bmfSetObj->getAll();
01814
01815 $lieferadresse = new LieferAdresse();
01816
01817 $tmp = array(
01818 'mandantNr' => $bmfConfig["mandantNr"],
01819 'Kunde' => $customer,
01820 'Kreditkarte' => $creditCard,
01821 'buchungsListe' => $bookingList,
01822 'lieferadresse' => $lieferadresse
01823 );
01824
01825 $result = $this->_soapClient->call("zahlenUndAnlegenKunde", $tmp, "KreditkartenzahlungWS");
01826 return $result;
01827 }
01828 }
01829
01830 class LastschriftWS
01831 {
01832
01833 var $_soapClient = NULL;
01834
01835 function LastschriftWS ()
01836 {
01837 $bmfSetObj = ilBMFSettings::getInstance();
01838 $bmfConfig = $bmfSetObj->getAll();
01839
01840 $this->_soapClient = new ilBMFClient($bmfConfig["ePaymentServer"], false, false, array('curl' => array(CURLOPT_SSLCERT => $bmfConfig["clientCertificate"], CURLE_SSL_PEER_CERTIFICATE => $bmfConfig["caCertificate"], CURLOPT_TIMEOUT => (int)$bmfConfig["timeOut"])));
01841 }
01842
01843 function abbuchenOhneEinzugsermaechtigung($eShopCustomerNumber, $address, $bank, $bookingList)
01844 {
01845 $bmfSetObj = ilBMFSettings::getInstance();
01846 $bmfConfig = $bmfSetObj->getAll();
01847
01848 $tmp = array(
01849 'mandantNr' => $bmfConfig["mandantNr"],
01850 'eShopKundenNr' => $eShopCustomerNumber,
01851 'lieferAdresse' => $address,
01852 'bankverbindung' => $bank,
01853 'buchungsListe' => $bookingList
01854 );
01855
01856 $result = $this->_soapClient->call("abbuchenOhneEinzugsermaechtigung", $tmp, "LastschriftWS");
01857 return $result;
01858 }
01859
01860 };
01861
01862 class Kunde
01863 {
01864 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kunde');
01865
01866 function Kunde ($customerNumber = "", $values = "")
01867 {
01868
01869
01870
01871
01872
01873
01874 $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
01875 if ($customerNumber != "")
01876 {
01877 $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
01878 }
01879
01880
01881 if ($values == "")
01882 {
01883 $values = $_SESSION["bmf"]["personal_data"];
01884 }
01885
01886 if ($values["sprache"] != NULL)
01887 {
01888 $this->sprache = $values["sprache"];
01889 }
01890 if ($values["vorname"] != NULL)
01891 {
01892 $this->vorname = utf8_decode($values["vorname"]);
01893 }
01894 if ($values["nachname"] != NULL)
01895 {
01896 $this->nachname = utf8_decode($values["nachname"]);
01897 }
01898 if ($values["EMailAdresse"] != NULL)
01899 {
01900 $this->EMailAdresse = utf8_decode($values["EMailAdresse"]);
01901 }
01902
01903 $address = new Adresse();
01904
01905 $this->rechnungsAdresse = $address;
01906 }
01907
01908 function getEShopCustomerNumber()
01909 {
01910 return $this->EShopKundenNr;
01911 }
01912
01913 }
01914
01915 class Adresse
01916 {
01917 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Adresse');
01918
01919 function Adresse ($values = "")
01920 {
01921 if ($values == "")
01922 {
01923 $values = $_SESSION["bmf"]["personal_data"];
01924 }
01925
01926 if (is_array($values))
01927 {
01928 if ($values["strasse"] != NULL)
01929 {
01930 $this->strasse = utf8_decode($values["strasse"]);
01931 }
01932 if ($values["hausNr"] != NULL)
01933 {
01934 $this->hausNr = utf8_decode($values["hausNr"]);
01935 }
01936 if ($values["postfach"] != NULL)
01937 {
01938 $this->postfach = utf8_decode($values["postfach"]);
01939 }
01940 if ($values["land"] != NULL)
01941 {
01942 $this->land = utf8_decode($values["land"]);
01943 }
01944 if ($values["PLZ"] != NULL)
01945 {
01946 $this->PLZ = utf8_decode($values["PLZ"]);
01947 }
01948 if ($values["ort"] != NULL)
01949 {
01950 $this->ort = utf8_decode($values["ort"]);
01951 }
01952 }
01953 }
01954
01955 }
01956
01957 class Kreditkarte
01958 {
01959 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Kreditkarte');
01960
01961 function Kreditkarte ($values = "")
01962 {
01963 if ($values == "")
01964 {
01965 $values = $_SESSION["bmf"]["credit_card"];
01966 }
01967
01968 if (is_array($values))
01969 {
01970 if ($values["karteninhaber"] != NULL)
01971 {
01972 $this->karteninhaber = utf8_decode($values["karteninhaber"]);
01973 }
01974 if ($values["kartenpruefnummer"] != NULL)
01975 {
01976 $this->kartenpruefnummer = utf8_decode($values["kartenpruefnummer"]);
01977 }
01978 if (is_array ($values["kreditkartenNr"]) &&
01979 count($values["kreditkartenNr"]) == 4)
01980 {
01981 for ($i = 1; $i <= count($values["kreditkartenNr"]); $i++)
01982 {
01983 $this->kreditkartenNr .= utf8_decode($values["kreditkartenNr"]["block_".$i]);# . "-";
01984 }
01985 # $this->kreditkartenNr = substr($this->kreditkartenNr, 0, strlen($this->kreditkartenNr)-1);
01986 }
01987 if (is_array($values["gueltigkeit"]) &&
01988 $values["gueltigkeit"]["monat"] != "" &&
01989 $values["gueltigkeit"]["jahr"] != "")
01990 {
01991 $this->gueltigkeit = utf8_decode($values["gueltigkeit"]["monat"]);
01992 $this->gueltigkeit .= utf8_decode($values["gueltigkeit"]["jahr"]);
01993 }
01994 }
01995 }
01996
01997 }
01998
01999 class Lastschrift
02000 {
02001 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Lastschrift');
02002
02003 function Lastschrift ($customerNumber = "", $values = "")
02004 {
02005 $this->EShopKundenNr = time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
02006 if ($customerNumber != "")
02007 {
02008 $this->EShopKundenNr = $customerNumber . "_" . time() . "_" . substr(md5(uniqid(rand(), true)), 0, 4);
02009 }
02010 }
02011
02012 }
02013
02014 class Bankverbindung
02015 {
02016 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'Bankverbindung');
02017
02018 function Bankverbindung ($values = "")
02019 {
02020 if ($values == "")
02021 {
02022 $values = $_SESSION["bmf"]["debit_entry"];
02023 }
02024
02025 if (is_array($values))
02026 {
02027 if ($values["kontoinhaber"] != NULL)
02028 {
02029 $this->kontoinhaber = utf8_decode($values["kontoinhaber"]);
02030 }
02031 if ($values["kontoNr"] != NULL)
02032 {
02033 $this->kontoNr = utf8_decode($values["kontoNr"]);
02034 }
02035 if ($values["BLZ"] != NULL)
02036 {
02037 $this->BLZ = utf8_decode($values["BLZ"]);
02038 }
02039 }
02040 }
02041
02042 }
02043
02044 class Buchung
02045 {
02046 var $OBJTypeNS = array ('namespace' => 'http://schemas.xmlsoap.org/soap/encoding/', 'nsPrefix' => 'ns3', 'type' => 'Buchung', 'pnamespace' => 'http://www.bff.bund.de/ePayment', 'pnsPrefix' => 'ns2', 'item' => 'ns2:Buchung');
02047
02048 function Buchung($values = "")
02049 {
02050 $bmfSetObj = ilBMFSettings::getInstance();
02051 $bmfConfig = $bmfSetObj->getAll();
02052
02053 if ($bmfConfig["haushaltsstelle"] != NULL)
02054 {
02055 $this->haushaltsstelle = $bmfConfig["haushaltsstelle"];
02056 }
02057 if ($bmfConfig["objektNr"] != NULL)
02058 {
02059 $this->objektnummer = $bmfConfig["objektNr"];
02060 }
02061
02062 if (is_array($values))
02063 {
02064 if ($values["buchungstext"] != NULL)
02065 {
02066 $buchungstext = utf8_decode($values["buchungstext"]);
02067 if(strlen($buchungstext) > 16)
02068 {
02069 $buchungstext = substr($buchungstext,0,15).'...';
02070 }
02071
02072 $this->buchungstext = $buchungstext;
02073 }
02074 if ($values["betrag"] != "")
02075 {
02076 $this->betrag = $values["betrag"];
02077 }
02078 }
02079 }
02080
02081
02082 function setVoucherNumber($voucherNumber)
02083 {
02084 if ($voucherNumber != NULL)
02085 {
02086 $this->belegNr = $voucherNumber;
02087 }
02088 }
02089
02090 function getVoucherNumber()
02091 {
02092 return $this->belegNr;
02093 }
02094 }
02095
02096 class BuchungsListe
02097 {
02098 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment', 'nsPrefix' => 'ns2', 'type' => 'BuchungsListe');
02099
02100 function BuchungsListe($userId, $values = "")
02101 {
02102 global $ilias;
02103
02104 $bmfSetObj = ilBMFSettings::getInstance();
02105 $bmfConfig = $bmfSetObj->getAll();
02106
02107 if ($bmfConfig["bewirtschafterNr"] != NULL)
02108 {
02109 $this->bewirtschafterNr = $bmfConfig["bewirtschafterNr"];
02110 }
02111 if ($bmfConfig["waehrungskennzeichen"] != NULL)
02112 {
02113 $this->waehrungskennzeichen = $bmfConfig["waehrungskennzeichen"];
02114 }
02115 $this->faelligkeitsdatum = date("Y-m-d") . "T" . date("H:i:s") . "Z";
02116 if ($bmfConfig["kennzeichenMahnverfahren"] != NULL)
02117 {
02118 $this->kennzeichenMahnverfahren = $bmfConfig["kennzeichenMahnverfahren"];
02119 }
02120
02121 $inst_id_time = $ilias->getSetting('inst_id').'_'.$userId.'_'.substr((string) time(),-3);
02122 $this->EShopTransaktionsNr = $inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4);
02123
02124 if (is_array($values))
02125 {
02126 if ($values["betrag"] != NULL)
02127 {
02128 $this->betrag = $values["betrag"];
02129 }
02130 if ($values["buchungen"] != NULL)
02131 {
02132 $this->buchungen = $values["buchungen"];
02133 }
02134 }
02135 }
02136 function getTransaction()
02137 {
02138 return $this->EShopTransaktionsNr;
02139 }
02140
02141
02142 function setKassenzeichen($kassenzeichen)
02143 {
02144 if ($kassenzeichen != NULL)
02145 {
02146 $this->kassenzeichen = $kassenzeichen;
02147 }
02148 }
02149
02150 function getKassenzeichen()
02151 {
02152 return $this->kassenzeichen;
02153 }
02154
02155 }
02156
02157 class LieferAdresse
02158 {
02159 var $OBJTypeNS = array ('namespace' => 'http://www.bff.bund.de/ePayment' , 'type' => 'LieferAdresse');
02160
02161 function LieferAdresse ($values = "")
02162 {
02163 if ($values == "")
02164 {
02165 $values = $_SESSION["bmf"]["personal_data"];
02166 }
02167
02168 if (is_array($values))
02169 {
02170 if ($values["vorname"] != NULL)
02171 {
02172 $this->vorname = utf8_decode($values["vorname"]);
02173 }
02174 if ($values["nachname"] != NULL)
02175 {
02176 $this->nachname = utf8_decode($values["nachname"]);
02177 }
02178 if ($values["strasse"] != NULL)
02179 {
02180 $this->strasse = utf8_decode($values["strasse"]);
02181 }
02182 if ($values["hausNr"] != NULL)
02183 {
02184 $this->hausNr = utf8_decode($values["hausNr"]);
02185 }
02186 if ($values["postfach"] != NULL)
02187 {
02188 $this->postfach = utf8_decode($values["postfach"]);
02189 }
02190 if ($values["land"] != NULL)
02191 {
02192 $this->land = utf8_decode($values["land"]);
02193 }
02194 if ($values["PLZ"] != NULL)
02195 {
02196 $this->PLZ = utf8_decode($values["PLZ"]);
02197 }
02198 if ($values["ort"] != NULL)
02199 {
02200 $this->ort = utf8_decode($values["ort"]);
02201 }
02202 }
02203 }
02204 }
02205
02206 ?>