Esempio n. 1
0
 /**
  * Reads the vat datasets from database.
  * 
  * @access	public 
  * @return	ilShopVatsList
  *  
  */
 public function read()
 {
     $this->vat_list = array();
     $query = "SELECT * FROM payment_vats ";
     $query .= "WHERE 1 = 1 ";
     if (!in_array($this->getOrderColumn(), array('vat_title', 'vat_rate'))) {
         $this->setOrderColumn('vat_rate');
         $this->setOrderDirection('ASC');
     }
     $order_limit = " ORDER BY " . $this->getOrderColumn() . " " . strtoupper($this->getOrderDirection()) . " ";
     if ((int) $this->getListMax()) {
         $order_limit .= "LIMIT " . $this->getListStart() . ", " . $this->getListMax();
     }
     $res = $this->db->query($query . $order_limit);
     while ($row = $this->db->fetchObject($res)) {
         $oVAT = new ilShopVats();
         $oVAT->setId($row->vat_id);
         $oVAT->setTitle($row->vat_title);
         $oVAT->setRate($row->vat_rate);
         $this->vat_list[$oVAT->getId()] = $oVAT;
     }
     $res = $this->db->query(str_replace('*', 'COUNT(vat_id) AS num_vat_list', $query));
     while ($row = $this->db->fetchObject($res)) {
         $this->num_vat_list = $row->num_vat_list;
         break;
     }
     return $this;
 }
 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&amp;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;
 }
 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 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 __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);
 }
 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 showObjects()
 {
     /** 
      * @var $ilToolbar ilToolbarGUI */
     global $ilToolbar;
     include_once './Services/Payment/classes/class.ilPayMethods.php';
     $ilToolbar->addButton($this->lng->txt('paya_sell_object'), $this->ctrl->getLinkTarget($this, 'showObjectSelector'));
     if (!$_POST['show_filter'] && $_POST['updateView'] == '1') {
         $this->resetObjectFilter();
     } else {
         if ($_POST['updateView'] == 1) {
             $_SESSION['pay_objects']['updateView'] = $_POST['updateView'];
             $_SESSION['pay_objects']['show_filter'] = $_POST['show_filter'];
             $_SESSION['pay_objects']['title_type'] = $_POST['title_type'];
             $_SESSION['pay_objects']['title_value'] = $_POST['title_value'];
             $_SESSION['pay_objects']['pay_method'] = $_POST['pay_method'];
             $_SESSION['pay_objects']['vendor'] = $_POST['vendor'];
         }
     }
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $this->__initPaymentObject();
     $this->lng->loadLanguageModule('search');
     $filter_form = new ilPropertyFormGUI();
     $filter_form->setFormAction($this->ctrl->getFormAction($this));
     $filter_form->setTitle($this->lng->txt('pay_filter'));
     $filter_form->setId('filter_form');
     $filter_form->setTableWidth('100 %');
     //hide_filter
     $o_hide_check = new ilCheckBoxInputGUI($this->lng->txt('show_filter'), 'show_filter');
     $o_hide_check->setValue(1);
     $o_hide_check->setChecked($_SESSION['pay_objects']['show_filter'] ? 1 : 0);
     $o_hidden = new ilHiddenInputGUI('updateView');
     $o_hidden->setValue(1);
     $o_hidden->setPostVar('updateView');
     $o_hide_check->addSubItem($o_hidden);
     //title
     $radio_group = new ilRadioGroupInputGUI($this->lng->txt('search_in_title'), 'title_type');
     $radio_option = new ilRadioOption($this->lng->txt('search_any_word'), 'or');
     $radio_group->addOption($radio_option);
     $radio_option = new ilRadioOption($this->lng->txt('search_all_words'), 'and');
     $radio_group->addOption($radio_option);
     $radio_group->setRequired(false);
     $radio_group->setValue('or');
     $radio_group->setPostVar('title_type');
     $o_title = new ilTextInputGUI();
     $o_title->setValue($_SESSION['pay_objects']['title_value']);
     $o_title->setPostVar('title_value');
     $o_title->setTitle($this->lng->txt('title'));
     $o_hide_check->addSubItem($radio_group);
     $o_hide_check->addSubItem($o_title);
     //vendor
     $o_vendor = new ilTextInputGUI();
     $o_vendor->setTitle($this->lng->txt('paya_vendor'));
     $o_vendor->setValue($_SESSION['pay_objects']['vendor']);
     $o_vendor->setPostVar('vendor');
     $o_hide_check->addSubItem($o_vendor);
     // paymethod
     $o_paymethod = new ilSelectInputGUI();
     $o_paymethod->setTitle($this->lng->txt('payment_system'));
     $o_paymethod->setOptions(ilPaymethods::getPayMethodsOptions('all'));
     $o_paymethod->setValue($_SESSION['pay_objects']['pay_method']);
     $o_paymethod->setPostVar('pay_method');
     $o_hide_check->addSubItem($o_paymethod);
     $filter_form->addCommandButton('showObjects', $this->lng->txt('pay_update_view'));
     $filter_form->addCommandButton('resetObjectFilter', $this->lng->txt('pay_reset_filter'));
     $filter_form->addItem($o_hide_check);
     if (!count($objects = ilPaymentObject::_getObjectsData($this->user_obj->getId()))) {
         ilUtil::sendInfo($this->lng->txt('paya_no_objects_assigned'));
         return true;
     }
     $this->tpl->setVariable('FORM', $filter_form->getHTML());
     $counter = 0;
     foreach ($objects as $data) {
         /** @var $tmp_obj ilObject */
         $tmp_obj = ilObjectFactory::getInstanceByRefId($data['ref_id'], false);
         if ($tmp_obj) {
             $f_result[$counter]['title'] = $tmp_obj->getTitle();
         } else {
             $f_result[$counter]['title'] = $this->lng->txt('object_not_found');
         }
         switch ($data['status']) {
             case $this->pobject->STATUS_BUYABLE:
                 $f_result[$counter]['status'] = $this->lng->txt('paya_buyable');
                 break;
             case $this->pobject->STATUS_NOT_BUYABLE:
                 $f_result[$counter]['status'] = $this->lng->txt('paya_not_buyable');
                 break;
             case $this->pobject->STATUS_EXPIRES:
                 $f_result[$counter]['status'] = $this->lng->txt('paya_expires');
                 break;
         }
         $str_paymethod = ilPayMethods::getStringByPaymethod($data['pay_method']);
         $f_result[$counter]['pay_method'] = $str_paymethod;
         if ($data['vat_id'] <= 0) {
             $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
         } else {
             try {
                 $oVAT = new ilShopVats((int) $data['vat_id']);
                 $vat_rate = ilShopUtils::_formatVAT((double) $oVAT->getRate());
             } catch (ilShopException $e) {
                 $vat_rate = $this->lng->txt('payment_vat_has_to_be_defined_by_administration_short');
             }
         }
         $f_result[$counter]['vat_rate'] = $vat_rate;
         /** @var $tmp_user ilObjUser */
         $tmp_user = ilObjectFactory::getInstanceByObjId($data['vendor_id']);
         $f_result[$counter]['vendor'] = $tmp_user->getFullname() . ' [' . $tmp_user->getLogin() . ']';
         // Get number of purchasers
         $f_result[$counter]['purchasers'] = ilPaymentBookings::_getCountBookingsByObject($data['pobject_id']);
         // edit link
         $this->ctrl->setParameter($this, 'pobject_id', $data['pobject_id']);
         $link_change = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"" . $this->ctrl->getLinkTarget($this, "editDetails") . "\">" . $this->lng->txt("edit") . "</a></div>";
         $f_result[$counter]['options'] = $link_change;
         unset($tmp_user);
         unset($tmp_obj);
         ++$counter;
     }
     return $this->__showObjectsTable($f_result);
 }