diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index b2645840..46e6cbef 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -10,7 +10,7 @@ import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.reporting.ReportType; import info.bukova.isspst.services.numberseries.NumberSeriesService; -import info.bukova.isspst.services.requirements.RequirementTypeService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.users.PermissionService; import info.bukova.isspst.services.users.RoleService; diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index d1455733..cb2695e3 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -8,11 +8,11 @@ import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.buildings.BuildingService; -import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.reqsubjects.MaterialService; import info.bukova.isspst.services.reqsubjects.ServiceItemService; +import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.requirement.RequirementService; -import info.bukova.isspst.services.requirements.RequirementTypeService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; diff --git a/src/main/java/info/bukova/isspst/DateTimeUtils.java b/src/main/java/info/bukova/isspst/DateTimeUtils.java new file mode 100644 index 00000000..884c5bf7 --- /dev/null +++ b/src/main/java/info/bukova/isspst/DateTimeUtils.java @@ -0,0 +1,57 @@ +package info.bukova.isspst; + +import java.util.Calendar; +import java.util.Date; + +import org.apache.commons.lang.time.DateUtils; + +public class DateTimeUtils +{ + public static Date getDate(Date value) + { + if (value == null) + { + return value; + } + + // Keep date - truncate time + return DateUtils.truncate(value, Calendar.DAY_OF_MONTH); + } + + public static boolean isEqualByDate(Date d1, Date d2) + { + if (d1 != null && d2 != null) + { + d1 = DateTimeUtils.getDate(d1); + d2 = DateTimeUtils.getDate(d2); + boolean equals = (d1.compareTo(d2) == 0); + return equals; + } + + return false; + } + + public static boolean isEqualByDateForFilter(Date value, Date search) + { + if (search == null) + { + return true; + } + else if (value != null) + { + return DateTimeUtils.isEqualByDate(value, search); + } + + return false; + } + + public static Date getCurrDateTime() + { + return new Date(); + } + + public static Date getCurrDate() + { + return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime()); + } +} diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index d3b8bcf2..f3728dfd 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -44,4 +44,10 @@ public class StringUtils { return Labels.getLabel("Db" + key); } + public static boolean isEqualForFilter(String value, String search) + { + value = StringUtils.nullStr(value).toLowerCase(); + search = StringUtils.nullStr(search).toLowerCase(); + return value.contains(search); + } } diff --git a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java index a8663e2b..6a6296dd 100644 --- a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java +++ b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java @@ -1,6 +1,7 @@ package info.bukova.isspst.filters; -import static info.bukova.isspst.StringUtils.nullStr; +import info.bukova.isspst.DateTimeUtils; +import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.Requirement; import org.hamcrest.Description; @@ -37,10 +38,11 @@ public class RequirementFilter implements Filter @Override public boolean matchesSafely(Requirement item) { - return nullStr(item.getNumser()).toLowerCase().contains(nullStr(condition.getNumser()).toLowerCase()) - && item.getReqDate().equals(condition.getReqDate()) - && item.getDeliveryDate().equals(condition.getDeliveryDate()) - && nullStr(item.getDescription()).toLowerCase().contains(nullStr(condition.getDescription()).toLowerCase()); + boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); + boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getReqDate(), condition.getReqDate()); + boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); + boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); + return foundNumser && foundReqDate && foundDescription && foundDeliveryDate; } @Factory diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index b0fbb427..32c8d7b4 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -5,8 +5,10 @@ import info.bukova.isspst.Constants; import info.bukova.isspst.Module; import info.bukova.isspst.dao.BaseDao; import info.bukova.isspst.data.DataModel; +import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.filters.Filter; import info.bukova.isspst.reporting.Report; +import info.bukova.isspst.services.numberseries.NumberSeriesService; import java.util.Arrays; import java.util.Date; @@ -25,7 +27,20 @@ public abstract class AbstractService implements Service protected BaseDao dao; private Validator validator; + + private NumberSeriesService numberSeriesService; + + public NumberSeriesService getNumberSeriesService() + { + return numberSeriesService; + } + + public void setNumberSeriesService(NumberSeriesService numberSeriesService) + { + this.numberSeriesService = numberSeriesService; + } + public void setDao(BaseDao dao) { this.dao = dao; } @@ -150,4 +165,22 @@ public abstract class AbstractService implements Service } } + protected String getNumberSerie() + { + String currentNumber = ""; + + if (numberSeriesService != null) + { + String moduleName = this.getModule().getId(); + NumberSeries ns = numberSeriesService.getNumberSerie(moduleName); + + if (ns != null) + { + currentNumber = ns.getCurrentNumber(); + numberSeriesService.increase(ns); + } + } + + return currentNumber; + } } diff --git a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java index e38ecb54..fc275425 100644 --- a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java @@ -1,10 +1,10 @@ package info.bukova.isspst.services.numberseries; -import org.springframework.transaction.annotation.Transactional; - import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.services.AbstractService; +import org.springframework.transaction.annotation.Transactional; + public class NumberSeriesServiceImpl extends AbstractService implements NumberSeriesService { @Transactional diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index 4206d5ea..d0e9c52a 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -1,9 +1,31 @@ package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.Requirement; -import info.bukova.isspst.services.AbstractService; +import info.bukova.isspst.services.AbstractOwnedService; -public class RequirementServiceImpl extends AbstractService implements RequirementService +import java.util.Date; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; + +public class RequirementServiceImpl extends AbstractOwnedService implements RequirementService { + @Override + protected Requirement createEntity() + { + Requirement entity = new Requirement(); + + entity.setReqDate(new Date()); + + return entity; + } + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_ADD')") + public void add(Requirement entity) + { + entity.setNumser(this.getNumberSerie()); + super.add(entity); + } } diff --git a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java similarity index 77% rename from src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java rename to src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java index 53727d34..60fd752e 100644 --- a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java @@ -1,4 +1,4 @@ -package info.bukova.isspst.services.requirements; +package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.services.Service; diff --git a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java similarity index 82% rename from src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java rename to src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java index 276d8917..ee7d9ada 100644 --- a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java @@ -1,4 +1,4 @@ -package info.bukova.isspst.services.requirements; +package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.services.AbstractOwnedService; diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java index 61144417..d2c3646e 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java @@ -1,15 +1,77 @@ package info.bukova.isspst.ui.requirement; import info.bukova.isspst.data.Requirement; +import info.bukova.isspst.data.RequirementSubject; +import info.bukova.isspst.data.Workgroup; +import info.bukova.isspst.services.requirement.RequirementService; +import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.FormViewModel; +import java.util.List; + +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; public class RequirementForm extends FormViewModel { + @WireVariable + private UserService userService; + + @WireVariable + private WorkgroupService workgroupService; + + public List getCentres() { + return workgroupService.getUserCentres(userService.getCurrent()); + } + @WireVariable + private RequirementService requirementService; + + private RequirementSubject item; + + private int selItemIndex; + @Init(superclass = true) public void init() { + this.setSelItemIndex(-1); + } + + public RequirementSubject getItem() + { + return item; + } + + public void setItem(RequirementSubject item) + { + this.item = item; + } + + public int getSelItemIndex() + { + return selItemIndex; + } + public void setSelItemIndex(int selItemIndex) + { + this.selItemIndex = selItemIndex; + } + + @Command + @NotifyChange({"dataBean", "selItemIndex"}) + public void addItem() { +// RequirementSubject item = new Material(); +// requirementService.addItem(getDataBean(), item); +// selItemIndex = getDataBean().getItems().indexOf(item); + } +/* + @Command + @NotifyChange({"dataBean", "selItemIndex"}) + public void removeItem(@BindingParam("item") RequirementItem item) { + requirementService.removeItem(getDataBean(), item); + selItemIndex = -1; } +*/ } diff --git a/src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java similarity index 98% rename from src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java rename to src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java index 6d7340e6..863e61a3 100644 --- a/src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java @@ -1,10 +1,10 @@ -package info.bukova.isspst.ui.requirements; +package info.bukova.isspst.ui.requirement; import info.bukova.isspst.Constants; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Workflow; -import info.bukova.isspst.services.requirements.RequirementTypeService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.RoleService; import java.math.BigDecimal; diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index e4394694..5281aee1 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -12,24 +12,28 @@ - + - + - + - + - + + + + + diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index acae1cc4..b68bf9f2 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -10,7 +10,17 @@ MenuUser=Uživatel AgendaActRequirements=Aktuální požadavky AgendaRequirementsHistory=Ukončené požadavky -RequirementsFormTitle="Požadavek" +RequirementsFormTitle=Požadavek +RequirementsFormNumberSerie=Číslo +RequirementsFormReqDate=Datum požadavku +RequirementsFormCenter=Středisko +RequirementsFormDescription=Popis +RequirementsFormDeliveryDate=Datum dodání +RequirementsGridNumberSerie=Číslo +RequirementsGridReqDate=Datum požadavku +RequirementsGridCenter=Středisko +RequirementsGridDescription=Popis +RequirementsGridDeliveryDate=Datum dodání AgendaMyOrders=Aktuální AgendaOrdersHistory=Ukončené @@ -166,4 +176,8 @@ DbValidationError=Chyba validace true=Ano false=Ne + +DateFormat=dd. MM. yyyy + +AddItem=Přidat položku... \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index 9c2d7ec2..7bff9f17 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -47,7 +47,7 @@ ${jdbc.dialect} - true + false update @@ -223,7 +223,7 @@ - + @@ -231,6 +231,7 @@ + diff --git a/src/main/webapp/WEB-INF/zk.xml b/src/main/webapp/WEB-INF/zk.xml index 287ac23d..5eaade67 100644 --- a/src/main/webapp/WEB-INF/zk.xml +++ b/src/main/webapp/WEB-INF/zk.xml @@ -1,43 +1,28 @@ - + - - + - true - - - org.zkoss.web.classWebResource.cache - false - - - - /WEB-INF/locales/zk-label.properties - /WEB-INF/locales/columns.properties - /WEB-INF/locales/validators.properties - - + true + + + org.zkoss.web.classWebResource.cache + false + + + /WEB-INF/locales/zk-label.properties + /WEB-INF/locales/columns.properties + /WEB-INF/locales/validators.properties + - /WEB-INF/lang-addons/mapa-lang-addon.xml - /WEB-INF/lang-addons/ckez-bind-lang-addon.xml - /WEB-INF/lang-addons/CzechSortListheader.xml - - + /WEB-INF/lang-addons/mapa-lang-addon.xml + /WEB-INF/lang-addons/ckez-bind-lang-addon.xml + /WEB-INF/lang-addons/CzechSortListheader.xml + /css/zk-modify.css /css/form.css /css/page.css - - - + + \ No newline at end of file diff --git a/src/main/webapp/img/item-add.png b/src/main/webapp/img/item-add.png new file mode 100644 index 00000000..271ad40f Binary files /dev/null and b/src/main/webapp/img/item-add.png differ diff --git a/src/main/webapp/img/item-remove.png b/src/main/webapp/img/item-remove.png new file mode 100644 index 00000000..1355f25e Binary files /dev/null and b/src/main/webapp/img/item-remove.png differ diff --git a/src/main/webapp/requirements/actual/requirements.zul b/src/main/webapp/requirements/actual/requirements.zul index 5945c28d..9cf94a1e 100644 --- a/src/main/webapp/requirements/actual/requirements.zul +++ b/src/main/webapp/requirements/actual/requirements.zul @@ -1,22 +1,50 @@ - - + + - - + - - - + + + + + - - +
- +
@@ -26,7 +54,42 @@
- + +
+
+ +
+
+
+ +
+ + + +
+ +
+
+
+ +
+
+
@@ -36,7 +99,13 @@
- +
@@ -44,15 +113,15 @@
- - \ No newline at end of file diff --git a/src/main/webapp/requirements/actual/requirementsForm.zul b/src/main/webapp/requirements/actual/requirementsForm.zul index 01a57305..958234f0 100644 --- a/src/main/webapp/requirements/actual/requirementsForm.zul +++ b/src/main/webapp/requirements/actual/requirementsForm.zul @@ -1,34 +1,87 @@ - - + + - + - ${labels.BuildingsFormCode} : + ${labels.RequirementsFormNumberSerie} : - + - ${labels.BuildingsFormName} : + ${labels.RequirementsFormReqDate} : - + - ${labels.BuildingsFormDescription} : + ${labels.RequirementsFormCenter} : - + + + + + + + ${labels.RequirementsFormDescription} : + + + + + + ${labels.RequirementsFormDeliveryDate} : + + + +