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