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/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/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/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..b83c18bb 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -399,3 +399,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/main/trips/tripBillInterior.zul b/src/main/webapp/main/trips/tripBillInterior.zul index 1e0d4545..2e877373 100644 --- a/src/main/webapp/main/trips/tripBillInterior.zul +++ b/src/main/webapp/main/trips/tripBillInterior.zul @@ -43,37 +43,53 @@ - - + + + - - - + + + + + - - + + - - + +