Na formulář objednávky k adrese dodavatele bylo přidáno tlačítko "Hledat

v ARESu". Tlačítko je aktivní, pokud není vybraná adresa z comba.
closes #171
Verze_1.0
Josef Rokos 10 years ago
parent a9a98cfd63
commit 9088a88b9a

@ -44,7 +44,15 @@ public class BindingForm<T> extends SimpleForm {
// } // }
try try
{ {
PropertyUtils.setProperty(object, key, getField(key)); if (PropertyUtils.getPropertyType(object, key).isPrimitive()
&& (getField(key) == null))
{
PropertyUtils.setProperty(object, key, 0);
}
else
{
PropertyUtils.setProperty(object, key, getField(key));
}
} }
catch (NoSuchMethodException e) catch (NoSuchMethodException e)
{ {

@ -4,14 +4,18 @@ import info.bukova.isspst.data.Address;
import info.bukova.isspst.data.AddressEmb; import info.bukova.isspst.data.AddressEmb;
import info.bukova.isspst.data.Order; import info.bukova.isspst.data.Order;
import info.bukova.isspst.data.OrderItem; import info.bukova.isspst.data.OrderItem;
import info.bukova.isspst.services.IsspstException;
import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.addressbook.AdbService;
import info.bukova.isspst.services.addressbook.AddressFinder;
import info.bukova.isspst.services.orders.OrderService; import info.bukova.isspst.services.orders.OrderService;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.ui.FormViewModel; import info.bukova.isspst.ui.FormViewModel;
import info.bukova.isspst.validators.OrderFormValidator; import info.bukova.isspst.validators.OrderFormValidator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -19,9 +23,13 @@ import org.zkoss.bind.BindUtils;
import org.zkoss.bind.SimpleForm; 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.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;
import org.zkoss.zul.impl.InputElement; import org.zkoss.zul.impl.InputElement;
public class OrderForm extends FormViewModel<Order> public class OrderForm extends FormViewModel<Order>
@ -29,7 +37,11 @@ public class OrderForm extends FormViewModel<Order>
private final static Logger log = LoggerFactory.getLogger(OrderForm.class.getName()); private final static Logger log = LoggerFactory.getLogger(OrderForm.class.getName());
@WireVariable @WireVariable
protected AdbService adbService; private AdbService adbService;
@WireVariable
private AddressFinder addressFinderAres;
@WireVariable
private AddressFinder addressFinderTaxID;
@WireVariable @WireVariable
protected GlobalSettingsService settingsService; protected GlobalSettingsService settingsService;
@ -61,14 +73,19 @@ public class OrderForm extends FormViewModel<Order>
{ {
this.orderFormValidator = new OrderFormValidator(); this.orderFormValidator = new OrderFormValidator();
if (this.getDataBean().getSuplier() == null) if (getDataBean().getSuplier() != null)
{
if (getDataBean().getSuplier().getAddress().getId() != 0)
{
this.selectedSuppAddrItem = this.getDataBean().getSuplier().getAddress();
}
this.suppCompany = getDataBean().getSuplier().getCompany();
}
else
{ {
this.getDataBean().setSuplier(new AddressEmb()); this.getDataBean().setSuplier(new AddressEmb());
} }
this.selectedSuppAddrItem = this.getDataBean().getSuplier().getAddress();
this.suppCompany = this.selectedSuppAddrItem.getCompany();
if (this.getDataBean().getDeliveryAddress() == null) if (this.getDataBean().getDeliveryAddress() == null)
{ {
this.getDataBean().setDeliveryAddress(new AddressEmb()); this.getDataBean().setDeliveryAddress(new AddressEmb());
@ -289,4 +306,60 @@ public class OrderForm extends FormViewModel<Order>
// jiných objednávek // jiných objednávek
orderService.updateApprovedItems(this.getDataBean(), orderedChanged); orderService.updateApprovedItems(this.getDataBean(), orderedChanged);
} }
@Command
@NotifyChange({"dataBean", "suppCompany"})
public void searchAddress()
{
getDataForm().bind();
Address adr = getDataBean().getSuplier().getAddress();
if (adr.getIc() != 0)
{
try
{
adbService.fillFoundData(addressFinderTaxID, adr);
getDataBean().setSuplier(new AddressEmb(adr));
suppCompany = adr.getCompany();
}
catch (IsspstException e)
{
Messagebox.show("Chyba při hledání adresy", "Chyba", Messagebox.OK, Messagebox.ERROR);
return;
}
}
else
{
Map<String, List<Address>> arg = new HashMap<String, List<Address>>();
try {
arg.put("result", adbService.lookForAddr(addressFinderAres, adr));
} catch (IsspstException e) {
Messagebox.show("Chyba při hledání adresy", "Chyba", Messagebox.OK, Messagebox.ERROR);
return;
}
Window resWin = (Window) Executions.createComponents("/lists/addressbook/addrFindResult.zul", null, arg);
resWin.doModal();
}
}
@GlobalCommand
@NotifyChange({"dataBean", "suppCompany"})
public void selectAddress(@BindingParam("selected") Address selected, @BindingParam("window") Window window) {
try {
adbService.fillFoundData(addressFinderTaxID, selected);
} catch (IsspstException e) {
e.printStackTrace();
}
Address adr = getDataBean().getSuplier().getAddress();
adbService.mergeAddress(adr, selected, true);
getDataBean().setSuplier(new AddressEmb(adr));
suppCompany = adr.getCompany();
if (window != null)
window.detach();
}
} }

@ -172,6 +172,7 @@ GlobalSettingsHours=Hodin
GlobalSettingsUploadStamp=Nahrát obrázek razítka GlobalSettingsUploadStamp=Nahrát obrázek razítka
GlobalSettingsStamp=Razítko GlobalSettingsStamp=Razítko
GlobalSettingsReqEnable=Povolení požadavků GlobalSettingsReqEnable=Povolení požadavků
GlobalSettingsInsertUrl=Vložit URL záznamu
UserSettings=Uživatelské nastavení UserSettings=Uživatelské nastavení

@ -146,19 +146,29 @@
<row> <row>
<cell sclass="row-title">${labels.SuppliersFormCompany} :</cell> <cell sclass="row-title">${labels.SuppliersFormCompany} :</cell>
<cell colspan="3"> <cell colspan="3">
<combobox <hbox hflex="1">
ctrlKeys="${labels.HandleComboKey}" <combobox
onCtrlKey="@command('handleComboKey', ctrl=self, keyEvent=event)" ctrlKeys="${labels.HandleComboKey}"
onChange="@command('doFillSuppAddress')" onCtrlKey="@command('handleComboKey', ctrl=self, keyEvent=event)"
width="100%" onChange="@command('doFillSuppAddress')"
selectedItem="@bind(vm.selectedSuppAddrItem)" hflex="4"
value="@bind(vm.suppCompany)" selectedItem="@bind(vm.selectedSuppAddrItem)"
model="@load(vm.suppAddresses)" value="@bind(vm.suppCompany)"
readonly="false"> model="@load(vm.suppAddresses)"
<template name="model"> instant="true"
<comboitem label="@load(each)" /> readonly="false">
</template> <template name="model">
</combobox> <comboitem label="@load(each)" />
</template>
</combobox>
<hbox hflex="2">
<button image="/img/search.png"
label="${labels.SuppliersFormFindInARES}"
sclass="nicebutton"
disabled="@load((not empty vm.selectedSuppAddrItem) or ((empty vm.suppCompany) and (fx.suplier.ic eq 0)))"
onClick="@command('searchAddress')"/>
</hbox>
</hbox>
</cell> </cell>
</row> </row>
<row> <row>
@ -166,7 +176,8 @@
<cell> <cell>
<textbox <textbox
id="idSuppIC" id="idSuppIC"
value="@bind(fx.suplier.ic)" /> value="@bind(fx.suplier.ic)"
instant="true" />
</cell> </cell>
<cell sclass="row-title">${labels.SuppliersFormDIC} :</cell> <cell sclass="row-title">${labels.SuppliersFormDIC} :</cell>
<cell> <cell>

Loading…
Cancel
Save