diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java index 5e6805b7..cd44cea2 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java @@ -3,10 +3,19 @@ package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.TripRequirement; +import java.util.List; + public interface TripRequirementService extends RequirementBaseService { public void loadPassangers(TripRequirement entity); - public TripBill getTripBill(TripRequirement requirement); + + /** + * Vrátí seznam vyúčtování, která josu vázána k požadavku + * + * @param entity požadavek + * @return seznam vyúčtování + */ + public List getBills(TripRequirement entity); } 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 180626fd..1a0fea5e 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -5,10 +5,13 @@ import info.bukova.isspst.data.*; import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.workgroups.WorkgroupService; -import org.hibernate.Hibernate; + +import java.util.Date; + import org.hibernate.LazyInitializationException; import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import java.util.Date; @@ -34,6 +37,23 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl result = q.list(); - - if (result.size() > 0) { - return result.get(0); - } - - return null; + public List getBills(TripRequirement entity) { + Query q = queryDao.getQuery("from TripBill bill where bill.requirement = :req"); + q.setParameter("req", entity); + return q.list(); } @Transactional diff --git a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java index 7420bf1b..a38524d6 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java @@ -1,5 +1,7 @@ package info.bukova.isspst.ui.requirement; +import info.bukova.isspst.StringUtils; +import info.bukova.isspst.data.RequirementState; import info.bukova.isspst.data.SettingsData; import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.User; @@ -16,11 +18,15 @@ import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.select.annotation.WireVariable; +import org.zkoss.zul.Messagebox; +import org.zkoss.zul.Window; import java.util.List; -public class TripRequirementForm extends FormWithUpload { +public class TripRequirementForm extends FormViewModel { @WireVariable private UserService userService; @@ -35,6 +41,30 @@ public class TripRequirementForm extends FormWithUpload { @WireVariable private DocumentFileStorage documentStorage; private List centres; + + @Override + @NotifyChange("errMessages") + @Command + public void save(@BindingParam("window") Window win) { + final Window editWin = win; + + if (getDataBean().getState() == RequirementState.APPROVED) { + Messagebox.show(StringUtils.localize("TripRequirementChangeWarn"), StringUtils.localize("TripRequirementSave"), Messagebox.YES + | Messagebox.NO, Messagebox.QUESTION, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + if (((Integer) event.getData()).intValue() == Messagebox.YES) { + TripRequirementForm.super.save(editWin); + } else { + editWin.detach(); + } + } + }); + } else { + super.save(win); + } + } + private List users; private List passengers; private User selUser; diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 31e76fe0..ec72b795 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -233,6 +233,9 @@ TripBillTotal=Celkem TripRequirement=Požadavek na služební cestu ShowTripBill=Zobrazit vyúčtování +TripRequirementChangeWarn=Editací schváleného požadavku se znovu vygeneruje vyúčtování. Opravdu chcete záznam uložit? +TripRequirementSave=Uložit požadavek? + CentresForRequirements=Střediska, pro která lze vkládat požadavky WorkgroupMembership=Členství v komisích LogedInUser=Přihlášený uživatel: diff --git a/src/main/webapp/app/template.zhtml b/src/main/webapp/app/template.zhtml index 2bdf230c..659149bf 100644 --- a/src/main/webapp/app/template.zhtml +++ b/src/main/webapp/app/template.zhtml @@ -51,6 +51,6 @@
- + \ No newline at end of file