parent
81ff039da8
commit
4f9db2bd51
@ -0,0 +1,41 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.AddressEmb;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AddressUtils
|
||||
{
|
||||
public static AddressEmb convertAddressToAddressEmb(Address input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
AddressEmb output = new AddressEmb(input);
|
||||
return output;
|
||||
}
|
||||
|
||||
public static List<AddressEmb> convertListAddressToListAddressEmb(List<Address> inputList)
|
||||
{
|
||||
if (inputList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<AddressEmb> outputList = new ArrayList<AddressEmb>();
|
||||
|
||||
for (int i = 0; i < inputList.size(); i++)
|
||||
{
|
||||
Address inputItem = inputList.get(i);
|
||||
AddressEmb outputItem = new AddressEmb(inputItem);
|
||||
outputList.add(outputItem);
|
||||
}
|
||||
|
||||
return outputList;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.BigDecimalUtils;
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.AddressEmb;
|
||||
import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.User;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class OrderFilter implements Filter<Order>
|
||||
{
|
||||
private Order condition;
|
||||
|
||||
public OrderFilter(Order cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
// this.condition.setSuplier(new AddressEmb());
|
||||
// this.condition.setDeliveryAddress(new AddressEmb());
|
||||
// this.condition.setAddress(new AddressEmb());
|
||||
// this.condition.setOwnedBy(new User());
|
||||
}
|
||||
|
||||
private static class OrderMatcher extends TypeSafeMatcher<Order>
|
||||
{
|
||||
private Order condition;
|
||||
|
||||
public OrderMatcher(Order cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("Order matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Order item)
|
||||
{
|
||||
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||
boolean foundOrderDate = DateTimeUtils.isEqualByDateForFilter(item.getOrderDate(), condition.getOrderDate());
|
||||
boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal());
|
||||
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
||||
boolean foundDeliveredDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveredDate(), condition.getDeliveredDate());
|
||||
boolean foundInvoiceNumber = StringUtils.isEqualForFilter(item.getInvoiceNumber(), condition.getInvoiceNumber());
|
||||
boolean foundSupplierAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getSuplier(), condition.getSuplier());
|
||||
boolean foundDeliveryAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getDeliveryAddress(), condition.getDeliveryAddress());
|
||||
boolean foundInvoiceAddr = AddressEmb.isEqualByAddressEmbForFilter(item.getAddress(), condition.getAddress());
|
||||
boolean foundOwnedBy = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
return (foundNumSer
|
||||
&& foundOrderDate
|
||||
&& foundTotal
|
||||
&& foundDeliveryDate
|
||||
&& foundDeliveredDate
|
||||
&& foundInvoiceNumber
|
||||
&& foundSupplierAddr
|
||||
&& foundDeliveryAddr
|
||||
&& foundInvoiceAddr
|
||||
&& foundOwnedBy && foundDescription);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<Order> matchBuilding(Order item)
|
||||
{
|
||||
return new OrderMatcher(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderMatcher matcher()
|
||||
{
|
||||
return new OrderMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package info.bukova.isspst.ui.main.orders.created;
|
||||
|
||||
import info.bukova.isspst.AddressUtils;
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.AddressEmb;
|
||||
import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.SettingsData;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.filters.OrderFilter;
|
||||
import info.bukova.isspst.services.addressbook.AdbService;
|
||||
import info.bukova.isspst.services.approved.OrderService;
|
||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
import info.bukova.isspst.ui.ListViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
|
||||
public class OrderList extends ListViewModel<Order>
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private final static Logger log = LoggerFactory.getLogger(OrderList.class.getName());
|
||||
|
||||
@WireVariable
|
||||
protected OrderService orderService;
|
||||
|
||||
@WireVariable
|
||||
protected AdbService adbService;
|
||||
|
||||
@WireVariable
|
||||
protected GlobalSettingsService settingsService;
|
||||
|
||||
@WireVariable
|
||||
protected UserService userService;
|
||||
|
||||
@Init(superclass = true)
|
||||
public void initOrderList()
|
||||
{
|
||||
service = orderService;
|
||||
dataClass = Order.class;
|
||||
formZul = "orderForm.zul";
|
||||
dataFilter = new OrderFilter(getFilterTemplate());
|
||||
}
|
||||
|
||||
public List<AddressEmb> getSuppAddresses()
|
||||
{
|
||||
List<Address> list = adbService.getAll();
|
||||
List<AddressEmb> listEmb = AddressUtils.convertListAddressToListAddressEmb(list);
|
||||
return listEmb;
|
||||
}
|
||||
|
||||
public List<AddressEmb> getDeliveryAddresses()
|
||||
{
|
||||
SettingsData data = settingsService.getSettings();
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Address> list = data.getAllShippingAddrs();
|
||||
List<AddressEmb> listEmb = AddressUtils.convertListAddressToListAddressEmb(list);
|
||||
return listEmb;
|
||||
}
|
||||
|
||||
public AddressEmb getInvoiceAddress()
|
||||
{
|
||||
SettingsData data = settingsService.getSettings();
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Address addr = data.getMainAddress();
|
||||
AddressEmb addrEmb = AddressUtils.convertAddressToAddressEmb(addr);
|
||||
return addrEmb;
|
||||
}
|
||||
|
||||
public List<User> getUsers()
|
||||
{
|
||||
return userService.getAll();
|
||||
}
|
||||
}
|
@ -0,0 +1,252 @@
|
||||
<?page title="${labels.CreatedOrders}" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<window
|
||||
vflex="1"
|
||||
border="normal"
|
||||
apply="org.zkoss.bind.BindComposer"
|
||||
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.created.OrderList')">
|
||||
<caption
|
||||
image="/img/autotruck-032.png"
|
||||
zclass="form-caption"
|
||||
label="${labels.CreatedOrders}" />
|
||||
<include src="/app/toolbar.zul" />
|
||||
<listbox
|
||||
vflex="1"
|
||||
selectedItem="@bind(vm.dataBean)"
|
||||
model="@load(vm.dataList)">
|
||||
<listhead menupopup="auto">
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="czech(numser)"
|
||||
label="${labels.OrderFormNumber}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="auto(orderDate)"
|
||||
label="${labels.OrderFormOrderDate}" />
|
||||
<listheader
|
||||
hflex="7"
|
||||
align="right"
|
||||
sort="auto(total)"
|
||||
label="${labels.OrderFormTotal}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="auto(deliveryDate)"
|
||||
label="${labels.RequirementsFormDeliveryDate}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="auto(deliveredDate))"
|
||||
label="${labels.OrderFormDeliveredDate}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="auto(invoiceNumber)"
|
||||
label="${labels.OrderFormInvoiceNumber}" />
|
||||
<listheader
|
||||
hflex="15"
|
||||
sort="auto(suplier.company)"
|
||||
label="${labels.SuppliersFormTitle}" />
|
||||
<listheader
|
||||
hflex="15"
|
||||
sort="auto(deliveryAddress.company)"
|
||||
label="${labels.DeliveryAddress}" />
|
||||
<listheader
|
||||
hflex="15"
|
||||
sort="auto(address.company)"
|
||||
visible="false"
|
||||
label="${labels.BillingAddress}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="auto(ownedBy.fullName)"
|
||||
label="${labels.Owner}" />
|
||||
<listheader
|
||||
hflex="10"
|
||||
sort="czech(description)"
|
||||
label="${labels.OrderFormDescription}" />
|
||||
</listhead>
|
||||
<auxhead visible="@load(vm.filter)">
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.numser)"
|
||||
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">
|
||||
<datebox
|
||||
value="@bind(vm.filterTemplate.orderDate)"
|
||||
format="${labels.DateFormat}"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox"
|
||||
width="100%" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<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"
|
||||
width="100%" />
|
||||
</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">
|
||||
<datebox
|
||||
value="@bind(vm.filterTemplate.deliveredDate)"
|
||||
format="${labels.DateFormat}"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox"
|
||||
width="100%" />
|
||||
</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.invoiceNumber)"
|
||||
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 zclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<combobox
|
||||
ctrlKeys="${labels.HandleComboKeyFilter}"
|
||||
onCtrlKey="@command('handleComboKeyFilter', ctrl=self, keyEvent=event)"
|
||||
onChange="@command('doFilter')"
|
||||
width="100%"
|
||||
selectedItem="@bind(vm.filterTemplate.suplier)"
|
||||
model="@load(vm.suppAddresses)">
|
||||
<template name="model">
|
||||
<comboitem label="@load(each)" />
|
||||
</template>
|
||||
</combobox>
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div zclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<combobox
|
||||
ctrlKeys="${labels.HandleComboKeyFilter}"
|
||||
onCtrlKey="@command('handleComboKeyFilter', ctrl=self, keyEvent=event)"
|
||||
onChange="@command('doFilter')"
|
||||
width="100%"
|
||||
selectedItem="@bind(vm.filterTemplate.deliveryAddress)"
|
||||
model="@load(vm.deliveryAddresses)"
|
||||
readonly="true">
|
||||
<template name="model">
|
||||
<comboitem label="@load(each)" />
|
||||
</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.filterTemplate.address)"
|
||||
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 zclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<combobox
|
||||
ctrlKeys="${labels.HandleComboKeyFilter}"
|
||||
onCtrlKey="@command('handleComboKeyFilter', ctrl=self, keyEvent=event)"
|
||||
onChange="@command('doFilter')"
|
||||
width="100%"
|
||||
selectedItem="@bind(vm.filterTemplate.ownedBy)"
|
||||
model="@load(vm.users)"
|
||||
readonly="true">
|
||||
<template name="model">
|
||||
<comboitem label="@load(each.fullName)" />
|
||||
</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.filterTemplate.description)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
</auxhead>
|
||||
<template name="model">
|
||||
<listitem>
|
||||
<listcell label="@load(each.numser)" />
|
||||
<listcell label="@load(each.orderDate) @converter('formatedDate', format=labels.DateFormat)" />
|
||||
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
|
||||
<listcell label="@load(each.deliveryDate) @converter('formatedDate', format=labels.DateFormat)" />
|
||||
<listcell label="@load(each.deliveredDate) @converter('formatedDate', format=labels.DateFormat)" />
|
||||
<listcell label="@load(each.invoiceNumber)" />
|
||||
<listcell label="@load(each.suplier)" />
|
||||
<listcell label="@load(each.deliveryAddress)" />
|
||||
<listcell label="@load(each.address)" />
|
||||
<listcell label="@load(each.ownedBy.fullName)" />
|
||||
<listcell label="@load(each.description)" />
|
||||
</listitem>
|
||||
</template>
|
||||
</listbox>
|
||||
</window>
|
||||
</zk>
|
@ -0,0 +1,10 @@
|
||||
<?page title="${labels.CreatedOrders}" contentType="text/html;charset=UTF-8"?>
|
||||
<zk>
|
||||
|
||||
<zscript>
|
||||
String gridZul = "grid.zul";
|
||||
</zscript>
|
||||
|
||||
<include src="/app/template.zhtml"/>
|
||||
|
||||
</zk>
|
Loading…
Reference in New Issue