public function saveVatObject() { $this->initVatForm('create'); if (!$this->form->checkInput()) { $this->form->setValuesByPost(); $this->tpl->setContent($this->form->getHtml()); return true; } if (!ilShopUtils::_checkVATRate($this->form->getInput('vat_rate'))) { $this->form->getItemByPostVar('vat_rate')->setAlert($this->lng->txt('payment_vat_input_invalid')); $this->form->setValuesByPost(); $this->tpl->setContent($this->form->getHtml()); return true; } try { $oVAT = new ilShopVats(); $oVAT->setTitle($this->form->getInput('vat_title')); $oVAT->setRate((double) str_replace(',', '.', $this->form->getInput('vat_rate'))); $oVAT->save(); } catch (ilShopException $e) { ilUtil::sendInfo($e->getMessage()); $this->form->setValuesByPost(); $this->tpl->setContent($this->form->getHtml()); return true; } ilUtil::sendInfo($this->lng->txt('saved')); $this->vatsObject(); return true; }
public function showItems() { global $ilObjDataCache, $ilUser, $ilToolbar; include_once './Services/Payment/classes/class.ilPaymentPrices.php'; include_once './Services/Payment/classes/class.ilPaymentCurrency.php'; $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.pay_shopping_cart.html', 'Services/Payment'); // var_dump($_SESSION['shop_user_id']); // if(isset($_SESSION['shop_user_id'])) // { // // $this->user_obj->_toggleActiveStatusOfUsers(array($this->user_obj->getId()), 1); // } if ($_SESSION['forceShoppingCartRedirect'] == '1') { $_SESSION['forceShoppingCartRedirect'] = 0; $this->tpl->touchBlock("close_js"); return true; } $this->initShoppingCartObject(); include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); $pay_methods = $this->_getPayMethods(true); $num_items = 0; $desc = array(); //course_objects $is_crs_object = false; $crs_obj_ids = array(); //file_objects,exercise_objects $is_file_object = false; // learning_modules, $is_lm_object = false; $lm_obj_ids = array(); if ($genSet->get('show_sr_shoppingcart') == 1) { require_once 'Services/RTE/classes/class.ilRTE.php'; $regulations = ilRTE::_replaceMediaObjectImageSrc($genSet->get('statutory_regulations'), 1); $this->tpl->setVariable('REGULATIONS_TITLE', $this->lng->txt('statutory_regulations')); $this->tpl->setVariable('REGULATIONS', $regulations); } $ilToolbar->addButton($this->lng->txt('payment_back_to_shop'), 'ilias.php?baseClass=ilShopController'); foreach ($pay_methods as $pay_method) { $this->totalVat = 0; $tpl = new ilTemplate($this->_getTemplateFilename($pay_method['pm_title']), true, 'Services/Payment'); $coupon_session_id = $pay_method['pm_title']; if (count($items = $this->psc_obj->getEntries($pay_method['pm_id']))) { $counter = 0; $paypal_counter = 0; $total_price = 0; foreach ($items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId()); $obj_type = $ilObjDataCache->lookupType($obj_id); $obj_title = $ilObjDataCache->lookupTitle($obj_id); $desc[] = "[" . $obj_type . "] " . $obj_title; $price_arr = ilPaymentPrices::_getPrice($item['price_id']); # checks object_type: needed for purchasing file or crs objects without login switch ($obj_type) { case 'crs': // if is_crs there an user-account will be autogenerated $is_crs_object = true; $_SESSION['is_crs_object'] = true; $crs_obj_ids[] = $obj_id; $_SESSION['crs_obj_ids'] = $crs_obj_ids; break; case 'lm': case 'sahs': case 'htlm': case 'tst': $is_lm_object = true; $_SESSION['is_lm_object'] = true; $lm_obj_ids[] = $obj_id; $_SESSION['lm_obj_ids'] = $lm_obj_ids; break; case 'exc': case 'file': $is_file_object = true; break; default: break; } $direct_paypal_info_output = true; $assigned_coupons = ''; if (!empty($_SESSION['coupons'][$coupon_session_id])) { $price = $price_arr['price']; $item['math_price'] = (double) $price; foreach ($_SESSION['coupons'][$coupon_session_id] as $key => $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $assigned_coupons .= $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code']; $_SESSION['coupons'][$coupon_session_id][$key]['total_objects_coupon_price'] += (double) $price; $_SESSION['coupons'][$coupon_session_id][$key]['items'][] = $item; $direct_paypal_info_output = false; } } } $f_result[$counter]['item'] = ilUtil::formCheckBox(0, 'item[]', $item['psc_id']); $subtype = ''; if ($obj_type == 'exc') { $subtype = ' (' . $this->lng->txt($tmp_pobject->getSubtype()) . ')'; $f_result[$counter]['title'] = "<a href=\"goto.php?target=" . $obj_type . "_" . $tmp_pobject->getRefId() . "\">" . $obj_title . "</a>" . $subtype; } else { $f_result[$counter]['title'] = "<a href=\"ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $tmp_pobject->getRefId() . "\">" . $obj_title . "</a>" . $subtype; } if ($assigned_coupons != '') { // !!! $f_result[$counter][count($f_result[$counter]) - 1] .= $assigned_coupons; $f_result[$counter]['assigned_coupons'] .= $assigned_coupons; } switch ($price_arr['price_type']) { case ilPaymentPrices::TYPE_DURATION_MONTH: $f_result[$counter]['duration'] = $price_arr['duration'] . ' ' . $this->lng->txt('paya_months'); break; case ilPaymentPrices::TYPE_DURATION_DATE: $f_result[$counter]['duration'] = ilDatePresentation::formatDate(new ilDate($price_arr['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price_arr['duration_until'], IL_CAL_DATE)); break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $f_result[$counter]['duration'] = $this->lng->txt('unlimited_duration'); break; } $float_price = $price_arr['price']; $total_price += $float_price; $oVAT = new ilShopVats((int) $tmp_pobject->getVatId()); $f_result[$counter]['vat_rate'] = ilShopUtils::_formatVAT($oVAT->getRate()); $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price); $f_result[$counter]['price'] = ilPaymentPrices::_getPriceString($item['price_id']) . ' ' . $genSet->get('currency_unit'); $f_result[$counter]['vat_unit'] = ilPaymentPrices::_getGUIPrice($tmp_pobject->getVat($float_price, 'CALCULATION')) . ' ' . $genSet->get('currency_unit'); if ($pay_method['pm_title'] == 'paypal') { if ($direct_paypal_info_output == true) { $tpl->setCurrentBlock('loop_items'); $tpl->setVariable('LOOP_ITEMS_NO', ++$paypal_counter); $tpl->setVariable('LOOP_ITEMS_NAME', "[" . $obj_id . "]: " . $obj_title); $tpl->setVariable('LOOP_ITEMS_AMOUNT', $float_price); $tpl->parseCurrentBlock('loop_items'); } } ++$counter; unset($tmp_pobject); } // foreach $this->showItemsTable($tpl, $f_result, $pay_method); if (!(bool) $genSet->get('hide_coupons')) { $tpl->setVariable('COUPON_TABLE', $this->showCouponInput($pay_method['pm_title'])); } $tpl->setCurrentBlock('buy_link'); # $tpl->setCurrentBlock('terms_checkbox'); $link_target = $this->ctrl->getLinkTargetByClass('iltermsconditionsgui', ''); $terms_link = '<a href="' . $link_target . '">' . $this->lng->txt('terms_conditions') . '</a>'; $tpl->setVariable('TERMS_CONDITIONS', sprintf($this->lng->txt('accept_terms_conditions'), $terms_link)); switch ($pay_method['pm_title']) { case 'bill': if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID == $this->user_obj->getId()) { $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBillObjectsInShoppingCart')); } else { # Anonymous user has to login if (ANONYMOUS_USER_ID == $this->user_obj->getId()) { ilUtil::sendInfo($this->lng->txt('click_to_continue_info')); $tpl->touchBlock('attach_submit_event_bill'); $tpl->setVariable('TXT_BUY', $this->lng->txt('continue')); $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1'); } else { ilUtil::sendInfo($this->lng->txt('click_to_buy_info')); $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBillGUI', '')); $tpl->parseCurrentBlock('terms_checkbox'); } } break; case 'bmf': #$tpl->setVariable("SCRIPT_LINK", './payment.php?view=start_bmf'); if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId()) { $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBMFObjectsInShoppingCart')); } else { # Anonymous user has to login if (ANONYMOUS_USER_ID == $this->user_obj->getId()) { ilUtil::sendInfo($this->lng->txt('click_to_continue_info')); $tpl->setVariable('TXT_BUY', $this->lng->txt('continue')); $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1'); } else { $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBMFGUI', '')); } } break; case 'epay': # Anonymous user has to login // if(ANONYMOUS_USER_ID == $ilUser->getId()) // { // $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); // $tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1'); // } // else // { // /// http://uk.epay.dk/support/docs.asp?solution=2#pfinput // $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); // $tpl->setVariable('SCRIPT_LINK', 'https://'.$this->epayConfig['server_host'].$this->epayConfig['server_path']); // $tpl->setVariable('MERCHANT_NUMBER', $this->epayConfig['merchant_number']); // $tpl->setVariable('AMOUNT', $total_price * 100); // $tpl->setVariable('CURRENCY', "208"); // $tpl->setVariable('ORDERID', $ilUser->getId()."_".uniqid()); // $tpl->setVariable('ACCEPT_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishEPay')); // $tpl->setVariable('DECLINE_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelEPay')); // $tpl->setVariable('INSTANT_CAPTURE', $this->epayConfig['instant_capture'] ? "1" : "0"); // $tpl->setVariable('ADDFEE', 1); // $tpl->setVariable('LANGUAGE', 1); // $tpl->setVariable('GROUP', ""); // $tpl->setVariable('CARDTYPE', ""); // $tpl->setVariable("CALLBACK_URL", ILIAS_HTTP_PATH . "/Services/Payment/classes/class.ilCallback.php?ilUser="******"&pay_method=". PAY_METHOD_EPAY); // // $tpl->setVariable('DESCRIPTION', $ilUser->getFullName() . " (" . $ilUser->getEmail() . ") #" . $ilUser->getId() . " " . implode(",", $desc)); // $tpl->setVariable('AUTH_MAIL', $this->epayConfig['auth_email']); // $tpl->setVariable('MD5KEY', $this->epSet->generateKeyForEpay(208, $total_price*100, $ilUser->getId()."_".uniqid())); // } break; case 'paypal': if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId()) { $tpl->touchBlock('attach_submit_event'); $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTarget($this, 'unlockPAYPALObjectsInShoppingCart')); } else { if (ANONYMOUS_USER_ID == $this->user_obj->getId()) { ilUtil::sendInfo($this->lng->txt('click_to_continue_info')); $tpl->touchBlock('attach_submit_event'); $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1'); } else { $tpl->setCurrentBlock('terms_checkbox'); ilUtil::sendInfo($this->lng->txt('click_to_buy_info')); $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy')); $tpl->setVariable('SCRIPT_LINK', 'https://' . $this->paypalConfig['server_host'] . $this->paypalConfig['server_path']); $tpl->parseCurrentBlock('terms_checkbox'); } } $tpl->setVariable('POPUP_BLOCKER', $this->lng->txt('popup_blocker')); $tpl->setVariable('VENDOR', $this->paypalConfig['vendor']); $tpl->setVariable('RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishPaypal')); $tpl->setVariable('CANCEL_RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelPaypal')); $tpl->setVariable('CUSTOM', $this->user_obj->getId()); $tpl->setVariable('CURRENCY', $genSet->get('currency_unit')); $tpl->setVariable('PAGE_STYLE', $this->paypalConfig['page_style']); if (!empty($_SESSION['coupons'][$coupon_session_id])) { $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session_id]); if (is_array($coupon_discount_items) && !empty($coupon_discount_items)) { foreach ($coupon_discount_items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId()); $obj_title = $ilObjDataCache->lookupTitle($obj_id); $tmp_amount = round($item['discount_price'], 2); $loop_items_amount = str_replace(',', '.', $tmp_amount); $tpl->setCurrentBlock('loop_items'); $tpl->setVariable('LOOP_ITEMS_NO', ++$paypal_counter); $tpl->setVariable('LOOP_ITEMS_NAME', "[" . $obj_id . "]: " . $obj_title); $tpl->setVariable('LOOP_ITEMS_AMOUNT', $loop_items_amount); $tpl->parseCurrentBlock('loop_items'); unset($tmp_pobject); } } } break; } if ($pay_method['pm_title'] == 'paypal') { $tpl->setVariable('PAYPAL_HINT', $this->lng->txt('pay_hint_paypal')); $tpl->setVariable('PAYPAL_INFO', $this->lng->txt('pay_info_paypal')); } else { if ($pay_method['pm_title'] == 'epay') { $tpl->setVariable('EPAY_HINT', $this->lng->txt('pay_hint_epay')); $tpl->setVariable('EPAY_INFO', $this->lng->txt('pay_info_epay')); } } $tpl->parseCurrentBlock('buy_link'); $tpl->setCurrentBlock('loop'); unset($f_result); $tpl->parseCurrentBlock('loop'); $this->tpl->setVariable('' . strtoupper($pay_method['pm_title']) . '', $tpl->get()); $num_items += $counter; } } if ($num_items == 0) { # ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty')); return false; } 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; } }
function getVat($a_amount = 0, $type = 'CALCULATION') { $oVAT = new ilShopVats($this->getVatId()); switch ($type) { case 'CALCULATION': $val = (double) ($a_amount - round($a_amount / (1 + $oVAT->getRate() / 100) * 100) / 100); return number_format((double) $val, '2', '.', ''); default: $val = (double) ($a_amount - round($a_amount / (1 + $oVAT->getRate() / 100) * 100) / 100); $val = ilShopUtils::_formatFloat($val); return $val; } }
public function performDeleteDeassignCrs() { include_once './Services/Payment/classes/class.ilShopUtils.php'; if (!isset($_GET['booking_id'])) { ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given')); $this->showStatistics(); return true; } $this->__initBookingObject(); $bookings = $this->booking_obj->getBookings(); $booking = $bookings[(int) $_GET['booking_id']]; $pobject_data = ilPaymentObject::_getObjectData($booking['pobject_id']); ilShopUtils::_deassignPurchasedCourseMemberRole($pobject_data['ref_id'], $booking['customer_id']); $this->booking_obj->setBookingId((int) $_GET['booking_id']); if (!$this->booking_obj->delete()) { die('Error deleting booking'); } ilUtil::sendInfo($this->lng->txt('pay_deleted_booking')); $this->showStatistics(); return true; }
public function __showShoppingCart() { include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); $this->psc_obj = new ilPaymentShoppingCart($this->user_obj); if (!count($items = $this->psc_obj->getEntries($this->pm_id))) { ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty')); } $counter = 0; foreach ($items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); $tmp_obj = ilObjectFactory::getInstanceByRefId($tmp_pobject->getRefId(), false); $price_arr = ilPaymentPrices::_getPrice($item['price_id']); $assigned_coupons = ''; if (!empty($_SESSION['coupons'][$this->session_var])) { 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())) { $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code']; } } } $f_result[$counter]['item'] = ''; if ($tmp_obj) { $f_result[$counter]['title'] = $tmp_obj->getTitle(); } else { $f_result[$counter]['title'] = $this->lng->txt('object_not_found'); } if ($assigned_coupons != '') { $f_result[$counter][count($f_result[$counter]) - 1] .= $assigned_coupons; } switch ($price_arr['price_type']) { case ilPaymentPrices::TYPE_DURATION_MONTH: $f_result[$counter]['duration'] = $price_arr['duration'] . ' ' . $this->lng->txt('paya_months'); break; case ilPaymentPrices::TYPE_DURATION_DATE: $f_result[$counter]['duration'] = ilDatePresentation::formatDate(new ilDate($price_arr['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price_arr['duration_until'], IL_CAL_DATE)); break; case ilPaymentPrices::TYPE_UNLIMITED_DURATION: $f_result[$counter]['duration'] = $this->lng->txt('unlimited_duration'); break; } $oVAT = new ilShopVats((int) $tmp_pobject->getVatId()); $f_result[$counter]['vat_rate'] = ilShopUtils::_formatVAT($oVAT->getRate()); $float_price = $price_arr['price']; $f_result[$counter]['vat_unit'] = $tmp_pobject->getVat($float_price, 'GUI') . ' ' . $genSet->get('currency_unit'); $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price); $f_result[$counter]['price'] = number_format($float_price, 2, ',', '.') . ' ' . $genSet->get('currency_unit'); unset($tmp_obj); unset($tmp_pobject); ++$counter; } return $this->__showItemsTable($f_result); }
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()); } }
public function editDetails($a_show_confirm = false) { /** * @var $ilToolbar ilToolbarGUI */ global $ilToolbar; include_once './Services/Payment/classes/class.ilPaymentSettings.php'; /** @var $genSet ilPaymentSettings */ $genSet = ilPaymentSettings::_getInstance(); if (!(int) $_GET['pobject_id']) { ilUtil::sendInfo($this->lng->txt('paya_no_object_selected')); return $this->showObjects(); } $this->__initPaymentObject((int) $_GET['pobject_id']); $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); /** @var $tmp_obj ilObject */ $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false); if (is_object($tmp_obj)) { $trash = ''; if (ilObject::_isInTrash($this->pobject->getRefId())) { $trash = ' (' . $this->lng->txt('object_deleted') . ')'; } $tmp_object['title'] = $tmp_obj->getTitle() . '' . $trash; $tmp_object['type'] = $tmp_obj->getType(); } else { $tmp_object['title'] = $this->lng->txt('object_not_found'); $tmp_object['type'] = false; } if ($a_show_confirm) { include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; $oConfirmationGUI = new ilConfirmationGUI(); // set confirm/cancel commands $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDelete")); $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object")); $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editDetails"); $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete"); $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']); $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML()); return true; } $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails')); $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices')); $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'edit')); include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $oForm = new ilPropertyFormGUI(); $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails')); $oForm->setTitle($tmp_object['title']); if ($tmp_object['type']) { $oForm->setTitleIcon(ilUtil::getImagePath('icon_' . $tmp_object['type'] . '_b.png')); } // repository path $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path')); $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId())); $oForm->addItem($oPathGUI); switch ($tmp_object['type']) { case 'exc': $exc_subtype_option = array(); $check_subtypes = ilPaymentObject::_checkExcSubtype($this->pobject->getRefId()); if (!in_array('download', $check_subtypes) || $this->pobject->getSubtype() == 'download') { $exc_subtype_option['download'] = $this->lng->txt('download'); } if (!in_array('upload', $check_subtypes) || $this->pobject->getSubtype() == 'upload') { $exc_subtype_option['upload'] = $this->lng->txt('upload'); } $oExcSubtype = new ilSelectInputGUI($this->lng->txt('select_subtype'), 'exc_subtype'); $oExcSubtype->setOptions($exc_subtype_option); $oExcSubtype->setValue($this->pobject->getSubtype()); $oForm->addItem($oExcSubtype); break; default: break; } // number of purchasers $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser')); $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id'])); $oForm->addItem($oPurchasersGUI); // vendors $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor'); $oVendorsGUI->setOptions($this->__getVendors()); $oVendorsGUI->setValue($this->pobject->getVendorId()); $oForm->addItem($oVendorsGUI); // status $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status'); $oStatusGUI->setOptions($this->__getStatus()); $oStatusGUI->setValue($this->pobject->getStatus()); $oForm->addItem($oStatusGUI); // pay methods $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method'); $PMoptions = ilPaymethods::getPayMethodsOptions('not_specified'); $oPayMethodsGUI->setOptions($PMoptions); $oPayMethodsGUI->setValue($this->pobject->getPayMethod()); $oForm->addItem($oPayMethodsGUI); // topics /** @var $shopTopicsObj ilShopTopics */ $shopTopicsObj = ilShopTopics::_getInstance(); $shopTopicsObj->read(); if (is_array($topics = $shopTopicsObj->getTopics()) && count($topics)) { $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id'); include_once 'Services/Payment/classes/class.ilShopTopics.php'; /** @var $shopTopicsObj ilShopTopics */ $shopTopicsObj = ilShopTopics::_getInstance(); $shopTopicsObj->read(); $topic_options = array(); $topic_options[''] = $this->lng->txt('please_choose'); /** @var $oTopic ilShopTopic */ foreach ($topics as $oTopic) { $topic_options[$oTopic->getId()] = $oTopic->getTitle(); } $oTopicsGUI->setOptions($topic_options); $oTopicsGUI->setValue($this->pobject->getTopicId()); $oForm->addItem($oTopicsGUI); } // vats $oShopVatsList = new ilShopVatsList(); $oShopVatsList->read(); if ($oShopVatsList->hasItems()) { $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id'); $vats_options = array(); /** @var $oVAT ilShopVats */ foreach ($oShopVatsList as $oVAT) { $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle(); } $oVatsGUI->setOptions($vats_options); $oVatsGUI->setValue($this->pobject->getVatId()); $oForm->addItem($oVatsGUI); } else { $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate')); $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned')); $oForm->addItem($oVatsGUI); } $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail'); $oFile = new ilFileDataShop($this->pobject->getPobjectId()); if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) { $oThumbnail->setImage($webpath_file); } $oForm->addItem($oThumbnail); if ($genSet->get('use_shop_specials')) { // special object $oSpecial = new ilCheckboxInputGUI($this->lng->txt('special'), 'is_special'); $oSpecial->setChecked((int) $this->pobject->getSpecial()); $oSpecial->setInfo($this->lng->txt('special_info')); $oForm->addItem($oSpecial); } // buttons $oForm->addCommandButton('updateDetails', $this->lng->txt('save')); $oForm->addCommandButton('deleteObject', $this->lng->txt('delete')); $this->tpl->setVariable('FORM', $oForm->getHTML()); return true; }