public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new ilPaymentVendors(); } return self::$_instance; }
private function forwardToDefault() { global $ilCtrl, $lng; $is_vendor = ilPaymentVendors::_isVendor($this->user_obj->getId()); $has_stat_perm = ilPaymentTrustees::_hasStatisticPermission($this->user_obj->getId()); $has_obj_perm = ilPaymentTrustees::_hasObjectPermission($this->user_obj->getId()); $has_coup_perm = ilPaymentTrustees::_hasCouponsPermission($this->user_obj->getId()); if ($is_vendor || $has_stat_perm) { $ilCtrl->redirectByClass('ilpaymentstatisticgui'); } else { if ($has_obj_perm) { $ilCtrl->redirectByClass('ilpaymentobjectgui'); } else { if ($has_coup_perm) { $ilCtrl->redirectByClass('ilpaymentcoupongui'); } } } ilUtil::sendInfo($lng->txt("no_permission")); return false; }
public function addStatisticWorksheet(&$pewa) { include_once './Services/Excel/classes/class.ilExcelUtils.php'; include_once './Services/Payment/classes/class.ilPaymentVendors.php'; $this->__initBookingObject(); $workbook = $pewa->getWorkbook(); $worksheet = $workbook->addWorksheet(utf8_decode($this->lng->txt('bookings'))); $worksheet->mergeCells(0, 0, 0, 3); $worksheet->setColumn(0, 0, 16); $worksheet->setColumn(0, 1, 32); $worksheet->setColumn(0, 2, 32); $worksheet->setColumn(0, 3, 16); $worksheet->setColumn(0, 4, 16); $worksheet->setColumn(0, 5, 16); $worksheet->setColumn(0, 6, 24); $worksheet->setColumn(0, 7, 8); $worksheet->setColumn(0, 8, 12); $worksheet->setColumn(0, 9, 16); $title = $this->lng->txt('bookings'); $title .= ' ' . $this->lng->txt('as_of') . ' '; $title .= strftime('%Y-%m-%d %R', time()); $worksheet->writeString(0, 0, $title, $pewa->getFormatTitle()); $worksheet->writeString(1, 0, $this->lng->txt('payment_system'), $pewa->getFormatHeader()); $worksheet->writeString(1, 1, $this->lng->txt('paya_transaction'), $pewa->getFormatHeader()); $worksheet->writeString(1, 2, $this->lng->txt('title'), $pewa->getFormatHeader()); $worksheet->writeString(1, 3, $this->lng->txt('paya_vendor'), $pewa->getFormatHeader()); $worksheet->writeString(1, 4, $this->lng->txt('pays_cost_center'), $pewa->getFormatHeader()); $worksheet->writeString(1, 5, $this->lng->txt('paya_customer'), $pewa->getFormatHeader()); $worksheet->writeString(1, 6, $this->lng->txt('email'), $pewa->getFormatHeader()); $worksheet->writeString(1, 7, $this->lng->txt('paya_order_date'), $pewa->getFormatHeader()); $worksheet->writeString(1, 8, $this->lng->txt('duration'), $pewa->getFormatHeader()); $worksheet->writeString(1, 9, $this->lng->txt('price_a'), $pewa->getFormatHeader()); $worksheet->writeString(1, 10, $this->lng->txt('paya_payed_access'), $pewa->getFormatHeader()); $worksheet->writeString(1, 11, $this->lng->txt('street'), $pewa->getFormatHeader()); $worksheet->writeString(1, 12, $this->lng->txt('pay_bmf_po_box'), $pewa->getFormatHeader()); $worksheet->writeString(1, 13, $this->lng->txt('zipcode'), $pewa->getFormatHeader()); $worksheet->writeString(1, 14, $this->lng->txt('city'), $pewa->getFormatHeader()); $worksheet->writeString(1, 15, $this->lng->txt('country'), $pewa->getFormatHeader()); if (!count($bookings = $this->booking_obj->getBookings())) { return false; } include_once 'Services/User/classes/class.ilObjUser.php'; $object_title_cache = array(); $user_title_cache = array(); $counter = 2; foreach ($bookings as $booking) { if (array_key_exists($booking['ref_id'], $object_title_cache)) { $tmp_obj = $object_title_cache[$booking['ref_id']]; } else { $tmp_obj = ilObject::_lookupTitle(ilObject::_lookupObjId($booking['ref_id'])); $object_title_cache[$booking['ref_id']] = $tmp_obj; } if (array_key_exists($booking['b_vendor_id'], $user_title_cache)) { $tmp_vendor = $user_title_cache[$booking['b_vendor_id']]; } else { $tmp_vendor = ilObjUser::_lookupLogin($booking['b_vendor_id']); $user_title_cache[$booking['b_vendor_id']] = $tmp_vendor; } if (array_key_exists($booking['customer_id'], $user_title_cache)) { $tmp_purchaser = $user_title_cache[$booking['customer_id']]; } else { $tmp_purchaser_name = ilObjUser::_lookupName($booking['customer_id']); $tmp_purchaser_login = ilObjUser::_lookupLogin($booking['customer_id']); $tmp_purchaser_email = ilObjUser::_lookupEmail($booking['customer_id']); $tmp_purchaser = '' . $tmp_purchaser_name['firstname'] . ' ' . $tmp_purchaser_name['lastname'] . ' [' . $tmp_purchaser_login . ']'; $user_title_cache[$booking['customer_id']] = $tmp_purchaser; } include_once './Services/Payment/classes/class.ilPayMethods.php'; $str_paymethod = ilPayMethods::getStringByPaymethod($booking['b_pay_method']); $worksheet->writeString($counter, 0, $str_paymethod); $worksheet->writeString($counter, 1, $booking['transaction']); $worksheet->writeString($counter, 2, $tmp_obj != '' ? $tmp_obj : $this->lng->txt('object_deleted')); $worksheet->writeString($counter, 3, $tmp_vendor != '' ? $tmp_vendor : $this->lng->txt('user_deleted')); $worksheet->writeString($counter, 4, ilPaymentVendors::_getCostCenter($booking['b_vendor_id'])); $worksheet->writeString($counter, 5, $tmp_purchaser != '' ? $tmp_purchaser : $this->lng->txt('user_deleted')); $worksheet->writeString($counter, 6, $tmp_purchaser_email); $worksheet->writeString($counter, 7, strftime('%Y-%m-%d %R', $booking['order_date'])); $worksheet->writeString($counter, 8, $booking['duration']); $worksheet->writeString($counter, 9, $booking['price']); $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'); $worksheet->writeString($counter, 10, $payed_access); $worksheet->writeString($counter, 11, $booking['street']); $worksheet->writeString($counter, 12, $booking['po_box']); $worksheet->writeString($counter, 13, $booking['zipcode']); $worksheet->writeString($counter, 14, $booking['city']); $worksheet->writeString($counter, 15, $booking['country']); unset($tmp_obj); unset($tmp_vendor); unset($tmp_purchaser); ++$counter; } return true; }
private function buildTabs() { global $ilTabs, $ilUser; // $shop_obj = new ilPaymentShoppingCart($ilUser); $obj = ilPaymentSettings::_getInstance(); $allSet = $obj->getAll(); $ilTabs->addTarget('content', $this->ctrl->getLinkTargetByClass('ilshopgui', 'firstpage'), '', '', ''); if (!(bool) $allSet['hide_advanced_search']) { $ilTabs->addTarget('advanced_search', $this->ctrl->getLinkTargetByClass('ilshopadvancedsearchgui'), '', '', ''); } if (!(bool) $allSet['hide_shop_info']) { $ilTabs->addTarget('shop_info', $this->ctrl->getLinkTargetByClass('ilshopinfogui'), '', '', ''); } if (!(bool) $allSet['hide_news']) { $ilTabs->addTarget('payment_news', $this->ctrl->getLinkTargetByClass('ilshopnewsgui'), '', '', ''); } if (ANONYMOUS_USER_ID != $ilUser->getId()) { if ((bool) ilPaymentSettings::_getInstance()->get('topics_allow_custom_sorting')) { $ilTabs->addTarget('pay_personal_settings', $this->ctrl->getLinkTargetByClass('ilshoppersonalsettingsgui'), '', '', ''); } // Only show if not empty $ilTabs->addTarget('paya_buyed_objects', $this->ctrl->getLinkTargetByClass('ilshopboughtobjectsgui'), '', '', ''); // Only show if user is vendor if (ilPaymentVendors::_isVendor($ilUser->getId()) || ilPaymentTrustees::_hasAccess($ilUser->getId())) { $ilTabs->addTarget('paya_header', $this->ctrl->getLinkTargetByClass('ilpaymentadmingui'), '', '', ''); } } // Only show cart if not empty $ilTabs->addTarget('paya_shopping_cart', $this->ctrl->getLinkTargetByClass('ilshopshoppingcartgui'), '', '', ''); $ilTabs->addTarget('terms_conditions', $this->ctrl->getLinkTargetByClass(array('iltermsconditionsgui'), '')); }
public function __getVendorIds() { if (ilPaymentVendors::_isVendor($this->user_id)) { $vendors[] = $this->user_id; } $vend = ilPaymentTrustees::_getVendorsForStatisticsByTrusteeId($this->user_id); if (isset($vend)) { foreach ($vend as $v) { if (ilPaymentTrustees::_hasStatisticPermissionByVendor($this->user_id, $v)) { $vendors[] = $v; } } } return $vendors ? $vendors : array(); }
private function getVendorIds() { $vendors[] = $this->user_obj->getId(); if (ilPaymentVendors::_isVendor($this->user_obj->getId())) { $ptObj = new ilPaymentTrustees($this->user_obj); if ($trustees = $ptObj->getTrustees()) { foreach ($trustees as $trustee) { if ((bool) $trustee["perm_coupons"]) { $vendors[] = $trustee["trustee_id"]; } } } } if ($vend = ilPaymentTrustees::_getVendorsForCouponsByTrusteeId($this->user_obj->getId())) { foreach ($vend as $v) { $vendors[] = $v; if ($trustees = ilPaymentTrustees::_getTrusteesForCouponsByVendorId($v)) { foreach ($trustees as $t) { $vendors[] = $t; } } } } return $vendors ? $vendors : array(); }
public static function _isPurchasable($a_ref_id, $a_vendor_id = 0, $a_check_trustee = false, $a_check_status = false) { global $ilDB; // In the moment it's not possible to sell one object twice $data = array(); $data_types = array(); $query = 'SELECT * FROM payment_objects WHERE ref_id = %s '; $data_types[] = 'integer'; $data[] = $a_ref_id; // check if object is buyable !! if ($a_check_status) { $query .= 'AND status > %s '; $data_types[] = 'integer'; $data[] = 0; } if ($a_vendor_id > 0) { $query .= 'AND vendor_id = %s'; $data_types[] = 'integer'; $data[] = $a_vendor_id; if ($a_check_trustee) { include_once './Services/Payment/classes/class.ilPaymentTrustees.php'; include_once './Services/Payment/classes/class.ilPaymentVendors.php'; $vendors = ilPaymentTrustees::_getVendorsForObjects($a_vendor_id); if (ilPaymentVendors::_isVendor($a_user_id)) { $vendors[] = $a_user_id; } if (is_array($vendors) && count($vendors)) { $query .= ' OR ' . $ilDB->in('vendor_id', $vendors, false, 'integer'); } } } $res = $ilDB->queryf($query, $data_types, $data); $rows = $ilDB->numRows($res); return $rows ? true : false; }
private function __getVendors() { include_once 'Services/Payment/classes/class.ilPaymentVendors.php'; $options = array(); $vendors = array(); if (ilPaymentVendors::_isVendor($this->user_obj->getId())) { $vendors[] = $this->user_obj->getId(); } if ($vend = ilPaymentTrustees::_getVendorsForObjects($this->user_obj->getId())) { $vendors = array_merge($vendors, $vend); } foreach ($vendors as $vendor) { /** @var $tmp_obj ilObjUser */ $tmp_obj = ilObjectFactory::getInstanceByObjId($vendor, false); $options[$vendor] = $tmp_obj->getFullname() . ' [' . $tmp_obj->getLogin() . ']'; } return $options; }
protected function buildSubTabs() { global $ilUser, $ilTabs; switch ($this->getSection()) { case 6: if (ilPaymentVendors::_isVendor($ilUser->getId()) || ilPaymentTrustees::_hasStatisticPermission($ilUser->getId())) { $ilTabs->addSubTabTarget('bookings', $this->ctrl->getLinkTargetByClass('ilpaymentstatisticgui'), '', '', ''); } if (ilPaymentVendors::_isVendor($ilUser->getId()) || ilPaymentTrustees::_hasObjectPermission($ilUser->getId())) { $ilTabs->addSubTabTarget('paya_object', $this->ctrl->getLinkTargetByClass('ilpaymentobjectgui'), '', '', ''); } if (ilPaymentVendors::_isVendor($ilUser->getId())) { $ilTabs->addSubTabTarget('paya_trustees', $this->ctrl->getLinkTargetByClass('ilpaymenttrusteegui'), '', '', ''); } if (!(bool) $this->oGeneralSettings->get('hide_coupons')) { if (ilPaymentVendors::_isVendor($ilUser->getId()) || ilPaymentTrustees::_hasCouponsPermission($ilUser->getId())) { $ilTabs->addSubTabTarget('paya_coupons_coupons', $this->ctrl->getLinkTargetByClass('ilpaymentcoupongui'), '', '', ''); } } break; default: break; } }