19 package org.turro.erp.task.usage;
21 import org.turro.command.Command;
22 import org.turro.command.CommandUtil;
23 import org.turro.command.Context;
24 import org.turro.elephant.context.Application;
25 import org.turro.elephant.util.DateFormats;
26 import org.turro.elephant.util.DecimalFormats;
27 import org.turro.elephant.util.ZkossUtils;
28 import org.turro.elephant.zkoss.Modal;
29 import org.turro.erp.db.ErpPU;
30 import org.turro.erp.entity.OrderItem;
31 import org.turro.erp.entity.ReceiptItem;
32 import org.turro.zkoss.label.PercentLabel;
33 import org.turro.zkoss.layout.GridLayout;
34 import org.zkoss.zk.ui.Executions;
35 import org.zkoss.zk.ui.event.Event;
36 import org.zkoss.zk.ui.event.EventListener;
37 import org.zkoss.zk.ui.event.Events;
38 import org.zkoss.zul.*;
50 this.orderItem = orderItem;
51 setSclass(
"orderBox");
57 private void addComponents() {
58 if(getCaption() !=
null) {
61 getCaption().setImage(
"/_zul/images/order.png");
62 gl.
getRows().getChildren().clear();
66 "/_zul/images/order.png"));
67 gl =
new GridLayout(
"min,right-1,right-1");
78 private void renderOrder() {
84 gl.
addCaption(Application.getString(
"lUnits"));
89 gl.
addCaption(Application.getString(
"lDedication"));
98 Hlayout hbox =
new Hlayout();
99 hbox.setStyle(
"text-align:right");
100 Button edit =
new Button(Application.getString(
"lEdit"));
101 hbox.appendChild(edit);
102 edit.addEventListener(Events.ON_CLICK,
new EventListener() {
104 public void onEvent(Event event)
throws Exception {
105 doEdit(orderItem,
new Command() {
107 public Object execute(Context context) {
109 orderItem =
new ErpPU().saveObject(orderItem);
111 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
OrderBox.this, UsageTree.class)));
118 Button
delete =
new Button(Application.getString(
"lDelete"));
119 hbox.appendChild(
delete);
120 delete.addEventListener(Events.ON_CLICK,
new EventListener() {
122 public void onEvent(Event event)
throws Exception {
123 ZkossUtils.confirmDeletion(
null,
new Command() {
125 public Object execute(Context context) {
126 new ErpPU().deleteObject(orderItem);
127 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
OrderBox.this, UsageTree.class)));
134 if(orderItem.
getId() > 0) {
135 Button order =
new Button(Application.getString(
"lNewReceipt"));
136 hbox.appendChild(order);
137 order.addEventListener(Events.ON_CLICK,
new EventListener() {
139 public void onEvent(Event event)
throws Exception {
142 new ErpPU().saveObject(ri);
144 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
OrderBox.this, UsageTree.class)));
152 Window w = (Window) Executions.createComponents(
"/WEB-INF/_zul/erp/purchase/editOrder.zul",
null,
null);
153 w.setMode(Window.MODAL);
154 Events.sendEvent(Events.ON_USER, w, oi);
static String getString(String key)
static int doModal(String file)
HumanResource getHumanResource()
ReceiptItem startReceipt(Date startWorking)
double getRealDedication()
Set< ReceiptItem > getReceiptItems()
String getDocumentNumber()
double getExpectedUnits()
OrderBox(OrderItem orderItem)
static void doEdit(OrderItem oi, Command command)
void setColCaptions(String captions)
GridLayout addComponent(HtmlBasedComponent comp)
Rows getRows(boolean create)
GridLayout addSpannedComponent(HtmlBasedComponent comp, int cols)
GridLayout addCaption(String label)