Do globálního nastavení byla přidaná sekce pro nastavení cestovních

náhrad. 
refs #112
multitenant
Josef Rokos 10 years ago
parent 0a4ba55b82
commit 7f1f214b5d

@ -6,6 +6,7 @@ import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportMapping; 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.RoleService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
@ -273,6 +275,20 @@ public class AppInitListener implements ServletContextListener {
gSettingsService.add(gs); 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();
}
} }
} }

@ -1,7 +1,10 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import info.bukova.isspst.mail.MailMessage; import info.bukova.isspst.mail.MailMessage;
@ -17,6 +20,7 @@ public class SettingsData {
private String accountNumber; private String accountNumber;
private String bankCode; private String bankCode;
private List<Vehicle> vehicles; private List<Vehicle> vehicles;
private Map<Integer, BigDecimal[]> refunds;
public SettingsData() { public SettingsData() {
newReqTemplate = new MailMessage(); newReqTemplate = new MailMessage();
@ -25,6 +29,7 @@ public class SettingsData {
mainAddress = new Address(); mainAddress = new Address();
shippingAddrs = new ArrayList<Address>(); shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>(); vehicles = new ArrayList<Vehicle>();
refunds = new HashMap<Integer, BigDecimal[]>();
} }
public boolean isEnableRequirements() { public boolean isEnableRequirements() {
@ -107,4 +112,12 @@ public class SettingsData {
this.vehicles = vehicles; this.vehicles = vehicles;
} }
public Map<Integer, BigDecimal[]> getRefunds() {
return refunds;
}
public void setRefunds(Map<Integer, BigDecimal[]> refunds) {
this.refunds = refunds;
}
} }

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.codehaus.org/mapping.dtd">
<mapping>
<class name="info.bukova.isspst.data.SettingsData" auto-complete="true" >
<map-to xml="settings-data"/>
<field name="refunds" collection="map">
<bind-xml name="refunds">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="java.lang.Integer">
<bind-xml name="key" node="attribute" />
</field>
<field name="value" collection="array" type="java.math.BigDecimal">
<bind-xml name="nested" />
</field>
</class>
</bind-xml>
</field>
</class>
</mapping>

@ -1,14 +1,5 @@
package info.bukova.isspst.ui.settings; 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.Address;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.SettingsData; 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.sort.ReflectionTools;
import info.bukova.isspst.ui.LocaleConverter; 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 { public class GlobalSettingsVM {
@WireVariable @WireVariable
@ -25,11 +28,13 @@ public class GlobalSettingsVM {
private SettingsData settings; private SettingsData settings;
private LocaleConverter locConverter; private LocaleConverter locConverter;
private Address selAddress; private Address selAddress;
private List<Integer> refundsHours;
@Init @Init
public void init() { public void init() {
settings = settingsService.getSettings(); settings = settingsService.getSettings();
locConverter = new LocaleConverter(); locConverter = new LocaleConverter();
setRefundsHours(settings.getRefunds().keySet());
} }
public SettingsData getSettings() { public SettingsData getSettings() {
@ -92,4 +97,13 @@ public class GlobalSettingsVM {
this.selAddress = selAddress; this.selAddress = selAddress;
} }
public List<Integer> getRefundsHours() {
return refundsHours;
}
private void setRefundsHours(Set<Integer> refundsHours) {
this.refundsHours = new ArrayList<Integer>(settings.getRefunds().keySet());
Collections.sort(this.refundsHours);
}
} }

@ -157,6 +157,9 @@ BankCode=Kód banky
AccountNumber=Číslo účtu AccountNumber=Číslo účtu
TravelOrders=Cestovní příkazy TravelOrders=Cestovní příkazy
GlobalSettingsVehicles=Dopravní prostředky 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 CentresForRequirements=Střediska, pro která lze vkládat požadavky
WorkgroupMembership=Členství v komisích WorkgroupMembership=Členství v komisích

@ -275,6 +275,11 @@
<prop key="org.exolab.castor.xml.introspector.primitive.nodetype">element</prop> <prop key="org.exolab.castor.xml.introspector.primitive.nodetype">element</prop>
</props> </props>
</property> </property>
<property name="mappingLocations">
<list>
<value>info/bukova/isspst/services/settings/mappingSettings.xml</value>
</list>
</property>
</bean> </bean>
<bean id="unmarshallerSettings" class="org.castor.spring.xml.CastorUnmarshallerFactoryBean"> <bean id="unmarshallerSettings" class="org.castor.spring.xml.CastorUnmarshallerFactoryBean">

@ -1,23 +1,60 @@
<?page title="travel orders" contentType="text/html;charset=UTF-8"?> <?page title="travel orders" contentType="text/html;charset=UTF-8"?>
<zk> <zk>
<vbox> <tabbox>
<label value="Dopravní prostředky:"/> <tabs>
<button label="${labels.AddItem}" onClick="@command('addVehicle')"/> <tab label="${labels.GlobalSettingsRefunds}"/>
<grid model="@load(vm.settings.vehicles)"> <tab label="${labels.GlobalSettingsVehicles}"/>
<columns> </tabs>
<column label="${labels.code}"/> <tabpanels>
<column label="${labels.name}"/> <tabpanel>
<column/> <grid model="@load(vm.refundsHours)">
</columns> <auxhead>
<rows> <auxheader colspan="1"/>
<template name="model"> <auxheader label="${labels.GlobalSettingsFreeMealsCount}" colspan="4"/>
<row> </auxhead>
<textbox inplace="true" value="@bind(each.code)"/> <columns>
<textbox inplace="true" value="@bind(each.description)"/> <column label="${labels.GlobalSettingsHours}"/>
<button label="${labels.RemoveItem}" onClick="@command('removeVehicle', vehicle=each)"/> <column label="0"/>
</row> <column label="1"/>
</template> <column label="2"/>
</rows> <column label="3"/>
</grid> </columns>
</vbox> <rows>
<template name="model">
<row>
<label value="@load(each)"/>
<textbox value="@bind(vm.settings.refunds[each][0])" inplace="true"/>
<textbox value="@bind(vm.settings.refunds[each][1])" inplace="true"/>
<textbox value="@bind(vm.settings.refunds[each][2])" inplace="true"/>
<textbox value="@bind(vm.settings.refunds[each][3])" inplace="true"/>
</row>
</template>
</rows>
</grid>
</tabpanel>
<tabpanel>
<vbox>
<button label="${labels.AddItem}" onClick="@command('addVehicle')" sclass="nicebutton"/>
<grid model="@load(vm.settings.vehicles)">
<columns>
<column label="${labels.code}"/>
<column label="${labels.name}"/>
<column/>
</columns>
<rows>
<template name="model">
<row>
<textbox inplace="true" value="@bind(each.code)"/>
<textbox inplace="true" value="@bind(each.description)"/>
<button label="${labels.RemoveItem}" onClick="@command('removeVehicle', vehicle=each)"/>
</row>
</template>
</rows>
</grid>
</vbox>
</tabpanel>
</tabpanels>
</tabbox>
</zk> </zk>
Loading…
Cancel
Save