diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index 28724080..ec6af4c0 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -33,7 +33,7 @@ import java.util.Map; public class Constants { - public final static long DB_VERSION = 3; + public final static long DB_VERSION = 4; public final static String DEF_ADMIN = "admin"; public final static String DEF_ADMIN_PASSWD = "admin"; diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index 9185bb93..fb27faa2 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -7,6 +7,15 @@ import org.zkoss.util.resource.Labels; public class StringUtils { + public static boolean isNullOrEmpty(String str) + { + return ((str == null) || (str.isEmpty())); + } + + public static boolean isNullOrTrimmedEmpty(String str) + { + return ((str == null) || (str.trim().isEmpty())); + } public static String nullToEmptyString(String str) { diff --git a/src/main/java/info/bukova/isspst/data/SettingsData.java b/src/main/java/info/bukova/isspst/data/SettingsData.java index acbb9fdd..ae1674dd 100644 --- a/src/main/java/info/bukova/isspst/data/SettingsData.java +++ b/src/main/java/info/bukova/isspst/data/SettingsData.java @@ -22,6 +22,7 @@ public class SettingsData { private List vehicles; private Map refunds; private String stampFile; + private String logoFile; public SettingsData() { newReqTemplate = new MailMessage(); @@ -140,4 +141,13 @@ public class SettingsData { this.stampFile = stampFile; } + public String getLogoFile() + { + return logoFile; + } + + public void setLogoFile(String logoFile) + { + this.logoFile = logoFile; + } } diff --git a/src/main/java/info/bukova/isspst/data/TripBill.java b/src/main/java/info/bukova/isspst/data/TripBill.java index 0f75f7aa..f5fc295e 100644 --- a/src/main/java/info/bukova/isspst/data/TripBill.java +++ b/src/main/java/info/bukova/isspst/data/TripBill.java @@ -1,10 +1,11 @@ package info.bukova.isspst.data; import info.bukova.isspst.storage.EntityWithAttachment; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; -import org.hibernate.search.annotations.Indexed; -import org.hibernate.search.annotations.IndexedEmbedded; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -15,10 +16,14 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; + +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +import org.hibernate.search.annotations.Analyze; +import org.hibernate.search.annotations.Field; +import org.hibernate.search.annotations.Index; +import org.hibernate.search.annotations.Indexed; +import org.hibernate.search.annotations.IndexedEmbedded; @Entity @Table(name = "TRIP_BILL") @@ -32,6 +37,11 @@ public class TripBill extends BaseData implements EntityWithAttachment { private Date resultMessageDate; @Column(name = "SIGN_DATE") private Date signDate; + + @Column(name = "RESULT_MESSAGE") + @Field(index = Index.YES, analyze = Analyze.YES) + private String resultMessage; + @Column(name = "FREE_MEALS") private boolean freeMeals; @Column(name = "FREE_HOUSING") @@ -85,6 +95,16 @@ public class TripBill extends BaseData implements EntityWithAttachment { this.signDate = signDate; } + public String getResultMessage() + { + return resultMessage; + } + + public void setResultMessage(String resultMessage) + { + this.resultMessage = resultMessage; + } + public boolean isFreeMeals() { return freeMeals; } diff --git a/src/main/java/info/bukova/isspst/data/UsersAddress.java b/src/main/java/info/bukova/isspst/data/UsersAddress.java index d5aeb44b..f3f761ba 100644 --- a/src/main/java/info/bukova/isspst/data/UsersAddress.java +++ b/src/main/java/info/bukova/isspst/data/UsersAddress.java @@ -1,5 +1,10 @@ package info.bukova.isspst.data; +import info.bukova.isspst.StringUtils; + +import java.util.ArrayList; +import java.util.List; + import javax.persistence.Column; import javax.persistence.Embeddable; @@ -47,4 +52,22 @@ public class UsersAddress { this.city = city; } + public String toString() { + List list = new ArrayList(); + list.add(this.street); + list.add(this.houseNumber); + final String s1 = StringUtils.joinNotEmpty(list, " "); + + list.clear(); + list.add(this.zipCode); + list.add(this.city); + final String s2 = StringUtils.joinNotEmpty(list, " "); + + list.clear(); + list.add(s1); + list.add(s2); + final String s = StringUtils.joinNotEmpty(list, ", "); + + return s; + } } diff --git a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java index 4cb8e873..24b6e544 100644 --- a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java +++ b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java @@ -1,8 +1,6 @@ package info.bukova.isspst.reporting; -import java.util.HashMap; -import java.util.Map; - +import info.bukova.isspst.data.Address; import info.bukova.isspst.data.AuthItem; import info.bukova.isspst.data.Order; import info.bukova.isspst.data.TripBill; @@ -13,8 +11,13 @@ import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.storage.FileStorage; +import java.util.HashMap; +import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; +import com.mysql.jdbc.StringUtils; + public class ParamFiller { @Autowired @@ -45,6 +48,7 @@ public class ParamFiller { if ((definition.getDataSet().get(0) instanceof TripBill) && definition.getReport().isSingleRecord()) { + if (userService.getUserSettings().getSignatureFile() != null && !userService.getUserSettings().getSignatureFile().isEmpty()) { definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile())); @@ -52,17 +56,25 @@ public class ParamFiller { TripBill tb = (TripBill)definition.getDataSet().get(0); tripReqService.loadAuthItems(tb.getRequirement()); + + AuthItem lastButOneAuth = tb.getRequirement().getAuthorization().get(0); + definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate()); + + User lastButOneUser = lastButOneAuth.getApprover(); + UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser); + + if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) { + definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile())); + } + + AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1); - definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate()); User u = lastAuth.getApprover(); - UserSettingsData approverSettings = userService.getUserSettings(u); - if (approverSettings != null - && approverSettings.getSignatureFile() != null - && !approverSettings.getSignatureFile().isEmpty()) { + if (approverSettings != null && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) { definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile())); } } @@ -74,6 +86,15 @@ public class ParamFiller { definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile())); } } + + definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile())); + + Address mainAddress = settingService.getSettings().getMainAddress(); + + if (mainAddress != null) { + String addr = (StringUtils.isNullOrEmpty(mainAddress.getCompany()) ? "" : mainAddress.getCompany()); + definition.setParam("P_MAIN_ADDRESS", addr); + } } } diff --git a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java index 60d74265..72c5a3fc 100644 --- a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java @@ -126,6 +126,13 @@ public class DbInfoServiceImpl extends AbstractService implements DbInfo sq.executeUpdate(); } + if (dbVersion < 4) + { + sql = "UPDATE TRIP_BILL SET RESULT_MESSAGE = 'Zpráva z pracovní cesty' WHERE (RESULT_MESSAGE Is NULL) "; + sq = this.dao.getSession().createSQLQuery(sql); + sq.executeUpdate(); + } + this.updateDatabaseVersion(); } } 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 fdeda412..3577e450 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java @@ -1,6 +1,7 @@ package info.bukova.isspst.ui.settings; import info.bukova.isspst.Constants; +import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.Address; import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.SettingsData; @@ -77,7 +78,24 @@ public class GlobalSettingsVM extends DocumentViewModel storage.removeFile(settings.getStampFile()); settings.setStampFile(null); } - + + @Command + @NotifyChange({ "settings", "logoImg" }) + public void uploadLogo(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent upEvent) { + int i = upEvent.getMedia().getName().lastIndexOf("."); + String fileName = "LogoImageFile" + upEvent.getMedia().getName().substring(i); + storage.saveFile(upEvent.getMedia().getByteData(), fileName); + settings.setLogoFile(fileName); + } + + @Command + @NotifyChange("logoImg") + public void removeLogo() + { + storage.removeFile(settings.getLogoFile()); + settings.setLogoFile(null); + } + public List getRequirementFields() { return ReflectionTools.getEntityFields(Requirement.class); } @@ -144,7 +162,7 @@ public class GlobalSettingsVM extends DocumentViewModel } public RenderedImage getStampImg() { - if (settings.getStampFile() == null || settings.getStampFile().isEmpty()) { + if (StringUtils.isNullOrEmpty(settings.getStampFile())) { return null; } @@ -155,4 +173,16 @@ public class GlobalSettingsVM extends DocumentViewModel } } + public RenderedImage getLogoImg() { + if (StringUtils.isNullOrEmpty(settings.getLogoFile())) { + return null; + } + + try { + return ImageIO.read(storage.file(settings.getLogoFile())); + } + catch (IOException e) { + return null; + } + } } diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java index 94102475..6d03e144 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java @@ -8,6 +8,10 @@ import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.tripbill.TripBillApprovalService; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.ui.FormWithUpload; + +import java.util.ArrayList; +import java.util.List; + import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; @@ -18,9 +22,6 @@ import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Window; -import java.util.ArrayList; -import java.util.List; - public class TripBillForm extends FormWithUpload { @WireVariable @@ -63,8 +64,16 @@ public class TripBillForm extends FormWithUpload { @Override @Command @NotifyChange("errMessages") - public void save(@BindingParam("window") Window win) { + public void save(@BindingParam("window") Window win) + { + if (StringUtils.isNullOrTrimmedEmpty(this.getDataBean().getResultMessage())) + { + Messagebox.show(StringUtils.localize("ErrFillTripBillResultMessageText"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR); + return; + } + final Window editWin = win; + if (getDataBean().getApproval() == null && !isBillDisabled()) { Messagebox.show(StringUtils.localize("TripBillSaveApprove"), StringUtils.localize("TripBillSave"), Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, new EventListener() { diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index fc15aa6b..a800620e 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -182,6 +182,8 @@ GlobalSettingsFreeMealsCount=Počet jídel zdarma GlobalSettingsHours=Hodin GlobalSettingsUploadStamp=Nahrát obrázek razítka GlobalSettingsStamp=Razítko +GlobalSettingsUploadOrganizationLogo=Nahrát logo +GlobalSettingsOrganizationLogo=Logo GlobalSettingsReqEnable=Povolení požadavků GlobalSettingsInsertUrl=Vložit URL záznamu @@ -399,3 +401,5 @@ Passenger = Pasažér ChooseThePasseger = Vyberte pasažéra TransportMode = Způsob dopravy ForeignPersons = Cizí osoby +TripBillResultMessageText = Zpráva z pracovní cesty +ErrFillTripBillResultMessageText = Vyplňte zprávu z pracovní cesty. diff --git a/src/main/webapp/WEB-INF/reports/tripBill.jasper b/src/main/webapp/WEB-INF/reports/tripBill.jasper index a2febae2..d324b8cd 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripBill.jasper and b/src/main/webapp/WEB-INF/reports/tripBill.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripBill.jrxml b/src/main/webapp/WEB-INF/reports/tripBill.jrxml index 2a937252..6fb9ddf4 100644 --- a/src/main/webapp/WEB-INF/reports/tripBill.jrxml +++ b/src/main/webapp/WEB-INF/reports/tripBill.jrxml @@ -1,12 +1,18 @@ - - - - + + + + - + + + + + + + @@ -46,169 +52,194 @@ + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - + + + - + - + - + - + - + - + - + - - + + - + + + + + + + + + + + + + + + + + + + @@ -239,12 +270,12 @@ tuzemské pracovní cesty]]> - + - + @@ -329,7 +360,7 @@ tuzemské pracovní cesty]]> - + @@ -390,6 +421,18 @@ tuzemské pracovní cesty]]> + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/reports/tripBillFreeMeals.jasper b/src/main/webapp/WEB-INF/reports/tripBillFreeMeals.jasper index 2683be74..096bd0e6 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripBillFreeMeals.jasper and b/src/main/webapp/WEB-INF/reports/tripBillFreeMeals.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripBillItems.jasper b/src/main/webapp/WEB-INF/reports/tripBillItems.jasper index a5f52472..3b13ab43 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripBillItems.jasper and b/src/main/webapp/WEB-INF/reports/tripBillItems.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripRequirement.jasper b/src/main/webapp/WEB-INF/reports/tripRequirement.jasper index eff4bf30..4e5a43a6 100644 Binary files a/src/main/webapp/WEB-INF/reports/tripRequirement.jasper and b/src/main/webapp/WEB-INF/reports/tripRequirement.jasper differ diff --git a/src/main/webapp/WEB-INF/reports/tripRequirement.jrxml b/src/main/webapp/WEB-INF/reports/tripRequirement.jrxml index e1bbf087..f8a88eba 100644 --- a/src/main/webapp/WEB-INF/reports/tripRequirement.jrxml +++ b/src/main/webapp/WEB-INF/reports/tripRequirement.jrxml @@ -2,7 +2,7 @@ - +