diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index cd418556..71df933f 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -1,5 +1,7 @@ package info.bukova.isspst; +import java.util.List; + import org.zkoss.util.resource.Labels; public class StringUtils @@ -91,4 +93,35 @@ public class StringUtils return value; } + + public static String addSeparator(String value, String separator, boolean toTail) + { + if ((value != null) && (separator != null)) + { + if (!value.isEmpty() && !separator.isEmpty()) + { + value = (toTail ? value + separator : separator + value); + } + } + + return value; + } + + public static String addSeparator(String value, String separator) + { + return StringUtils.addSeparator(value, separator, true); + } + + public static String join(List list, String separator) + { + String result = ""; + + for (int i = 0; i < list.size(); i++) + { + result = StringUtils.addSeparator(result, separator); + result += list.get(i); + } + + return result; + } } diff --git a/src/main/java/info/bukova/isspst/data/User.java b/src/main/java/info/bukova/isspst/data/User.java index f1b36fe7..133be197 100644 --- a/src/main/java/info/bukova/isspst/data/User.java +++ b/src/main/java/info/bukova/isspst/data/User.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.StringUtils; + import java.util.ArrayList; import java.util.List; @@ -134,14 +136,22 @@ public class User extends Member implements UserDetails, DataModel { this.authorities.remove(role); } - public String getFullName() { - String ret = ""; - if (lastName != null && !lastName.isEmpty()) { - ret = lastName + " "; + public String getFullName() + { + List list = new ArrayList(); + + if (this.lastName != null) + { + list.add(this.lastName); } - ret = ret + (firstName == null ? "" : firstName); - - return ret; + + if (this.firstName != null) + { + list.add(this.firstName); + } + + String result = StringUtils.join(list, " "); + return result; } public String getFirstName() { @@ -193,6 +203,28 @@ public class User extends Member implements UserDetails, DataModel { } } + public static boolean isEqualByUserForFilter(User value, User search) + { + if (search == null) + { + return true; + } + + else if (value != null) + { + if (search.getFullName().isEmpty()) + { + return true; + } + + String valueS = value.getFullName(); + String searchS = search.getFullName(); + return (valueS.compareTo(searchS) == 0); + } + + return false; + } + @Override public String toString() { return getFullName(); diff --git a/src/main/java/info/bukova/isspst/data/Workgroup.java b/src/main/java/info/bukova/isspst/data/Workgroup.java index 0163d69b..28654853 100644 --- a/src/main/java/info/bukova/isspst/data/Workgroup.java +++ b/src/main/java/info/bukova/isspst/data/Workgroup.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.StringUtils; + import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; @@ -103,8 +105,22 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable { } @Override - public String getFullName() { - return code + " " + name; + public String getFullName() + { + List list = new ArrayList(); + + if (this.code != null) + { + list.add(this.code); + } + + if (this.name != null) + { + list.add(this.name); + } + + String result = StringUtils.join(list, " "); + return result; } @Override @@ -136,6 +152,28 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable { return false; } + public static boolean isEqualByWorkgroupForFilter(Workgroup value, Workgroup search) + { + if (search == null) + { + return true; + } + + else if (value != null) + { + if (search.getFullName().isEmpty()) + { + return true; + } + + String valueS = value.getFullName(); + String searchS = search.getFullName(); + return (valueS.compareTo(searchS) == 0); + } + + return false; + } + @Override public String toString() { return getFullName(); diff --git a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java index 313b065d..8955ad8a 100644 --- a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java +++ b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java @@ -4,6 +4,8 @@ import info.bukova.isspst.BigDecimalUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.MUnitEmb; +import info.bukova.isspst.data.User; +import info.bukova.isspst.data.Workgroup; import org.hamcrest.Description; import org.hamcrest.Factory; @@ -17,6 +19,10 @@ public class JoinedItemFilter implements Filter public JoinedItemFilter(JoinedItem cond) { this.condition = cond; + this.condition.setMunit(new MUnitEmb()); + this.condition.setWorkgroup(new Workgroup()); + this.condition.setCentre(new Workgroup()); + this.condition.setOwnedBy(new User()); } private static class JoinedItemMatcher extends TypeSafeMatcher @@ -44,8 +50,11 @@ public class JoinedItemFilter implements Filter boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice()); boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit()); boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal()); + boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getWorkgroup(), condition.getWorkgroup()); + boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre()); + boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); - return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundDescription); + return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription); } @Factory diff --git a/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java b/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java index c6fef229..f17d69be 100644 --- a/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java @@ -11,6 +11,7 @@ import info.bukova.isspst.services.workgroups.WorkgroupService; import java.util.ArrayList; import java.util.List; +import org.hibernate.Hibernate; import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PostFilter; @@ -33,12 +34,17 @@ public class ApprovedServiceImpl extends AbstractService implements public List getAll() { List wgList = workgroupService.getUserCentres(userService.getCurrent()); - Query q = queryDao.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)"); + Query q = queryDao +.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)"); q.setParameterList("wgList", wgList); q.setParameter("state", RequirementState.APPROVED); List items = new ArrayList(); - for (RequirementItem it : (List)q.list()) { + for (RequirementItem it : (List) q.list()) + { + // Kvůli lazy loadu načteme jakoukoli hodnotu objektu + Hibernate.initialize(it.getRequirement().getOwnedBy()); + items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy())); } diff --git a/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java b/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java index e4ad6144..e52f1b47 100644 --- a/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java +++ b/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java @@ -1,11 +1,16 @@ package info.bukova.isspst.ui.main.approved; import info.bukova.isspst.data.JoinedItem; +import info.bukova.isspst.data.User; +import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.filters.JoinedItemFilter; import info.bukova.isspst.services.approved.ApprovedService; +import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.BigDecimalConverter; import info.bukova.isspst.ui.ListViewModel; +import java.util.ArrayList; import java.util.List; import org.zkoss.bind.annotation.Init; @@ -16,6 +21,12 @@ public class ApprovedList extends ListViewModel @WireVariable protected ApprovedService approvedService; + @WireVariable + protected WorkgroupService workgroupService; + + @WireVariable + protected UserService userService; + private BigDecimalConverter bigDecimalConverter; @Init @@ -37,4 +48,25 @@ public class ApprovedList extends ListViewModel { return approvedService.getAll(); } + + public List getWorkgroups() + { + Workgroup empty = new Workgroup(); + empty.setCode(""); + empty.setName(""); + List list = new ArrayList(); + list.add(empty); + list.addAll(this.workgroupService.getWorkgroups()); + return list; + } + + public List getCenters() + { + return this.workgroupService.getCentres(); + } + + public List getUsers() + { + return this.userService.getAll(); + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 8b42b8b6..cee66227 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -292,6 +292,8 @@ SelectGroup=Vybrat skupinu... RemoveItem=Smazat Amount=Částka +Owner=Vlastník +CreateOrder=Vytvořit objednávku WorkgroupFormUserIsCenterMember=Uživatel je členem střediska, jehož je komise členem! WorkgroupFormMemberIsCenterMember=Některý ze členů přidávané komise je členem tohoto střediska! diff --git a/src/main/webapp/img/autotruck-016.png b/src/main/webapp/img/autotruck-016.png new file mode 100644 index 00000000..e6ea477a Binary files /dev/null and b/src/main/webapp/img/autotruck-016.png differ diff --git a/src/main/webapp/img/autotruck-032.png b/src/main/webapp/img/autotruck-032.png new file mode 100644 index 00000000..1d1dc6c9 Binary files /dev/null and b/src/main/webapp/img/autotruck-032.png differ diff --git a/src/main/webapp/main/orders/approved/grid.zul b/src/main/webapp/main/orders/approved/grid.zul index d7a529cf..7239043f 100644 --- a/src/main/webapp/main/orders/approved/grid.zul +++ b/src/main/webapp/main/orders/approved/grid.zul @@ -26,6 +26,7 @@ multiple="true" checkmark="true" vflex="1" + context="popupMenu" model="@load(vm.dataList)"> @@ -61,7 +62,19 @@ sort="auto(total)" label="${labels.RequirementItemTotal}" /> + + + @@ -112,19 +125,19 @@ + - + + + + +
+
+ + + +
+
+
+
+ +
- + + + +
+
+
- +
+
+ +
+
+ + + +
+
+ +
+
@@ -190,9 +260,18 @@ + + + + + + \ No newline at end of file