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.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();
}
}
}

@ -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<Vehicle> vehicles;
private Map<Integer, BigDecimal[]> refunds;
public SettingsData() {
newReqTemplate = new MailMessage();
@ -25,6 +29,7 @@ public class SettingsData {
mainAddress = new Address();
shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>();
refunds = new HashMap<Integer, BigDecimal[]>();
}
public boolean isEnableRequirements() {
@ -107,4 +112,12 @@ public class SettingsData {
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;
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<Integer> 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<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
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

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

@ -1,8 +1,41 @@
<?page title="travel orders" contentType="text/html;charset=UTF-8"?>
<zk>
<tabbox>
<tabs>
<tab label="${labels.GlobalSettingsRefunds}"/>
<tab label="${labels.GlobalSettingsVehicles}"/>
</tabs>
<tabpanels>
<tabpanel>
<grid model="@load(vm.refundsHours)">
<auxhead>
<auxheader colspan="1"/>
<auxheader label="${labels.GlobalSettingsFreeMealsCount}" colspan="4"/>
</auxhead>
<columns>
<column label="${labels.GlobalSettingsHours}"/>
<column label="0"/>
<column label="1"/>
<column label="2"/>
<column label="3"/>
</columns>
<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>
<label value="Dopravní prostředky:"/>
<button label="${labels.AddItem}" onClick="@command('addVehicle')"/>
<button label="${labels.AddItem}" onClick="@command('addVehicle')" sclass="nicebutton"/>
<grid model="@load(vm.settings.vehicles)">
<columns>
<column label="${labels.code}"/>
@ -20,4 +53,8 @@
</rows>
</grid>
</vbox>
</tabpanel>
</tabpanels>
</tabbox>
</zk>
Loading…
Cancel
Save