public function editPriceObject() { $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); $price_id = $_GET['price_id'] ? $_GET['price_id'] : $_POST['price_id']; $price = ilPaymentPrices::_getPrice($price_id); $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']); $tmp_pobject = ilPaymentObject::_getObjectData($_GET['pobject_id']); include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $tmp_obj = ilObjectFactory::getInstanceByRefId($tmp_pobject['ref_id'], false); if ($tmp_obj) { $form->setTitle($tmp_obj->getTitle()); } else { $form->setTitle($this->lng->txt('object_not_found')); } //price_type $radio_group = new ilRadioGroupInputGUI('', 'price_type'); $radio_group->setTitle($this->lng->txt('duration')); $radio_group->setRequired(true); $radio_group->setValue($price['price_type']); $radio_group->setPostVar('price_type'); $radio_option_1 = new ilRadioOption($this->lng->txt('duration_month'), ilPaymentPrices::TYPE_DURATION_MONTH); // duration month $oDuration = new ilNumberInputGUI(); $oDuration->setTitle($this->lng->txt('paya_months')); $oDuration->setSize('20%'); $oDuration->setValue($price['duration']); $oDuration->setPostVar('duration_month'); $radio_option_1->addSubItem($oDuration); $radio_group->addOption($radio_option_1); $radio_option_3 = new ilRadioOption($this->lng->txt('duration_date'), ilPaymentPrices::TYPE_DURATION_DATE); // duration_date from $o_date_from = new ilDateTimeInputGUI(); $o_date_from->setTitle($this->lng->txt('cal_from')); $o_date_from->setDate(new ilDate($price['duration_from'], IL_CAL_DATE)); $o_date_from->setPostVar('duration_date_from'); $radio_option_3->addSubItem($o_date_from); // duration_date until $o_date_until = new ilDateTimeInputGUI(); $o_date_until->setTitle($this->lng->txt('cal_until')); $o_date_until->setDate(new ilDate($price['duration_until'], IL_CAL_DATE)); $o_date_until->setPostVar('duration_date_until'); $radio_option_3->addSubItem($o_date_until); $radio_group->addOption($radio_option_3); $radio_option_2 = new ilRadioOption($this->lng->txt('unlimited_duration'), ilPaymentPrices::TYPE_UNLIMITED_DURATION); $radio_group->addOption($radio_option_2); $form->addItem($radio_group); // description $oDescription = new ilTextAreaInputGUI($this->lng->txt('description'), 'description'); $oDescription->setRows(4); $oDescription->setCols(35); $oDescription->setValue($price['description']); $form->addItem($oDescription); // price $oPrice = new ilNumberInputGUI(); $oPrice->setTitle($this->lng->txt('price_a')); $oPrice->setSize('20%'); $oPrice->setRequired(true); $oPrice->setValue($price['price']); include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); $oPrice->setInfo($genSet->get('currency_unit')); $oPrice->setPostVar('price'); $oPrice->allowDecimals(true); $form->addItem($oPrice); //extension $oExtension = new ilCheckboxInputGUI($this->lng->txt('extension_price'), 'extension'); $oExtension->setChecked($price['extension']); $form->addItem($oExtension); $o_hidden_1 = new ilHiddenInputGUI('pobject_id'); $o_hidden_1->setValue((int) $_GET['pobject_id']); $o_hidden_1->setPostVar('pobject_id'); $o_hidden_2 = new ilHiddenInputGUI('price_id'); $o_hidden_2->setValue((int) $_GET['price_id']); $o_hidden_2->setPostVar('price_id'); $form->addItem($o_hidden_1); $form->addItem($o_hidden_2); $form->addCommandButton('updatePrice', $this->lng->txt('save')); $form->addCommandButton('editPrices', $this->lng->txt('cancel')); $this->tpl->setVariable('FORM', $form->getHTML()); }
private function showItemsTable(&$a_tpl, $a_result_set, $a_pay_method = 0) { include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); include_once './Services/Payment/classes/class.ilShoppingCartTableGUI.php'; $tbl = new ilShoppingCartTableGUI($this); $tbl->setId('tbl_id_' . $a_pay_method); $tbl->setTitle($this->lng->txt('paya_shopping_cart') . " (" . $this->lng->txt('payment_system') . ": " . ilPayMethods::getStringByPaymethod($a_pay_method['pm_title']) . ")"); $coupon_session = $a_pay_method['pm_title']; $tbl->setRowTemplate("tpl.shop_shoppingcart_row.html", "Services/Payment"); $tbl->addColumn('', 'item', '1%', true); $tbl->addColumn($this->lng->txt('title'), "table" . $a_pay_method['pm_title'] . "_title", '30%'); $tbl->addColumn($this->lng->txt('duration'), "table" . $a_pay_method['pm_title'] . "_duration", '30%'); $tbl->addColumn($this->lng->txt('vat_rate'), "table" . $a_pay_method['pm_title'] . "_vat_rate", '15%'); $tbl->addColumn($this->lng->txt('vat_unit'), "table" . $a_pay_method['pm_title'] . "_vat_unit", '15%'); $tbl->addColumn($this->lng->txt('price_a'), "table" . $a_pay_method['pm_title'] . "_price", '10%'); $tbl->setPrefix("table" . $a_pay_method['pm_title'] . "_"); $tbl->addMultiCommand('deleteItem', $this->lng->txt('delete')); // show total amount of costs $sc_obj = new ilPaymentShoppingCart($this->user_obj); $totalAmount = $sc_obj->getTotalAmount(); if (!empty($_SESSION['coupons'][$coupon_session])) { if (count($items = $sc_obj->getEntries($a_pay_method['pm_id']))) { $tbl->setTotalData('TXT_SUB_TOTAL', $this->lng->txt('pay_bmf_subtotal_amount') . ": "); $tbl->setTotalData('VAL_SUB_TOTAL', number_format($totalAmount[$a_pay_method['pm_id']], 2, ',', '.') . " " . $genSet->get('currency_unit')); foreach ($_SESSION['coupons'][$coupon_session] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); $total_object_price = 0.0; $current_coupon_bonus = 0.0; foreach ($items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $price_data = ilPaymentPrices::_getPrice($item['price_id']); $price = (double) $price_data['price']; $total_object_price += $price; } unset($tmp_pobject); } $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price); $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * -1; } $tbl->setTotalData('TXT_COUPON_BONUS', $this->lng->txt('paya_coupons_coupon') . ": "); # . $coupon['pcc_code'] . ": "); #$tbl->setTotalData('VAL_COUPON_BONUS', number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get('currency_unit')); $tbl->setTotalData('VAL_COUPON_BONUS', number_format($totalAmount[$current_coupon_bonus], 2, ',', '.') . " " . $genSet->get('currency_unit')); if ($totalAmount[$a_pay_method['pm_id']] < 0) { $totalAmount[$a_pay_method['pm_id']] = 0; $this->totalVat = 0; } } } $this->totalAmount[$a_pay_method['pm_id']] = $totalAmount[$a_pay_method['pm_id']] - $totalAmount[$current_coupon_bonus] * -1; $tbl->setTotalData('TXT_TOTAL_AMOUNT', $this->lng->txt('pay_bmf_total_amount') . ": "); $tbl->setTotalData('VAL_TOTAL_AMOUNT', number_format($this->totalAmount[$a_pay_method['pm_id']], 2, ',', '.') . " " . $genSet->get('currency_unit')); #.$item['currency']); if ($this->totalVat > 0) { $tbl->setTotalData('TXT_TOTAL_VAT', $this->lng->txt('pay_bmf_vat_included') . ": "); $tbl->setTotalData('VAL_TOTAL_VAT', number_format($this->totalVat, 2, ',', '.') . " " . $genSet->get('currency_unit')); } $tbl->setData($a_result_set); $a_tpl->setVariable('ITEMS_TABLE', $tbl->getCartHTML()); return true; }
private function renderItems($oContainerTpl, $results, $topic) { // main shop_content global $ilUser; $items_counter = 0; $cur_obj_type = ''; $tpl = $this->newBlockTemplate(); foreach ($this->type_ordering as $act_type) { $item_html = array(); if (count($results[(int) $topic['id']][$act_type])) { foreach ($results[$topic['id']][$act_type] as $key => $item) { // price presentation $oPaymentObject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id'])); $oPrice = new ilPaymentPrices((int) $oPaymentObject->getPobjectId()); $lowest_price = $oPrice->getLowestPrice(); $special_icon = ' '; if ($oPaymentObject->getSpecial() == '1') { $special_icon = ilShopUtils::_getSpecialObjectSymbol(); } $results[$topic['id']][$act_type][$key]['title'] = $item['title'] . ' ' . ($results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon); $results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price']; $paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod()); $shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($item['ref_id']); $results[$topic['id']][$act_type][$key]['price_string'] = ($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from') . ' ' : '') . ilPaymentPrices::_formatPriceToString($lowest_price['price']) . ' ' . ($results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon . ' ' . ($results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon)); // authors include_once 'Services/MetaData/classes/class.ilMD.php'; $md_obj = new ilMD($item['obj_id'], 0, $item['type']); if (is_object($md_section = $md_obj->getLifecycle())) { $sep = $ent_str = ""; foreach ($ids = $md_section->getContributeIds() as $con_id) { $md_con = $md_section->getContribute($con_id); if ($md_con->getRole() == "Author") { foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) { $md_ent = $md_con->getEntity($ent_id); $ent_str = $ent_str . $sep . $md_ent->getEntity(); $sep = ", "; } } } $results[$topic['id']][$act_type][$key]['author'] = $ent_str; } } $results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]); foreach ($results[$topic['id']][$act_type] as $key => $item) { // get list gui class for each object type list($item, $html) = $this->getObjectListItem($cur_obj_type, $item); if ($html) { $item_html[$item['ref_id']] = $html; } } // output block for resource type if (count($item_html) > 0) { // add a header for each resource type $tpl->setCurrentBlock("container_header_row_image"); $tpl->setVariable("HEADER_IMG", ilObject::_getIcon('', '', $act_type)); $tpl->setVariable("HEADER_ALT", $this->lng->txt("objs_" . $act_type)); $tpl->setVariable("BLOCK_HEADER_CONTENT", $this->lng->txt("objs_" . $act_type)); $this->resetRowType(); // content row foreach ($item_html as $ref_id => $html) { $this->addStandardRow($tpl, $html); } ++$items_counter; } } } if ($items_counter > 0) { $oContainerTpl->setCurrentBlock('loop_item'); $oContainerTpl->setCurrentBlock('topic_title'); $oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']); $oContainerTpl->parseCurrentBlock('topic_title'); $oContainerTpl->setVariable('CONTAINER_LIST_BLOCK', $html); $oContainerTpl->parseCurrentBlock('loop_item'); $tpl->setContent($oContainerTpl->get()); $container_html = $tpl->get(); return $container_html; } }
public function saveCustomer() { global $ilObjDataCache; if (!isset($_GET['sell_id'])) { ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given')); $this->showObjectSelector(); return true; } if (!isset($_GET['user_id'])) { ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given')); $this->searchUser(); return true; } if ($_POST["pay_method"] == "" || $_POST["duration"] == "") { ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields')); $this->addCustomer(); return true; } $pObjectId = ilPaymentObject::_lookupPobjectId($_GET["sell_id"]); $obj = new ilPaymentObject($this->user_obj, $pObjectId); $this->__initBookingObject(); $transaction = ilInvoiceNumberPlaceholdersPropertyGUI::_generateInvoiceNumber($_GET["user_id"]); $this->booking_obj->setTransaction($transaction); $this->booking_obj->setTransactionExtern($_POST["transaction"]); $this->booking_obj->setPobjectId($pObjectId); $this->booking_obj->setCustomerId($_GET["user_id"]); $this->booking_obj->setVendorId($obj->getVendorId()); $this->booking_obj->setPayMethod((int) $_POST["pay_method"]); $this->booking_obj->setOrderDate(time()); $price = ilPaymentPrices::_getPrice($_POST["duration"]); $this->booking_obj->setDuration($price["duration"]); $this->booking_obj->setAccessExtension($price['extension']); switch ((int) $price['price_type']) { case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $this->booking_obj->setDuration(0); break; case ilPaymentPrices::TYPE_DURATION_DATE: $this->booking_obj->setAccessStartdate($price['duration_from']); $this->booking_obj->setAccessEnddate($price['duration_until']); $this->booking_obj->setDuration(0); break; default: case ilPaymentPrices::TYPE_DURATION_MONTH: $this->booking_obj->setDuration($price["duration"]); break; } $this->booking_obj->setPriceType($price['price_type']); $this->booking_obj->setPrice(ilPaymentPrices::_getPriceString($_POST["duration"])); $this->booking_obj->setAccess((int) $_POST['access']); $this->booking_obj->setPayed((int) $_POST['payed']); $this->booking_obj->setVoucher(''); $obj_id = $ilObjDataCache->lookupObjId($obj->getRefId()); $obj_type = $ilObjDataCache->lookupType($obj_id); $obj_title = $ilObjDataCache->lookupTitle($obj_id); include_once 'Services/Payment/classes/class.ilShopVatsList.php'; $oVAT = new ilShopVats((int) $obj->getVatId()); $obj_vat_rate = $oVAT->getRate(); $obj_vat_unit = $obj->getVat($this->booking_obj->getPrice()); $this->booking_obj->setObjectTitle($obj_title); $this->booking_obj->setVatRate($obj_vat_rate); $this->booking_obj->setVatUnit($obj_vat_unit); include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); $this->booking_obj->setCurrencyUnit($genSet->get('currency_unit')); include_once './Services/Payment/classes/class.ilPayMethods.php'; if (ilPayMethods::_EnabledSaveUserAddress((int) $_POST["pay_method"]) == 1) { /** * @class $ilObjUser ilObjUser */ global $ilObjUser; $user_id[] = $_GET["user_id"]; $cust_obj = ilObjUser::_readUsersProfileData($user_id); $this->booking_obj->setStreet($cust_obj[$_GET["user_id"]]['street'], ''); $this->booking_obj->setZipcode($cust_obj[$_GET["user_id"]]['zipcode']); $this->booking_obj->setCity($cust_obj[$_GET["user_id"]]['city']); $this->booking_obj->setCountry($cust_obj[$_GET["user_id"]]['country']); } if ($this->booking_obj->add()) { // add purchased item to desktop ilShopUtils::_addPurchasedObjToDesktop($obj, $this->booking_obj->getCustomerId()); // autosubscribe user if purchased object is a course if ($obj_type == 'crs') { ilShopUtils::_assignPurchasedCourseMemberRole($obj, $this->booking_obj->getCustomerId()); } ilUtil::sendInfo($this->lng->txt('paya_customer_added_successfully')); $this->showStatistics(); } else { ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer')); $this->addCustomer(); } return true; }
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()); }
public static function _getTotalAmount($a_price_ids) { include_once './Services/Payment/classes/class.ilPaymentPrices.php'; $amount = array(); if (is_array($a_price_ids)) { for ($i = 0; $i < count($a_price_ids); $i++) { $price_data = ilPaymentPrices::_getPrice($a_price_ids[$i]["id"]); $price = (double) $price_data["price"]; $amount[$a_price_ids[$i]["pay_method"]] += (double) $price; } } return $amount; }
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; }
private function renderItems($oContainerTpl, $results, $topic) { // main shop_content global $ilUser; $items_counter = 0; $cur_obj_type = ''; $tpl = $this->newBlockTemplate(); $first = true; foreach ($this->type_ordering as $act_type) { $item_html = array(); if (count($results[$topic['id']][$act_type])) { foreach ($results[$topic['id']][$act_type] as $key => $item) { // price presentation $oPaymentObject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id'])); $oPrice = new ilPaymentPrices((int) $oPaymentObject->getPobjectId()); $lowest_price = $oPrice->getLowestPrice(); $special_icon = ' '; if ($oPaymentObject->getSpecial() == '1') { $special_icon = ilShopUtils::_getSpecialObjectSymbol(); } $results[$topic['id']][$act_type][$key]['title'] = $item['title'] . ' ' . ($results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon); $results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price']; $paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod()); // if(!ilPaymentObject::_hasAccess($item['ref_id'])) // { $shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($act_type, $item['ref_id']); // } // else $shoppingcart_icon = ''; $results[$topic['id']][$act_type][$key]['price_string'] = ($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from') . ' ' : '') . ilPaymentPrices::_formatPriceToString($lowest_price['price']) . ' ' . ($results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon . ' ' . ($results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon)); // authors include_once 'Services/MetaData/classes/class.ilMD.php'; $md_obj = new ilMD($item['obj_id'], 0, $item['type']); if (is_object($md_section = $md_obj->getLifecycle())) { $sep = $ent_str = ""; foreach ($ids = $md_section->getContributeIds() as $con_id) { $md_con = $md_section->getContribute($con_id); if ($md_con->getRole() == "Author") { foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) { $md_ent = $md_con->getEntity($ent_id); $ent_str = $ent_str . $sep . $md_ent->getEntity(); $sep = ", "; } } } $results[$topic['id']][$act_type][$key]['author'] = $ent_str; } } $results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]); foreach ($results[$topic['id']][$act_type] as $key => $item) { // get list gui class for each object type if ($cur_obj_type != $item['type']) { include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php'; $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item['type']); } $item_list_gui->initItem($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], ilObjectListGUI::CONTEXT_SHOP); $item_list_gui->enableDelete(false); $item_list_gui->enableCut(false); $item_list_gui->enableCopy(false); $item_list_gui->enableLink(false); $item_list_gui->enableSubscribe(false); $item_list_gui->enablePayment(true); $item_list_gui->enableCommands(true); $item_list_gui->enablePath(false); $item_list_gui->insertCommands(); $item_list_gui->enableInfoScreen(false); $item_list_gui->enableSubstitutions(false); $item_list_gui->enableNoticeProperties(false); $item_list_gui->enablePreconditions(false); $item_list_gui->enableProperties(false); $item_list_gui->setBoldTitle(true); if (ilPaymentObject::_hasAccess($item['ref_id'])) { $item_list_gui->enableInfoScreen(true); $item_list_gui->enableCommands(true); } else { switch ($item['type']) { case 'sahs': $demo_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo'; break; case 'lm': $demo_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo'; break; case 'exc': $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"]; break; default: $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"]; break; } $item['title'] = '<a href="' . $demo_link . '">' . $item["title"] . '</a>'; } $tpl_pinfo = new ilTemplate('tpl.shop_item_info.html', true, true, 'Services/Payment'); if ($item['price_string'] != '') { $tpl_pinfo->setCurrentBlock('ploop'); $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('price_a')); $tpl_pinfo->setVariable('VALUE', $item['price_string']); $tpl_pinfo->parseCurrentBlock(); } if ($item['author'] != '') { $tpl_pinfo->setCurrentBlock('ploop'); $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('author')); $tpl_pinfo->setVariable('VALUE', $item['author']); $tpl_pinfo->parseCurrentBlock(); } $oFile = new ilFileDataShop(ilPaymentObject::_lookupPobjectId($item['ref_id'])); if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) { $tpl_pinfo->setCurrentBlock('image'); $tpl_pinfo->setVariable('SRC', $webpath_file); $tpl_pinfo->setVariable('ALT', strip_tags($item['title'])); $tpl_pinfo->parseCurrentBlock(); } $item_list_gui->addSubItemHTML($tpl_pinfo->get()); $html = $item_list_gui->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], false, false, "", ilObjectListGUI::CONTEXT_SHOP); if ($html) { $html = $this->__appendChildLinks($html, $item, $item_list_gui); $item_html[$item['ref_id']] = $html; } } // output block for resource type if (count($item_html) > 0) { // separator row if (!$first) { $this->addSeparatorRow($tpl); } $first = false; // add a header for each resource type $this->addHeaderRow($tpl, $act_type); $this->resetRowType(); // content row foreach ($item_html as $ref_id => $html) { $this->addStandardRow($tpl, $html, $ref_id); } ++$items_counter; } } } if ($items_counter > 0) { $oContainerTpl->setCurrentBlock('loop'); $oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']); $oContainerTpl->setVariable('COTAINER_LIST_BLOCK', $tpl->get()); $oContainerTpl->parseCurrentBlock(); global $tpl; $tpl->setContent($oContainerTpl->get()); } }
function getShoppingCart($a_pay_method = 0) { if (!count($items = $this->getEntries($a_pay_method))) { return 0; } $counter = 0; $f_result = array(); foreach ($items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); $tmp_obj = ilObjectFactory::getInstanceByRefId($tmp_pobject->getRefId(), false); $f_result[$counter]["psc_id"] = $item['psc_id']; $f_result[$counter]["pobject_id"] = $item['pobject_id']; if ($tmp_obj) { $f_result[$counter]["obj_id"] = $tmp_obj->getId(); $f_result[$counter]["type"] = $tmp_obj->getType(); $f_result[$counter]["object_title"] = $tmp_obj->getTitle(); } else { global $lng; $f_result[$counter]["obj_id"] = ''; $f_result[$counter]["type"] = ''; $f_result[$counter]["object_title"] = $lng->txt('object_deleted'); } $price_data = ilPaymentPrices::_getPrice($item['price_id']); $price_string = ilPaymentPrices::_getPriceString($item['price_id']); $price = number_format($price_data['price'], 2, '.', ''); $f_result[$counter]["price"] = $price; $f_result[$counter]["price_string"] = $price_string; $f_result[$counter]['extension'] = $price_data['extension']; require_once './Services/Payment/classes/class.ilShopVats.php'; $oVAT = new ilShopVats((int) $tmp_pobject->getVatId()); $f_result[$counter]['vat_rate'] = $oVAT->getRate(); $f_result[$counter]['vat_unit'] = $tmp_pobject->getVat($price); $f_result[$counter]["duration"] = $price_data["duration"]; $f_result[$counter]['unlimited_duration'] = $price_data['unlimited_duration']; $f_result[$counter]["price_type"] = $price_data["price_type"]; $f_result[$counter]["duration_from"] = $price_data["duration_from"]; $f_result[$counter]["duration_until"] = $price_data["duration_until"]; $f_result[$counter]["description"] = $price_data["description"]; unset($tmp_obj); unset($tmp_pobject); ++$counter; } return $f_result; }
public function updatePrice() { include_once './Services/Payment/classes/class.ilPaymentPrices.php'; if (!$_GET['pobject_id'] && !$_POST['pobject_id']) { ilUtil::sendInfo($this->lng->txt('paya_no_object_selected')); $this->showObjects(); return true; } if (isset($_GET['pobject_id'])) { $pobject_id = (int) $_GET['pobject_id']; } else { $pobject_id = (int) $_POST['pobject_id']; } if (!(int) $_GET['price_id'] && !$_POST['price_id']) { ilUtil::sendInfo($this->lng->txt('payment_no_price_selected')); return $this->editPrices(); } if (isset($_GET['price_id'])) { $price_id = (int) $_GET['price_id']; } else { $price_id = (int) $_POST['price_id']; } $po = new ilPaymentPrices((int) $pobject_id); switch ($_POST['price_type']) { case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $po->setPriceType(ilPaymentPrices::TYPE_UNLIMITED_DURATION); $po->setDuration(NULL); $po->setDurationFrom(NULL); $po->setDurationUntil(NULL); $po->setUnlimitedDuration(1); break; case ilPaymentPrices::TYPE_DURATION_DATE: $po->setPriceType(ilPaymentPrices::TYPE_DURATION_DATE); $po->setDuration(NULL); $po->setDurationFrom(ilUtil::stripSlashes($_POST['duration_date_from']['date']['y'] . '-' . $_POST['duration_date_from']['date']['m'] . '-' . $_POST['duration_date_from']['date']['d'])); $po->setDurationUntil(ilUtil::stripSlashes($_POST['duration_date_until']['date']['y'] . '-' . $_POST['duration_date_until']['date']['m'] . '-' . $_POST['duration_date_until']['date']['d'])); break; default: case ilPaymentPrices::TYPE_DURATION_MONTH: $po->setPriceType(ilPaymentPrices::TYPE_DURATION_MONTH); $po->setDuration($_POST['duration_month']); $po->setDurationFrom(NULL); $po->setDurationUntil(NULL); break; } $po->setDescription($_POST['description'] ? ilUtil::stripSlashes($_POST['description']) : NULL); $po->setPrice(ilUtil::stripSlashes($_POST['price'])); $po->setCurrency(ilUtil::stripSlashes($_POST['currency'])); if ($_POST['extension']) { $po->setExtension(1); } else { $po->setExtension(0); } try { $po->validate(); $po->update($price_id); ilUtil::sendInfo($this->lng->txt('paya_updated_price')); return $this->editPrices(); } catch (ilShopException $e) { ilUtil::sendInfo($e->getMessage()); return $this->editPrices(); } }