diff --git a/src/main/java/info/bukova/isspst/data/SettingsData.java b/src/main/java/info/bukova/isspst/data/SettingsData.java index b068c08b..9272a483 100644 --- a/src/main/java/info/bukova/isspst/data/SettingsData.java +++ b/src/main/java/info/bukova/isspst/data/SettingsData.java @@ -15,6 +15,7 @@ public class SettingsData { private MailMessage authReqTemplate; private MailMessage confReqTemplate; private MailMessage confReqTripPassenger; + private MailMessage reqPassenger; private Address mainAddress; private List
shippingAddrs; private String bankName; @@ -30,6 +31,7 @@ public class SettingsData { authReqTemplate = new MailMessage(); confReqTemplate = new MailMessage(); confReqTripPassenger = new MailMessage(); + reqPassenger = new MailMessage(); mainAddress = new Address(); shippingAddrs = new ArrayList
(); vehicles = new ArrayList(); @@ -160,4 +162,12 @@ public class SettingsData { public void setConfReqTripPassenger(MailMessage confReqTripPassenger) { this.confReqTripPassenger = confReqTripPassenger; } + + public MailMessage getReqPassenger() { + return reqPassenger; + } + + public void setReqPassenger(MailMessage reqPassenger) { + this.reqPassenger = reqPassenger; + } } diff --git a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java index 24b6e544..41aec3b7 100644 --- a/src/main/java/info/bukova/isspst/reporting/ParamFiller.java +++ b/src/main/java/info/bukova/isspst/reporting/ParamFiller.java @@ -1,5 +1,6 @@ package info.bukova.isspst.reporting; +import com.mysql.jdbc.StringUtils; import info.bukova.isspst.data.Address; import info.bukova.isspst.data.AuthItem; import info.bukova.isspst.data.Order; @@ -8,16 +9,14 @@ 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.tripbill.TripBillApprovalService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.storage.FileStorage; +import org.springframework.beans.factory.annotation.Autowired; import java.util.HashMap; import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; - -import com.mysql.jdbc.StringUtils; - public class ParamFiller { @Autowired @@ -30,6 +29,8 @@ public class ParamFiller { private TripRequirementService tripReqService; @Autowired private GlobalSettingsService settingService; + @Autowired + private TripBillApprovalService tripBillApprovalService; public void fill() { if (definition.getDataSet() == null || definition.getDataSet().isEmpty()) { @@ -57,25 +58,31 @@ 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()); + if (tb.getApproval() != null) { + tripBillApprovalService.loadAuthItems(tb.getApproval()); + } - User lastButOneUser = lastButOneAuth.getApprover(); - UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser); + if (tb.getApproval() != null && tb.getApproval().getAuthorization() != null && !tb.getApproval().getAuthorization().isEmpty()) { - if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) { - definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile())); - } + AuthItem lastButOneAuth = tb.getApproval().getAuthorization().get(0); + definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate()); + User lastButOneUser = lastButOneAuth.getApprover(); + UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser); - 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 && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) { - definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile())); + if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) { + definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile())); + } + + AuthItem lastAuth = tb.getApproval().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 && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) { + definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile())); + } } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java index 0a2c823c..52f7e8da 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -77,6 +77,21 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl { @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 92db7881..535c0d1b 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -173,6 +173,8 @@ EMails=E-maily NewRequirement=Nový požadavek AuthRequirement=Dílčí schválení ConfirmRequirement=Schválení +ConfirmTripPassengers=Schválení SC - spolucestující +ReqTripPassengers=SC - spolucestujici InsertField=Vložit pole EnableRequirements=Povolit zadávání požadavků ShippingAddresses=Dodací adresy: @@ -409,3 +411,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/WEB-INF/reports/tripBill.jasper b/src/main/webapp/WEB-INF/reports/tripBill.jasper index 2d1911c6..11f966a1 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 6fb9ddf4..c51d0ef8 100644 --- a/src/main/webapp/WEB-INF/reports/tripBill.jrxml +++ b/src/main/webapp/WEB-INF/reports/tripBill.jrxml @@ -2,7 +2,7 @@ - + @@ -571,6 +571,20 @@ tuzemské pracovní cesty]]> + + + + + + + + + + + + + + diff --git a/src/main/webapp/main/trips/tripBillInterior.zul b/src/main/webapp/main/trips/tripBillInterior.zul index 676747a0..f9d29037 100644 --- a/src/main/webapp/main/trips/tripBillInterior.zul +++ b/src/main/webapp/main/trips/tripBillInterior.zul @@ -341,13 +341,13 @@ diff --git a/src/main/webapp/settings/global/email.zul b/src/main/webapp/settings/global/email.zul index e8ac7caf..4bfc4e4d 100644 --- a/src/main/webapp/settings/global/email.zul +++ b/src/main/webapp/settings/global/email.zul @@ -7,7 +7,8 @@ - + + @@ -91,6 +92,31 @@ + + + + + + + + + + + + + +