private function addBookings($pay_method, $coupon_session) { global $ilUser, $ilObjDataCache; include_once './Services/Payment/classes/class.ilPaymentBookings.php'; include_once './Services/Payment/classes/class.ilPaymentObject.php'; include_once './Services/Payment/classes/class.ilPaymentPrices.php'; $booking_obj = new ilPaymentBookings(); $sc_obj = new ilPaymentShoppingCart($this->user_obj); $items = $sc_obj->getEntries($pay_method); $sc_obj->clearCouponItemsSession(); foreach ($items as $entry) { $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']); $price = ilPaymentPrices::_getPrice($entry['price_id']); if (!empty($_SESSION['coupons'][$coupon_session])) { $entry['math_price'] = $entry['price']; // (float) ilPaymentPrices::_getPriceFromArray($price); foreach ($_SESSION['coupons'][$coupon_session] as $key => $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) { $_SESSION['coupons'][$coupon_session][$key]['total_objects_coupon_price'] += $entry['price']; //(float) ilPaymentPrices::_getPriceFromArray($price); $_SESSION['coupons'][$coupon_session][$key]['items'][] = $entry; } } } unset($pobject); } $coupon_discount_items = $sc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session]); foreach ($items as $entry) { $pobject = new ilPaymentObject($this->user_obj, $entry['pobject_id']); $price = ilPaymentPrices::_getPrice($entry['price_id']); if (array_key_exists($entry['pobject_id'], $coupon_discount_items)) { $bonus = $coupon_discount_items[$entry['pobject_id']]['math_price'] - $coupon_discount_items[$entry['pobject_id']]['discount_price']; } $booking_obj->setPobjectId($entry['pobject_id']); $booking_obj->setCustomerId($this->user_obj->getId()); $booking_obj->setVendorId($pobject->getVendorId()); $booking_obj->setPayMethod($pobject->getPayMethod()); $booking_obj->setOrderDate(time()); $booking_obj->setDuration($price['duration']); $booking_obj->setPrice(ilPaymentPrices::_getPriceString($entry['price_id'])); $booking_obj->setDiscount($bonus > 0 ? -1 * $bonus : 0); $booking_obj->setPayed(1); $booking_obj->setAccess(1); switch ($price['price_type']) { case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $booking_obj->setDuration(0); break; case ilPaymentPrices::TYPE_DURATION_MONTH: $booking_obj->setDuration($price['duration']); break; case ilPaymentPrices::TYPE_DURATION_DATE: $booking_obj->setAccessStartdate($price['duration_from']); $booking_obj->setAccessEnddate($price['duration_until']); break; } $booking_obj->setAccessExtension($price['extension']); $obj_id = $ilObjDataCache->lookupObjId($pobject->getRefId()); $obj_title = $ilObjDataCache->lookupTitle($obj_id); $oVAT = new ilShopVats((int) $pobject->getVatId()); $obj_vat_rate = $oVAT->getRate(); if ($bonus > 0) { $tmp_price = $booking_obj->getPrice() - $bonus; $obj_vat_unit = $pobject->getVat($tmp_price); } else { $obj_vat_unit = $pobject->getVat($booking_obj->getPrice()); } $booking_obj->setObjectTitle($obj_title); $booking_obj->setVatRate($obj_vat_rate); $booking_obj->setVatUnit($obj_vat_unit); if (ilPaymethods::_EnabledSaveUserAddress($booking_obj->getPayMethod())) { $booking_obj->setStreet($this->user_obj->getStreet(), $this->user_obj->getHouseNumber); $booking_obj->setZipcode($this->user_obj->getZipcode()); $booking_obj->setCity($this->user_obj->getCity()); $booking_obj->setCountry($this->user_obj->getCountry()); } $current_booking_id = $booking_obj->add(); if ($current_booking_id) { $sc_obj->delete($entry['psc_id']); if (!empty($_SESSION['coupons'][$coupon_session])) { foreach ($_SESSION['coupons'][$coupon_session] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) { $this->coupon_obj->addCouponForBookingId($current_booking_id); } } } } unset($current_booking_id); unset($pobject); } if (!empty($_SESSION['coupons'][$coupon_session])) { foreach ($_SESSION['coupons'][$coupon_session] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); $this->coupon_obj->addTracking(); } } }
public function deleteVendorsObject() { //include_once './Services/Payment/classes/class.ilPaymentBookings.php'; if (!count($_POST['vendor'])) { ilUtil::sendFailure($this->lng->txt('pays_no_vendor_selected')); $this->vendorsObject(); return true; } // CHECK BOOKINGS foreach ($_POST['vendor'] as $vendor) { if (ilPaymentBookings::_getCountBookingsByVendor($vendor)) { ilUtil::sendInfo($this->lng->txt('pays_active_bookings')); $this->vendorsObject(); return true; } } $_SESSION['pays_vendor'] = $_POST['vendor']; ilUtil::sendQuestion($this->lng->txt('pays_sure_delete_selected_vendors')); $this->vendorsObject(true); return true; }
public function purchase($tid) { global $lng; $this->getDebtor(); $this->deb->createInvoice(); $products = array(); foreach ($this->sc as $i) { $pod = ilPaymentObject::_getObjectData($i['pobject_id']); $bo = new ilPaymentBookings($this->ilUser->getId()); $ilias_tid = $this->ilUser->getId() . "_" . $tid; // psc_id, pobject_id, obj_id, typ, betrag_string $bo->setTransaction($ilias_tid); $bo->setPobjectId(isset($i['pobject_id']) ? $i['pobject_id'] : 0); $bo->setCustomerId($this->ilUser->getId()); $bo->setVendorId($pod['vendor_id']); $bo->setPayMethod($this->paytype); $bo->setOrderDate(time()); // $bo->setDuration($i['dauer']); // duration // $bo->setPrice( $i['betrag'] ); // amount //$bo->setPrice( ilPaymentPrices::_getPriceString( $i['price_id'] )); $bo->setDuration($i['duration']); $bo->setPrice($i['price_string']); $bo->setDiscount(0); $bo->setVoucher(''); $bo->setVatRate($i['vat_rate']); $bo->setVatUnit($i['vat_unit']); $bo->setTransactionExtern($tid); // $product_name = $i['buchungstext']; //$duration = $i['dauer']; //$amount = $i['betrag']; $product_name = $i['object_title']; $duration = $i['duration']; $amount = $i['price']; // -> ? $i['price_string'] include_once './Services/Payment/classes/class.ilPayMethods.php'; $save_adr = (int) ilPaymethods::_EnabledSaveUserAddress($this->paytype) ? 1 : 0; //if($save_adr == 1) //{ $bo->setStreet($this->ilUser->getStreet(), ''); $bo->setPoBox(''); //$this->ilUser->); $bo->setZipcode($this->ilUser->getZipcode()); $bo->setCity($this->ilUser->getCity()); $bo->setCountry($this->ilUser->getCountry()); //} $bo->setPayed(1); $bo->setAccess(1); $bo->setAccessExtension($this->sc['extension']); $boid = $bo->add(); //$bo->update(); if ($i['typ'] == 'crs') { include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $this->deb->createInvoiceLine(0, $product_name . " (" . $duration . ")", 1, $amount); $products[] = $product_name; $obj_id = ilObject::_lookupObjId($pod["ref_id"]); $cp = ilCourseParticipants::_getInstanceByObjId($obj_id); $cp->add($this->ilUser->getId(), IL_CRS_MEMBER); $cp->sendNotification($cp->NOTIFY_ACCEPT_SUBSCRIBER, $this->ilUser->getId()); } } $inv = $this->deb->bookInvoice(); $invoice_number = $this->deb->getInvoiceNumber(); $attach = $this->deb->getInvoicePDF($inv); $this->deb->saveInvoice($attach, false); $lng->loadLanguageModule('payment'); $this->deb->sendInvoice($lng->txt('pay_order_paid_subject'), $this->ilUser->getFullName() . ",\n" . str_replace('%products%', implode(", ", $products), $lng->txt('pay_order_paid_body')), $this->ilUser->getEmail(), $attach, $lng->txt('pays_invoice') . "-" . $invoice_number); $this->cart->emptyShoppingCart(); }
public function showDetails() { global $ilMainMenu, $ilTabs, $ilToolbar, $ilUser; $this->__initPaymentObject(); $this->__initPricesObject(); $this->__initShoppingCartObject(); $ilToolbar->addButton($this->lng->txt('payment_back_to_shop'), 'ilias.php?baseClass=ilShopController'); $this->tpl->getStandardTemplate(); $ilTabs->setTabActive('buy'); $ilMainMenu->setActive('shop'); if ($this->pobject->getStatus() == $this->pobject->STATUS_EXPIRES) { ilUtil::sendInfo($this->lng->txt('pay_expires_info')); return false; } $extension_prices = array(); if ($ilUser->getId() != ANONYMOUS_USER_ID) { include_once './Services/Payment/classes/class.ilPaymentBookings.php'; $has_extension_price = ilPaymentBookings::_hasAccesstoExtensionPrice($ilUser->getId(), $this->pobject->getPobjectId()); if ($has_extension_price) { $extension_prices = $this->price_obj->getExtensionPrices(); } } $org_prices = $this->price_obj->getPrices(); $tmp_prices = array_merge($org_prices, $extension_prices); $prices = array(); foreach ($tmp_prices as $price) { // expired prices must be filtered out if ($price['price_type'] == ilPaymentPrices::TYPE_DURATION_DATE && $price['duration_until'] < date('Y-m-d')) { //do nothing } else { $prices[] = $price; } } include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $buyedObject = ""; if ($this->sc_obj->isInShoppingCart($this->pobject->getPobjectId())) { $buyedObject = $this->sc_obj->getEntry($this->pobject->getPobjectId()); if (is_array($prices) && count($prices) > 1) { ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc_choose_another')); } else { ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc')); } } $this->ctrl->setParameter($this, "ref_id", $this->pobject->getRefId()); $subtype = ''; if ($this->object) { if ($this->object->getType() == 'exc') { $subtype = ' (' . $this->lng->txt($this->pobject->getSubtype()) . ')'; } $form->setTitle($this->object->getTitle() . ' ' . $subtype); $form->setTitleIcon(ilObject::_getIcon($this->object->getId())); } else { ilUtil::sendFailure($this->lng->txt('object_not_found')); } // payment infos $info = new ilNonEditableValueGUI($this->lng->txt('info')); $info->setValue($this->lng->txt('pay_info')); $form->addItem($info); if (is_array($buyedObject)) { if (is_array($prices) && count($prices) > 1) { $button_txt = $this->lng->txt('pay_change_price'); } else { $button_txt = $this->lng->txt('pay_add_to_shopping_cart'); } } else { $button_txt = $this->lng->txt('pay_add_to_shopping_cart'); } $rg_prices = new ilRadioGroupInputGUI($this->lng->txt('prices'), 'price_id'); if (is_array($prices)) { foreach ($prices as $price) { if (is_array($buyedObject) && $buyedObject["price_id"] == $price['price_id']) { $rg_prices->setValue($price['price_id']); } else { if (count($prices) == 1) { $rg_prices->setValue($price['price_id']); } } switch ($price['price_type']) { case ilPaymentPrices::TYPE_DURATION_MONTH: $txt_price = $price['duration'] . ' ' . $this->lng->txt('paya_months') . ': '; break; case ilPaymentPrices::TYPE_DURATION_DATE: $txt_price = ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE)) . ': '; break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $txt_price = $this->lng->txt('unlimited_duration') . ': '; break; } $tmp_price = $price['price']; $extension_txt = ''; if ($price['extension'] == 1) { $extension_txt = '(' . $this->lng->txt('extension_price') . ')'; } $price_row = new ilRadioOption($txt_price . ' ' . ilPaymentPrices::_formatPriceToString((double) $tmp_price) . ' ' . $extension_txt, $price['price_id']); $price_row->setInfo($price['description']); $rg_prices->addOption($price_row); } $form->addItem($rg_prices); } $form->addCommandButton('addToShoppingCart', $button_txt); return $this->tpl->setContent($form->getHTML()); }
function executeCommand() { global $ilNavigationHistory, $ilCtrl, $ilUser, $ilTabs, $ilAccess, $ilErr; $next_class = $this->ctrl->getNextClass($this); $cmd = $this->ctrl->getCmd(); if ($this->id_type == self::WORKSPACE_NODE_ID) { include_once "Services/Form/classes/class.ilFileInputGUI.php"; ilFileInputGUI::setPersonalWorkspaceQuotaCheck(true); } if (!$this->getCreationMode()) { // do not move this payment block!! if (IS_PAYMENT_ENABLED) { include_once './Services/Payment/classes/class.ilPaymentObject.php'; if (ANONYMOUS_USER_ID == $ilUser->getId() && isset($_GET['transaction'])) { $transaction = $_GET['transaction']; include_once './Services/Payment/classes/class.ilPaymentBookings.php'; $valid_transaction = ilPaymentBookings::_readBookingByTransaction($transaction); } if (ilPaymentObject::_requiresPurchaseToAccess($this->node_id, $type = isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL)) { $this->setLocator(); $this->tpl->getStandardTemplate(); include_once './Services/Payment/classes/class.ilShopPurchaseGUI.php'; $pp = new ilShopPurchaseGUI((int) $this->node_id); $ret = $this->ctrl->forwardCommand($pp); return true; } } else { if ($this->id_type == self::REPOSITORY_NODE_ID && $this->checkPermissionBool("read")) { $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->node_id); $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen"); $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]); // add entry to navigation history $ilNavigationHistory->addItem($this->node_id, $link, "file"); } } } $this->prepareOutput(); switch ($next_class) { case "ilinfoscreengui": $this->infoScreenForward(); // forwards command break; case 'ilmdeditorgui': if (!$this->checkPermissionBool("write")) { $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING); } $ilTabs->activateTab("id_meta"); include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php'; $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType()); $md_gui->addObserver($this->object, 'MDUpdateListener', 'General'); // todo: make this work $md_gui->addObserver($this->object, 'MDUpdateListener', 'Technical'); $this->ctrl->forwardCommand($md_gui); break; // repository permissions // repository permissions case 'ilpermissiongui': $ilTabs->activateTab("id_permissions"); include_once "Services/AccessControl/classes/class.ilPermissionGUI.php"; $perm_gui =& new ilPermissionGUI($this); $ret =& $this->ctrl->forwardCommand($perm_gui); break; case "ilexportgui": $ilTabs->activateTab("export"); include_once "./Services/Export/classes/class.ilExportGUI.php"; $exp_gui = new ilExportGUI($this); $exp_gui->addFormat("xml"); $ret = $this->ctrl->forwardCommand($exp_gui); break; case 'ilobjectcopygui': include_once './Services/Object/classes/class.ilObjectCopyGUI.php'; $cp = new ilObjectCopyGUI($this); $cp->setType('file'); $this->ctrl->forwardCommand($cp); break; // personal workspace permissions // personal workspace permissions case "ilworkspaceaccessgui": $ilTabs->activateTab("id_permissions"); include_once './Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php'; $wspacc = new ilWorkspaceAccessGUI($this->node_id, $this->getAccessHandler()); $this->ctrl->forwardCommand($wspacc); break; case "ilcommonactiondispatchergui": include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php"; $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); $this->ctrl->forwardCommand($gui); break; default: // in personal workspace use object2gui if ($this->id_type == self::WORKSPACE_NODE_ID) { $this->addHeaderAction(); // coming from goto we need default command if (empty($cmd)) { $ilCtrl->setCmd("infoScreen"); } $ilTabs->clearTargets(); return parent::executeCommand(); } if (empty($cmd)) { $cmd = "infoScreen"; } $this->{$cmd}(); break; } $this->addHeaderAction(); }
public static function _hasAccess($a_ref_id, $a_transaction = 0, $a_subtype = '') { include_once './Services/Payment/classes/class.ilPaymentBookings.php'; include_once './Services/Payment/classes/class.ilPaymentTrustees.php'; include_once './Services/Payment/classes/class.ilPaymentVendors.php'; global $rbacsystem, $ilDB, $ilUser; // check write access if ($rbacsystem->checkAccess('write', $a_ref_id)) { return true; } // check if user is vendor/trustee $vendors_of_trustee = ilPaymentTrustees::_getVendorIdsByTrustee($ilUser->getId()); if (!IS_PAYMENT_ENABLED) { return true; } if ($a_subtype) { $result = $ilDB->queryf(' SELECT * FROM payment_objects WHERE ref_id = %s AND (status = %s or status = %s) AND subtype = %s', array('integer', 'integer', 'integer', 'text'), array($a_ref_id, '1', '2', $a_subtype)); } else { $result = $ilDB->queryf(' SELECT * FROM payment_objects WHERE ref_id = %s AND (status = %s OR status = %s) OR (vendor_id = %s)', array('integer', 'integer', 'integer', 'integer'), array($a_ref_id, '1', '2', $ilUser->getId())); } while ($row = $ilDB->fetchObject($result)) { if ($row->vendor_id == $ilUser->getId() || in_array($row->vendor_id, $vendors_of_trustee)) { return true; } else { if (!ilPaymentBookings::_hasAccess($row->pobject_id, '', $a_transaction)) { return false; } else { return true; } } } return false; }
public function showItems() { include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php"; $this->initBookingsObject(); $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); if (!count($bookings = ilPaymentBookings::getBookingsOfCustomer($this->user_obj->getId()))) { ilUtil::sendInfo($this->lng->txt('pay_not_buyed_any_object')); return true; } $counter = 0; foreach ($bookings as $booking) { $tmp_obj = ilObjectFactory::getInstanceByRefId($booking['ref_id'], false); $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false); $tmp_purchaser = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false); $transaction = $booking['transaction']; include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']); $transaction .= " (" . $str_paymethod . ")"; $f_result[$counter]['transaction'] = $transaction; if ($tmp_obj) { $obj_link = ilRepositoryExplorer::buildLinkTarget($booking['ref_id'], $tmp_obj->getType()); $obj_target = ilRepositoryExplorer::buildFrameTarget($tmp_obj->getType(), $booking['ref_id'], $tmp_obj->getId()); $f_result[$counter]['object_title'] = "<a href=\"" . $obj_link . "\" target=\"" . $obj_target . "\">" . $tmp_obj->getTitle() . "</a>"; } else { $obj_link = ''; $obj_target = ''; $f_result[$counter]['object_title'] = $booking['object_title'] . '<br> (' . $this->lng->txt('object_deleted') . ')'; } $f_result[$counter]['vendor'] = '[' . $tmp_vendor->getLogin() . ']'; $f_result[$counter]['customer'] = '[' . $tmp_purchaser->getLogin() . ']'; $f_result[$counter]['order_date'] = ilDatePresentation::formatDate(new ilDateTime($booking['order_date'], IL_CAL_UNIX)); //todo check for accessduration!! if ($booking['duration'] == 0 && $booking['access_enddate'] == NULL) { $f_result[$counter]['duration'] = $this->lng->txt("unlimited_duration"); } else { if ($booking['duration'] > 0) { $f_result[$counter]['duration'] = $booking['duration'] . ' ' . $this->lng->txt('paya_months'); } $f_result[$counter]['duration'] .= ilDatePresentation::formatDate(new ilDateTime($booking['access_startdate'], IL_CAL_DATETIME)) . ' - ' . ilDatePresentation::formatDate(new ilDateTime($booking['access_enddate'], IL_CAL_DATETIME)); } $f_result[$counter]['price'] = $booking['price'] . ' ' . $booking['currency_unit']; $f_result[$counter]['discount'] = $booking['discount'] != '' ? round($booking['discount'], 2) . ' ' . $booking['currency_unit'] : ' '; $payed_access = $booking['payed'] ? $this->lng->txt('yes') : $this->lng->txt('no'); $payed_access .= '/'; $payed_access .= $booking['access_granted'] ? $this->lng->txt('yes') : $this->lng->txt('no'); $f_result[$counter]['payed_access'] = $payed_access; unset($tmp_obj); unset($tmp_vendor); unset($tmp_purchaser); ++$counter; } return $this->showStatisticTable($f_result); }
public function __addBookings($external_data = null) { global $ilUser, $ilObjDataCache; $sc = $this->psc_obj->getShoppingCart($this->pm_id); $total = 0; $total_vat = 0; $total_discount = 0; # $this->psc_obj->clearCouponItemsSession(); if (is_array($sc) && count($sc) > 0) { include_once './Services/Payment/classes/class.ilPaymentBookings.php'; //@todo check $this->usr_obj $book_obj = new ilPaymentBookings($this->usr_obj); for ($i = 0; $i < count($sc); $i++) { if (!empty($_SESSION['coupons'][$this->session_var])) { $sc[$i]['math_price'] = (double) $sc[$i]['price']; $tmp_pobject = new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']); foreach ($_SESSION['coupons'][$this->session_var] as $key => $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $_SESSION['coupons'][$this->session_var][$key]['total_objects_coupon_price'] += (double) $sc[$i]['price']; $_SESSION['coupons'][$this->session_var][$key]['items'][] = $sc[$i]; } } unset($tmp_pobject); } } $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION['coupons'][$this->session_var]); $transaction = ilInvoiceNumberPlaceholdersPropertyGUI::_generateInvoiceNumber($ilUser->getId()); for ($i = 0; $i < count($sc); $i++) { $pobjectData = ilPaymentObject::_getObjectData($sc[$i]['pobject_id']); $pobject = new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']); $price = $sc[$i]['price']; $bonus = 0.0; if (array_key_exists($sc[$i]['pobject_id'], $coupon_discount_items)) { $bonus = $coupon_discount_items[$sc[$i]['pobject_id']]['math_price'] - $coupon_discount_items[$sc[$i]['pobject_id']]['discount_price']; if ($bonus > 0) { $discount = round($bonus, 2) * -1; } else { $discount = round($bonus, 2); } } $book_obj->setTransaction($transaction); $book_obj->setPobjectId($sc[$i]['pobject_id']); $book_obj->setCustomerId($this->user_obj->getId()); $book_obj->setVendorId($pobjectData['vendor_id']); $book_obj->setPayMethod($pobjectData['pay_method']); $book_obj->setOrderDate(time()); $book_obj->setPrice($sc[$i]['price_string']); //$book_obj->setDiscount($bonus > 0 ? ilPaymentPrices::_getPriceStringFromAmount($bonus * (-1)) : ''); $book_obj->setDiscount($discount); $book_obj->setPayed($this->getPayed()); $book_obj->setAccess($this->getAccess()); $book_obj->setVoucher(''); // bmf $book_obj->setTransactionExtern(''); // bmf , paypal $book_obj->setVatRate($sc[$i]['vat_rate']); $book_obj->setVatUnit($sc[$i]['vat_unit']); $book_obj->setObjectTitle(strip_tags($sc[$i]['object_title'])); $book_obj->setAccessExtension($sc[$i]['extension']); switch ($sc[$i]["price_type"]) { case ilPaymentPrices::TYPE_DURATION_MONTH: $book_obj->setDuration($sc[$i]['duration']); break; case ilPaymentPrices::TYPE_DURATION_DATE: $book_obj->setDuration(0); $book_obj->setAccessStartdate($sc[$i]['duration_from']); $book_obj->setAccessEnddate($sc[$i]['duration_until']); break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $book_obj->setDuration(0); $book_obj->setAccessEnddate(NULL); $book_obj->setUnlimitedDuration($sc[$i]['unlimited_duration']); break; } $book_obj->setPriceType($sc[$i]["price_type"]); // if ($external_data) { $book_obj->setVoucher($external_data['voucher']); // bmf $book_obj->setTransactionExtern($external_data['transaction_extern']); // bmf, paypal $book_obj->setStreet($external_data['street'], ''); $book_obj->setZipcode($external_data['zipcode']); $book_obj->setCity($external_data['city']); $book_obj->setCountry($external_data['country']); } else { if (isset($_SESSION[$this->session_var]['personal_data'])) { $book_obj->setStreet($_SESSION[$this->session_var]['personal_data']['street'], $_SESSION[$this->session_var]['personal_data']['house_number']); $book_obj->setPoBox($_SESSION[$this->session_var]['personal_data']['po_box']); $book_obj->setZipcode($_SESSION[$this->session_var]['personal_data']['zipcode']); $book_obj->setCity($_SESSION[$this->session_var]['personal_data']['city']); $book_obj->setCountry($_SESSION[$this->session_var]['personal_data']['country']); } else { $book_obj->setStreet($this->user_obj->getStreet(), ''); $book_obj->setPoBox($this->user_obj->getPoBox()); $book_obj->setZipcode($this->user_obj->getZipCode()); $book_obj->setCity($this->user_obj->getCity()); $book_obj->setCountry($this->user_obj->getCountry()); } } $booking_id = $book_obj->add(); // add purchased item to desktop ilShopUtils::_addPurchasedObjToDesktop($pobject); // autosubscribe user if purchased object is a course $obj_type = ilObject::_lookupType((int) $pobject->getRefId(), true); if ($obj_type == 'crs') { ilShopUtils::_assignPurchasedCourseMemberRole($pobject); } if (!empty($_SESSION['coupons'][$this->session_var]) && $booking_id) { foreach ($_SESSION['coupons'][$this->session_var] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) { $this->coupon_obj->addCouponForBookingId($booking_id); } } } $obj_id = $ilObjDataCache->lookupObjId($pobjectData['ref_id']); $obj_type = $ilObjDataCache->lookupType($obj_id); $obj_title = $ilObjDataCache->lookupTitle($obj_id); $bookings['list'][] = array('pobject_id' => $sc[$i]['pobject_id'], 'type' => $obj_type, 'title' => '[' . $obj_id . ']: ' . $obj_title, 'duration' => $sc[$i]['duration'], 'vat_rate' => $sc[$i]['vat_rate'], 'vat_unit' => $sc[$i]['vat_unit'], 'price_string' => $sc[$i]['price_string'], 'price' => $sc[$i]['price'], "price_type" => $sc[$i]["price_type"], "duration_from" => $sc[$i]["duration_from"], "duration_until" => $sc[$i]["duration_until"], "b_pay_method" => $pobjectData["pay_method"], 'discount' => $discount, 'access_startdate' => $book_obj->getAccessStartdate(), 'access_enddate' => $book_obj->getAccessEnddate()); $total += $sc[$i]['price']; $total_vat += $sc[$i]['vat_unit']; $total_discount += $discount; if ($sc[$i]['psc_id']) { $this->psc_obj->delete($sc[$i]['psc_id']); } } if (!empty($_SESSION['coupons'][$this->session_var])) { foreach ($_SESSION['coupons'][$this->session_var] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); $this->coupon_obj->addTracking(); } } } $bookings['total'] = $total; $bookings['total_vat'] = $total_vat; $bookings['total_discount'] = $total_discount; $bookings['transaction'] = $transaction; $bookings['street'] = $book_obj->getStreet(); $bookings['zipcode'] = $book_obj->getZipCode(); $bookings['city'] = $book_obj->getCity(); if (2 == strlen($book_obj->getCountry())) { $bookings['country'] = $this->__getCountryName(strtoupper($book_obj->getCountry())); } else { $bookings['country'] = $book_obj->getCountry(); } $bookings['transaction_extern'] = $book_obj->getTransactionExtern(); $this->user_obj->_toggleActiveStatusOfUsers(array($this->user_obj->getId()), 1); $_SESSION['forceRedirectToShoppingcart'] = 1; $this->__sendBill($bookings); }
public function showDetails() { global $ilMainMenu, $ilTabs, $ilToolbar, $ilUser; $this->__initPaymentObject(); $this->__initPricesObject(); $this->__initShoppingCartObject(); $ilToolbar->addButton($this->lng->txt('payment_back_to_shop'), 'ilias.php?baseClass=ilShopController'); $this->tpl->getStandardTemplate(); $ilTabs->setTabActive('buy'); $ilMainMenu->setActive('shop'); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.pay_purchase_details.html', 'Services/Payment'); if ($this->pobject->getStatus() == $this->pobject->STATUS_EXPIRES) { ilUtil::sendInfo($this->lng->txt('pay_expires_info')); return false; } $extension_prices = array(); if ($ilUser->getId() != ANONYMOUS_USER_ID) { include_once './Services/Payment/classes/class.ilPaymentBookings.php'; $has_extension_price = ilPaymentBookings::_hasAccesstoExtensionPrice($ilUser->getId(), $this->pobject->getPobjectId()); if ($has_extension_price) { $extension_prices = $this->price_obj->getExtensionPrices(); } } $org_prices = $this->price_obj->getPrices(); $tmp_prices = array_merge($org_prices, $extension_prices); $prices = array(); foreach ($tmp_prices as $price) { // expired prices must be filtered out if ($price['price_type'] == ilPaymentPrices::TYPE_DURATION_DATE && $price['duration_until'] < date('Y-m-d')) { //do nothing } else { $prices[] = $price; } } $buyedObject = ""; if ($this->sc_obj->isInShoppingCart($this->pobject->getPobjectId())) { $buyedObject = $this->sc_obj->getEntry($this->pobject->getPobjectId()); if (is_array($prices) && count($prices) > 1) { ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc_choose_another')); } else { ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc')); } $this->tpl->setCurrentBlock("shopping_cart_1"); $this->tpl->setVariable("LINK_GOTO_SHOPPING_CART", 'ilias.php?baseClass=ilShopController&cmd=redirect&redirect_class=ilShopShoppingCartGUI'); $this->tpl->setVariable("TXT_GOTO_SHOPPING_CART", $this->lng->txt('pay_goto_shopping_cart')); $this->tpl->parseCurrentBlock("shopping_cart_1"); } $this->ctrl->setParameter($this, "ref_id", $this->pobject->getRefId()); $subtype = ''; if ($this->object) { if ($this->object->getType() == 'exc') { $subtype = ' (' . $this->lng->txt($this->pobject->getSubtype()) . ')'; } $this->tpl->setVariable("DETAILS_FORMACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_' . $this->object->getType() . '_b.png')); $this->tpl->setVariable("ALT_IMG", $this->lng->txt('obj_' . $this->object->getType())); $this->tpl->setVariable("TITLE", $this->object->getTitle() . ' ' . $subtype); } else { $this->tpl->setVariable("DETAILS_FORMACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("TITLE", $this->lng->txt('object_not_found')); } // payment infos $this->tpl->setVariable("TXT_INFO", $this->lng->txt('info')); $this->tpl->setVariable("INFO_PAY", $this->lng->txt('pay_info')); if (is_array($buyedObject)) { if (is_array($prices) && count($prices) > 1) { $this->tpl->setVariable("INPUT_CMD", 'addToShoppingCart'); $this->tpl->setVariable("INPUT_VALUE", $this->lng->txt('pay_change_price')); } else { $this->tpl->setVariable("INPUT_CMD", 'addToShoppingCart'); $this->tpl->setVariable("INPUT_VALUE", $this->lng->txt('pay_add_to_shopping_cart')); } } else { $this->tpl->setVariable("INPUT_CMD", 'addToShoppingCart'); $this->tpl->setVariable("INPUT_VALUE", $this->lng->txt('pay_add_to_shopping_cart')); } $this->tpl->setVariable("ROWSPAN", count($prices)); $this->tpl->setVariable("TXT_PRICES", $this->lng->txt('prices')); if (is_array($prices)) { $counter = 0; foreach ($prices as $price) { if ($counter == 0) { $placeholderCheckbox = "CHECKBOX"; $placeholderDuration = "DURATION"; $placeholderPrice = "PRICE"; $placeholderDescription = "DESCRIPTION"; } else { $placeholderCheckbox = "ROW_CHECKBOX"; $placeholderDuration = "ROW_DURATION"; $placeholderPrice = "ROW_PRICE"; $placeholderDescription = "ROW_DESCRIPTION"; } $this->tpl->setCurrentBlock("price_row"); if ($buyedObject["price_id"] == $price['price_id']) { $this->tpl->setVariable($placeholderCheckbox, ilUtil::formRadioButton(1, 'price_id', $price['price_id'])); } else { if (count($prices) == 1) { $this->tpl->setVariable($placeholderCheckbox, ilUtil::formRadioButton(1, 'price_id', $price['price_id'])); } else { $this->tpl->setVariable($placeholderCheckbox, ilUtil::formRadioButton(0, 'price_id', $price['price_id'])); } } switch ($price['price_type']) { case ilPaymentPrices::TYPE_DURATION_MONTH: $this->tpl->setVariable($placeholderDuration, $price['duration'] . ' ' . $this->lng->txt('paya_months') . ': '); break; case ilPaymentPrices::TYPE_DURATION_DATE: ilDatePresentation::setUseRelativeDates(false); $this->tpl->setVariable($placeholderDuration, ilDatePresentation::formatDate(new ilDate($price['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price['duration_until'], IL_CAL_DATE)) . ' -> '); break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $this->tpl->setVariable($placeholderDuration, $this->lng->txt('unlimited_duration') . ': '); break; } $tmp_price = $price['price']; if ($price['extension'] == 1) { $extension_txt = '(' . $this->lng->txt('extension_price') . ')'; } else { $extension_txt = ''; } $this->tpl->setVariable($placeholderPrice, ilPaymentPrices::_formatPriceToString((double) $tmp_price) . ' ' . $extension_txt); if ($price['description'] != NULL) { $this->tpl->setVariable($placeholderDescription, $price['description']); } $this->tpl->parseCurrentBlock(); $counter++; } } return true; }
/** * insert payment information * * @access private */ function insertPayment() { global $ilAccess, $ilObjDataCache, $ilUser; if (IS_PAYMENT_ENABLED && $this->payment_enabled) { include_once './Services/Payment/classes/class.ilPaymentObject.php'; include_once './Services/Payment/classes/class.ilPaymentBookings.php'; if (ilPaymentobject::_requiresPurchaseToAccess($this->ref_id)) { if (ilPaymentBookings::_hasAccess(ilPaymentObject::_lookupPobjectId($a_ref_id), $ilUser->getId())) { // get additional information about order_date and duration $order_infos = array(); $order_infos = ilPaymentBookings::_lookupOrder(ilPaymentObject::_lookupPobjectId($this->ref_id)); if (count($order_infos) > 0) { global $lng; $pay_lang = $lng; $pay_lang->loadLanguageModule('payment'); $alert = true; $a_newline = true; $a_property = $pay_lang->txt('object_purchased_date'); $a_value = ilDatePresentation::formatDate(new ilDateTime($order_infos["order_date"], IL_CAL_UNIX)); $this->addCustomProperty($a_property, $a_value, $alert, $a_newline); $alert = true; $a_newline = true; $a_property = $this->lng->txt('object_duration'); if ($order_infos['duration'] == 0) { $a_value = $pay_lang->txt('unlimited_duration'); } else { $a_value = $order_infos['duration'] . ' ' . $this->lng->txt('months'); } $this->addCustomProperty($a_property, $a_value, $alert, $a_newline); } // check for extension prices if (ilPaymentObject::_hasExtensions($this->ref_id)) { $has_extension_prices = true; $this->insertPaymentCommand($has_extension_prices); } } else { // only relevant and needed for the shop content page $this->ctpl = new ilTemplate("tpl.container_list_item_commands.html", true, true, "Services/Container", "DEFAULT", false, true); $this->ctpl->setCurrentBlock('payment'); $this->ctpl->setVariable('PAYMENT_TYPE_IMG', ilUtil::getImagePath('icon_pays.svg')); $this->ctpl->setVariable('PAYMENT_ALT_IMG', $this->lng->txt('payment_system') . ': ' . $this->lng->txt('payment_buyable')); $this->ctpl->parseCurrentBlock(); $this->insertPaymentCommand(); } } } }
public function deleteObject() { include_once './Services/Payment/classes/class.ilPaymentBookings.php'; if (!$_GET['pobject_id']) { ilUtil::sendFailure($this->lng->txt('paya_no_object_selected')); $this->showObjects(); return true; } if (ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id'])) { ilUtil::sendInfo($this->lng->txt('paya_bookings_available')); $this->editDetails(); return false; } else { $this->editDetails(true); return true; } }