private function showItemsTable(&$a_tpl, $a_result_set, $a_pay_method = 0) { include_once './Services/Payment/classes/class.ilPaymentSettings.php'; $genSet = ilPaymentSettings::_getInstance(); include_once './Services/Payment/classes/class.ilShoppingCartTableGUI.php'; $tbl = new ilShoppingCartTableGUI($this); $tbl->setId('tbl_id_' . $a_pay_method); $tbl->setTitle($this->lng->txt('paya_shopping_cart') . " (" . $this->lng->txt('payment_system') . ": " . ilPayMethods::getStringByPaymethod($a_pay_method['pm_title']) . ")"); $coupon_session = $a_pay_method['pm_title']; $tbl->setRowTemplate("tpl.shop_shoppingcart_row.html", "Services/Payment"); $tbl->addColumn('', 'item', '1%', true); $tbl->addColumn($this->lng->txt('title'), "table" . $a_pay_method['pm_title'] . "_title", '30%'); $tbl->addColumn($this->lng->txt('duration'), "table" . $a_pay_method['pm_title'] . "_duration", '30%'); $tbl->addColumn($this->lng->txt('vat_rate'), "table" . $a_pay_method['pm_title'] . "_vat_rate", '15%'); $tbl->addColumn($this->lng->txt('vat_unit'), "table" . $a_pay_method['pm_title'] . "_vat_unit", '15%'); $tbl->addColumn($this->lng->txt('price_a'), "table" . $a_pay_method['pm_title'] . "_price", '10%'); $tbl->setPrefix("table" . $a_pay_method['pm_title'] . "_"); $tbl->addMultiCommand('deleteItem', $this->lng->txt('delete')); // show total amount of costs $sc_obj = new ilPaymentShoppingCart($this->user_obj); $totalAmount = $sc_obj->getTotalAmount(); if (!empty($_SESSION['coupons'][$coupon_session])) { if (count($items = $sc_obj->getEntries($a_pay_method['pm_id']))) { $tbl->setTotalData('TXT_SUB_TOTAL', $this->lng->txt('pay_bmf_subtotal_amount') . ": "); $tbl->setTotalData('VAL_SUB_TOTAL', number_format($totalAmount[$a_pay_method['pm_id']], 2, ',', '.') . " " . $genSet->get('currency_unit')); foreach ($_SESSION['coupons'][$coupon_session] as $coupon) { $this->coupon_obj->setId($coupon['pc_pk']); $this->coupon_obj->setCurrentCoupon($coupon); $total_object_price = 0.0; $current_coupon_bonus = 0.0; foreach ($items as $item) { $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $price_data = ilPaymentPrices::_getPrice($item['price_id']); $price = (double) $price_data['price']; $total_object_price += $price; } unset($tmp_pobject); } $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price); $totalAmount[$current_coupon_bonus] += $current_coupon_bonus * -1; } $tbl->setTotalData('TXT_COUPON_BONUS', $this->lng->txt('paya_coupons_coupon') . ": "); # . $coupon['pcc_code'] . ": "); #$tbl->setTotalData('VAL_COUPON_BONUS', number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get('currency_unit')); $tbl->setTotalData('VAL_COUPON_BONUS', number_format($totalAmount[$current_coupon_bonus], 2, ',', '.') . " " . $genSet->get('currency_unit')); if ($totalAmount[$a_pay_method['pm_id']] < 0) { $totalAmount[$a_pay_method['pm_id']] = 0; $this->totalVat = 0; } } } $this->totalAmount[$a_pay_method['pm_id']] = $totalAmount[$a_pay_method['pm_id']] - $totalAmount[$current_coupon_bonus] * -1; $tbl->setTotalData('TXT_TOTAL_AMOUNT', $this->lng->txt('pay_bmf_total_amount') . ": "); $tbl->setTotalData('VAL_TOTAL_AMOUNT', number_format($this->totalAmount[$a_pay_method['pm_id']], 2, ',', '.') . " " . $genSet->get('currency_unit')); #.$item['currency']); if ($this->totalVat > 0) { $tbl->setTotalData('TXT_TOTAL_VAT', $this->lng->txt('pay_bmf_vat_included') . ": "); $tbl->setTotalData('VAL_TOTAL_VAT', number_format($this->totalVat, 2, ',', '.') . " " . $genSet->get('currency_unit')); } $tbl->setData($a_result_set); $a_tpl->setVariable('ITEMS_TABLE', $tbl->getCartHTML()); return true; }
public function payMethodsObject($askForDeletingAddresses = array()) { include_once './Services/Payment/classes/class.ilPayMethods.php'; global $rbacsystem, $ilCtrl; $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); if (!$rbacsystem->checkAccess('read', $this->object->getRefId())) { $this->ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilErr->MESSAGE); } if (count($askForDeletingAddresses)) { $oConfirmationGUI = new ilConfirmationGUI(); // set confirm/cancel commands $oConfirmationGUI->setFormAction($ilCtrl->getFormAction($this, "deleteAddressesForPaymethods")); $oConfirmationGUI->setHeaderText($this->lng->txt("info_delete_sure")); $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "payMethods"); $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "deleteAddressesForPaymethods"); foreach ($askForDeletingAddresses as $pm_id) { $pm_obj = new ilPayMethods($pm_id); $oConfirmationGUI->additem('paymethod[' . $pm_obj->getPmId() . ']', $pm_obj->getPmId(), $this->lng->txt('delete_addresses_bill') . ' -> ' . ilPayMethods::getStringByPaymethod($pm_obj->getPmTitle())); } $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHtml()); return true; } $obj_paymethods = new ilPayMethods(); $paymethods = $obj_paymethods->readAll(); $result = array(); $counter = 0; foreach ($paymethods as $paymethod) { if ($paymethod['pm_title'] != 'epay') { $result[$counter]['pm_title'] = ilPayMethods::getStringByPaymethod($paymethod['pm_title']); $result[$counter]['pm_enabled'] = ilUtil::formCheckbox($paymethod['pm_enabled'] ? 1 : 0, 'pm_enabled[' . $paymethod['pm_id'] . ']', 1); $result[$counter]['save_usr_adr'] = ilUtil::formCheckbox($paymethod['save_usr_adr'] ? 1 : 0, 'save_usr_adr[' . $paymethod['pm_id'] . ']', 1); $this->ctrl->clearParameters($this); $counter++; } } $this->ctrl->setParameter($this, 'cmd', 'savePayMethods'); $tbl = new ilShopTableGUI($this); $tbl->setTitle($this->lng->txt('pays_pay_methods')); $tbl->setId('tbl_paymethods'); $tbl->setRowTemplate("tpl.shop_paymethods_row.html", "Services/Payment"); $tbl->addColumn($this->lng->txt('title'), 'pm_title', '10%'); $tbl->addColumn($this->lng->txt('enabled'), 'pm_enabled', '10%'); $tbl->addColumn($this->lng->txt('save_customer_address'), 'save_usr_adr', '10%'); $tbl->addCommandButton('savePayMethods', $this->lng->txt('save')); $tbl->disable('sort'); $tbl->setData($result); $this->tpl->setVariable('TABLE', $tbl->getHTML()); return true; }
public static function getPayMethodsOptions($type = 0) { global $ilDB, $lng; $res = $ilDB->query('SELECT * FROM payment_paymethods WHERE pm_enabled = 1'); $options = array(); //this is only for additional entries in SelectInputGUIs switch ($type) { case 'all': $options['all'] = $lng->txt('pay_all'); break; case 'not_specified': $options[0] = $lng->txt('paya_pay_method_not_specified'); break; //default: break; } while ($row = $ilDB->fetchAssoc($res)) { $options[$row['pm_id']] = ilPayMethods::getStringByPaymethod($row['pm_title']); } return $options; }
public function editStatistic($a_show_confirm_delete = false) { global $ilToolbar; if (!isset($_GET['booking_id'])) { ilUtil::sendInfo($this->lng->txt('paya_no_booking_id_given')); $this->showStatistics(); return true; } include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'showStatistics')); $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); $this->ctrl->setParameter($this, 'booking_id', (int) $_GET['booking_id']); $this->__initBookingObject(); $bookings = $this->booking_obj->getBookings(); $booking = $bookings[(int) $_GET['booking_id']]; // confirm delete if ($a_show_confirm_delete) { $pobject_data = ilPaymentObject::_getObjectData($booking['pobject_id']); $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pobject_data['ref_id'])); $type = ilObject::_lookupType(ilObject::_lookupObjId($pobject_data['ref_id'])); $oConfirmationGUI = new ilConfirmationGUI(); // set confirm/cancel commands $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performDelete")); $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_stat")); $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "editStatistic"); if ($type == 'crs') { $oConfirmationGUI->addButton($this->lng->txt("confirm"), "performDeleteDeassignCrs"); } else { $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performDelete"); } $oConfirmationGUI->addItem('booking_id', $_GET['booking_id'], $tmp_obj); $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML()); return true; } // get customer_obj $tmp_user = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false); $oForm = new ilPropertyFormGUI(); $oForm->setFormAction($this->ctrl->getFormAction($this)); $oForm->setId('stat_form'); $oForm->setTableWidth('50 %'); if (is_object($tmp_user)) { $frm_user = $tmp_user->getFullname() . ' [' . $tmp_user->getLogin() . ']'; } else { $frm_user = $this->lng->txt('user_deleted'); } $oForm->setTitle($frm_user); $pObj = new ilPaymentObject($this->user_obj, $booking['pobject_id']); $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($pObj->getRefId())); // object_title $oTitleGUI = new ilNonEditableValueGUI($this->lng->txt('title')); $oTitleGUI->setValue($tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')); $oForm->addItem($oTitleGUI); // transaction $oTransactionGUI = new ilNonEditableValueGUI($this->lng->txt('paya_transaction')); $oTransactionGUI->setValue($booking['transaction']); $oForm->addItem($oTransactionGUI); //vendor $oVendorGUI = new ilNonEditableValueGUI($this->lng->txt('paya_vendor')); $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false); if (is_object($tmp_vendor)) { $frm_vendor = $tmp_vendor->getFullname() . ' [' . $tmp_vendor->getLogin() . ']'; } else { $frm_vendor = $this->lng->txt('user_deleted'); } $oVendorGUI->setValue($frm_vendor); $oForm->addItem($oVendorGUI); // paymethod $oPaymethodGUI = new ilNonEditableValueGUI($this->lng->txt('paya_pay_method')); $oPaymethodGUI->setValue(ilPayMethods::getStringByPaymethod($booking['b_pay_method'])); $oForm->addItem($oPaymethodGUI); // order_date $oOrderdateGUI = new ilNonEditableValueGUI($this->lng->txt('paya_order_date')); $oOrderdateGUI->setValue(ilDatePresentation::formatDate(new ilDateTime($booking["order_date"], IL_CAL_UNIX))); $oForm->addItem($oOrderdateGUI); // duration $oDurationGUI = new ilNonEditableValueGUI($this->lng->txt('duration')); if ($booking['duration'] == 0 && $booking['access_enddate'] == NULL) { $frm_duration = $this->lng->txt("unlimited_duration"); } else { if ($booking['duration'] > 0) { $frm_duration = $booking['duration'] . ' ' . $this->lng->txt('paya_months'); } $frm_duration .= ilDatePresentation::formatDate(new ilDate($booking['access_startdate'], IL_CAL_DATETIME)) . ' - ' . ilDatePresentation::formatDate(new ilDate($booking['access_enddate'], IL_CAL_DATETIME)); } $oDurationGUI->setValue($frm_duration); $oForm->addItem($oDurationGUI); // price $oPriceGUI = new ilNonEditableValueGUI($this->lng->txt('price_a')); $oPriceGUI->setValue($booking['price'] . ' ' . $booking['currency_unit']); $oForm->addItem($oPriceGUI); // payed $oPayedGUI = new ilSelectInputGUI(); $payed_option = array(0 => $this->lng->txt('no'), 1 => $this->lng->txt('yes')); $oPayedGUI->setTitle($this->lng->txt('paya_payed')); $oPayedGUI->setOptions($payed_option); $oPayedGUI->setValue($booking['payed']); $oPayedGUI->setPostVar('payed'); $oForm->addItem($oPayedGUI); // access $oAccessGUI = new ilSelectInputGUI(); $access_option = array(0 => $this->lng->txt('no'), 1 => $this->lng->txt('yes')); $oAccessGUI->setTitle($this->lng->txt('paya_access')); $oAccessGUI->setOptions($access_option); $oAccessGUI->setValue($booking['access_granted']); $oAccessGUI->setPostVar('access'); $oForm->addItem($oAccessGUI); $oForm->addCommandButton('updateStatistic', $this->lng->txt('save')); $oForm->addCommandButton('deleteStatistic', $this->lng->txt('delete')); $this->tpl->setVariable('FORM', $oForm->getHTML()); /* //Same output as in ilobjpaymentsettingsgui->statistics // show CUSTOMER_DATA if isset -> setting: save_user_address if(ilPayMethods::isCustomerAddressEnabled($booking['b_pay_method'])) { $oForm2 = new ilPropertyFormGUI(); $oForm2->setId('cust_form'); $oForm2->setTableWidth('50 %'); $oForm2->setTitle($frm_user); // email $oEmailGUI = new ilNonEditableValueGUI($this->lng->txt('email')); $email = (!isset($tmp_user)) ? $this->lng->txt('user_deleted') : $tmp_user->getEmail(); $oEmailGUI->setValue($email); $oForm2->addItem($oEmailGUI); // street $oStreetGUI = new ilNonEditableValueGUI($this->lng->txt('street')); $oStreetGUI->setValue($booking['street']); $oForm2->addItem($oStreetGUI); // pobox $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('pay_bmf_po_box')); $oPoBoxGUI->setValue($booking['po_box']); $oForm2->addItem($oPoBoxGUI); // zipcode $oPoBoxGUI = new ilNonEditableValueGUI($this->lng->txt('zipcode')); $oPoBoxGUI->setValue($booking['zipcode']); $oForm2->addItem($oPoBoxGUI); // city $oCityGUI = new ilNonEditableValueGUI($this->lng->txt('city')); $oCityGUI->setValue($booking['city']); $oForm2->addItem($oCityGUI); // country $oCountryGUI = new ilNonEditableValueGUI($this->lng->txt('country')); $oCountryGUI->setValue($booking['country']); $oForm2->addItem($oCountryGUI); } $this->tpl->setVariable('FORM_2',$oForm2->getHTML()); */ return true; }
public function showItems() { include_once "./Services/Repository/classes/class.ilRepositoryExplorer.php"; $this->initBookingsObject(); $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment'); if (!count($bookings = ilPaymentBookings::getBookingsOfCustomer($this->user_obj->getId()))) { ilUtil::sendInfo($this->lng->txt('pay_not_buyed_any_object')); return true; } $counter = 0; foreach ($bookings as $booking) { $tmp_obj = ilObjectFactory::getInstanceByRefId($booking['ref_id'], false); $tmp_vendor = ilObjectFactory::getInstanceByObjId($booking['b_vendor_id'], false); $tmp_purchaser = ilObjectFactory::getInstanceByObjId($booking['customer_id'], false); $transaction = $booking['transaction']; include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']); $transaction .= " (" . $str_paymethod . ")"; $f_result[$counter]['transaction'] = $transaction; if ($tmp_obj) { $obj_link = ilRepositoryExplorer::buildLinkTarget($booking['ref_id'], $tmp_obj->getType()); $obj_target = ilRepositoryExplorer::buildFrameTarget($tmp_obj->getType(), $booking['ref_id'], $tmp_obj->getId()); $f_result[$counter]['object_title'] = "<a href=\"" . $obj_link . "\" target=\"" . $obj_target . "\">" . $tmp_obj->getTitle() . "</a>"; } else { $obj_link = ''; $obj_target = ''; $f_result[$counter]['object_title'] = $booking['object_title'] . '<br> (' . $this->lng->txt('object_deleted') . ')'; } $f_result[$counter]['vendor'] = '[' . $tmp_vendor->getLogin() . ']'; $f_result[$counter]['customer'] = '[' . $tmp_purchaser->getLogin() . ']'; $f_result[$counter]['order_date'] = ilDatePresentation::formatDate(new ilDateTime($booking['order_date'], IL_CAL_UNIX)); //todo check for accessduration!! if ($booking['duration'] == 0 && $booking['access_enddate'] == NULL) { $f_result[$counter]['duration'] = $this->lng->txt("unlimited_duration"); } else { if ($booking['duration'] > 0) { $f_result[$counter]['duration'] = $booking['duration'] . ' ' . $this->lng->txt('paya_months'); } $f_result[$counter]['duration'] .= ilDatePresentation::formatDate(new ilDateTime($booking['access_startdate'], IL_CAL_DATETIME)) . ' - ' . ilDatePresentation::formatDate(new ilDateTime($booking['access_enddate'], IL_CAL_DATETIME)); } $f_result[$counter]['price'] = $booking['price'] . ' ' . $booking['currency_unit']; $f_result[$counter]['discount'] = $booking['discount'] != '' ? round($booking['discount'], 2) . ' ' . $booking['currency_unit'] : ' '; $payed_access = $booking['payed'] ? $this->lng->txt('yes') : $this->lng->txt('no'); $payed_access .= '/'; $payed_access .= $booking['access_granted'] ? $this->lng->txt('yes') : $this->lng->txt('no'); $f_result[$counter]['payed_access'] = $payed_access; unset($tmp_obj); unset($tmp_vendor); unset($tmp_purchaser); ++$counter; } return $this->showStatisticTable($f_result); }
public function __sendBill($bookings) { global $tpl, $ilSetting; $i = 0; include_once './Services/UICore/classes/class.ilTemplate.php'; include_once './Services/Utilities/classes/class.ilUtil.php'; include_once './Services/Payment/classes/class.ilPaymentSettings.php'; include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php'; include_once 'Services/Mail/classes/class.ilMimeMail.php'; // $psc_obj = new ilPaymentShoppingCart($this->user_obj); $genSet = ilPaymentSettings::_getInstance(); $currency = $genSet->get('currency_unit'); // $tpl = new ilTemplate('./Services/Payment/templates/default/tpl.pay_bill.html', true, true, true); $tpl = new ilTemplate('tpl.pay_bill.html', true, true, 'Services/Payment'); if ($tpl->placeholderExists('HTTP_PATH')) { $http_path = ilUtil::_getHttpPath(); $tpl->setVariable('HTTP_PATH', $http_path); } ilDatePresentation::setUseRelativeDates(false); $tpl->setVariable('DATE', utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['order_date'], IL_CAL_UNIX)))); $tpl->setVariable('TXT_CREDIT', utf8_decode($this->lng->txt('credit'))); $tpl->setVariable('TXT_DAY_OF_SERVICE_PROVISION', $this->lng->txt('day_of_service_provision')); include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($bookings['list'][$i]['b_pay_method']); if (strlen(trim($bookings['transaction_extern']))) { $tpl->setVariable('TXT_EXTERNAL_BILL_NO', str_replace('%s', $str_paymethod, utf8_decode($this->lng->txt('external_bill_no')))); $tpl->setVariable('EXTERNAL_BILL_NO', $bookings['transaction_extern']); } $tpl->setVariable('TXT_POSITION', $this->lng->txt('position')); $tpl->setVariable('TXT_AMOUNT', $this->lng->txt('amount')); $tpl->setVariable('TXT_UNIT_PRICE', utf8_decode($this->lng->txt('unit_price'))); $tpl->setVariable('VENDOR_ADDRESS', nl2br(utf8_decode($genSet->get('address')))); $tpl->setVariable('VENDOR_ADD_INFO', nl2br(utf8_decode($genSet->get('add_info')))); $tpl->setVariable('VENDOR_BANK_DATA', nl2br(utf8_decode($genSet->get('bank_data')))); $tpl->setVariable('TXT_BANK_DATA', utf8_decode($this->lng->txt('pay_bank_data'))); $tpl->setVariable('CUSTOMER_FIRSTNAME', utf8_decode($this->user_obj->getFirstname())); $tpl->setVariable('CUSTOMER_LASTNAME', utf8_decode($this->user_obj->getLastname())); if ($bookings['po_box'] == '') { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings['street'])); // contains also housenumber } else { $tpl->setVariable('CUSTOMER_STREET', utf8_decode($bookings['po_box'])); } $tpl->setVariable('CUSTOMER_ZIPCODE', utf8_decode($bookings['zipcode'])); $tpl->setVariable('CUSTOMER_CITY', utf8_decode($bookings['city'])); $tpl->setVariable('CUSTOMER_COUNTRY', utf8_decode($bookings['country'])); $tpl->setVariable('BILL_NO', $bookings['transaction']); $tpl->setVariable('DATE', date('d.m.Y')); $tpl->setVariable('TXT_BILL', utf8_decode($this->lng->txt('pays_bill'))); $tpl->setVariable('TXT_BILL_NO', utf8_decode($this->lng->txt('pay_bill_no'))); $tpl->setVariable('TXT_DATE', utf8_decode($this->lng->txt('date'))); $tpl->setVariable('TXT_ARTICLE', utf8_decode($this->lng->txt('pay_article'))); $tpl->setVariable('TXT_VAT_RATE', utf8_decode($this->lng->txt('vat_rate'))); $tpl->setVariable('TXT_VAT_UNIT', utf8_decode($this->lng->txt('vat_unit'))); $tpl->setVariable('TXT_PRICE', utf8_decode($this->lng->txt('price_a'))); for ($i = 0; $i < count($bookings['list']); $i++) { $tmp_pobject = new ilPaymentObject($this->user_obj, $bookings['list'][$i]['pobject_id']); $assigned_coupons = ''; 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); if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) { $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code']; } } } $tpl->setCurrentBlock('loop'); $tpl->setVariable('LOOP_POSITION', $i + 1); $tpl->setVariable('LOOP_AMOUNT', '1'); $tpl->setVariable('LOOP_TXT_PERIOD_OF_SERVICE_PROVISION', utf8_decode($this->lng->txt('period_of_service_provision'))); $tpl->setVariable('LOOP_OBJ_TYPE', utf8_decode($this->lng->txt($bookings['list'][$i]['type']))); $tpl->setVariable('LOOP_TITLE', $tmp = utf8_decode($bookings['list'][$i]['title'])); $tpl->setVariable('LOOP_COUPON', utf8_decode($assigned_coupons)); $tpl->setVariable('LOOP_TXT_ENTITLED_RETRIEVE', utf8_decode($this->lng->txt('pay_entitled_retrieve'))); if ($bookings['list'][$i]['duration'] == 0 && $bookings['list'][$i]['access_enddate'] == NULL) { $tpl->setVariable('LOOP_DURATION', utf8_decode($this->lng->txt('unlimited_duration'))); } else { $access_startdate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['access_startdate'], IL_CAL_DATE))); $access_enddate = utf8_decode(ilDatePresentation::formatDate(new ilDate($bookings['list'][$i]['access_enddate'], IL_CAL_DATE))); $tmp_duration = $access_startdate . ' - ' . $access_enddate; if ($bookings['list'][$i]['duration'] > 0) { $tmp_duration .= ' / ' . $bookings['list'][$i]['duration'] . ' ' . utf8_decode($this->lng->txt('paya_months')); } $tpl->setVariable('LOOP_DURATION', $tmp_duration); } #$currency = $bookings['list'][$i]['currency_unit']; $tpl->setVariable('LOOP_VAT_RATE', number_format($bookings['list'][$i]['vat_rate'], 2, ',', '.') . ' %'); $tpl->setVariable('LOOP_VAT_UNIT', number_format($bookings['list'][$i]['vat_unit'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_PRICE', number_format($bookings['list'][$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('LOOP_UNIT_PRICE', number_format($bookings['list'][$i]['price'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock('loop'); $bookings['total'] += (double) $bookings[$i]['price']; $bookings['total_vat'] += (double) $bookings[$i]['vat_unit']; #$bookings['total_discount'] +=(float) $bookings[$i]['discount']; unset($tmp_pobject); $sub_total_amount = $bookings['total']; } $bookings['total'] += $bookings['total_discount']; if ($bookings['total_discount'] < 0) { $tpl->setCurrentBlock('cloop'); $tpl->setVariable('TXT_SUBTOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_subtotal_amount'))); $tpl->setVariable('SUBTOTAL_AMOUNT', number_format($sub_total_amount, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_COUPON', utf8_decode($this->lng->txt('paya_coupons_coupon'))); $tpl->setVariable('BONUS', number_format($bookings['total_discount'], 2, ',', '.') . ' ' . $currency); $tpl->parseCurrentBlock(); } if ($bookings['total'] < 0) { $bookings['total'] = 0.0; // $bookings['total_vat'] = 0.0; } $total_net_price = $sub_total_amount - $bookings['total_vat']; $tpl->setVariable('TXT_TOTAL_NETPRICE', utf8_decode($this->lng->txt('total_netprice'))); $tpl->setVariable('TOTAL_NETPRICE', number_format($total_net_price, 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_AMOUNT', utf8_decode($this->lng->txt('pay_bmf_total_amount'))); $tpl->setVariable('TOTAL_AMOUNT', number_format($bookings['total'], 2, ',', '.') . ' ' . $currency); if ($bookings['total_vat'] > 0) { $tpl->setVariable('TOTAL_VAT', number_format($bookings['total_vat'], 2, ',', '.') . ' ' . $currency); $tpl->setVariable('TXT_TOTAL_VAT', utf8_decode($this->lng->txt('plus_vat'))); } if (1 == $bookings['list'][0]['b_pay_method']) { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_unpayed_bill'))); } else { $tpl->setVariable('TXT_PAYMENT_TYPE', utf8_decode($this->lng->txt('pay_payed_bill'))); } if (!@file_exists($genSet->get('pdf_path'))) { ilUtil::makeDir($genSet->get('pdf_path')); } $file_name = time(); if (@file_exists($genSet->get('pdf_path'))) { ilUtil::html2pdf($tpl->get(), $genSet->get('pdf_path') . '/' . $file_name . '.pdf'); } if (@file_exists($genSet->get('pdf_path') . '/' . $file_name . '.pdf') && $this->user_obj->getEmail() != '' && $ilSetting->get('admin_email') != '') { $m = new ilMimeMail(); // create the mail $m->From($ilSetting->get('admin_email')); $m->To($this->user_obj->getEmail()); $m->Subject($this->lng->txt('pay_message_subject')); // if there is no mailbillingtext use this as standard $message = $this->lng->txt('pay_message_hello') . ' ' . $this->user_obj->getFirstname() . ' ' . $this->user_obj->getLastname() . ",\n\n"; $message .= $this->lng->txt('pay_message_thanks') . "\n\n"; $message .= $this->lng->txt('pay_message_attachment') . "\n\n"; $message .= $this->lng->txt('pay_message_regards') . "\n\n"; $message .= strip_tags($genSet->get('address')); //replacePlaceholders... $billing_text = $genSet->getMailBillingText(); if (!$billing_text) { $message = ''; } if ($genSet->getMailUsePlaceholders() == 1) { include_once './Services/Payment/classes/class.ilBillingMailPlaceholdersPropertyGUI.php'; $message = ilBillingMailPlaceholdersPropertyGUI::replaceBillingMailPlaceholders($billing_text, $this->user_obj->getId()); } $m->Body($message); // set the body $m->Attach($genSet->get('pdf_path') . '/' . $file_name . '.pdf', 'application/pdf'); // attach a file of type image/gif if ($genSet->get('attach_sr_invoice') == 1) { require_once 'Services/RTE/classes/class.ilRTE.php'; $regulations = ilRTE::_replaceMediaObjectImageSrc($genSet->get('statutory_regulations'), 1); $reg_file_name = 'statutory_regulations'; if (@file_exists($genSet->get('pdf_path'))) { ilUtil::html2pdf($regulations, $genSet->get('pdf_path') . '/' . $reg_file_name . '.pdf'); } $m->Attach($genSet->get('pdf_path') . '/' . $reg_file_name . '.pdf', 'application/pdf'); // attach a file of type image/gif } $m->Send(); // send the mail } @unlink($genSet->get('pdf_path') . '/' . $file_name . '.html'); @unlink($genSet->get('pdf_path') . '/' . $file_name . '.pdf'); unset($current_booking_id); unset($pobject); unset($_SESSION['coupons'][$this->session_var]); $this->ctrl->redirectByClass('ilShopBoughtObjectsGUI', ''); }
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); }