| 1 | |
package org.paneris.bibliomania; |
| 2 | |
|
| 3 | |
import org.melati.Melati; |
| 4 | |
import org.melati.servlet.Form; |
| 5 | |
import org.melati.poem.BaseFieldAttributes; |
| 6 | |
import org.melati.poem.Field; |
| 7 | |
import org.melati.poem.FieldAttributes; |
| 8 | |
import org.webmacro.servlet.WebContext; |
| 9 | |
|
| 10 | 0 | public class DeliveryCharges extends BibliomaniaServlet { |
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
private static final long serialVersionUID = 1L; |
| 16 | |
|
| 17 | |
protected String bibliomaniaHandle(Melati melati, WebContext context) |
| 18 | |
throws Exception { |
| 19 | |
|
| 20 | 0 | BibliomaniaDatabase db = (BibliomaniaDatabase) melati.getDatabase(); |
| 21 | 0 | db.setupContext(melati, context, null, null); |
| 22 | 0 | String localeString = |
| 23 | |
Form.getFieldNulled(melati.getServletTemplateContext(),"locale"); |
| 24 | 0 | Integer countryCodeId = |
| 25 | |
Form.getIntegerField(melati.getServletTemplateContext(),"field_country"); |
| 26 | 0 | context.put("countries", new Field(countryCodeId, |
| 27 | |
new BaseFieldAttributes( |
| 28 | |
(FieldAttributes)db.getShopOrderTable().getCountryColumn(), true))); |
| 29 | 0 | if (countryCodeId != null) { |
| 30 | 0 | Country country = (Country)db.getCountryTable().getIdColumn().firstWhereEq(countryCodeId); |
| 31 | 0 | context.put("country", country); |
| 32 | 0 | DeliveryChargeBand band = country.getDeliverycharge(); |
| 33 | 0 | context.put("charges", db.getDeliveryChargeTable().getBandColumn().selectionWhereEq(band.getTroid())); |
| 34 | |
} |
| 35 | 0 | context.put("currency", db.getCurrencyTable().getCurrency(localeString)); |
| 36 | 0 | context.put("locale", localeString); |
| 37 | 0 | return "DeliveryCharges.wm"; |
| 38 | |
} |
| 39 | |
} |