@@ -1,5 +1,10 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
@@ -10,126 +15,326 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
@Entity
|
||||
@Table(name="ADDRESS")
|
||||
public class Address extends BaseData {
|
||||
|
||||
@Column(name="COMPANY")
|
||||
@Table(name = "ADDRESS")
|
||||
public class Address extends BaseData
|
||||
{
|
||||
|
||||
@Column(name = "COMPANY")
|
||||
private String company;
|
||||
@Column(name="DEPARTMENT")
|
||||
@Column(name = "DEPARTMENT")
|
||||
private String department;
|
||||
@Column(name="CONTACT_NAME")
|
||||
@Column(name = "CONTACT_NAME")
|
||||
private String contactName;
|
||||
@Column(name="STREET")
|
||||
@Column(name = "STREET")
|
||||
private String street;
|
||||
@Column(name="HOUSE_NUMBER")
|
||||
@Column(name = "HOUSE_NUMBER")
|
||||
private String houseNumber;
|
||||
@Column(name="ZIP_CODE")
|
||||
@Column(name = "ZIP_CODE")
|
||||
private String zipCode;
|
||||
@Column(name="CITY")
|
||||
@Column(name = "CITY")
|
||||
private String city;
|
||||
@Column(name="STATE")
|
||||
@Column(name = "STATE")
|
||||
private String state;
|
||||
@Column(name="IC")
|
||||
@Column(name = "IC")
|
||||
private long ic;
|
||||
@Column(name="DIC")
|
||||
@Column(name = "DIC")
|
||||
private String dic;
|
||||
@Column(name="PHONE")
|
||||
@Column(name = "PHONE")
|
||||
private String phone;
|
||||
@Column(name="EMAIL")
|
||||
@Column(name = "EMAIL")
|
||||
private String email;
|
||||
@Column(name="WEB")
|
||||
@Column(name = "WEB")
|
||||
private String web;
|
||||
@Column(name="DESCRIPTION")
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
|
||||
@NotNull(message = "Zadejte firmu")
|
||||
@NotEmpty(message = "Zadejte firmu")
|
||||
public String getCompany() {
|
||||
public String getCompany()
|
||||
{
|
||||
return company;
|
||||
}
|
||||
public void setCompany(String company) {
|
||||
|
||||
public void setCompany(String company)
|
||||
{
|
||||
this.company = company;
|
||||
}
|
||||
public String getDepartment() {
|
||||
|
||||
public String getDepartment()
|
||||
{
|
||||
return department;
|
||||
}
|
||||
public void setDepartment(String department) {
|
||||
|
||||
public void setDepartment(String department)
|
||||
{
|
||||
this.department = department;
|
||||
}
|
||||
public String getContactName() {
|
||||
|
||||
public String getContactName()
|
||||
{
|
||||
return contactName;
|
||||
}
|
||||
public void setContactName(String contactName) {
|
||||
|
||||
public void setContactName(String contactName)
|
||||
{
|
||||
this.contactName = contactName;
|
||||
}
|
||||
public String getStreet() {
|
||||
|
||||
public String getStreet()
|
||||
{
|
||||
return street;
|
||||
}
|
||||
public void setStreet(String street) {
|
||||
|
||||
public void setStreet(String street)
|
||||
{
|
||||
this.street = street;
|
||||
}
|
||||
public String getHouseNumber() {
|
||||
|
||||
public String getHouseNumber()
|
||||
{
|
||||
return houseNumber;
|
||||
}
|
||||
public void setHouseNumber(String houseNumber) {
|
||||
|
||||
public void setHouseNumber(String houseNumber)
|
||||
{
|
||||
this.houseNumber = houseNumber;
|
||||
}
|
||||
public String getZipCode() {
|
||||
|
||||
public String getZipCode()
|
||||
{
|
||||
return zipCode;
|
||||
}
|
||||
public void setZipCode(String zipCode) {
|
||||
|
||||
public void setZipCode(String zipCode)
|
||||
{
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
@NotNull(message = "Zadejte město")
|
||||
@NotEmpty(message = "Zadejte město")
|
||||
public String getCity() {
|
||||
public String getCity()
|
||||
{
|
||||
return city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
|
||||
public void setCity(String city)
|
||||
{
|
||||
this.city = city;
|
||||
}
|
||||
public String getState() {
|
||||
|
||||
public String getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
|
||||
public void setState(String state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
public long getIc() {
|
||||
|
||||
public long getIc()
|
||||
{
|
||||
return ic;
|
||||
}
|
||||
public void setIc(long ic) {
|
||||
|
||||
public void setIc(long ic)
|
||||
{
|
||||
this.ic = ic;
|
||||
}
|
||||
public String getDic() {
|
||||
|
||||
public String getDic()
|
||||
{
|
||||
return dic;
|
||||
}
|
||||
public void setDic(String dic) {
|
||||
|
||||
public void setDic(String dic)
|
||||
{
|
||||
this.dic = dic;
|
||||
}
|
||||
public String getPhone() {
|
||||
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
|
||||
public void setPhone(String phone)
|
||||
{
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "Špatný formát adresy")
|
||||
public String getEmail() {
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@URL(message = "Špatný formát adresy")
|
||||
public String getWeb() {
|
||||
public String getWeb()
|
||||
{
|
||||
return web;
|
||||
}
|
||||
public void setWeb(String web) {
|
||||
|
||||
public void setWeb(String web)
|
||||
{
|
||||
this.web = web;
|
||||
}
|
||||
public String getDescription() {
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String str, street;
|
||||
|
||||
List<String> listStreet = new ArrayList<String>();
|
||||
if (this.street != null)
|
||||
listStreet.add(this.street);
|
||||
if (this.houseNumber != null)
|
||||
listStreet.add(this.houseNumber);
|
||||
street = StringUtils.join(listStreet, " ");
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (this.company != null)
|
||||
list.add(this.company);
|
||||
if (street != null)
|
||||
list.add(street);
|
||||
if (this.city != null)
|
||||
list.add(this.city);
|
||||
list.add(Long.toString(this.ic));
|
||||
str = StringUtils.join(list, ", ");
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Address other = (Address) obj;
|
||||
|
||||
if (other.getId() == this.getId())
|
||||
{
|
||||
if (other.getId() == 0)
|
||||
{
|
||||
// Protože globální nastavení je serializováno (není v DB), nemá
|
||||
// vyplněno ID - musíme porovnávat jinak - obsahově
|
||||
if (city == null)
|
||||
{
|
||||
if (other.city != null)
|
||||
return false;
|
||||
}
|
||||
else if (!city.equals(other.city))
|
||||
return false;
|
||||
if (company == null)
|
||||
{
|
||||
if (other.company != null)
|
||||
return false;
|
||||
}
|
||||
else if (!company.equals(other.company))
|
||||
return false;
|
||||
if (contactName == null)
|
||||
{
|
||||
if (other.contactName != null)
|
||||
return false;
|
||||
}
|
||||
else if (!contactName.equals(other.contactName))
|
||||
return false;
|
||||
if (department == null)
|
||||
{
|
||||
if (other.department != null)
|
||||
return false;
|
||||
}
|
||||
else if (!department.equals(other.department))
|
||||
return false;
|
||||
if (description == null)
|
||||
{
|
||||
if (other.description != null)
|
||||
return false;
|
||||
}
|
||||
else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (dic == null)
|
||||
{
|
||||
if (other.dic != null)
|
||||
return false;
|
||||
}
|
||||
else if (!dic.equals(other.dic))
|
||||
return false;
|
||||
if (email == null)
|
||||
{
|
||||
if (other.email != null)
|
||||
return false;
|
||||
}
|
||||
else if (!email.equals(other.email))
|
||||
return false;
|
||||
if (houseNumber == null)
|
||||
{
|
||||
if (other.houseNumber != null)
|
||||
return false;
|
||||
}
|
||||
else if (!houseNumber.equals(other.houseNumber))
|
||||
return false;
|
||||
if (ic != other.ic)
|
||||
return false;
|
||||
if (phone == null)
|
||||
{
|
||||
if (other.phone != null)
|
||||
return false;
|
||||
}
|
||||
else if (!phone.equals(other.phone))
|
||||
return false;
|
||||
if (state == null)
|
||||
{
|
||||
if (other.state != null)
|
||||
return false;
|
||||
}
|
||||
else if (!state.equals(other.state))
|
||||
return false;
|
||||
if (street == null)
|
||||
{
|
||||
if (other.street != null)
|
||||
return false;
|
||||
}
|
||||
else if (!street.equals(other.street))
|
||||
return false;
|
||||
if (web == null)
|
||||
{
|
||||
if (other.web != null)
|
||||
return false;
|
||||
}
|
||||
else if (!web.equals(other.web))
|
||||
return false;
|
||||
if (zipCode == null)
|
||||
{
|
||||
if (other.zipCode != null)
|
||||
return false;
|
||||
}
|
||||
else if (!zipCode.equals(other.zipCode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import javax.persistence.Embeddable;
|
||||
@Embeddable
|
||||
public class AddressEmb {
|
||||
|
||||
private int id;
|
||||
private String company;
|
||||
private String department;
|
||||
private String contactName;
|
||||
@@ -24,7 +25,14 @@ public class AddressEmb {
|
||||
super();
|
||||
}
|
||||
|
||||
public AddressEmb(Address address) {
|
||||
public AddressEmb(Address address)
|
||||
{
|
||||
if (address == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = address.getId();
|
||||
this.company = address.getCompany();
|
||||
this.department = address.getDepartment();
|
||||
this.contactName = address.getContactName();
|
||||
@@ -41,6 +49,39 @@ public class AddressEmb {
|
||||
this.description = address.getDescription();
|
||||
}
|
||||
|
||||
public Address getAddress()
|
||||
{
|
||||
Address address = new Address();
|
||||
|
||||
address.setId(this.id);
|
||||
address.setCompany(this.company);
|
||||
address.setDepartment(this.department);
|
||||
address.setContactName(this.contactName);
|
||||
address.setStreet(this.street);
|
||||
address.setHouseNumber(this.houseNumber);
|
||||
address.setZipCode(this.zipCode);
|
||||
address.setCity(this.city);
|
||||
address.setState(this.state);
|
||||
address.setIc(this.ic);
|
||||
address.setDic(this.dic);
|
||||
address.setPhone(this.phone);
|
||||
address.setEmail(this.email);
|
||||
address.setWeb(this.web);
|
||||
address.setDescription(this.description);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Order extends BaseData {
|
||||
|
||||
@Embedded
|
||||
@AttributeOverrides({
|
||||
@AttributeOverride(name = "id", column = @Column(name = "SUPPLIER_ID")),
|
||||
@AttributeOverride(name = "city", column = @Column(name = "SUPPLIER_CITY")),
|
||||
@AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")),
|
||||
@AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")),
|
||||
@@ -48,6 +49,7 @@ public class Order extends BaseData {
|
||||
|
||||
@Embedded
|
||||
@AttributeOverrides({
|
||||
@AttributeOverride(name = "id", column = @Column(name = "INVOICE_ID")),
|
||||
@AttributeOverride(name = "city", column = @Column(name = "INVOICE_CITY")),
|
||||
@AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")),
|
||||
@AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")),
|
||||
@@ -67,6 +69,7 @@ public class Order extends BaseData {
|
||||
|
||||
@Embedded
|
||||
@AttributeOverrides({
|
||||
@AttributeOverride(name = "id", column = @Column(name = "DELIVERY_ID")),
|
||||
@AttributeOverride(name = "city", column = @Column(name = "DELIVERY_CITY")),
|
||||
@AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")),
|
||||
@AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.mail.MailMessage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import info.bukova.isspst.mail.MailMessage;
|
||||
|
||||
public class SettingsData {
|
||||
|
||||
private boolean enableRequirements;
|
||||
@@ -76,6 +76,17 @@ public class SettingsData {
|
||||
return shippingAddrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Seznam všech doručovacích adres včetně hlavní fakturační adresy
|
||||
*/
|
||||
public List<Address> getAllShippingAddrs()
|
||||
{
|
||||
List<Address> list = new ArrayList<Address>();
|
||||
list.add(this.mainAddress);
|
||||
list.addAll(this.getShippingAddrs());
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setShippingAddrs(List<Address> shippingAddrs) {
|
||||
this.shippingAddrs = shippingAddrs;
|
||||
}
|
||||
|
||||
@@ -205,18 +205,12 @@ public class User extends Member implements UserDetails, DataModel {
|
||||
|
||||
public static boolean isEqualByUserForFilter(User value, User search)
|
||||
{
|
||||
if (search == null)
|
||||
if ((search == null) || search.getFullName().isEmpty())
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -154,18 +154,12 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable {
|
||||
|
||||
public static boolean isEqualByWorkgroupForFilter(Workgroup value, Workgroup search)
|
||||
{
|
||||
if (search == null)
|
||||
if ((search == null) || search.getFullName().isEmpty())
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package info.bukova.isspst.ui;
|
||||
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.KeyEvent;
|
||||
import org.zkoss.zul.Combobox;
|
||||
|
||||
public class DocumentViewModel
|
||||
{
|
||||
protected BigDecimalConverter standardBigDecimalConverter;
|
||||
|
||||
public BigDecimalConverter getStandardBigDecimalConverter()
|
||||
{
|
||||
return standardBigDecimalConverter;
|
||||
}
|
||||
|
||||
public void setStandardBigDecimalConverter(BigDecimalConverter standardBigDecimalConverter)
|
||||
{
|
||||
this.standardBigDecimalConverter = standardBigDecimalConverter;
|
||||
}
|
||||
|
||||
@Init
|
||||
public void initDocumentViewModel()
|
||||
{
|
||||
this.standardBigDecimalConverter = new BigDecimalConverter();
|
||||
}
|
||||
|
||||
@Command
|
||||
public void handleComboKeyFilter(@BindingParam("ctrl") Combobox cb, @BindingParam("keyEvent") KeyEvent keyEvent)
|
||||
{
|
||||
if (cb == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int keyCode = keyEvent.getKeyCode();
|
||||
|
||||
switch (keyCode)
|
||||
{
|
||||
case 46: // del
|
||||
// Zrušit jakoukoli vybranou položku
|
||||
cb.setSelectedIndex(-1);
|
||||
// Zavřít listbox
|
||||
cb.close();
|
||||
// Vyvolat událost změny
|
||||
Events.postEvent("onChange", cb, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import org.zkoss.bind.annotation.NotifyChange;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
public class FormViewModel<T extends DataModel>
|
||||
public class FormViewModel<T extends DataModel> extends DocumentViewModel
|
||||
{
|
||||
|
||||
private T dataBean;
|
||||
@@ -32,6 +32,8 @@ public class FormViewModel<T extends DataModel>
|
||||
@Init
|
||||
public void init(@ExecutionArgParam("selected") T selected, @ExecutionArgParam("service") Service<T> service)
|
||||
{
|
||||
super.initDocumentViewModel();
|
||||
|
||||
this.dataBean = selected;
|
||||
this.service = service;
|
||||
constraint = new ServiceConstraint<T>();
|
||||
|
||||
@@ -23,7 +23,8 @@ import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
public class ListViewModel<T extends DataModel> {
|
||||
public class ListViewModel<T extends DataModel> extends DocumentViewModel
|
||||
{
|
||||
|
||||
private boolean confirmDelete = false;
|
||||
private boolean filter = false;
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
package info.bukova.isspst.ui.main.approved;
|
||||
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.data.Order;
|
||||
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.approved.OrderService;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
{
|
||||
@@ -27,8 +34,13 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
@WireVariable
|
||||
protected UserService userService;
|
||||
|
||||
@WireVariable
|
||||
protected OrderService orderService;
|
||||
|
||||
private BigDecimalConverter bigDecimalConverter;
|
||||
|
||||
protected List<JoinedItem> selectedItems;
|
||||
|
||||
@Init
|
||||
public void initApprovedList()
|
||||
{
|
||||
@@ -37,6 +49,7 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
// formZul = "form.zul";
|
||||
dataFilter = new JoinedItemFilter(getFilterTemplate());
|
||||
bigDecimalConverter = new BigDecimalConverter();
|
||||
selectedItems = new ArrayList<JoinedItem>();
|
||||
}
|
||||
|
||||
public BigDecimalConverter getBigDecimalConverter()
|
||||
@@ -49,15 +62,19 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
return approvedService.getAll();
|
||||
}
|
||||
|
||||
public List<JoinedItem> getSelectedItems()
|
||||
{
|
||||
return this.selectedItems;
|
||||
}
|
||||
|
||||
public void setSelectedItems(List<JoinedItem> selectedItems)
|
||||
{
|
||||
this.selectedItems = selectedItems;
|
||||
}
|
||||
|
||||
public List<Workgroup> getWorkgroups()
|
||||
{
|
||||
Workgroup empty = new Workgroup();
|
||||
empty.setCode("");
|
||||
empty.setName("");
|
||||
List<Workgroup> list = new ArrayList<Workgroup>();
|
||||
list.add(empty);
|
||||
list.addAll(this.workgroupService.getWorkgroups());
|
||||
return list;
|
||||
return this.workgroupService.getWorkgroups();
|
||||
}
|
||||
|
||||
public List<Workgroup> getCenters()
|
||||
@@ -69,4 +86,28 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
{
|
||||
return this.userService.getAll();
|
||||
}
|
||||
|
||||
@Command
|
||||
// @NotifyChange({ "selectedItems" })
|
||||
public void onCreateOrder()
|
||||
{
|
||||
if (this.selectedItems == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectedItems.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Order order = orderService.createOrder(this.selectedItems);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("selected", order);
|
||||
params.put("service", orderService);
|
||||
|
||||
Window orderForm = (Window) Executions.createComponents("/main/orders/created/orderForm.zul", null, params);
|
||||
orderForm.doModal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package info.bukova.isspst.ui.main.orders.created;
|
||||
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.AddressEmb;
|
||||
import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.OrderItem;
|
||||
import info.bukova.isspst.services.addressbook.AdbService;
|
||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
import info.bukova.isspst.ui.FormViewModel;
|
||||
import info.bukova.isspst.validators.OrderFormValidator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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 OrderForm extends FormViewModel<Order>
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private final static Logger log = LoggerFactory.getLogger(OrderForm.class.getName());
|
||||
|
||||
@WireVariable
|
||||
protected AdbService adbService;
|
||||
|
||||
@WireVariable
|
||||
protected GlobalSettingsService settingsService;
|
||||
|
||||
protected OrderFormValidator orderFormValidator;
|
||||
|
||||
protected OrderItem selectedItem;
|
||||
|
||||
protected Address selectedSuppAddrItem;
|
||||
|
||||
protected Address selectedDeliveryAddrItem;
|
||||
|
||||
@Init(superclass = true)
|
||||
public void initOrderForm()
|
||||
{
|
||||
this.orderFormValidator = new OrderFormValidator();
|
||||
this.selectedDeliveryAddrItem = this.getDataBean().getDeliveryAddress().getAddress();
|
||||
|
||||
if (this.getDataBean().getSuplier() == null)
|
||||
{
|
||||
this.getDataBean().setSuplier(new AddressEmb());
|
||||
}
|
||||
|
||||
if (this.getDataBean().getDeliveryAddress() == null)
|
||||
{
|
||||
this.getDataBean().setDeliveryAddress(new AddressEmb());
|
||||
}
|
||||
|
||||
if (this.getDataBean().getAddress() == null)
|
||||
{
|
||||
this.getDataBean().setAddress(new AddressEmb());
|
||||
}
|
||||
}
|
||||
|
||||
public OrderFormValidator getOrderFormValidator()
|
||||
{
|
||||
return orderFormValidator;
|
||||
}
|
||||
|
||||
public void setOrderFormValidator(OrderFormValidator orderFormValidator)
|
||||
{
|
||||
this.orderFormValidator = orderFormValidator;
|
||||
}
|
||||
|
||||
public List<Address> getSuppAddresses()
|
||||
{
|
||||
return adbService.getAll();
|
||||
}
|
||||
|
||||
public List<Address> getDeliveryAddresses()
|
||||
{
|
||||
return settingsService.getSettings().getAllShippingAddrs();
|
||||
}
|
||||
|
||||
public Address getInvoiceAddress()
|
||||
{
|
||||
return settingsService.getSettings().getMainAddress();
|
||||
}
|
||||
|
||||
public OrderItem getSelectedItem()
|
||||
{
|
||||
return this.selectedItem;
|
||||
}
|
||||
|
||||
public void setSelectedItem(OrderItem selectedItem)
|
||||
{
|
||||
this.selectedItem = selectedItem;
|
||||
}
|
||||
|
||||
public Address getSelectedSuppAddrItem()
|
||||
{
|
||||
return selectedSuppAddrItem;
|
||||
}
|
||||
|
||||
public void setSelectedSuppAddrItem(Address selectedSuppAddrItem)
|
||||
{
|
||||
this.selectedSuppAddrItem = selectedSuppAddrItem;
|
||||
}
|
||||
|
||||
public Address getSelectedDeliveryAddrItem()
|
||||
{
|
||||
return selectedDeliveryAddrItem;
|
||||
}
|
||||
|
||||
public void setSelectedDeliveryAddrItem(Address selectedDeliveryAddrItem)
|
||||
{
|
||||
this.selectedDeliveryAddrItem = selectedDeliveryAddrItem;
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange("dataBean")
|
||||
public void doFillSuppAddress()
|
||||
{
|
||||
if (this.selectedSuppAddrItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Naplnit pole podle vybrané adresy z comba
|
||||
AddressEmb supplier = new AddressEmb(this.selectedSuppAddrItem);
|
||||
this.getDataBean().setSuplier(supplier);
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange("dataBean")
|
||||
public void doFillDeliveryAddress()
|
||||
{
|
||||
if (this.selectedDeliveryAddrItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Naplnit pole podle vybrané adresy z comba
|
||||
AddressEmb delivery = new AddressEmb(this.selectedDeliveryAddrItem);
|
||||
this.getDataBean().setDeliveryAddress(delivery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package info.bukova.isspst.validators;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.zkoss.bind.ValidationContext;
|
||||
|
||||
public class OrderFormValidator extends BaseValidator
|
||||
{
|
||||
private final static Logger log = LoggerFactory.getLogger(OrderFormValidator.class.getName());
|
||||
|
||||
@Override
|
||||
protected Logger getLogger()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ValidationContext ctx)
|
||||
{
|
||||
// Property propertyCentre = ctx.getProperties("centre")[0];
|
||||
// Workgroup workgroup = (Workgroup) propertyCentre.getValue();
|
||||
//
|
||||
// if (workgroup == null)
|
||||
// {
|
||||
// this.errorMsg(ctx, StringUtils.localize("RequirementCenterIsEmpty"),
|
||||
// "idReqCenter");
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user