/** * @param $cur_obj_type * @param $item * @return array */ private function getObjectListItem($cur_obj_type, $item) { 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); return array($item, $html); }
public function saveCustomerObject() { global $ilUser, $ilObjDataCache; if (!isset($_GET['sell_id'])) { ilUtil::sendInfo($this->lng->txt('paya_error_no_object_id_given')); $this->showObjectSelectorObject(); return true; } if (!isset($_GET['user_id'])) { ilUtil::sendInfo($this->lng->txt('paya_error_no_user_id_given')); $this->searchUserSPObject(); return true; } if ($_POST['pay_method'] == '' || $_POST['price_id'] == '') { ilUtil::sendInfo($this->lng->txt('paya_error_mandatory_fields')); $this->addCustomerObject(); return true; } $pObjectId = ilPaymentObject::_lookupPobjectId($_GET['sell_id']); $obj = new ilPaymentObject($this->user_obj, $pObjectId); $this->__initBookingObject(); $transaction = ilInvoiceNumberPlaceholdersPropertyGUI::_generateInvoiceNumber($ilUser->getId()); $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($_POST['pay_method']); $this->booking_obj->setOrderDate(time()); $price = ilPaymentPrices::_getPrice($_POST['price_id']); // $currency = ilPaymentCurrency::_getUnit($price['currency']); #@todo check this. switch ($price['price_type']) { case ilPaymentPrices::TYPE_DURATION_MONTH: $this->booking_obj->setDuration($price['duration']); break; case ilPaymentPrices::TYPE_DURATION_DATE: $this->booking_obj->setDuration(0); $this->booking_obj->setAccessStartdate($price['duration_from']); $this->booking_obj->setAccessEnddate($price['duration_until']); break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $this->booking_obj->setDuration(0); $this->booking_obj->setAccessEnddate(NULL); break; } $this->booking_obj->setPriceType($price['price_type']); $this->booking_obj->setPrice($price['price']); $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); $genSet = ilPaymentSettings::_getInstance(); $this->booking_obj->setCurrencyUnit($genSet->get('currency_unit')); include_once './Services/Payment/classes/class.ilPayMethods.php'; $save_user_address_enabled = ilPayMethods::_EnabledSaveUserAddress($this->booking_obj->getPayMethod()); if ($save_user_address_enabled == 1) { 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->statisticObject(); } else { ilUtil::sendInfo($this->lng->txt('paya_error_adding_customer')); $this->addCustomerObject(); } return true; }
private function __initPaymentObject() { global $ilUser; $this->pobject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($this->ref_id)); return true; }
public function showContainerContent() { global $ilUser, $rbacreview, $ilToolbar, $tpl; if ($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) { $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit')); } include_once './Services/Payment/classes/class.ilPaymentObject.php'; $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.shop_content.html', 'Services/Payment'); $this->tpl->setVariable('PAGE_CONTENT', $this->getPageHTML()); $is_buyable = ilPaymentObject::_isBuyable($this->cur_ref_id); if ($is_buyable) { $pobjects = ilPaymentObject::_getObjectData(ilPaymentObject::_lookupPobjectId($this->cur_ref_id)); $obj_id = ilObject::_lookupObjId($this->cur_ref_id); $title = ilObject::_lookupTitle($obj_id); $description = ilObject::_lookupDescription($obj_id); $type = ilObject::_lookupType($obj_id); $presentation_results[$pobjects['pt_topic_fk']][$type][] = array('ref_id' => $pobjects['ref_id'], 'title' => $title, 'description' => $description, 'type' => $type, 'obj_id' => $obj_id, 'topic_id' => $pobjects['pt_topic_fk'], 'child' => $pobjects['child']); } else { $pobjects = ilPaymentObject::_getContainerObjects($this->cur_ref_id); if (count($pobjects) >= 1) { foreach ($pobjects as $result) { $obj_id = $result['obj_id']; $title = $result['title']; $description = $result['description']; $type = $result['type']; $presentation_results[$result['pt_topic_fk']][$type][] = array('ref_id' => $result['ref_id'], 'title' => $title, 'description' => $description, 'type' => $type, 'obj_id' => $obj_id, 'topic_id' => $result['pt_topic_fk'], 'child' => $result['child']); } } } include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php'; $search_result_presentation = new ilShopResultPresentationGUI($presentation_results); $search_result_presentation->setSortField(strtolower(trim($this->getSortField()))); $search_result_presentation->setSortDirection(trim($this->getSortDirection())); if (!$presentation_results) { $this->tpl->setVariable('RESULTS', $this->lng->txt('payment_shop_not_objects_found')); } else { $html = $search_result_presentation->showSpecials(); $this->tpl->setVariable('RESULTS', $html); } $this->showFilters(); }
public function showContainerContent() { global $ilUser, $rbacreview, $ilToolbar; if ($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) { $ilToolbar->addButton($this->lng->txt('edit_page'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit')); } include_once './Services/Payment/classes/class.ilPaymentObject.php'; $is_buyable = ilPaymentObject::_isBuyable($this->cur_ref_id); if ($is_buyable) { $pobjects = ilPaymentObject::_getObjectData(ilPaymentObject::_lookupPobjectId($this->cur_ref_id)); $obj_id = ilObject::_lookupObjId($this->cur_ref_id); $title = ilObject::_lookupTitle($obj_id); $description = ilObject::_lookupDescription($obj_id); $type = ilObject::_lookupType($obj_id); $presentation_results[$pobjects['pt_topic_fk']][$type][] = array('ref_id' => $pobjects['ref_id'], 'title' => $title, 'description' => $description, 'type' => $type, 'obj_id' => $obj_id, 'topic_id' => $pobjects['pt_topic_fk'], 'child' => $pobjects['child']); } else { $pobjects = ilPaymentObject::_getContainerObjects($this->cur_ref_id); if (count($pobjects) >= 1) { foreach ($pobjects as $result) { $obj_id = $result['obj_id']; $title = $result['title']; $description = $result['description']; $type = $result['type']; $presentation_results[$result['pt_topic_fk']][$type][] = array('ref_id' => $result['ref_id'], 'title' => $title, 'description' => $description, 'type' => $type, 'obj_id' => $obj_id, 'topic_id' => $result['pt_topic_fk'], 'child' => $result['child']); } } } $shop_content_tpl = new ilTemplate('tpl.shop_content.html', true, true, 'Services/Payment'); $shop_content_tpl->setVariable('PAGE_CONTENT', $this->getPageHTML()); include_once 'Services/Payment/classes/class.ilShopResultPresentationGUI.php'; $search_result_presentation = new ilShopResultPresentationGUI($presentation_results); $search_result_presentation->setSortField(strtolower(trim($this->getSortField()))); $search_result_presentation->setSortDirection(trim($this->getSortDirection())); $html = $search_result_presentation->showSpecials(); $shop_content_tpl->setVariable('RESULTS', $html); $show_general_filter = $this->oGeneralSettings->get('show_general_filter'); $show_topics_filter = $this->oGeneralSettings->get('show_topics_filter'); $show_shop_explorer = $this->oGeneralSettings->get('show_shop_explorer'); if ($show_general_filter) { $g_filter_html = $this->showGeneralFilter(count($search_result_presentation)); $shop_content_tpl->setVariable('FORM', $g_filter_html); } if ($show_topics_filter) { $this->showTopicsFilter(count($search_result_presentation)); } if ($show_shop_explorer) { $this->showShopExplorer(); } global $tpl; $tpl->setContent($shop_content_tpl->parse()); }
/** * 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(); } } } }
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()); } }