use of org.olat.resource.accesscontrol.Price in project openolat by klemens.
the class PaypalAccessConfigurationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String desc = null;
if (link.getOffer() != null) {
desc = link.getOffer().getDescription();
}
descEl = uifactory.addTextAreaElement("offer-desc", "offer.description", 2000, 6, 80, false, desc, formLayout);
Price price = null;
if (link.getOffer() != null && link.getOffer().getPrice() != null) {
price = link.getOffer().getPrice();
}
String amount = null;
if (price != null && price.getAmount() != null) {
amount = price.getAmount().setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
}
priceEl = uifactory.addTextElement("price", "price", 32, amount, formLayout);
currencyEl = uifactory.addDropdownSingleselect("currency", "currency", formLayout, currencies, currencies, null);
boolean selected = false;
if (price != null && price.getCurrencyCode() != null) {
for (String currency : currencies) {
if (currency.equals(price.getCurrencyCode())) {
currencyEl.select(currency, true);
selected = true;
}
}
}
if (!selected) {
if (StringHelper.containsNonWhitespace(paypalModule.getPaypalCurrency())) {
currencyEl.select(paypalModule.getPaypalCurrency(), true);
currencyEl.setEnabled(false);
} else {
currencyEl.select("CHF", true);
}
}
vatEnabledEl = uifactory.addCheckboxesHorizontal("vat.enabled", "vat.enabled", formLayout, vatKeys, vatValues);
if (acModule.isVatEnabled()) {
vatEnabledEl.select(vatKeys[0], true);
}
vatEnabledEl.setEnabled(false);
dateFrom = uifactory.addDateChooser("from_" + link.getKey(), "from", link.getValidFrom(), formLayout);
dateFrom.setHelpText(translate("from.hint"));
dateTo = uifactory.addDateChooser("to_" + link.getKey(), "to", link.getValidTo(), formLayout);
dateTo.setHelpText(translate("from.hint"));
super.initForm(formLayout, listener, ureq);
}
use of org.olat.resource.accesscontrol.Price in project openolat by klemens.
the class PaypalTransactionDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Formatter format = Formatter.getInstance(getLocale());
String ack = transaction.getAck();
uifactory.addStaticTextElement("ack", "paypal.transaction.ack", ack, formLayout);
String execStatus = transaction.getPaymentExecStatus();
uifactory.addStaticTextElement("exec.status", "paypal.transaction.exec.status", execStatus, formLayout);
Date respDate = transaction.getPayResponseDate();
String respDateStr = format.formatDateAndTime(respDate);
uifactory.addStaticTextElement("resp.date", "paypal.transaction.response.date", respDateStr, formLayout);
Price securePrice = transaction.getSecurePrice();
String securePriceStr = PriceFormat.fullFormat(securePrice);
uifactory.addStaticTextElement("amount", "paypal.transaction.amount", securePriceStr, formLayout);
uifactory.addSpacerElement("ipn-spacer", formLayout, false);
String transactionId = transaction.getTransactionId();
uifactory.addStaticTextElement("trx-id", "paypal.transaction.id", removeNull(transactionId), formLayout);
String trxStatus = transaction.getTransactionStatus();
uifactory.addStaticTextElement("trx-status", "paypal.transaction.status", removeNull(trxStatus), formLayout);
String senderTransactionId = transaction.getSenderTransactionId();
uifactory.addStaticTextElement("trx-sender-id", "paypal.transaction.sender.id", removeNull(senderTransactionId), formLayout);
String senderTrxStatus = transaction.getSenderTransactionStatus();
uifactory.addStaticTextElement("trx-sender-status", "paypal.transaction.sender.status", removeNull(senderTrxStatus), formLayout);
String pendingReason = transaction.getPendingReason();
uifactory.addStaticTextElement("trx-pending-reason", "paypal.transaction.pending.reason", removeNull(pendingReason), formLayout);
String senderEmail = transaction.getSenderEmail();
uifactory.addStaticTextElement("trx-sender", "paypal.transaction.sender", removeNull(senderEmail), formLayout);
}
use of org.olat.resource.accesscontrol.Price in project openolat by klemens.
the class PriceCellRenderer method render.
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
if (val instanceof Price) {
Price amount = (Price) val;
sb.append(PriceFormat.fullFormat(amount));
}
}
use of org.olat.resource.accesscontrol.Price in project openolat by klemens.
the class BusinessGroupDAO method loadOfferAccess.
public void loadOfferAccess(Map<Long, ? extends BusinessGroupRow> resourceKeyToGroup) {
if (resourceKeyToGroup.isEmpty())
return;
final int OFFERS_IN_LIMIT = 255;
// offers
StringBuilder so = new StringBuilder();
so.append("select access.method, resource.key, offer.price from acofferaccess access ").append(" inner join access.offer offer").append(" inner join offer.resource resource");
if (resourceKeyToGroup.size() < OFFERS_IN_LIMIT) {
so.append(" where resource.key in (:resourceKeys)");
} else {
so.append(" where exists (select bgi.key from businessgroup bgi where bgi.resource=resource)");
}
TypedQuery<Object[]> offersQuery = dbInstance.getCurrentEntityManager().createQuery(so.toString(), Object[].class);
if (resourceKeyToGroup.size() < OFFERS_IN_LIMIT) {
List<Long> resourceKeys = new ArrayList<>(resourceKeyToGroup.size());
for (Long resourceKey : resourceKeyToGroup.keySet()) {
resourceKeys.add(resourceKey);
}
offersQuery.setParameter("resourceKeys", resourceKeys);
}
List<Object[]> offers = offersQuery.getResultList();
for (Object[] offer : offers) {
Long resourceKey = (Long) offer[1];
BusinessGroupRow row = resourceKeyToGroup.get(resourceKey);
if (row != null) {
AccessMethod method = (AccessMethod) offer[0];
Price price = (Price) offer[2];
if (row.getBundles() == null) {
row.setBundles(new ArrayList<>(3));
}
row.getBundles().add(new PriceMethodBundle(price, method));
}
}
}
use of org.olat.resource.accesscontrol.Price in project OpenOLAT by OpenOLAT.
the class PaypalTransactionDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Formatter format = Formatter.getInstance(getLocale());
String ack = transaction.getAck();
uifactory.addStaticTextElement("ack", "paypal.transaction.ack", ack, formLayout);
String execStatus = transaction.getPaymentExecStatus();
uifactory.addStaticTextElement("exec.status", "paypal.transaction.exec.status", execStatus, formLayout);
Date respDate = transaction.getPayResponseDate();
String respDateStr = format.formatDateAndTime(respDate);
uifactory.addStaticTextElement("resp.date", "paypal.transaction.response.date", respDateStr, formLayout);
Price securePrice = transaction.getSecurePrice();
String securePriceStr = PriceFormat.fullFormat(securePrice);
uifactory.addStaticTextElement("amount", "paypal.transaction.amount", securePriceStr, formLayout);
uifactory.addSpacerElement("ipn-spacer", formLayout, false);
String transactionId = transaction.getTransactionId();
uifactory.addStaticTextElement("trx-id", "paypal.transaction.id", removeNull(transactionId), formLayout);
String trxStatus = transaction.getTransactionStatus();
uifactory.addStaticTextElement("trx-status", "paypal.transaction.status", removeNull(trxStatus), formLayout);
String senderTransactionId = transaction.getSenderTransactionId();
uifactory.addStaticTextElement("trx-sender-id", "paypal.transaction.sender.id", removeNull(senderTransactionId), formLayout);
String senderTrxStatus = transaction.getSenderTransactionStatus();
uifactory.addStaticTextElement("trx-sender-status", "paypal.transaction.sender.status", removeNull(senderTrxStatus), formLayout);
String pendingReason = transaction.getPendingReason();
uifactory.addStaticTextElement("trx-pending-reason", "paypal.transaction.pending.reason", removeNull(pendingReason), formLayout);
String senderEmail = transaction.getSenderEmail();
uifactory.addStaticTextElement("trx-sender", "paypal.transaction.sender", removeNull(senderEmail), formLayout);
}
Aggregations