multitenant
Josef Rokos 11 years ago
commit 05704827a4

@ -80,92 +80,74 @@ public class AppInitListener implements ServletContextListener {
{ {
MUnit mUnit = new MUnit(); MUnit mUnit = new MUnit();
mUnit.setCode("ks");
mUnit.setName("ks"); mUnit.setName("ks");
mUnit.setDescription("kus (množství)"); mUnit.setDescription("kus (množství)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-m");
mUnit.setName("m"); mUnit.setName("m");
mUnit.setDescription("metr (délka)"); mUnit.setDescription("metr (délka)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-km");
mUnit.setName("km"); mUnit.setName("km");
mUnit.setDescription("kilometr (délka)"); mUnit.setDescription("kilometr (délka)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-kg");
mUnit.setName("kg"); mUnit.setName("kg");
mUnit.setDescription("kilogram (hmotnost)"); mUnit.setDescription("kilogram (hmotnost)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-g");
mUnit.setName("g"); mUnit.setName("g");
mUnit.setDescription("gram (hmotnost)"); mUnit.setDescription("gram (hmotnost)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-dkg");
mUnit.setName("dkg"); mUnit.setName("dkg");
mUnit.setDescription("dekagram (hmotnost)"); mUnit.setDescription("dekagram (hmotnost)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-t");
mUnit.setName("t"); mUnit.setName("t");
mUnit.setDescription("tuna (hmotnost)"); mUnit.setDescription("tuna (hmotnost)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-s");
mUnit.setName("s"); mUnit.setName("s");
mUnit.setDescription("sekunda (čas)"); mUnit.setDescription("sekunda (čas)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-min");
mUnit.setName("min"); mUnit.setName("min");
mUnit.setDescription("minuta (čas)"); mUnit.setDescription("minuta (čas)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("VEDL-hod");
mUnit.setName("hod"); mUnit.setName("hod");
mUnit.setDescription("hodina (čas)"); mUnit.setDescription("hodina (čas)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("ODV-m2"); mUnit.setName("m²");
mUnit.setName("m[up]2[/up]");
mUnit.setDescription("metr čtverečný (plocha)"); mUnit.setDescription("metr čtverečný (plocha)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("ODV-ha");
mUnit.setName("ha"); mUnit.setName("ha");
mUnit.setDescription("hektar = 10.000 m² (plocha)"); mUnit.setDescription("hektar = 10.000 m² (plocha)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("ODV-m3");
mUnit.setName("m³"); mUnit.setName("m³");
mUnit.setDescription("metr krychlový (objem)"); mUnit.setDescription("metr krychlový (objem)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("ODV-l");
mUnit.setName("l"); mUnit.setName("l");
mUnit.setDescription("litr = 10E-3 m³ (objem)"); mUnit.setDescription("litr = 10E-3 m³ (objem)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-A");
mUnit.setName("A"); mUnit.setName("A");
mUnit.setDescription("ampér (elektrický proud)"); mUnit.setDescription("ampér (elektrický proud)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-K");
mUnit.setName("K"); mUnit.setName("K");
mUnit.setDescription("kelvin (termodynamická teplota)"); mUnit.setDescription("kelvin (termodynamická teplota)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-cd");
mUnit.setName("cd"); mUnit.setName("cd");
mUnit.setDescription("kandela (svítivost)"); mUnit.setDescription("kandela (svítivost)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);
mUnit.setCode("SI-mol");
mUnit.setName("mol"); mUnit.setName("mol");
mUnit.setDescription("mol (látkové množství)"); mUnit.setDescription("mol (látkové množství)");
mUnitsService.add(mUnit); mUnitsService.add(mUnit);

@ -50,4 +50,26 @@ public class StringUtils {
search = StringUtils.nullStr(search).toLowerCase(); search = StringUtils.nullStr(search).toLowerCase();
return value.contains(search); return value.contains(search);
} }
public static String encodeSpecialChars(String value)
{
if (value != null)
{
value = value.replace("²", "[up]2[/up]");
value = value.replace("³", "[up]3[/up]");
}
return value;
}
public static String decodeSpecialChars(String value)
{
if (value != null)
{
value = value.replace("[up]2[/up]", "²");
value = value.replace("[up]3[/up]", "³");
}
return value;
}
} }

@ -1,90 +1,38 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.validator.constraints.NotBlank;
@Entity @Entity
@Table(name = "MUNIT") @Table(name = "MUNIT")
public class MUnit extends BaseData implements DataModel { public class MUnit extends BaseData
{
@Column(name = "CODE", unique = true)
private String code;
@Column(name = "NAME") @Column(name = "NAME")
private String name; private String name;
@Column(name = "DESCRIPTION") @Column(name = "DESCRIPTION")
private String description; private String description;
/** public String getName()
* @return the code
*/
@NotBlank(message = "{MUnitsFormCodeConstr}")
public String getCode() {
return code;
}
/**
* @param code
* the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the name
*/
public String getName() {
return this.name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
public String getNameSpecial()
{ {
String special = this.getName(); return StringUtils.decodeSpecialChars(this.name);
if (special != null)
{
special = special.replace("[up]2[/up]", "²");
}
return special;
} }
public void setNameSpecial(String special) public void setName(String name)
{ {
if (special != null) this.name = StringUtils.encodeSpecialChars(name);
{
special = special.replace("²", "[up]2[/up]");
}
this.setName(special);
} }
/** public String getDescription()
* @return the description {
*/ return StringUtils.decodeSpecialChars(this.description);
public String getDescription() {
return description;
} }
/** public void setDescription(String description)
* @param description {
* the description to set this.description = StringUtils.encodeSpecialChars(description);
*/
public void setDescription(String description) {
this.description = description;
} }
} }

@ -1,81 +1,86 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
@Embeddable @Embeddable
public class MUnitEmb { public class MUnitEmb
{
@Column(name = "MUNIT_ID") @Column(name = "MUNIT_ID")
private Integer id; private Integer id;
@Column(name = "MUNIT_CODE")
private String code;
@Column(name = "MUNIT_DESCRIPTION")
private String description;
@Column(name = "MUNIT_NAME") @Column(name = "MUNIT_NAME")
private String name; private String name;
public MUnitEmb() { @Column(name = "MUNIT_DESCRIPTION")
private String description;
public MUnitEmb()
{
} }
public MUnitEmb(MUnit munit) { public MUnitEmb(MUnit munit)
this.id = munit.getId(); {
this.code = munit.getCode(); this.setId(munit.getId());
this.description = munit.getDescription(); this.setDescription(munit.getDescription());
this.name = munit.getName(); this.setName(munit.getName());
} }
public Integer getId() { public Integer getId()
return id; {
return this.id;
} }
public void setId(Integer id) { public void setId(Integer id)
{
this.id = id; this.id = id;
} }
public String getCode() { public String getName()
return code; {
} return StringUtils.decodeSpecialChars(this.name);
public void setCode(String code) {
this.code = code;
} }
public String getDescription() { public void setName(String name)
return description; {
this.name = StringUtils.encodeSpecialChars(name);
} }
public void setDescription(String description) { public String getDescription()
this.description = description; {
return StringUtils.decodeSpecialChars(this.description);
} }
public String getName() { public void setDescription(String description)
return name; {
this.description = StringUtils.encodeSpecialChars(description);
} }
public void setName(String name) { public boolean eqWith(MUnit munit)
this.name = name; {
} if (munit == null)
{
return false;
}
public boolean eqWith(MUnit munit) { return this.getId() == munit.getId() && this.getName().equals(munit.getName()) && this.getDescription().equals(munit.getDescription());
return this.id == munit.getId()
&& this.code.equals(munit.getCode())
&& this.name.equals(munit.getName())
&& this.description.equals(munit.getDescription());
} }
@Override @Override
public boolean equals(Object munit) { public boolean equals(Object munit)
{
return munit != null return munit != null
&& (munit instanceof MUnitEmb) && (munit instanceof MUnitEmb)
&& this.id == ((MUnitEmb)munit).getId() && this.getId() == ((MUnitEmb) munit).getId()
&& (this.code == ((MUnitEmb)munit).getCode() || this.code.equals(((MUnitEmb)munit).getCode())) && (this.getName() == ((MUnitEmb) munit).getName() || this.getName().equals(((MUnitEmb) munit).getName()))
&& (this.name == ((MUnitEmb)munit).getName() || this.name.equals(((MUnitEmb)munit).getName())) && (this.getDescription() == ((MUnitEmb) munit).getDescription() || this.getDescription().equals(((MUnitEmb) munit).getDescription()));
&& (this.description == ((MUnitEmb)munit).getDescription() || this.description.equals(((MUnitEmb)munit).getDescription()));
} }
@Override @Override
public String toString() { public String toString()
return this.code + " - " + this.name; {
return this.getName();
} }
} }

@ -1,5 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -8,37 +10,27 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@Entity @Entity
@Table(name = "REQUIREMENT") @Table(name = "REQUIREMENT")
public class Requirement extends BaseData implements DataModel public class Requirement extends RequirementBase
{ {
@Column(name = "NUMSER", unique = true) @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private String numser; @JoinColumn(name = "REQUIREMENT_ID")
private List<RequirementItem> items;
@Column(name = "REQDATE")
private Date reqDate;
@Column(name = "DELIVERYDATE") @Column(name = "DELIVERYDATE")
private Date deliveryDate; private Date deliveryDate;
@ManyToOne(fetch = FetchType.EAGER) @Column(name = "SUMTOTAL")
@JoinColumn(name = "WORKGROUP_ID") private BigDecimal sumTotal;
private Workgroup workgroup;
@Column(name = "DESCRIPTION") public Requirement()
private String description; {
this.setItems(new ArrayList<RequirementItem>());
@OneToMany(cascade=CascadeType.ALL) }
@JoinColumn(name = "REQUIREMENT_ID")
@LazyCollection(LazyCollectionOption.FALSE)
private List<RequirementItem> items;
public List<RequirementItem> getItems() public List<RequirementItem> getItems()
{ {
@ -50,26 +42,6 @@ public class Requirement extends BaseData implements DataModel
this.items = items; this.items = items;
} }
public String getNumser()
{
return numser;
}
public void setNumser(String numser)
{
this.numser = numser;
}
public Date getReqDate()
{
return reqDate;
}
public void setReqDate(Date reqDate)
{
this.reqDate = reqDate;
}
public Date getDeliveryDate() public Date getDeliveryDate()
{ {
return deliveryDate; return deliveryDate;
@ -80,23 +52,13 @@ public class Requirement extends BaseData implements DataModel
this.deliveryDate = deliveryDate; this.deliveryDate = deliveryDate;
} }
public Workgroup getWorkgroup() public BigDecimal getSumTotal()
{
return workgroup;
}
public void setWorkgroup(Workgroup workgroup)
{
this.workgroup = workgroup;
}
public String getDescription()
{ {
return description; return sumTotal;
} }
public void setDescription(String description) public void setSumTotal(BigDecimal sumTotal)
{ {
this.description = description; this.sumTotal = sumTotal;
} }
} }

@ -72,6 +72,16 @@ public class RequirementBase extends BaseData {
this.reqDate = reqDate; this.reqDate = reqDate;
} }
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public Workgroup getWorkgroup() { public Workgroup getWorkgroup() {
return workgroup; return workgroup;
} }
@ -96,14 +106,6 @@ public class RequirementBase extends BaseData {
this.state = state; this.state = state;
} }
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Workgroup getCentre() { public Workgroup getCentre() {
return centre; return centre;
} }

@ -35,7 +35,7 @@ public class RequirementItem
private BigDecimal quantity; private BigDecimal quantity;
@Embedded @Embedded
private MUnitEmb mUnit; private MUnitEmb munit;
@Column(name = "UNITPRICE", precision=15, scale=4) @Column(name = "UNITPRICE", precision=15, scale=4)
private BigDecimal unitPrice; private BigDecimal unitPrice;
@ -96,12 +96,12 @@ public class RequirementItem
this.quantity = quantity; this.quantity = quantity;
} }
public MUnitEmb getMUnit() { public MUnitEmb getMunit() {
return mUnit; return munit;
} }
public void setMUnit(MUnitEmb mUnit) { public void setMunit(MUnitEmb munit) {
this.mUnit = mUnit; this.munit = munit;
} }
public BigDecimal getUnitPrice() public BigDecimal getUnitPrice()
@ -133,4 +133,20 @@ public class RequirementItem
{ {
this.description = description; this.description = description;
} }
@Override
public boolean equals(Object obj)
{
if (obj != null)
{
if (obj instanceof RequirementItem)
{
RequirementItem item = (RequirementItem)obj;
return (this.getId() == item.getId());
}
}
return false;
}
} }

@ -1,6 +1,6 @@
package info.bukova.isspst.filters; package info.bukova.isspst.filters;
import static info.bukova.isspst.StringUtils.nullStr; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.MUnit; import info.bukova.isspst.data.MUnit;
import org.hamcrest.Description; import org.hamcrest.Description;
@ -30,10 +30,11 @@ public class MUnitFilter implements Filter<MUnit> {
} }
@Override @Override
public boolean matchesSafely(MUnit item) { public boolean matchesSafely(MUnit item)
return nullStr(item.getCode()).toLowerCase().contains(nullStr(condMUnit.getCode()).toLowerCase()) {
&& nullStr(item.getName()).toLowerCase().contains(nullStr(condMUnit.getName()).toLowerCase()) boolean nameIsEqual = StringUtils.isEqualForFilter(item.getName(), condMUnit.getName());
&& nullStr(item.getDescription()).toLowerCase().contains(nullStr(condMUnit.getDescription()).toLowerCase()); boolean descriptionIsEqual = StringUtils.isEqualForFilter(item.getDescription(), condMUnit.getDescription());
return (nameIsEqual && descriptionIsEqual);
} }
@Factory @Factory

@ -1,6 +1,6 @@
package info.bukova.isspst.filters; package info.bukova.isspst.filters;
import static info.bukova.isspst.StringUtils.nullStr; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.Material; import info.bukova.isspst.data.Material;
import org.hamcrest.Description; import org.hamcrest.Description;
@ -30,10 +30,14 @@ public class MaterialFilter implements Filter<Material> {
} }
@Override @Override
public boolean matchesSafely(Material item) { public boolean matchesSafely(Material item)
return nullStr(item.getCode()).toLowerCase().contains(nullStr(condMaterial.getCode()).toLowerCase()) {
&& nullStr(item.getName()).toLowerCase().contains(nullStr(condMaterial.getName()).toLowerCase()) boolean isEqualCode = StringUtils.isEqualForFilter(item.getCode(), this.condMaterial.getCode());
&& nullStr(item.getDescription()).toLowerCase().contains(nullStr(condMaterial.getDescription()).toLowerCase()); boolean isEqualName = StringUtils.isEqualForFilter(item.getName(), this.condMaterial.getName());
boolean isEqualMUnitName = (this.condMaterial.getMunit() == null) || (item.getMunit().getId() == this.condMaterial.getMunit().getId());
boolean isEqualDescription = StringUtils.isEqualForFilter(item.getDescription(), this.condMaterial.getDescription());
return isEqualCode && isEqualName && isEqualDescription && isEqualMUnitName;
} }
@Factory @Factory

@ -1,8 +1,12 @@
package info.bukova.isspst.services.munits; package info.bukova.isspst.services.munits;
import info.bukova.isspst.data.MUnit; import info.bukova.isspst.data.MUnit;
import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
public interface MUnitService extends Service<MUnit> { import java.util.List;
public interface MUnitService extends Service<MUnit>
{
public List<MUnitEmb> getEmbAll();
} }

@ -1,8 +1,29 @@
package info.bukova.isspst.services.munits; package info.bukova.isspst.services.munits;
import info.bukova.isspst.data.MUnit; import info.bukova.isspst.data.MUnit;
import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.services.AbstractService; import info.bukova.isspst.services.AbstractService;
public class MUnitServiceImpl extends AbstractService<MUnit> implements MUnitService{ import java.util.ArrayList;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;
public class MUnitServiceImpl extends AbstractService<MUnit> implements MUnitService
{
@Override
@Transactional
public List<MUnitEmb> getEmbAll()
{
List<MUnit> munitList = this.getAll();
List<MUnitEmb> munitEmbList = new ArrayList<MUnitEmb>();
for (MUnit m : munitList)
{
MUnitEmb muEmb = new MUnitEmb(m);
munitEmbList.add(muEmb);
}
return munitEmbList;
}
} }

@ -0,0 +1,62 @@
package info.bukova.isspst.ui;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.bind.BindContext;
import org.zkoss.bind.Converter;
import org.zkoss.zk.ui.Component;
public class BigDecimalConverter implements Converter<String, BigDecimal, Component>
{
private final static Logger log = LoggerFactory.getLogger(BigDecimalConverter.class.getName());
@Override
public BigDecimal coerceToBean(String str, Component component, BindContext cx)
{
BigDecimal val = BigDecimal.ZERO;
if (str != null)
{
try
{
DecimalFormat format = new DecimalFormat();
format.setParseBigDecimal(true);
val = (BigDecimal) format.parse(str);
}
catch (NumberFormatException e)
{
log.warn(str, e);
}
catch (ParseException e)
{
log.warn(str, e);
}
}
return val;
}
@Override
public String coerceToUi(BigDecimal val, Component component, BindContext cx)
{
if (val == null)
{
val = BigDecimal.ZERO;
}
val = val.setScale(2, BigDecimal.ROUND_DOWN);
DecimalFormat format = new DecimalFormat();
format.setMaximumFractionDigits(2);
format.setMinimumFractionDigits(2);
format.setGroupingUsed(true);
format.setGroupingSize(3);
return format.format(val);
}
}

@ -47,6 +47,16 @@ public class FormViewModel<T extends DataModel> {
return dataBean; return dataBean;
} }
public boolean isNewRec()
{
return this.newRec;
}
public boolean isEditRec()
{
return !this.newRec;
}
@Command @Command
@NotifyChange("errMessages") @NotifyChange("errMessages")
public void save(@BindingParam("window") Window win) { public void save(@BindingParam("window") Window win) {

@ -1,17 +1,15 @@
package info.bukova.isspst.ui.reqsubjects; package info.bukova.isspst.ui.reqsubjects;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import info.bukova.isspst.data.MUnit;
import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.data.Material; import info.bukova.isspst.data.Material;
import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.ui.FormViewModel; import info.bukova.isspst.ui.FormViewModel;
import java.util.List;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
public class MaterialForm extends FormViewModel<Material> { public class MaterialForm extends FormViewModel<Material> {
@WireVariable @WireVariable
@ -19,13 +17,9 @@ public class MaterialForm extends FormViewModel<Material> {
private List<MUnitEmb> munits; private List<MUnitEmb> munits;
@Init(superclass = true) @Init(superclass = true)
public void init() { public void init()
List<MUnit> mu = munitService.getAll(); {
munits = new ArrayList<MUnitEmb>(); this.munits = munitService.getEmbAll();
for (MUnit m : mu) {
MUnitEmb muEmb = new MUnitEmb(m);
munits.add(muEmb);
}
} }
public List<MUnitEmb> getMunits() { public List<MUnitEmb> getMunits() {

@ -1,24 +1,45 @@
package info.bukova.isspst.ui.reqsubjects; package info.bukova.isspst.ui.reqsubjects;
import org.zkoss.bind.annotation.Init; import info.bukova.isspst.data.MUnitEmb;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import info.bukova.isspst.data.Material; import info.bukova.isspst.data.Material;
import info.bukova.isspst.filters.MaterialFilter; import info.bukova.isspst.filters.MaterialFilter;
import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.reqsubjects.MaterialService; import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.ui.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
import java.util.List;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
public class MaterialList extends ListViewModel<Material> { public class MaterialList extends ListViewModel<Material> {
@WireVariable @WireVariable
private MaterialService materialService; private MaterialService materialService;
@WireVariable
private MUnitService munitService;
private List<MUnitEmb> munitList;
@Init @Init
public void init() { public void init() {
service = materialService; service = materialService;
dataClass = Material.class; dataClass = Material.class;
formZul = "materialForm.zul"; formZul = "materialForm.zul";
dataFilter = new MaterialFilter(getFilterTemplate()); dataFilter = new MaterialFilter(getFilterTemplate());
this.setMunitList(munitService.getEmbAll());
}
public List<MUnitEmb> getMunitList()
{
return munitList;
}
public void setMunitList(List<MUnitEmb> munitList)
{
this.munitList = munitList;
} }
} }

@ -1,57 +1,70 @@
package info.bukova.isspst.ui.requirement; package info.bukova.isspst.ui.requirement;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementItem; import info.bukova.isspst.data.RequirementItem;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.requirement.RequirementService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.BigDecimalConverter;
import info.bukova.isspst.ui.FormViewModel; import info.bukova.isspst.ui.FormViewModel;
import info.bukova.isspst.validators.RequirementFormValidator;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.SimpleForm;
import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window; import org.zkoss.zul.Window;
import org.zkoss.zul.impl.InputElement;
public class RequirementForm extends FormViewModel<Requirement> public class RequirementForm extends FormViewModel<Requirement>
{ {
private final static Logger log = LoggerFactory.getLogger(RequirementForm.class.getName());
@WireVariable @WireVariable
private UserService userService; private UserService userService;
@WireVariable @WireVariable
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
public List<Workgroup> getCentres()
{
return workgroupService.getUserCentres(userService.getCurrent());
}
@WireVariable @WireVariable
private RequirementService requirementService; private RequirementService requirementService;
private RequirementItem item; private RequirementItem selectedItem;
private int selItemIndex; private int selItemIndex;
@Init(superclass = true) private BigDecimalConverter bigDecimalConverter;
public void init()
private RequirementFormValidator requirementFormValidator;
private List<RequirementItem> syncItems;
public List<Workgroup> getCentres()
{ {
this.setSelItemIndex(-1); return workgroupService.getUserCentres(userService.getCurrent());
} }
public RequirementItem getItem() public RequirementItem getSelectedItem()
{ {
return item; return selectedItem;
} }
public void setItem(RequirementItem item) public void setSelectedItem(RequirementItem selectedItem)
{ {
this.item = item; this.selectedItem = selectedItem;
} }
public int getSelItemIndex() public int getSelItemIndex()
@ -64,20 +77,149 @@ public class RequirementForm extends FormViewModel<Requirement>
this.selItemIndex = selItemIndex; this.selItemIndex = selItemIndex;
} }
public BigDecimalConverter getBigDecimalConverter()
{
return bigDecimalConverter;
}
public void setBigDecimalConverter(BigDecimalConverter bigDecimalConverter)
{
this.bigDecimalConverter = bigDecimalConverter;
}
public RequirementFormValidator getRequirementFormValidator()
{
return requirementFormValidator;
}
public void setRequirementFormValidator(RequirementFormValidator requirementFormValidator)
{
this.requirementFormValidator = requirementFormValidator;
}
@Init(superclass = true)
public void init()
{
this.setSelItemIndex(-1);
this.setBigDecimalConverter(new BigDecimalConverter());
this.setRequirementFormValidator(new RequirementFormValidator());
this.setSyncItems(this.getDataBean().getItems());
}
public List<RequirementItem> getSyncItems()
{
return syncItems;
}
public void setSyncItems(List<RequirementItem> syncItems)
{
this.syncItems = syncItems;
}
@Command @Command
@NotifyChange({ "dataBean", "selItemIndex" }) public void addSelectedItem()
public void addItem()
{ {
Window window = (Window) Executions.createComponents("/requirements/selectitems/selectItems.zul", null, null); Window window = (Window) Executions.createComponents("/requirements/selectitems/selectItems.zul", null, null);
window.doModal(); window.doModal();
} }
@Command
public void onFocusItem(@BindingParam("item") RequirementItem item, @BindingParam("ctrl") InputElement ctrl)
{
this.selItemIndex = this.getDataBean().getItems().indexOf(item);
this.selectedItem = item;
if (ctrl != null)
{
ctrl.select();
}
}
@Command @Command
@NotifyChange({ "dataBean", "selItemIndex" }) @NotifyChange({ "dataBean", "selItemIndex" })
public void removeItem(@BindingParam("item") RequirementItem item) public void removeItem(@BindingParam("item") RequirementItem item)
{ {
// requirementService.removeItem(getDataBean(), item); this.getDataBean().getItems().remove(item);
selItemIndex = -1; this.setSelItemIndex(-1);
}
@GlobalCommand("insertSelectedItem")
@NotifyChange({ "syncItems", "selItemIndex" })
public void insertSelectedItem(@BindingParam("selected") RequirementSubject selected, @BindingParam("window") Window window)
{
if (selected != null)
{
RequirementItem item = new RequirementItem();
boolean isMaterial = (selected instanceof Material);
//boolean isServiceItem = (selected instanceof ServiceItem);
item.setReqSubject(selected);
item.setCode(selected.getCode());
item.setName(selected.getName());
item.setQuantity(BigDecimal.valueOf(1));
item.setUnitPrice(BigDecimal.valueOf(0));
item.setTotal(BigDecimal.valueOf(0));
item.setDescription(selected.getDescription());
if (isMaterial)
{
Material materialItem = (Material) selected;
item.setMunit(materialItem.getMunit());
}
this.setSelectedItem(item);
this.getDataBean().getItems().add(item);
this.setSelItemIndex(this.getDataBean().getItems().indexOf(item));
}
if (window != null)
{
window.detach();
}
} }
@Command
@NotifyChange({ "selectedItem", "syncItems" })
public void recalculate(@BindingParam("form") SimpleForm form, @BindingParam("changed") String source)
{
if (this.selectedItem == null)
{
log.warn("Zavolat z formuláře onFocus pro nastavení vybrané položky!");
return;
}
// Recalculate selecte item
if ((source != null) && (source.equals("total")))
{
BigDecimal quantity = this.selectedItem.getQuantity();
if (quantity.equals(BigDecimal.ZERO))
{
this.selectedItem.setUnitPrice(BigDecimal.ZERO);
}
else
{
this.selectedItem.setUnitPrice(this.selectedItem.getTotal().divide(quantity, 2, BigDecimal.ROUND_HALF_UP));
}
}
else
{
this.selectedItem.setTotal(this.selectedItem.getQuantity().multiply(this.selectedItem.getUnitPrice()));
}
// Calculate total price at form
if (form != null)
{
BigDecimal sumTotal = new BigDecimal(0);
for (RequirementItem item : this.getDataBean().getItems())
{
sumTotal = sumTotal.add(item.getTotal());
}
form.setField("sumTotal", sumTotal);
BindUtils.postNotifyChange(null, null, form, "*");
}
}
} }

@ -1,10 +1,16 @@
package info.bukova.isspst.ui.requirement; package info.bukova.isspst.ui.requirement;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.filters.RequirementFilter; import info.bukova.isspst.filters.RequirementFilter;
import info.bukova.isspst.services.requirement.RequirementService; 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.BigDecimalConverter;
import info.bukova.isspst.ui.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
import java.util.List;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -13,12 +19,38 @@ public class RequirementList extends ListViewModel<Requirement> {
@WireVariable @WireVariable
private RequirementService requirementService; private RequirementService requirementService;
@WireVariable
private UserService userService;
@WireVariable
private WorkgroupService workgroupService;
private BigDecimalConverter bigDecimalConverter;
public List<Workgroup> getCentres()
{
return workgroupService.getUserCentres(userService.getCurrent());
}
public BigDecimalConverter getBigDecimalConverter()
{
return bigDecimalConverter;
}
public void setBigDecimalConverter(BigDecimalConverter bigDecimalConverter)
{
this.bigDecimalConverter = bigDecimalConverter;
}
@Init @Init
public void init() { public void init()
{
service = requirementService; service = requirementService;
dataClass = Requirement.class; dataClass = Requirement.class;
formZul = "requirementsForm.zul"; formZul = "requirementsForm.zul";
dataFilter = new RequirementFilter(getFilterTemplate()); dataFilter = new RequirementFilter(getFilterTemplate());
}
this.bigDecimalConverter = new BigDecimalConverter();
}
} }

@ -0,0 +1,254 @@
package info.bukova.isspst.ui.requirement;
import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.data.RequirementSubject;
import info.bukova.isspst.data.ServiceItem;
import info.bukova.isspst.filters.MaterialFilter;
import info.bukova.isspst.filters.ServiceItemFilter;
import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
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 SelectItems
{
@WireVariable
private MaterialService materialService;
private List<Material> materialList;
private List<Material> fullMaterialList;
private boolean activeFilterMaterial;
private Material filterTmpMaterial;
private MaterialFilter dataFilterMaterial;
@WireVariable
private ServiceItemService serviceItemService;
private List<ServiceItem> serviceItemList;
private List<ServiceItem> fullServiceItemList;
private boolean activeFilterService;
private ServiceItem filterTmpService;
private ServiceItemFilter dataFilterService;
private RequirementSubject selectedItem;
@WireVariable
private MUnitService munitService;
private List<MUnitEmb> munitList;
@Init
public void init()
{
this.setFullMaterialList(materialService.getAll());
this.setMaterialList(this.getFullMaterialList());
this.setActiveFilterMaterial(false);
this.setFilterTmpMaterial(new Material());
this.setDataFilterMaterial(new MaterialFilter(this.getFilterTmpMaterial()));
this.setFullServiceItemList(serviceItemService.getAll());
this.setServiceItemList(this.getFullServiceItemList());
this.setActiveFilterService(false);
this.setFilterTmpService(new ServiceItem());
this.setDataFilterService(new ServiceItemFilter(this.getFilterTmpService()));
this.setMunitList(munitService.getEmbAll());
}
public List<Material> getMaterialList()
{
return materialList;
}
public void setMaterialList(List<Material> materialList)
{
this.materialList = materialList;
}
public List<Material> getFullMaterialList()
{
return fullMaterialList;
}
public void setFullMaterialList(List<Material> fullMaterialList)
{
this.fullMaterialList = fullMaterialList;
}
public boolean isActiveFilterMaterial()
{
return activeFilterMaterial;
}
public void setActiveFilterMaterial(boolean activeFilterMaterial)
{
this.activeFilterMaterial = activeFilterMaterial;
}
public Material getFilterTmpMaterial()
{
return this.filterTmpMaterial;
}
private void setFilterTmpMaterial(Material material)
{
this.filterTmpMaterial = material;
}
public MaterialFilter getDataFilterMaterial()
{
return dataFilterMaterial;
}
public void setDataFilterMaterial(MaterialFilter dataFilterMaterial)
{
this.dataFilterMaterial = dataFilterMaterial;
}
public List<ServiceItem> getServiceItemList()
{
return serviceItemList;
}
public void setServiceItemList(List<ServiceItem> serviceItemList)
{
this.serviceItemList = serviceItemList;
}
public List<ServiceItem> getFullServiceItemList()
{
return fullServiceItemList;
}
public void setFullServiceItemList(List<ServiceItem> fullServiceItemList)
{
this.fullServiceItemList = fullServiceItemList;
}
public boolean isActiveFilterService()
{
return activeFilterService;
}
public void setActiveFilterService(boolean activeFilterService)
{
this.activeFilterService = activeFilterService;
}
public ServiceItem getFilterTmpService()
{
return this.filterTmpService;
}
private void setFilterTmpService(ServiceItem serviceItem)
{
this.filterTmpService = serviceItem;
}
public ServiceItemFilter getDataFilterService()
{
return dataFilterService;
}
public void setDataFilterService(ServiceItemFilter dataFilterService)
{
this.dataFilterService = dataFilterService;
}
public RequirementSubject getSelectedItem()
{
return selectedItem;
}
public void setSelectedItem(RequirementSubject selectedItem)
{
this.selectedItem = selectedItem;
}
public List<MUnitEmb> getMunitList()
{
return munitList;
}
public void setMunitList(List<MUnitEmb> munitList)
{
this.munitList = munitList;
}
@Command
@NotifyChange({ "activeFilterMaterial", "materialList", "selectedItem" })
public void onFilterMaterial()
{
this.setSelectedItem(null);
this.setActiveFilterMaterial(!this.isActiveFilterMaterial());
if (this.isActiveFilterMaterial())
{
this.doFilterMaterial();
}
else
{
this.setMaterialList(this.getFullMaterialList());
}
}
@Command
@NotifyChange("materialList")
public void doFilterMaterial()
{
this.setSelectedItem(null);
List<Material> result = this.materialService.filterList(this.getFullMaterialList(), this.getDataFilterMaterial());
this.setMaterialList(result);
}
@Command
@NotifyChange({ "activeFilterService", "serviceItemList", "selectedItem" })
public void onFilterService()
{
this.setSelectedItem(null);
this.setActiveFilterService(!this.isActiveFilterService());
if (this.isActiveFilterService())
{
this.doFilterService();
}
else
{
this.setServiceItemList(this.getFullServiceItemList());
}
}
@Command
@NotifyChange("serviceItemList")
public void doFilterService()
{
this.setSelectedItem(null);
List<ServiceItem> result = this.serviceItemService.filterList(this.getFullServiceItemList(), this.getDataFilterService());
this.setServiceItemList(result);
}
}

@ -1,82 +0,0 @@
package info.bukova.isspst.ui.requirements;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.data.ServiceItem;
import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
import java.util.List;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
public class SelectItems
{
@WireVariable
private MaterialService materialService;
@WireVariable
private ServiceItemService serviceItemService;
private List<Material> materialList;
private List<ServiceItem> serviceItemList;
private Material selectedMaterial;
private ServiceItem selectedServiceItem;
@Init
public void init()
{
this.setMaterialList(materialService.getAll());
this.setServiceItemList(serviceItemService.getAll());
}
public List<Material> getMaterialList()
{
return materialList;
}
public void setMaterialList(List<Material> materialList)
{
this.materialList = materialList;
}
public List<ServiceItem> getServiceItemList()
{
return serviceItemList;
}
public void setServiceItemList(List<ServiceItem> serviceItemList)
{
this.serviceItemList = serviceItemList;
}
public Material getSelectedMaterial()
{
return selectedMaterial;
}
public void setSelectedMaterial(Material selectedMaterial)
{
this.selectedMaterial = selectedMaterial;
}
public ServiceItem getSelectedServiceItem()
{
return selectedServiceItem;
}
public void setSelectedServiceItem(ServiceItem selectedServiceItem)
{
this.selectedServiceItem = selectedServiceItem;
}
@Command
public void addItem()
{
//this
}
}

@ -75,12 +75,7 @@ public class UserForm extends FormViewModel<User>
public boolean isLoginFree() public boolean isLoginFree()
{ {
return loginFree || isEdit(); return loginFree || this.isEditRec();
}
public boolean isEdit()
{
return getDataBean().getCreated() != null;
} }
@Override @Override

@ -0,0 +1,33 @@
package info.bukova.isspst.validators;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.Workgroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zkoss.bind.Property;
import org.zkoss.bind.ValidationContext;
public class RequirementFormValidator extends BaseValidator
{
private final static Logger log = LoggerFactory.getLogger(RequirementFormValidator.class.getName());
@Override
protected Logger getLogger()
{
return log;
}
@Override
public void validate(ValidationContext ctx)
{
Property propertyWorkgroup = ctx.getProperties("workgroup")[0];
Workgroup workgroup = (Workgroup) propertyWorkgroup.getValue();
if (workgroup == null)
{
this.errorMsg(ctx, StringUtils.localize("RequirementCenterIsEmpty"), "idReqCenter");
return;
}
}
}

@ -3,3 +3,4 @@ DataTypeErr=Chybný datový typ...
UserPasswordIsEmpty=Uživatelské heslo musí být zadané... UserPasswordIsEmpty=Uživatelské heslo musí být zadané...
UserPasswordsAreNotSame=Znovu zadané heslo není stejné... UserPasswordsAreNotSame=Znovu zadané heslo není stejné...
RequirementCenterIsEmpty=Musíte zadat středisko...

@ -47,10 +47,8 @@ AgendaOrdersHistory=Ukončené
AgendaMUnits=Měrné jednotky AgendaMUnits=Měrné jednotky
MUnitsFormTitle=Měrná jednotka MUnitsFormTitle=Měrná jednotka
MUnitsFormCode=Kód
MUnitsFormName=Název MUnitsFormName=Název
MUnitsFormDescription=Popis MUnitsFormDescription=Popis
MUnitsGridColumnCode=Kód
MUnitsGridColumnName=Název MUnitsGridColumnName=Název
MUnitsGridColumnDescription=Popis MUnitsGridColumnDescription=Popis
@ -204,5 +202,7 @@ false=Ne
DateFormat=dd. MM. yyyy DateFormat=dd. MM. yyyy
AddItem=Přidat položku... AddItem=Přidat položku...
RemoveItem=Smazat položku... RemoveItem=Smazat
Amount=Částka

@ -26,3 +26,16 @@
.find-grid-textbox { .find-grid-textbox {
width: 100%; width: 100%;
} }
.grid-textbox-max {
width: 100%;
}
.grid-textbox-max-right {
width: 100%;
text-align: right;
}
.row-title {
vertical-align: top;
}

@ -9,8 +9,8 @@
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader label="${labels.code}" sort="czech(code)" width="10%" /> <listheader label="${labels.code}" sort="czech(code)" width="10%" />
<listheader label="${labels.name}" sort="czech(name)" width="25%" /> <listheader label="${labels.name}" sort="czech(name)" width="25%" />
<listheader label="${labels.description}" sort="czech(description)" width="55%" /> <listheader label="${labels.munit}" width="15%"/>
<listheader label="${labels.munit}" width="10%"/> <listheader label="${labels.description}" sort="czech(description)" width="50%" />
</listhead> </listhead>
<auxhead sclass="category-center" visible="@load(vm.filter)"> <auxhead sclass="category-center" visible="@load(vm.filter)">
@ -34,6 +34,25 @@
</div> </div>
</div> </div>
</auxheader> </auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<combobox
model="@load(vm.munitList)"
selectedItem="@bind(vm.filterTemplate.munit)"
onChange="@command('doFilter')"
readonly="true"
sclass="find-grid-textbox">
<template name="model">
<comboitem label="@load(each.name)" />
</template>
</combobox>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
@ -50,8 +69,8 @@
<listitem> <listitem>
<listcell label="@load(each.code)" /> <listcell label="@load(each.code)" />
<listcell label="@load(each.name)" /> <listcell label="@load(each.name)" />
<listcell label="@load(each.munit.name)"/>
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
<listcell label="@load(each.munit.code)"/>
</listitem> </listitem>
</template> </template>
</listbox> </listbox>

@ -22,22 +22,22 @@
<textbox id="name" width="200px" value="@bind(vm.dataBean.name)" /> <textbox id="name" width="200px" value="@bind(vm.dataBean.name)" />
</cell> </cell>
</row> </row>
<row>
<cell sclass="row-title">${labels.description} :</cell>
<cell>
<textbox id="description" width="300px" value="@bind(vm.dataBean.description)" />
</cell>
</row>
<row> <row>
<cell sclass="row-title">${labels.munit} :</cell> <cell sclass="row-title">${labels.munit} :</cell>
<cell> <cell>
<combobox model="@load(vm.munits)" selectedItem="@bind(vm.dataBean.munit)" readonly="true"> <combobox model="@load(vm.munits)" selectedItem="@bind(vm.dataBean.munit)" readonly="true">
<template name="model"> <template name="model">
<comboitem label="@load(each.code)"/> <comboitem label="@load(each.name)"/>
</template> </template>
</combobox> </combobox>
</cell> </cell>
</row> </row>
<row>
<cell sclass="row-title">${labels.description} :</cell>
<cell>
<textbox id="description" width="300px" value="@bind(vm.dataBean.description)" />
</cell>
</row>
</rows> </rows>
</grid> </grid>
<include src="/app/formButtons.zul" /> <include src="/app/formButtons.zul" />

@ -9,12 +9,6 @@
<column /> <column />
</columns> </columns>
<rows> <rows>
<row>
<cell sclass="row-title">${labels.MUnitsFormCode} :</cell>
<cell>
<textbox id="code" constraint="@load(vm.constriant)" width="200px" value="@bind(vm.dataBean.code)" />
</cell>
</row>
<row> <row>
<cell sclass="row-title">${labels.MUnitsFormName} :</cell> <cell sclass="row-title">${labels.MUnitsFormName} :</cell>
<cell> <cell>

@ -7,26 +7,15 @@
<listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)"> <listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader label="${labels.MUnitsGridColumnCode}" sort="czech(code)" width="10%" />
<listheader label="${labels.MUnitsGridColumnName}" sort="czech(name)" width="30%" /> <listheader label="${labels.MUnitsGridColumnName}" sort="czech(name)" width="30%" />
<listheader label="${labels.MUnitsGridColumnDescription}" sort="czech(description)" width="60%" /> <listheader label="${labels.MUnitsGridColumnDescription}" sort="czech(description)" width="70%" />
</listhead> </listhead>
<auxhead sclass="category-center" visible="@load(vm.filter)"> <auxhead sclass="category-center" visible="@load(vm.filter)">
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.code)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" /> <textbox value="@bind(vm.filterTemplate.name)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.nameSpecial)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div> </div>
<div sclass="find-grid-img"> <div sclass="find-grid-img">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
@ -47,8 +36,7 @@
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell label="@load(each.code)" /> <listcell label="@load(each.name)" />
<listcell label="@load(each.nameSpecial)" />
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
</listitem> </listitem>
</template> </template>

@ -25,14 +25,19 @@
label="${labels.RequirementsGridCenter}" label="${labels.RequirementsGridCenter}"
sort="czech(description)" sort="czech(description)"
width="10%" /> width="10%" />
<listheader
label="${labels.RequirementsGridDescription}"
sort="czech(description)"
width="70%" />
<listheader <listheader
label="${labels.RequirementsGridDeliveryDate}" label="${labels.RequirementsGridDeliveryDate}"
sort="auto(reqDate)" sort="auto(reqDate)"
width="13%" /> width="13%" />
<listheader
label="${labels.Amount}"
sort="auto(sumTotal)"
align="right"
width="10%" />
<listheader
label="${labels.RequirementsGridDescription}"
sort="czech(description)"
width="60%" />
</listhead> </listhead>
<auxhead <auxhead
sclass="category-center" sclass="category-center"
@ -59,8 +64,7 @@
format="${labels.DateFormat}" format="${labels.DateFormat}"
instant="true" instant="true"
onChange="@command('doFilter')" onChange="@command('doFilter')"
sclass="find-grid-textbox" sclass="find-grid-textbox" />
width="100%" />
</div> </div>
<div sclass="find-grid-img"> <div sclass="find-grid-img">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
@ -70,11 +74,12 @@
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<combobox <combobox
model="@load(vm.centres)"
readonly="true" readonly="true"
width="100%" width="100%"
selectedItem="@bind(vm.filterTemplate.workgroup)"> selectedItem="@bind(vm.filterTemplate.workgroup)">
<template name="modelW"> <template name="model">
<comboitem label="@load(each.workgroup.fullName)" /> <comboitem label="@load(each.fullName)" />
</template> </template>
</combobox> </combobox>
<div sclass="find-grid-img"> <div sclass="find-grid-img">
@ -82,11 +87,26 @@
</div> </div>
</div> </div>
</auxheader> </auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<datebox
value="@bind(vm.filterTemplate.deliveryDate)"
format="${labels.DateFormat}"
instant="true"
onChange="@command('doFilter')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox <textbox
value="@bind(vm.filterTemplate.description)" value="@bind(vm.filterTemplate.sumTotal) @converter(vm.bigDecimalConverter)"
instant="true" instant="true"
onChange="@command('doFilter')" onChange="@command('doFilter')"
sclass="find-grid-textbox" /> sclass="find-grid-textbox" />
@ -99,13 +119,11 @@
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<datebox <textbox
value="@bind(vm.filterTemplate.deliveryDate)" value="@bind(vm.filterTemplate.description)"
format="${labels.DateFormat}"
instant="true" instant="true"
onChange="@command('doFilter')" onChange="@command('doFilter')"
sclass="find-grid-textbox" sclass="find-grid-textbox" />
width="100%" />
</div> </div>
<div sclass="find-grid-img"> <div sclass="find-grid-img">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
@ -118,8 +136,9 @@
<listcell label="@load(each.numser)" /> <listcell label="@load(each.numser)" />
<listcell label="@load(each.reqDate) @converter('formatedDate', format=labels.DateFormat)" /> <listcell label="@load(each.reqDate) @converter('formatedDate', format=labels.DateFormat)" />
<listcell label="@load(each.workgroup.fullName)" /> <listcell label="@load(each.workgroup.fullName)" />
<listcell label="@load(each.description)" />
<listcell label="@load(each.deliveryDate) @converter('formatedDate', format=labels.DateFormat)" /> <listcell label="@load(each.deliveryDate) @converter('formatedDate', format=labels.DateFormat)" />
<listcell label="@load(each.sumTotal) @converter(vm.bigDecimalConverter)" />
<listcell label="@load(each.description)" />
</listitem> </listitem>
</template> </template>
</listbox> </listbox>

@ -6,12 +6,15 @@
border="normal" border="normal"
position="center" position="center"
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementForm')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementForm')"
validationMessages="@id('vmsg')">
<caption <caption
src="/img/reqact.png" src="/img/reqact.png"
zclass="form-caption" zclass="form-caption"
label="${labels.RequirementsFormTitle}" /> label="${labels.RequirementsFormTitle}" />
<vlayout> <vlayout
form="@id('fx') @load(vm.dataBean) @save(vm.dataBean, before='save') @validator(vm.requirementFormValidator)"
hflex="1">
<grid hflex="min"> <grid hflex="min">
<columns> <columns>
<column <column
@ -25,9 +28,9 @@
<cell> <cell>
<textbox <textbox
id="numser" id="numser"
width="150px"
constraint="@load(vm.constriant)" constraint="@load(vm.constriant)"
width="200px" value="@bind(fx.numser)"
value="@bind(vm.dataBean.numser)"
readonly="true" /> readonly="true" />
</cell> </cell>
</row> </row>
@ -36,8 +39,8 @@
<cell> <cell>
<datebox <datebox
id="reqDate" id="reqDate"
width="200px" width="150px"
value="@bind(vm.dataBean.reqDate)" value="@bind(fx.reqDate)"
format="${labels.DateFormat}" /> format="${labels.DateFormat}" />
</cell> </cell>
</row> </row>
@ -45,9 +48,12 @@
<cell sclass="row-title">${labels.RequirementsFormCenter} :</cell> <cell sclass="row-title">${labels.RequirementsFormCenter} :</cell>
<cell> <cell>
<combobox <combobox
id="idReqCenter"
width="150px"
model="@load(vm.centres)" model="@load(vm.centres)"
readonly="true" readonly="true"
selectedItem="@bind(vm.dataBean.workgroup)"> disabled="@load(vm.editRec)"
selectedItem="@bind(fx.workgroup)">
<template name="model"> <template name="model">
<comboitem label="@load(each.fullName)" /> <comboitem label="@load(each.fullName)" />
</template> </template>
@ -55,112 +61,140 @@
</cell> </cell>
</row> </row>
<row> <row>
<cell sclass="row-title">${labels.RequirementsFormDescription} :</cell> <cell sclass="row-title">${labels.RequirementsFormDeliveryDate} :</cell>
<cell>
<datebox
id="deliveryDate"
width="150px"
value="@bind(fx.deliveryDate)"
format="${labels.DateFormat}" />
</cell>
</row>
<row>
<cell sclass="row-title">${labels.Amount} :</cell>
<cell> <cell>
<textbox <textbox
id="description" id="idSumTotal"
width="300px" readonly="true"
value="@bind(vm.dataBean.description)" /> width="150px"
value="@bind(fx.sumTotal) @converter(vm.bigDecimalConverter)" />
</cell> </cell>
</row> </row>
<row> <row>
<cell sclass="row-title">${labels.RequirementsFormDeliveryDate} :</cell> <cell sclass="row-title">${labels.RequirementsFormDescription} :</cell>
<cell> <cell>
<datebox <textbox
id="deliveryDate" id="description"
width="200px" width="400px"
value="@bind(vm.dataBean.deliveryDate)" rows="5"
format="${labels.DateFormat}" /> value="@bind(fx.description)" />
</cell> </cell>
</row> </row>
</rows> </rows>
</grid> </grid>
<hbox> <hbox>
<button <button
disabled="@load(empty fx.workgroup)"
image="/img/item-add.png" image="/img/item-add.png"
label="${labels.AddItem}" label="${labels.AddItem}"
onClick="@command('addItem')" onClick="@command('addSelectedItem')"
sclass="nicebutton" /> sclass="nicebutton" />
</hbox> </hbox>
<listbox <listbox
height="180px" height="180px"
model="@load(vm.dataBean.items)" model="@load(vm.syncItems)"
selectedItem="@bind(vm.item)" selectedItem="@bind(vm.selectedItem)"
selectedIndex="@bind(vm.selItemIndex)"> selectedIndex="@bind(vm.selItemIndex)">
<listhead> <listhead>
<listheader <listheader
hflex="1" hflex="1"
Label="${labels.RequirementItemCode}" /> label="${labels.RequirementItemCode}" />
<listheader <listheader
hflex="3" hflex="3"
label="${labels.RequirementItemName}" /> label="${labels.RequirementItemName}" />
<listheader <listheader
hflex="1" hflex="1"
align="right"
label="${labels.RequirementItemQuantity}" /> label="${labels.RequirementItemQuantity}" />
<listheader <listheader
hflex="1" hflex="1"
label="${labels.RequirementItemMUnit}" /> label="${labels.RequirementItemMUnit}" />
<listheader <listheader
hflex="2" hflex="1"
align="right"
label="${labels.RequirementItemUnitPrice}" /> label="${labels.RequirementItemUnitPrice}" />
<listheader <listheader
hflex="2" hflex="1"
align="right"
label="${labels.RequirementItemTotal}" /> label="${labels.RequirementItemTotal}" />
<listheader <listheader
width="120px" hflex="3"
label="${labels.RequirementItemDescription}" /> label="${labels.RequirementItemDescription}" />
<listheader hflex="2" /> <listheader hflex="1" />
</listhead> </listhead>
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max"
readonly="true"
onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.code)" /> value="@bind(each.code)" />
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max"
onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.name)" /> value="@bind(each.name)" />
</listcell> </listcell>
<listcell> <listcell>
<spinner <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max-right"
__onChange="@command('recalculate', zeroPrice=false)" onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.quantity)" /> onChange="@command('recalculate', form=fx, changed='quantity')"
value="@bind(each.quantity) @converter(vm.bigDecimalConverter)" />
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max"
value="@bind(each.mUnit)" /> readonly="true"
onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.munit.name)" />
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max-right"
value="@bind(each.unitPrice) @converter(vm.numConverter)" /> onFocus="@command('onFocusItem', item=each, ctrl=self)"
onChange="@command('recalculate', form=fx, changed='unitprice')"
value="@bind(each.unitPrice) @converter(vm.bigDecimalConverter)" />
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max-right"
value="@bind(each.total) @converter(vm.numConverter)" /> onFocus="@command('onFocusItem', item=each, ctrl=self)"
onChange="@command('recalculate', form=fx, changed='total')"
value="@bind(each.total) @converter(vm.bigDecimalConverter)" />
</listcell> </listcell>
<listcell> <listcell>
<textbox <textbox
inplace="true" inplace="true"
onFocus="@command('selectItem', item=each)" sclass="grid-textbox-max"
onFocus="@command('onFocusItem', item=each, ctrl=self)"
value="@bind(each.description)" /> value="@bind(each.description)" />
</listcell> </listcell>
<listcell> <listcell
sclass="grid-textbox-max"
style="text-align:center">
<button <button
image="/img/item-remove.png" image="~./zul/img/misc/drag-disallow.png"
label="${labels.RemoveItem}" label="${labels.RemoveItem}"
onClick="@command('removeItem', item=each)" onClick="@command('removeItem', item=each, ctrl=self)"
sclass="nicebutton" /> sclass="nicebutton" />
</listcell> </listcell>
</listitem> </listitem>

@ -6,7 +6,7 @@
border="normal" border="normal"
position="center" position="center"
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirements.SelectItems')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.SelectItems')">
<caption <caption
src="/img/item-add.png" src="/img/item-add.png"
zclass="form-caption" zclass="form-caption"
@ -27,9 +27,16 @@
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>
<toolbar>
<toolbarbutton
image="/img/funnel.png"
tooltiptext="${labels.ToolbarRecFilter}"
id="btnFilterMaterial"
onClick="@command('onFilterMaterial')" />
</toolbar>
<listbox <listbox
model="@load(vm.materialList)" model="@load(vm.materialList)"
selectedItem="@bind(vm.selectedMaterial)"> selectedItem="@bind(vm.selectedItem)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader <listheader
label="${labels.code}" label="${labels.code}"
@ -39,28 +46,101 @@
label="${labels.name}" label="${labels.name}"
sort="czech(name)" sort="czech(name)"
width="25%" /> width="25%" />
<listheader
label="${labels.munit}"
width="15%" />
<listheader <listheader
label="${labels.description}" label="${labels.description}"
sort="czech(description)" sort="czech(description)"
width="55%" /> width="50%" />
<listheader
label="${labels.munit}"
width="10%" />
</listhead> </listhead>
<auxhead
sclass="category-center"
visible="@load(vm.activeFilterMaterial)">
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpMaterial.code)"
instant="true"
onChange="@command('doFilterMaterial')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpMaterial.name)"
instant="true"
onChange="@command('doFilterMaterial')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<combobox
instant="true"
model="@load(vm.munitList)"
selectedItem="@bind(vm.filterTmpMaterial.munit)"
onChange="@command('doFilterMaterial')"
readonly="true"
sclass="find-grid-textbox">
<template name="model">
<comboitem label="@load(each.name)" />
</template>
</combobox>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpMaterial.description)"
instant="true"
onChange="@command('doFilterMaterial')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
</auxhead>
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell label="@load(each.code)" /> <listcell label="@load(each.code)" />
<listcell label="@load(each.name)" /> <listcell label="@load(each.name)" />
<listcell label="@load(each.munit.name)" />
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
<listcell label="@load(each.munit.code)" />
</listitem> </listitem>
</template> </template>
</listbox> </listbox>
</tabpanel> </tabpanel>
<tabpanel> <tabpanel>
<toolbar>
<toolbarbutton
image="/img/funnel.png"
tooltiptext="${labels.ToolbarRecFilter}"
id="btnFilterService"
onClick="@command('onFilterService')" />
</toolbar>
<listbox <listbox
model="@load(vm.serviceItemList)" model="@load(vm.serviceItemList)"
selectedItem="@bind(vm.selectedServiceItem)"> selectedItem="@bind(vm.selectedItem)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader <listheader
label="${labels.code}" label="${labels.code}"
@ -75,6 +155,52 @@
sort="czech(description)" sort="czech(description)"
width="60%" /> width="60%" />
</listhead> </listhead>
<auxhead
sclass="category-center"
visible="@load(vm.activeFilterService)">
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpService.code)"
instant="true"
onChange="@command('doFilterService')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpService.name)"
instant="true"
onChange="@command('doFilterService')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTmpService.description)"
instant="true"
onChange="@command('doFilterService')"
sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
</auxhead>
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell label="@load(each.code)" /> <listcell label="@load(each.code)" />
@ -99,8 +225,8 @@
<button <button
image="/img/item-add.png" image="/img/item-add.png"
label="${labels.AddItem}" label="${labels.AddItem}"
onClick="@command('addItem', window=selectItemsWnd)" onClick="@global-command('insertSelectedItem', selected=vm.selectedItem, window=selectItemsWnd)"
disabled="false" disabled="@load(empty vm.selectedItem ? 'true' : 'false')"
sclass="nicebutton" /> sclass="nicebutton" />
</div> </div>
</vlayout> </vlayout>

Loading…
Cancel
Save