From f13bc6e5c45d7e752188e65832890c3f23516ade Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sat, 7 Mar 2015 18:53:06 +0100 Subject: [PATCH] =?UTF-8?q?Zm=C4=9Bnou=20schv=C3=A1len=C3=A9ho=20po=C5=BEa?= =?UTF-8?q?davku=20na=20slu=C5=BEebn=C3=AD=20cestu=20se=20p=C5=99egeneruje?= =?UTF-8?q?=20vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD.=20closes=20#195?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../requirement/TripRequirementService.java | 11 +++++ .../TripRequirementServiceImpl.java | 33 ++++++++++++-- .../ui/requirement/TripRequirementForm.java | 45 +++++++++++++++---- .../WEB-INF/locales/zk-label.properties | 3 ++ src/main/webapp/app/template.zhtml | 2 +- 5 files changed, 82 insertions(+), 12 deletions(-) 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 373fee93..cd44cea2 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java @@ -1,10 +1,21 @@ 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); + + /** + * 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 64522ce9..71088bfa 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -9,13 +9,15 @@ import info.bukova.isspst.data.User; import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.workgroups.WorkgroupService; - -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; +import java.util.List; + public class TripRequirementServiceImpl extends RequirementBaseServiceImpl implements TripRequirementService, RequirementBaseService { @@ -36,6 +38,23 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl getBills(TripRequirement entity) { + Query q = queryDao.getQuery("from TripBill bill where bill.requirement = :req"); + q.setParameter("req", entity); + return q.list(); + } + @Override protected void postApprove(TripRequirement entity) { if (entity.getState() == RequirementState.APPROVED) { 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 a39ec9fe..59d7e510 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java @@ -1,13 +1,7 @@ package info.bukova.isspst.ui.requirement; -import java.util.List; - -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.select.annotation.WireVariable; - +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; @@ -19,6 +13,17 @@ import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.FormViewModel; import info.bukova.isspst.validators.TripRequirementFormValidator; +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 FormViewModel { @@ -33,6 +38,30 @@ public class TripRequirementForm extends FormViewModel { @WireVariable private TripRequirementService tripRequirementService; 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 709389c5..b370fabc 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -222,6 +222,9 @@ TripBillTo=Tam TripBillBack=Zpět TripBillTotal=Celkem +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