diff --git a/src/main/java/info/bukova/isspst/data/SettingsData.java b/src/main/java/info/bukova/isspst/data/SettingsData.java index d7795714..acbb9fdd 100644 --- a/src/main/java/info/bukova/isspst/data/SettingsData.java +++ b/src/main/java/info/bukova/isspst/data/SettingsData.java @@ -21,6 +21,7 @@ public class SettingsData { private String bankCode; private List vehicles; private Map refunds; + private String stampFile; public SettingsData() { newReqTemplate = new MailMessage(); @@ -131,4 +132,12 @@ public class SettingsData { this.refunds = refunds; } + public String getStampFile() { + return stampFile; + } + + public void setStampFile(String stampFile) { + this.stampFile = stampFile; + } + } diff --git a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java index ae17f290..3911a175 100644 --- a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java +++ b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java @@ -1,10 +1,12 @@ package info.bukova.isspst.reporting; import info.bukova.isspst.data.AuthItem; +import info.bukova.isspst.data.Order; import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.User; import info.bukova.isspst.data.UserSettingsData; import info.bukova.isspst.services.requirement.TripRequirementService; +import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.storage.FileStorage; @@ -20,12 +22,16 @@ public class ParamFiller { private FileStorage storage; @Autowired private TripRequirementService tripReqService; + @Autowired + private GlobalSettingsService settingService; public void fill() { if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) { return; } + definition.getParams().clear(); + if ((definition.getDataSet().get(0) instanceof TripBill) && definition.getReport().isSingleRecord()) { if (userService.getUserSettings().getSignatureFile() != null @@ -49,6 +55,14 @@ public class ParamFiller { definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile())); } } + + if ((definition.getDataSet().get(0) instanceof Order) + && definition.getReport().isSingleRecord()) { + if (settingService.getSettings().getStampFile() != null + && !settingService.getSettings().getStampFile().isEmpty()) { + definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile())); + } + } } } 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 2dca91f7..b085b676 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java @@ -8,18 +8,26 @@ import info.bukova.isspst.data.Vehicle; import info.bukova.isspst.mail.MailMessage; import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.sort.ReflectionTools; +import info.bukova.isspst.storage.FileStorage; import info.bukova.isspst.ui.LocaleConverter; import info.bukova.isspst.ui.SecurityHelper; +import java.awt.image.RenderedImage; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; +import javax.imageio.ImageIO; + import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; +import org.zkoss.bind.annotation.ContextParam; +import org.zkoss.bind.annotation.ContextType; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; +import org.zkoss.zk.ui.event.UploadEvent; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; @@ -31,7 +39,9 @@ public class GlobalSettingsVM { private LocaleConverter locConverter; private Address selAddress; private List refundsHours; - + @WireVariable + private FileStorage storage; + @Init public void init() { settings = settingsService.getSettings(); @@ -49,6 +59,23 @@ public class GlobalSettingsVM { window.detach(); } + @Command + @NotifyChange({"settings", "stampImg"}) + public void uploadStamp(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent upEvent) { + int i = upEvent.getMedia().getName().lastIndexOf("."); + String fileName = "StampImageFile" + upEvent.getMedia().getName().substring(i); + + storage.saveFile(upEvent.getMedia().getByteData(), fileName); + settings.setStampFile(fileName); + } + + @Command + @NotifyChange("stampImg") + public void removeStamp() { + storage.removeFile(settings.getStampFile()); + settings.setStampFile(null); + } + public List getRequirementFields() { return ReflectionTools.getEntityFields(Requirement.class); } @@ -107,5 +134,17 @@ public class GlobalSettingsVM { this.refundsHours = new ArrayList(settings.getRefunds().keySet()); Collections.sort(this.refundsHours); } + + public RenderedImage getStampImg() { + if (settings.getStampFile() == null || settings.getStampFile().isEmpty()) { + return null; + } + + try { + return ImageIO.read(storage.file(settings.getStampFile())); + } catch (IOException e) { + return null; + } + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 4c81e9a6..93e135cc 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -169,6 +169,9 @@ GlobalSettingsVehicles=Dopravní prostředky GlobalSettingsRefunds=Náhrady GlobalSettingsFreeMealsCount=Počet jídel zdarma GlobalSettingsHours=Hodin +GlobalSettingsUploadStamp=Nahrát obrázek razítka +GlobalSettingsStamp=Razítko +GlobalSettingsReqEnable=Povolení požadavků UserSettings=Uživatelské nastavení @@ -221,6 +224,7 @@ LogedInUser=Přihlášený uživatel: ButtonStorno=Storno ButtonSave=Uložit +ButtonDelete=Smazat HeaderText=Hlavička diff --git a/src/main/webapp/WEB-INF/reports/order.jasper b/src/main/webapp/WEB-INF/reports/order.jasper index fc9bb6cd..166a53ab 100644 Binary files a/src/main/webapp/WEB-INF/reports/order.jasper and b/src/main/webapp/WEB-INF/reports/order.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/order.jrxml b/src/main/webapp/WEB-INF/reports/order.jrxml index 0561e57d..de9d51de 100644 --- a/src/main/webapp/WEB-INF/reports/order.jrxml +++ b/src/main/webapp/WEB-INF/reports/order.jrxml @@ -2,10 +2,11 @@ - + + @@ -63,7 +64,7 @@ - + @@ -311,11 +312,15 @@ - - + + - + + + + + diff --git a/src/main/webapp/WEB-INF/reports/orderItems.jasper b/src/main/webapp/WEB-INF/reports/orderItems.jasper index 2ad94d32..0d72c3e8 100644 Binary files a/src/main/webapp/WEB-INF/reports/orderItems.jasper and b/src/main/webapp/WEB-INF/reports/orderItems.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/orderItems.jrxml b/src/main/webapp/WEB-INF/reports/orderItems.jrxml index b1adf29d..8a1e42a5 100644 --- a/src/main/webapp/WEB-INF/reports/orderItems.jrxml +++ b/src/main/webapp/WEB-INF/reports/orderItems.jrxml @@ -123,7 +123,7 @@ - + diff --git a/src/main/webapp/settings/global/requirements.zul b/src/main/webapp/settings/global/requirements.zul new file mode 100644 index 00000000..efc84862 --- /dev/null +++ b/src/main/webapp/settings/global/requirements.zul @@ -0,0 +1,28 @@ + + + + +
+ +
+
+ + + +