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());
 }
Пример #2
0
 public function purchase($tid)
 {
     global $lng;
     $this->getDebtor();
     $this->deb->createInvoice();
     $products = array();
     foreach ($this->sc as $i) {
         $pod = ilPaymentObject::_getObjectData($i['pobject_id']);
         $bo = new ilPaymentBookings($this->ilUser->getId());
         $ilias_tid = $this->ilUser->getId() . "_" . $tid;
         // psc_id, pobject_id, obj_id, typ, betrag_string
         $bo->setTransaction($ilias_tid);
         $bo->setPobjectId(isset($i['pobject_id']) ? $i['pobject_id'] : 0);
         $bo->setCustomerId($this->ilUser->getId());
         $bo->setVendorId($pod['vendor_id']);
         $bo->setPayMethod($this->paytype);
         $bo->setOrderDate(time());
         // $bo->setDuration($i['dauer']); // duration
         // $bo->setPrice(  $i['betrag'] ); // amount
         //$bo->setPrice( ilPaymentPrices::_getPriceString( $i['price_id'] ));
         $bo->setDuration($i['duration']);
         $bo->setPrice($i['price_string']);
         $bo->setDiscount(0);
         $bo->setVoucher('');
         $bo->setVatRate($i['vat_rate']);
         $bo->setVatUnit($i['vat_unit']);
         $bo->setTransactionExtern($tid);
         // $product_name = $i['buchungstext'];
         //$duration = $i['dauer'];
         //$amount = $i['betrag'];
         $product_name = $i['object_title'];
         $duration = $i['duration'];
         $amount = $i['price'];
         // -> ? $i['price_string']
         include_once './Services/Payment/classes/class.ilPayMethods.php';
         $save_adr = (int) ilPaymethods::_EnabledSaveUserAddress($this->paytype) ? 1 : 0;
         //if($save_adr == 1)
         //{
         $bo->setStreet($this->ilUser->getStreet(), '');
         $bo->setPoBox('');
         //$this->ilUser->);
         $bo->setZipcode($this->ilUser->getZipcode());
         $bo->setCity($this->ilUser->getCity());
         $bo->setCountry($this->ilUser->getCountry());
         //}
         $bo->setPayed(1);
         $bo->setAccess(1);
         $bo->setAccessExtension($this->sc['extension']);
         $boid = $bo->add();
         //$bo->update();
         if ($i['typ'] == 'crs') {
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             $this->deb->createInvoiceLine(0, $product_name . " (" . $duration . ")", 1, $amount);
             $products[] = $product_name;
             $obj_id = ilObject::_lookupObjId($pod["ref_id"]);
             $cp = ilCourseParticipants::_getInstanceByObjId($obj_id);
             $cp->add($this->ilUser->getId(), IL_CRS_MEMBER);
             $cp->sendNotification($cp->NOTIFY_ACCEPT_SUBSCRIBER, $this->ilUser->getId());
         }
     }
     $inv = $this->deb->bookInvoice();
     $invoice_number = $this->deb->getInvoiceNumber();
     $attach = $this->deb->getInvoicePDF($inv);
     $this->deb->saveInvoice($attach, false);
     $lng->loadLanguageModule('payment');
     $this->deb->sendInvoice($lng->txt('pay_order_paid_subject'), $this->ilUser->getFullName() . ",\n" . str_replace('%products%', implode(", ", $products), $lng->txt('pay_order_paid_body')), $this->ilUser->getEmail(), $attach, $lng->txt('pays_invoice') . "-" . $invoice_number);
     $this->cart->emptyShoppingCart();
 }
Пример #3
0
 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 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;
 }
Пример #5
0
 public function __addBookings($external_data = null)
 {
     global $ilUser, $ilObjDataCache;
     $sc = $this->psc_obj->getShoppingCart($this->pm_id);
     $total = 0;
     $total_vat = 0;
     $total_discount = 0;
     #		$this->psc_obj->clearCouponItemsSession();
     if (is_array($sc) && count($sc) > 0) {
         include_once './Services/Payment/classes/class.ilPaymentBookings.php';
         //@todo check $this->usr_obj
         $book_obj = new ilPaymentBookings($this->usr_obj);
         for ($i = 0; $i < count($sc); $i++) {
             if (!empty($_SESSION['coupons'][$this->session_var])) {
                 $sc[$i]['math_price'] = (double) $sc[$i]['price'];
                 $tmp_pobject = new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);
                 foreach ($_SESSION['coupons'][$this->session_var] as $key => $coupon) {
                     $this->coupon_obj->setId($coupon['pc_pk']);
                     $this->coupon_obj->setCurrentCoupon($coupon);
                     if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) {
                         $_SESSION['coupons'][$this->session_var][$key]['total_objects_coupon_price'] += (double) $sc[$i]['price'];
                         $_SESSION['coupons'][$this->session_var][$key]['items'][] = $sc[$i];
                     }
                 }
                 unset($tmp_pobject);
             }
         }
         $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION['coupons'][$this->session_var]);
         $transaction = ilInvoiceNumberPlaceholdersPropertyGUI::_generateInvoiceNumber($ilUser->getId());
         for ($i = 0; $i < count($sc); $i++) {
             $pobjectData = ilPaymentObject::_getObjectData($sc[$i]['pobject_id']);
             $pobject = new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);
             $price = $sc[$i]['price'];
             $bonus = 0.0;
             if (array_key_exists($sc[$i]['pobject_id'], $coupon_discount_items)) {
                 $bonus = $coupon_discount_items[$sc[$i]['pobject_id']]['math_price'] - $coupon_discount_items[$sc[$i]['pobject_id']]['discount_price'];
                 if ($bonus > 0) {
                     $discount = round($bonus, 2) * -1;
                 } else {
                     $discount = round($bonus, 2);
                 }
             }
             $book_obj->setTransaction($transaction);
             $book_obj->setPobjectId($sc[$i]['pobject_id']);
             $book_obj->setCustomerId($this->user_obj->getId());
             $book_obj->setVendorId($pobjectData['vendor_id']);
             $book_obj->setPayMethod($pobjectData['pay_method']);
             $book_obj->setOrderDate(time());
             $book_obj->setPrice($sc[$i]['price_string']);
             //$book_obj->setDiscount($bonus > 0 ? ilPaymentPrices::_getPriceStringFromAmount($bonus * (-1)) : '');
             $book_obj->setDiscount($discount);
             $book_obj->setPayed($this->getPayed());
             $book_obj->setAccess($this->getAccess());
             $book_obj->setVoucher('');
             // bmf
             $book_obj->setTransactionExtern('');
             // bmf , paypal
             $book_obj->setVatRate($sc[$i]['vat_rate']);
             $book_obj->setVatUnit($sc[$i]['vat_unit']);
             $book_obj->setObjectTitle(strip_tags($sc[$i]['object_title']));
             $book_obj->setAccessExtension($sc[$i]['extension']);
             switch ($sc[$i]["price_type"]) {
                 case ilPaymentPrices::TYPE_DURATION_MONTH:
                     $book_obj->setDuration($sc[$i]['duration']);
                     break;
                 case ilPaymentPrices::TYPE_DURATION_DATE:
                     $book_obj->setDuration(0);
                     $book_obj->setAccessStartdate($sc[$i]['duration_from']);
                     $book_obj->setAccessEnddate($sc[$i]['duration_until']);
                     break;
                 case ilPaymentPrices::TYPE_UNLIMITED_DURATION:
                     $book_obj->setDuration(0);
                     $book_obj->setAccessEnddate(NULL);
                     $book_obj->setUnlimitedDuration($sc[$i]['unlimited_duration']);
                     break;
             }
             $book_obj->setPriceType($sc[$i]["price_type"]);
             //
             if ($external_data) {
                 $book_obj->setVoucher($external_data['voucher']);
                 // bmf
                 $book_obj->setTransactionExtern($external_data['transaction_extern']);
                 // bmf, paypal
                 $book_obj->setStreet($external_data['street'], '');
                 $book_obj->setZipcode($external_data['zipcode']);
                 $book_obj->setCity($external_data['city']);
                 $book_obj->setCountry($external_data['country']);
             } else {
                 if (isset($_SESSION[$this->session_var]['personal_data'])) {
                     $book_obj->setStreet($_SESSION[$this->session_var]['personal_data']['street'], $_SESSION[$this->session_var]['personal_data']['house_number']);
                     $book_obj->setPoBox($_SESSION[$this->session_var]['personal_data']['po_box']);
                     $book_obj->setZipcode($_SESSION[$this->session_var]['personal_data']['zipcode']);
                     $book_obj->setCity($_SESSION[$this->session_var]['personal_data']['city']);
                     $book_obj->setCountry($_SESSION[$this->session_var]['personal_data']['country']);
                 } else {
                     $book_obj->setStreet($this->user_obj->getStreet(), '');
                     $book_obj->setPoBox($this->user_obj->getPoBox());
                     $book_obj->setZipcode($this->user_obj->getZipCode());
                     $book_obj->setCity($this->user_obj->getCity());
                     $book_obj->setCountry($this->user_obj->getCountry());
                 }
             }
             $booking_id = $book_obj->add();
             // add purchased item to desktop
             ilShopUtils::_addPurchasedObjToDesktop($pobject);
             // autosubscribe user if purchased object is a course
             $obj_type = ilObject::_lookupType((int) $pobject->getRefId(), true);
             if ($obj_type == 'crs') {
                 ilShopUtils::_assignPurchasedCourseMemberRole($pobject);
             }
             if (!empty($_SESSION['coupons'][$this->session_var]) && $booking_id) {
                 foreach ($_SESSION['coupons'][$this->session_var] as $coupon) {
                     $this->coupon_obj->setId($coupon['pc_pk']);
                     $this->coupon_obj->setCurrentCoupon($coupon);
                     if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId())) {
                         $this->coupon_obj->addCouponForBookingId($booking_id);
                     }
                 }
             }
             $obj_id = $ilObjDataCache->lookupObjId($pobjectData['ref_id']);
             $obj_type = $ilObjDataCache->lookupType($obj_id);
             $obj_title = $ilObjDataCache->lookupTitle($obj_id);
             $bookings['list'][] = array('pobject_id' => $sc[$i]['pobject_id'], 'type' => $obj_type, 'title' => '[' . $obj_id . ']: ' . $obj_title, 'duration' => $sc[$i]['duration'], 'vat_rate' => $sc[$i]['vat_rate'], 'vat_unit' => $sc[$i]['vat_unit'], 'price_string' => $sc[$i]['price_string'], 'price' => $sc[$i]['price'], "price_type" => $sc[$i]["price_type"], "duration_from" => $sc[$i]["duration_from"], "duration_until" => $sc[$i]["duration_until"], "b_pay_method" => $pobjectData["pay_method"], 'discount' => $discount, 'access_startdate' => $book_obj->getAccessStartdate(), 'access_enddate' => $book_obj->getAccessEnddate());
             $total += $sc[$i]['price'];
             $total_vat += $sc[$i]['vat_unit'];
             $total_discount += $discount;
             if ($sc[$i]['psc_id']) {
                 $this->psc_obj->delete($sc[$i]['psc_id']);
             }
         }
         if (!empty($_SESSION['coupons'][$this->session_var])) {
             foreach ($_SESSION['coupons'][$this->session_var] as $coupon) {
                 $this->coupon_obj->setId($coupon['pc_pk']);
                 $this->coupon_obj->setCurrentCoupon($coupon);
                 $this->coupon_obj->addTracking();
             }
         }
     }
     $bookings['total'] = $total;
     $bookings['total_vat'] = $total_vat;
     $bookings['total_discount'] = $total_discount;
     $bookings['transaction'] = $transaction;
     $bookings['street'] = $book_obj->getStreet();
     $bookings['zipcode'] = $book_obj->getZipCode();
     $bookings['city'] = $book_obj->getCity();
     if (2 == strlen($book_obj->getCountry())) {
         $bookings['country'] = $this->__getCountryName(strtoupper($book_obj->getCountry()));
     } else {
         $bookings['country'] = $book_obj->getCountry();
     }
     $bookings['transaction_extern'] = $book_obj->getTransactionExtern();
     $this->user_obj->_toggleActiveStatusOfUsers(array($this->user_obj->getId()), 1);
     $_SESSION['forceRedirectToShoppingcart'] = 1;
     $this->__sendBill($bookings);
 }
 public function 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());
 }