From 3b3e4b38e6a6dffd3805668c85d13a0224f9d715 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 14 Jun 2015 20:45:36 +0200 Subject: [PATCH] =?UTF-8?q?Vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD=20slu=C5=BEebn?= =?UTF-8?q?=C3=AD=20cesty=20nelze=20odeslat=20ke=20schv=C3=A1len=C3=AD,=20?= =?UTF-8?q?pokud=20nejsou=20vypln=C4=9Bn=C3=A9=20=C4=8Dasy=20odjezdu=20a?= =?UTF-8?q?=20p=C5=99=C3=ADjezdu.=20closes=20#230?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isspst/ui/tripbill/TripBillForm.java | 25 ++++++++++++++++--- .../WEB-INF/locales/zk-label.properties | 2 ++ src/main/webapp/settings/global/email.zul | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) 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 286269a6..1f2cfdbe 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java @@ -3,6 +3,7 @@ package info.bukova.isspst.ui.tripbill; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.TripBillApproval; +import info.bukova.isspst.data.TripBillItem; import info.bukova.isspst.data.Vehicle; import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.tripbill.TripBillApprovalService; @@ -66,9 +67,7 @@ public class TripBillForm extends FormWithUpload { @NotifyChange("errMessages") public void saveForApproval(@BindingParam("window") Window win) { - if (StringUtils.isNullOrTrimmedEmpty(this.getDataBean().getResultMessage())) - { - Messagebox.show(StringUtils.localize("ErrFillTripBillResultMessageText"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR); + if (!canSaveForApproval()) { return; } @@ -94,6 +93,26 @@ public class TripBillForm extends FormWithUpload { } + private boolean canSaveForApproval() { + if (StringUtils.isNullOrTrimmedEmpty(this.getDataBean().getResultMessage())) { + Messagebox.show(StringUtils.localize("ErrFillTripBillResultMessageText"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR); + return false; + } + + if (getDataBean().getBillItems() != null && !getDataBean().getBillItems().isEmpty()) { + TripBillItem first = getDataBean().getBillItems().get(0); + TripBillItem last = getDataBean().getBillItems().get(getDataBean().getBillItems().size() - 1); + + if (first.getToArrival() == null || first.getToDeparture() == null + || last.getBackArrival() == null || last.getBackDeparture() == null) { + Messagebox.show(StringUtils.localize("ErrFillTripBillResultTimes"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR); + return false; + } + } + + return true; + } + @Override protected void doSave() { maintainAttachment(); diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index a6754a1e..eaed015c 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -167,6 +167,7 @@ EMails=E-maily NewRequirement=Nový požadavek AuthRequirement=Dílčí schválení ConfirmRequirement=Schválení +ConfirmTripPassengers=Schválení SC - spolucestující InsertField=Vložit pole EnableRequirements=Povolit zadávání požadavků ShippingAddresses=Dodací adresy: @@ -403,3 +404,4 @@ TransportMode = Způsob dopravy ForeignPersons = Cizí osoby TripBillResultMessageText = Zpráva z pracovní cesty ErrFillTripBillResultMessageText = Vyplňte zprávu z pracovní cesty. +ErrFillTripBillResultTimes = Zadejte časy odjezdu a příjezdu. diff --git a/src/main/webapp/settings/global/email.zul b/src/main/webapp/settings/global/email.zul index e8ac7caf..73c2afed 100644 --- a/src/main/webapp/settings/global/email.zul +++ b/src/main/webapp/settings/global/email.zul @@ -7,7 +7,7 @@ - +