diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index f2bf42c1..24b78055 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -6,6 +6,7 @@ import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.Role; +import info.bukova.isspst.data.SettingsData; import info.bukova.isspst.data.User; import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; @@ -18,6 +19,7 @@ import info.bukova.isspst.services.users.PermissionService; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; +import java.math.BigDecimal; import java.util.List; import javax.servlet.ServletContextEvent; @@ -273,6 +275,20 @@ public class AppInitListener implements ServletContextListener { gSettingsService.add(gs); } + SettingsData data = gSettingsService.getSettings(); + if (data.getRefunds().isEmpty()) { + BigDecimal[] refunds0 = {BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO,BigDecimal.ZERO}; + BigDecimal[] refunds5 = {BigDecimal.valueOf(70),BigDecimal.valueOf(21),BigDecimal.ZERO,BigDecimal.ZERO}; + BigDecimal[] refunds12 = {BigDecimal.valueOf(105),BigDecimal.valueOf(68),BigDecimal.valueOf(32),BigDecimal.ZERO}; + BigDecimal[] refunds18 = {BigDecimal.valueOf(165),BigDecimal.valueOf(124),BigDecimal.valueOf(83),BigDecimal.valueOf(42)}; + + data.getRefunds().put(0, refunds0); + data.getRefunds().put(5, refunds5); + data.getRefunds().put(12, refunds12); + data.getRefunds().put(18, refunds18); + + gSettingsService.updateSettings(); + } } } diff --git a/src/main/java/info/bukova/isspst/data/SettingsData.java b/src/main/java/info/bukova/isspst/data/SettingsData.java index 3907d38a..3e152952 100644 --- a/src/main/java/info/bukova/isspst/data/SettingsData.java +++ b/src/main/java/info/bukova/isspst/data/SettingsData.java @@ -1,7 +1,10 @@ package info.bukova.isspst.data; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import info.bukova.isspst.mail.MailMessage; @@ -17,6 +20,7 @@ public class SettingsData { private String accountNumber; private String bankCode; private List vehicles; + private Map refunds; public SettingsData() { newReqTemplate = new MailMessage(); @@ -25,6 +29,7 @@ public class SettingsData { mainAddress = new Address(); shippingAddrs = new ArrayList
(); vehicles = new ArrayList(); + refunds = new HashMap(); } public boolean isEnableRequirements() { @@ -107,4 +112,12 @@ public class SettingsData { this.vehicles = vehicles; } + public Map getRefunds() { + return refunds; + } + + public void setRefunds(Map refunds) { + this.refunds = refunds; + } + } diff --git a/src/main/java/info/bukova/isspst/services/settings/mappingSettings.xml b/src/main/java/info/bukova/isspst/services/settings/mappingSettings.xml new file mode 100644 index 00000000..6489bb8f --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/settings/mappingSettings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java index 1ee533aa..4e5db21c 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java @@ -1,14 +1,5 @@ package info.bukova.isspst.ui.settings; -import java.util.List; - -import org.zkoss.bind.annotation.BindingParam; -import org.zkoss.bind.annotation.Command; -import org.zkoss.bind.annotation.Init; -import org.zkoss.bind.annotation.NotifyChange; -import org.zkoss.zk.ui.select.annotation.WireVariable; -import org.zkoss.zul.Window; - import info.bukova.isspst.data.Address; import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.SettingsData; @@ -18,6 +9,18 @@ import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.sort.ReflectionTools; import info.bukova.isspst.ui.LocaleConverter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.zkoss.bind.annotation.BindingParam; +import org.zkoss.bind.annotation.Command; +import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; +import org.zkoss.zk.ui.select.annotation.WireVariable; +import org.zkoss.zul.Window; + public class GlobalSettingsVM { @WireVariable @@ -25,11 +28,13 @@ public class GlobalSettingsVM { private SettingsData settings; private LocaleConverter locConverter; private Address selAddress; + private List refundsHours; @Init public void init() { settings = settingsService.getSettings(); locConverter = new LocaleConverter(); + setRefundsHours(settings.getRefunds().keySet()); } public SettingsData getSettings() { @@ -92,4 +97,13 @@ public class GlobalSettingsVM { this.selAddress = selAddress; } + public List getRefundsHours() { + return refundsHours; + } + + private void setRefundsHours(Set refundsHours) { + this.refundsHours = new ArrayList(settings.getRefunds().keySet()); + Collections.sort(this.refundsHours); + } + } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 9f0ab6e5..1718161c 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -157,6 +157,9 @@ BankCode=Kód banky AccountNumber=Číslo účtu TravelOrders=Cestovní příkazy GlobalSettingsVehicles=Dopravní prostředky +GlobalSettingsRefunds=Náhrady +GlobalSettingsFreeMealsCount=Počet jídel zdarma +GlobalSettingsHours=Hodin CentresForRequirements=Střediska, pro která lze vkládat požadavky WorkgroupMembership=Členství v komisích diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index 264d4fa1..651df02b 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -275,6 +275,11 @@ element + + + info/bukova/isspst/services/settings/mappingSettings.xml + + diff --git a/src/main/webapp/settings/global/travelOrders.zul b/src/main/webapp/settings/global/travelOrders.zul index 08ba275c..fef2a3d4 100644 --- a/src/main/webapp/settings/global/travelOrders.zul +++ b/src/main/webapp/settings/global/travelOrders.zul @@ -1,23 +1,60 @@ - -