From 369184940b173dd5a848fa76f27d3b833c096acc Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 11 Oct 2015 21:52:50 +0200 Subject: [PATCH] =?UTF-8?q?Do=20agendy=20Cestovn=C3=AD=20p=C5=99=C3=ADkazy?= =?UTF-8?q?=20byly=20p=C5=99id=C3=A1ny=20z=C3=A1lo=C5=BEky=20"M=C3=A1=20st?= =?UTF-8?q?=C5=99ediska",=20"M=C3=A9=20komise"=20a=20"V=C5=A1e",=20kde=20s?= =?UTF-8?q?e=20zobrazuj=C3=AD=20vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD=20slu=C5=BE?= =?UTF-8?q?ebn=C3=ADch=20ke=20schv=C3=A1len=C3=AD.=20V=20z=C3=A1lo=C5=BEk?= =?UTF-8?q?=C3=A1ch=20lze=20vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD=20ozna=C4=8Dit?= =?UTF-8?q?=20jako=20proplacen=C3=A9.=20Do=20e-mailu=20se=20generuje=20odk?= =?UTF-8?q?az=20do=20t=C4=9Bchto=20z=C3=A1lo=C5=BEek.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #253 closes #250 --- .../java/info/bukova/isspst/Constants.java | 7 +- .../isspst/TripBillAprovalUrlResolver.java | 2 +- .../info/bukova/isspst/data/TripBill.java | 20 ++ .../filters/TripBillApprovalFilter.java | 78 +++++++ .../services/tripbill/PayException.java | 18 ++ .../tripbill/TripBillApprovalServiceImpl.java | 28 +++ .../services/tripbill/TripBillService.java | 2 + .../tripbill/TripBillServiceImpl.java | 18 +- .../info/bukova/isspst/ui/ListViewModel.java | 13 +- .../TripBillApprovalItemRenderer.java | 40 ++++ .../ui/requirement/RequirementSubpage.java | 2 +- .../isspst/ui/tripbill/PayDialogVM.java | 60 ++++++ .../isspst/ui/tripbill/TripBillForm.java | 2 + .../isspst/ui/tripbill/TripBillListAll.java | 34 +++ .../isspst/ui/tripbill/TripBillListBase.java | 86 ++++++++ .../ui/tripbill/TripBillListCentre.java | 34 +++ .../ui/tripbill/TripBillListWorkgroup.java | 35 ++++ .../WEB-INF/locales/zk-label.properties | 6 + src/main/webapp/main/trips/bill/index.zul | 2 +- src/main/webapp/main/trips/bill/payDialog.zul | 32 +++ src/main/webapp/main/trips/bill/setup.zul | 21 ++ .../main/trips/bill/tripBillGridAll.zul | 14 ++ .../main/trips/bill/tripBillGridCenters.zul | 14 ++ .../main/trips/bill/tripBillGridInt.zul | 198 ++++++++++++++++++ .../webapp/main/trips/bill/tripBillGridMy.zul | 84 ++++++++ .../trips/bill/tripBillGridWorkgroups.zul | 14 ++ 26 files changed, 851 insertions(+), 13 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java create mode 100644 src/main/java/info/bukova/isspst/services/tripbill/PayException.java create mode 100644 src/main/java/info/bukova/isspst/ui/renderers/TripBillApprovalItemRenderer.java create mode 100644 src/main/java/info/bukova/isspst/ui/tripbill/PayDialogVM.java create mode 100644 src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java create mode 100644 src/main/java/info/bukova/isspst/ui/tripbill/TripBillListBase.java create mode 100644 src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java create mode 100644 src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java create mode 100644 src/main/webapp/main/trips/bill/payDialog.zul create mode 100644 src/main/webapp/main/trips/bill/setup.zul create mode 100644 src/main/webapp/main/trips/bill/tripBillGridAll.zul create mode 100644 src/main/webapp/main/trips/bill/tripBillGridCenters.zul create mode 100644 src/main/webapp/main/trips/bill/tripBillGridInt.zul create mode 100644 src/main/webapp/main/trips/bill/tripBillGridMy.zul create mode 100644 src/main/webapp/main/trips/bill/tripBillGridWorkgroups.zul diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index bf312895..9a10d6fc 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -116,6 +116,7 @@ public class Constants { public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN"; public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW"; public final static String PERM_SEARCH = "PERM_SEARCH"; + public final static String PERM_PAY_BILL = "PERM_PAY_BILL"; public final static Permission SPECIAL_PERMISSIONS[] = { new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), @@ -133,7 +134,9 @@ public class Constants { new Permission(PERM_APPROVE, "Schválení", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SEARCH, "Vyhledávat", MOD_SEARCH, PermissionType.GLOBAL), - new Permission(PERM_READ, "Číst", MOD_SIGNEDDOCS, PermissionType.GLOBAL) + new Permission(PERM_READ, "Číst", MOD_SIGNEDDOCS, PermissionType.GLOBAL), + + new Permission(PERM_PAY_BILL, "Vyplacení SC", MOD_TRIPBILL, PermissionType.GLOBAL) }; public final static String DYNAMIC_REPORT_NAME = "Tabulková sestava"; @@ -162,7 +165,7 @@ public class Constants { public final static Map, String> URL_MAP = Collections.unmodifiableMap(new HashMap, String>() {{ put(Requirement.class, "/main/orders/"); put(TripRequirement.class, "/main/trips/requirements/"); - put(TripBillApproval.class, "/main/trips/requirements/"); + put(TripBillApproval.class, "/main/trips/bill/"); put(Order.class, "/main/orders/created/"); put(TripBill.class, "/main/trips/bill/"); }} ); diff --git a/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java b/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java index 9f0b57c3..ae46f4d0 100644 --- a/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java +++ b/src/main/java/info/bukova/isspst/TripBillAprovalUrlResolver.java @@ -21,7 +21,7 @@ public class TripBillAprovalUrlResolver implements EntityUrlResolver { if (entity instanceof TripBillApproval) { String url = Constants.URL_MAP.get(entity.getClass()); - return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getBill().getRequirement().getId()); + return defUrl + url + "?select=" + String.valueOf(((TripBillApproval)entity).getId()); } return defUrl + "/app"; diff --git a/src/main/java/info/bukova/isspst/data/TripBill.java b/src/main/java/info/bukova/isspst/data/TripBill.java index 369de0e2..494c383c 100644 --- a/src/main/java/info/bukova/isspst/data/TripBill.java +++ b/src/main/java/info/bukova/isspst/data/TripBill.java @@ -65,6 +65,10 @@ public class TripBill extends BaseData implements EntityWithAttachment { private TripBillApproval approval; @Column(name = "SAVED") private Boolean saved; // Nastaveno na true, pokud uživatel udělá změnu- nepřenáší se pak částky od žadatele + @Column(name = "PAID") + private Boolean paid; + @Column(name = "PAID_DATE") + private Date paidDate; public TripBill() { billItems = new ArrayList(); @@ -186,4 +190,20 @@ public class TripBill extends BaseData implements EntityWithAttachment { public void setSaved(Boolean saved) { this.saved = saved; } + + public Boolean getPaid() { + return paid; + } + + public void setPaid(Boolean paid) { + this.paid = paid; + } + + public Date getPaidDate() { + return paidDate; + } + + public void setPaidDate(Date paidDate) { + this.paidDate = paidDate; + } } diff --git a/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java b/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java new file mode 100644 index 00000000..bc36d769 --- /dev/null +++ b/src/main/java/info/bukova/isspst/filters/TripBillApprovalFilter.java @@ -0,0 +1,78 @@ +package info.bukova.isspst.filters; + +import info.bukova.isspst.BooleanUtils; +import info.bukova.isspst.DateTimeUtils; +import info.bukova.isspst.StringUtils; +import info.bukova.isspst.data.TripBillApproval; +import info.bukova.isspst.data.User; +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +public class TripBillApprovalFilter implements Filter +{ + + private TripBillApproval condition; + + public TripBillApprovalFilter(TripBillApproval cond) + { + this.condition = cond; + } + + private static class TripBillApprovalMatcher extends TypeSafeMatcher + { + + private TripBillApproval condition; + + public TripBillApprovalMatcher(TripBillApproval cond) + { + this.condition = cond; + } + + @Override + public void describeTo(Description desc) + { + desc.appendText("requirement matches"); + } + + @Override + public boolean matchesSafely(TripBillApproval item) + { + if (item.getBill() == null) { + return false; + } + + boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); + boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getReqDate(), condition.getBill().getRequirement().getReqDate()); + boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); + boolean foundFrom = StringUtils.isEqualForFilter(item.getBill().getRequirement().getFrom(), condition.getBill().getRequirement().getFrom()); + boolean foundTo = StringUtils.isEqualForFilter(item.getBill().getRequirement().getTo(), condition.getBill().getRequirement().getTo()); + boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup()))); + boolean foundCentre = (condition.getCentre() == null || (item.getCentre() != null && item.getCentre().equals(condition.getCentre()))); + boolean foundOwner = User.isEqualByUserForFilter(item.getBill().getOwnedBy(), condition.getBill().getOwnedBy()); + boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid()); + boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate()); + return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid && foundPaidDate; + } + + @Factory + public static Matcher matchTripRequirement(TripBillApproval building) + { + return new TripBillApprovalMatcher(building); + } + } + + @Override + public TripBillApprovalMatcher matcher() + { + return new TripBillApprovalMatcher(condition); + } + + @Override + public String queryString() + { + return ""; + } + +} diff --git a/src/main/java/info/bukova/isspst/services/tripbill/PayException.java b/src/main/java/info/bukova/isspst/services/tripbill/PayException.java new file mode 100644 index 00000000..38819eab --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/tripbill/PayException.java @@ -0,0 +1,18 @@ +package info.bukova.isspst.services.tripbill; + +import info.bukova.isspst.services.IsspstException; + +/** + * @author Pepa Rokos + */ +public class PayException extends IsspstException { + + public PayException() { + super(); + } + + public PayException(String message) { + super(message); + setReason(message); + } +} diff --git a/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java b/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java index 4f3410f3..3e92cd03 100644 --- a/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/tripbill/TripBillApprovalServiceImpl.java @@ -1,6 +1,8 @@ package info.bukova.isspst.services.tripbill; import info.bukova.isspst.Constants; +import info.bukova.isspst.Module; +import info.bukova.isspst.ModuleUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.DataModel; import info.bukova.isspst.data.RequirementState; @@ -10,6 +12,7 @@ import info.bukova.isspst.services.IsspstException; import info.bukova.isspst.services.requirement.RequirementBaseServiceImpl; import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.signeddocs.SignedDocumentService; +import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; @@ -72,4 +75,29 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl { @@ -15,6 +16,7 @@ public interface TripBillService extends Service { public List getMy(); public void loadOwner(TripBill bill); public void loadPassengers(TripBill bill); + public void setPaid(TripBill bill, Date date); /** * Uloží vyúčtování a nastaví příznak přenosu vyúčtování od žadatele diff --git a/src/main/java/info/bukova/isspst/services/tripbill/TripBillServiceImpl.java b/src/main/java/info/bukova/isspst/services/tripbill/TripBillServiceImpl.java index d0aa9d21..c6e3510e 100644 --- a/src/main/java/info/bukova/isspst/services/tripbill/TripBillServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/tripbill/TripBillServiceImpl.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; +import java.util.Date; import java.util.List; public class TripBillServiceImpl extends AbstractOwnedService implements @@ -212,6 +213,19 @@ public class TripBillServiceImpl extends AbstractOwnedService implemen bill.getRequirement().setPassengers(tr.getPassengers()); } + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_PAY_BILL')") + public void setPaid(TripBill bill, Date date) { + if (bill.getApproval() == null || bill.getApproval().getState() != RequirementState.APPROVED) { + throw new PayException("BillNotApproved"); + } + + bill.setPaid(true); + bill.setPaidDate(date); + super.update(bill); + } + @Override @Transactional @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") @@ -252,7 +266,9 @@ public class TripBillServiceImpl extends AbstractOwnedService implemen @Override public boolean canPrintRecord(TripBill entity) { - if (entity.getApproval() != null && entity.getApproval().getState() == RequirementState.APPROVED) { + if (entity.getApproval() != null + && entity.getApproval().getState() == RequirementState.APPROVED + && (entity.getPaid() == null || !entity.getPaid())) { return true; } diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index 0b746112..6872e665 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -5,12 +5,6 @@ import info.bukova.isspst.data.DataModel; import info.bukova.isspst.filters.Filter; import info.bukova.isspst.services.IsspstException; import info.bukova.isspst.services.Service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataIntegrityViolationException; @@ -27,6 +21,11 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Window; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class ListViewModel extends DocumentViewModel { @@ -277,7 +276,7 @@ public class ListViewModel extends DocumentViewModel } @Command - @NotifyChange({"selIndex", "dataBean"}) + @NotifyChange({"selIndex", "dataBean", "ableToDelete"}) public void afterRender() { if (editBean != null && !editBean.isValid()) { return; diff --git a/src/main/java/info/bukova/isspst/ui/renderers/TripBillApprovalItemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/TripBillApprovalItemRenderer.java new file mode 100644 index 00000000..0b31d66d --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/renderers/TripBillApprovalItemRenderer.java @@ -0,0 +1,40 @@ +package info.bukova.isspst.ui.renderers; + +import info.bukova.isspst.data.RequirementState; +import info.bukova.isspst.data.TripBillApproval; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listitem; + +/** + * @author Pepa Rokos + */ +public class TripBillApprovalItemRenderer extends GenericListitemRenderer { + + @Override + protected void changeProperties(Listbox lb, Listitem li, int index, String varnm) { + + RequirementState state = getObjectOfStates().getState(); + + if (state != null) { + if (state == RequirementState.PARTIALLY) { + li.setSclass("req-select-partially"); + } + else if (state == RequirementState.APPROVED) { + Boolean isPaid; + + if (getObjectOfStates().getBill() == null) { + isPaid = false; + } else { + isPaid = getObjectOfStates().getBill().getPaid(); + } + + if ((isPaid != null) && (isPaid.booleanValue() == true)) { + li.setSclass("req-select-approved-project"); + } + else { + li.setSclass("req-select-approved"); + } + } + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java index b9695f26..f3c9f64b 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java @@ -50,7 +50,7 @@ public class RequirementSubpage extends ListViewModel this.requirementsItemRenderer = new RequirementsItemRenderer(); } - private RequirementBaseService getReqService() + protected RequirementBaseService getReqService() { return (RequirementBaseService) service; } diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/PayDialogVM.java b/src/main/java/info/bukova/isspst/ui/tripbill/PayDialogVM.java new file mode 100644 index 00000000..00c43dc1 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/tripbill/PayDialogVM.java @@ -0,0 +1,60 @@ +package info.bukova.isspst.ui.tripbill; + +import info.bukova.isspst.StringUtils; +import info.bukova.isspst.data.TripBill; +import info.bukova.isspst.services.tripbill.PayException; +import info.bukova.isspst.services.tripbill.TripBillService; +import info.bukova.isspst.ui.ListViewModel; +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.BindingParam; +import org.zkoss.bind.annotation.Command; +import org.zkoss.bind.annotation.ExecutionArgParam; +import org.zkoss.bind.annotation.Init; +import org.zkoss.zk.ui.select.annotation.WireVariable; +import org.zkoss.zul.Messagebox; +import org.zkoss.zul.Window; + +import java.util.Date; + +/** + * @author Pepa Rokos + */ +public class PayDialogVM { + + @WireVariable + private TripBillService tripBillService; + private TripBill bill; + private ListViewModel grid; + private Date payDate; + + @Init + public void init(@ExecutionArgParam("bill") TripBill bill, + @ExecutionArgParam("grid") ListViewModel grid) { + this.bill = bill; + this.grid = grid; + } + + @Command + public void pay(@BindingParam("window") Window window) { + try { + tripBillService.setPaid(bill, payDate); + BindUtils.postNotifyChange(null, null, grid, "dataBean"); + BindUtils.postGlobalCommand(null, null, "reload", null); + window.detach(); + } catch (PayException ex) { + Messagebox.show(StringUtils.localize(ex.getReason()), StringUtils.localize("Error"), Messagebox.OK, + Messagebox.ERROR); + } catch (AccessDeniedException ex) { + Messagebox.show(StringUtils.localize("ErrorRights"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR); + } + } + + public Date getPayDate() { + return payDate; + } + + public void setPayDate(Date payDate) { + this.payDate = payDate; + } +} 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 1f2cfdbe..2f639ec5 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillForm.java @@ -9,6 +9,7 @@ import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.tripbill.TripBillApprovalService; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.ui.FormWithUpload; +import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; @@ -82,6 +83,7 @@ public class TripBillForm extends FormWithUpload { TripBillApproval approval = tripBillApprovalService.createApproval(getDataBean()); tripBillApprovalService.add(approval); TripBillForm.super.save(editWin); + BindUtils.postGlobalCommand(null, null, "refresh", null); } else { TripBillForm.super.save(editWin); } diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java new file mode 100644 index 00000000..946f4767 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListAll.java @@ -0,0 +1,34 @@ +package info.bukova.isspst.ui.tripbill; + +import info.bukova.isspst.data.TripBillApproval; +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.Init; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pepa Rokos + */ +public class TripBillListAll extends TripBillListBase { + + @Init(superclass = true) + public void initAllList() { + } + + @Override + protected List getListFromService() { + try { + return getReqService().getAll(); + } catch (AccessDeniedException e) { + BindUtils.postGlobalCommand(null, null, "disableAll", null); + return new ArrayList(); + } + } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectAll", null); + } +} diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListBase.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListBase.java new file mode 100644 index 00000000..c039d9f2 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListBase.java @@ -0,0 +1,86 @@ +package info.bukova.isspst.ui.tripbill; + +import info.bukova.isspst.data.TripBill; +import info.bukova.isspst.data.TripBillApproval; +import info.bukova.isspst.data.TripRequirement; +import info.bukova.isspst.data.User; +import info.bukova.isspst.filters.TripBillApprovalFilter; +import info.bukova.isspst.services.tripbill.TripBillApprovalService; +import info.bukova.isspst.services.tripbill.TripBillService; +import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.ui.renderers.TripBillApprovalItemRenderer; +import info.bukova.isspst.ui.requirement.RequirementSubpage; +import org.zkoss.bind.annotation.Command; +import org.zkoss.bind.annotation.GlobalCommand; +import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.select.annotation.WireVariable; +import org.zkoss.zul.Window; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Pepa Rokos + */ +public class TripBillListBase extends RequirementSubpage { + + @WireVariable + private TripBillApprovalService tripBillApprovalService; + private TripBillApprovalItemRenderer itemRenderer; + @WireVariable + private TripBillService tripBillService; + @WireVariable + private UserService userService; + private List allUsers; + + @Init(superclass = true) + public void initListBase() { + service = tripBillApprovalService; + itemRenderer = new TripBillApprovalItemRenderer(); + dataClass = TripBillApproval.class; + TripBillApproval filter = getFilterTemplate(); + TripBill tb = new TripBill(); + tb.setRequirement(new TripRequirement()); + filter.setBill(tb); + dataFilter = new TripBillApprovalFilter(filter); + allUsers = userService.getUsersForCombo(); + } + + public TripBillApprovalItemRenderer getItemRenderer() { + return itemRenderer; + } + + @Command + public void pay() { + Map params = new HashMap(); + params.put("bill", getDataBean().getBill()); + params.put("grid", this); + Window payDialog = (Window) Executions.createComponents("payDialog.zul", null, params); + payDialog.doModal(); + } + + @Command + @Override + public void edit() { + Map params = new HashMap(); + params.put("selected", getDataBean().getBill()); + tripBillService.loadLazyData(getDataBean().getBill()); + Window win = (Window) Executions.createComponents("../requirements/tripBill.zul", null, params); + win.doModal(); + } + + @Override + public List getAllUsers() { + return allUsers; + } + + @GlobalCommand + @NotifyChange({ "dataList", "dataBean", "fullFill" }) + public void reloadRelated() + { + this.reload(); + } +} diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java new file mode 100644 index 00000000..9a6f868a --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListCentre.java @@ -0,0 +1,34 @@ +package info.bukova.isspst.ui.tripbill; + +import info.bukova.isspst.data.TripBillApproval; +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.Init; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pepa Rokos + */ +public class TripBillListCentre extends TripBillListBase { + + @Init(superclass = true) + public void initListCentre() { + } + + @Override + protected List getListFromService() { + try { + return getReqService().getCentreReq(); + } catch (AccessDeniedException e) { + BindUtils.postGlobalCommand(null, null, "disableCentre", null); + return new ArrayList(); + } + } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectCentre", null); + } +} diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java new file mode 100644 index 00000000..aee340bd --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillListWorkgroup.java @@ -0,0 +1,35 @@ +package info.bukova.isspst.ui.tripbill; + +import info.bukova.isspst.data.TripBillApproval; +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.Init; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Pepa Rokos + */ +public class TripBillListWorkgroup extends TripBillListBase { + + @Init(superclass = true) + public void initWorkgroupList() { + } + + @Override + protected List getListFromService() { + try { + return getReqService().getWorkgroupReq(); + } catch (AccessDeniedException e) { + BindUtils.postGlobalCommand(null, null, "disableWorkgroup", null); + return new ArrayList(); + } + } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectWorkgroup", null); + } + +} diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index d1af6cac..c0143471 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -244,9 +244,15 @@ TripBillSave=Odeslat ke schválení? TripBillCancelApproval=Zrušit schválení a povolit úpravy TripBillCancelApprovalQuestion=Opravdu zrušít schválení tohoto vyúčtování? TripBillCancelApprovalTitle=Zrušit schválení +TripBillPaid=Proplaceno +TripBillPaidDate=Datum proplacení +TripBillPay=Proplatit TripBillSummaryDetail=Detail +TripBilling=Proplacení vyúčtování +BillNotApproved=Vyúčtování není schválené, nelze proplatit. + TripRequirement=Požadavek na služební cestu ShowTripBill=Zobrazit vyúčtování diff --git a/src/main/webapp/main/trips/bill/index.zul b/src/main/webapp/main/trips/bill/index.zul index 7f9da3db..45e8340e 100644 --- a/src/main/webapp/main/trips/bill/index.zul +++ b/src/main/webapp/main/trips/bill/index.zul @@ -2,7 +2,7 @@ - String gridZul = "tripBillGrid.zul"; + String gridZul = "setup.zul"; diff --git a/src/main/webapp/main/trips/bill/payDialog.zul b/src/main/webapp/main/trips/bill/payDialog.zul new file mode 100644 index 00000000..db16050c --- /dev/null +++ b/src/main/webapp/main/trips/bill/payDialog.zul @@ -0,0 +1,32 @@ + + + + + + + + + + + + + +