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.ReceiptItem;
31 import org.turro.zkoss.label.PercentLabel;
32 import org.turro.zkoss.layout.GridLayout;
33 import org.zkoss.zk.ui.Executions;
34 import org.zkoss.zk.ui.event.Event;
35 import org.zkoss.zk.ui.event.EventListener;
36 import org.zkoss.zk.ui.event.Events;
37 import org.zkoss.zul.*;
49 this.receiptItem = receiptItem;
50 setSclass(
"receiptBox");
56 private void addComponents() {
57 if(getCaption() !=
null) {
60 getCaption().setImage(
"/_zul/images/receipt.png");
61 gl.
getRows().getChildren().clear();
65 "/_zul/images/receipt.png"));
66 gl =
new GridLayout(
"min,right-1");
72 private void renderReceipt() {
78 gl.
addCaption(Application.getString(
"lUnits"));
82 gl.
addCaption(Application.getString(
"lDedication"));
89 Hlayout hbox =
new Hlayout();
90 hbox.setStyle(
"text-align:right");
91 Button edit =
new Button(Application.getString(
"lEdit"));
92 hbox.appendChild(edit);
93 edit.addEventListener(Events.ON_CLICK,
new EventListener() {
95 public void onEvent(Event event)
throws Exception {
96 doEdit(receiptItem,
new Command() {
98 public Object execute(Context context) {
100 receiptItem =
new ErpPU().saveObject(receiptItem);
102 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
ReceiptBox.this, UsageTree.class)));
108 Button
delete =
new Button(Application.getString(
"lDelete"));
109 hbox.appendChild(
delete);
110 delete.addEventListener(Events.ON_CLICK,
new EventListener() {
112 public void onEvent(Event event)
throws Exception {
113 ZkossUtils.confirmDeletion(
null,
new Command() {
115 public Object execute(Context context) {
116 new ErpPU().deleteObject(receiptItem);
117 Events.postEvent(
new Event(Events.ON_CHANGE, ZkossUtils.getParent(
ReceiptBox.this, UsageTree.class)));
127 Window w = (Window) Executions.createComponents(
"/WEB-INF/_zul/erp/purchase/editReceipt.zul",
null,
null);
128 w.setMode(Window.MODAL);
129 Events.sendEvent(Events.ON_USER, w, ri);
static int doModal(String file)
String getDocumentNumber()
HumanResource getHumanResource()
static void doEdit(ReceiptItem ri, Command command)
ReceiptBox(ReceiptItem receiptItem)
GridLayout addComponent(HtmlBasedComponent comp)
Rows getRows(boolean create)
GridLayout addSpannedComponent(HtmlBasedComponent comp, int cols)
GridLayout addCaption(String label)