diff --git a/src/main/java/info/bukova/isspst/data/Workflow.java b/src/main/java/info/bukova/isspst/data/Workflow.java index ac489428..e6248890 100644 --- a/src/main/java/info/bukova/isspst/data/Workflow.java +++ b/src/main/java/info/bukova/isspst/data/Workflow.java @@ -1,15 +1,14 @@ package info.bukova.isspst.data; -import java.math.BigDecimal; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; - -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; +import java.math.BigDecimal; @Entity @Table(name = "WORKFLOW") @@ -24,7 +23,9 @@ public class Workflow extends BaseData { @Column(name = "WORDER") private Integer wOrder; @Column(name = "WLIMIT", precision=15, scale=4) - private BigDecimal limit; + private BigDecimal limit; + @Column(name = "SIGNATURE") + private Boolean signature; public Boolean getCentre() { return centre; @@ -68,4 +69,11 @@ public class Workflow extends BaseData { this.limit = limit; } + public Boolean getSignature() { + return signature; + } + + public void setSignature(Boolean signature) { + this.signature = signature; + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java index 860c4044..99b6834e 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java @@ -2,6 +2,7 @@ package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.RequirementBase; import info.bukova.isspst.data.User; +import info.bukova.isspst.data.Workflow; import info.bukova.isspst.services.Service; import java.util.Date; @@ -26,6 +27,7 @@ public interface RequirementBaseService extends Servi public boolean canApprove(T entity); public List getNextApprover(T entity); public boolean prepareSignData(T entity, Date approveDate); + public Workflow getNextWorkflow(T entity); public List getMy(); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 93427584..753e344a 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -150,6 +150,7 @@ public abstract class RequirementBaseServiceImpl exte workflow.setLimit(w.getLimit()); workflow.setOrder(w.getOrder()); workflow.setRole(w.getRole()); + workflow.setSignature(w.getSignature()); entity.getWorkflow().add(workflow); } } @@ -277,6 +278,12 @@ public abstract class RequirementBaseServiceImpl exte super.update(e); + if (signedPdf != null) { + saveSignedDoc(e, signedPdf); + } else if (wf.getSignature() != null && wf.getSignature()) { + throw new ApproveException("ErrApproveMustBeSigned"); + } + if (!autoApprove(e, approveDate)) { this.sendToApprovers(e); @@ -300,11 +307,6 @@ public abstract class RequirementBaseServiceImpl exte } } - if (signedPdf != null) - { - saveSignedDoc(e, signedPdf); - } - postApprove(e); } @@ -380,8 +382,12 @@ public abstract class RequirementBaseServiceImpl exte return false; } - - protected Workflow getNextWorkflow(T e) { + + @Override + @Transactional + public Workflow getNextWorkflow(T entity) { + T e = dao.getById(entity.getId()); + AuthItem authItem = null; if (e.getWorkflow() == null) { return null; diff --git a/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java b/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java index da74d6f8..3433900e 100644 --- a/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java +++ b/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java @@ -33,6 +33,7 @@ public class ApproveDialogVM { @WireVariable private SessionData sessionData; private boolean signed; + private boolean signRequired; private boolean timer; private byte[] signedPdf; @@ -53,7 +54,14 @@ public class ApproveDialogVM { this.grid = grid; this.approveDate = new Date(); - this.signed = false; + if (service.getNextWorkflow(requirement).getSignature() != null + && service.getNextWorkflow(requirement).getSignature()) { + this.signed = false; + this.signRequired = true; + } else { + this.signRequired = false; + } + this.timer = false; } @@ -103,4 +111,7 @@ public class ApproveDialogVM { return timer; } + public boolean isSignRequired() { + return signRequired; + } } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java index 279b8e7d..31a19d5a 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java @@ -6,13 +6,6 @@ import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Workflow; import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.RoleService; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.GlobalCommand; @@ -24,6 +17,12 @@ import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Listitem; import org.zkoss.zul.Window; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class RequirementTypesVM { @WireVariable @@ -236,6 +235,18 @@ public class RequirementTypesVM { Window win = (Window) Executions.createComponents("/settings/workflow/limit.zul", null, params); win.doModal(); } + + @Command + @NotifyChange({"selected", "centreSelWorkflow", "wgSelWorkflow"}) + public void toggleSignature(@BindingParam("workflow") Workflow workflow) { + if (workflow.getSignature() != null && workflow.getSignature()) { + workflow.setSignature(false); + } else { + workflow.setSignature(true); + } + + reqTypeService.update(selected); + } @GlobalCommand @NotifyChange("selected") diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 535c0d1b..1df6aba3 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -412,3 +412,7 @@ ForeignPersons = Cizí osoby TripBillResultMessageText = Zpráva z pracovní cesty ErrFillTripBillResultMessageText = Vyplňte zprávu z pracovní cesty. ErrFillTripBillResultTimes = Zadejte časy odjezdu a příjezdu. + +ErrApproveMustBeSigned = Schválení musí být digitálně podepsané. +DigitalSignature = Elektronický podpis +ContextMenu = Volby v kontextovém menu diff --git a/src/main/webapp/img/sign-small.png b/src/main/webapp/img/sign-small.png new file mode 100644 index 00000000..8834f3f5 Binary files /dev/null and b/src/main/webapp/img/sign-small.png differ diff --git a/src/main/webapp/main/approveDialog.zul b/src/main/webapp/main/approveDialog.zul index cd803199..b4645ece 100644 --- a/src/main/webapp/main/approveDialog.zul +++ b/src/main/webapp/main/approveDialog.zul @@ -17,12 +17,12 @@