19 package org.turro.erp.reference;
21 import java.util.Iterator;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.elephant.context.Application;
25 import org.turro.elephant.util.DecimalFormats;
26 import org.turro.elephant.util.Images;
27 import org.turro.elephant.util.ZkossUtils;
28 import org.turro.erp.entity.Breakdown;
29 import org.turro.erp.entity.Budget;
30 import org.turro.erp.entity.OrderReference;
31 import org.turro.erp.entity.WorkOrder;
32 import org.turro.erp.workorder.BreakdownSet;
33 import org.turro.zkoss.grid.PagingGrid;
34 import org.turro.zkoss.layout.GridLayout;
35 import org.zkoss.lang.Strings;
36 import org.zkoss.zk.ui.Component;
37 import org.zkoss.zk.ui.event.Event;
38 import org.zkoss.zk.ui.event.EventListener;
39 import org.zkoss.zk.ui.event.Events;
40 import org.zkoss.zk.ui.ext.AfterCompose;
41 import org.zkoss.zul.*;
50 private Long number = 1L;
53 this.workOrder = workOrder;
57 Long select = (Long) selnumber;
60 }
else if(select == 0) {
66 or.getBudgets().add(b);
86 private void addRows() {
89 int fractionDigits = workOrder.
getContract() !=
null ?
95 rows.getChildren().clear();
99 for(
Budget b : or.getBudgets()) {
100 if(b.getBudgetNumber() != number)
continue;
103 row.setSclass(
"textCaption3");
104 rows.appendChild(row);
106 row.appendChild(
new Label(b.getBudgetNumber() +
""));
108 Vlayout vbox =
new Vlayout();
109 row.appendChild(vbox);
110 vbox.appendChild(
new Label(b.getDescription()));
111 if(!b.getBreakdowns().isEmpty()) {
113 gl.setSclass(gl.getSclass() +
" textSubCaption3");
114 vbox.appendChild(gl);
116 if(!Strings.isBlank(bd.getDescription())) {
118 if(bd.getQuantity() ==
null || bd.getQuantity() == 0.0d) {
121 gl.
addComponent(
new Label(DecimalFormats.format(bd.getQuantity(), DecimalFormats.getStringFormat(3))));
124 if(bd.getPrice() ==
null || bd.getPrice() == 0.0d) {
128 gl.
addComponent(
new Label(DecimalFormats.format(bd.getPrice(), DecimalFormats.getStringFormat(fractionDigits))));
129 gl.
addComponent(
new Label(DecimalFormats.format(bd.getAmount(), DecimalFormats.getStringFormat(fractionDigits))));
134 row.appendChild(
new Label(DecimalFormats.format(b.getPrice(), DecimalFormats.getStringFormat(fractionDigits))));
135 row.appendChild(getActions(b));
143 private void addColumns() {
146 cols.getChildren().clear();
148 Column col =
new Column(
"#",
null,
"60px");
149 cols.appendChild(col);
151 col =
new Column(Application.getString(
"lQuantity"),
null,
"90px");
152 col.setAlign(
"right");
153 cols.appendChild(col);
155 col =
new Column(Application.getString(
"lDescription"));
157 cols.appendChild(col);
159 col =
new Column(Application.getString(
"lPrice"),
null,
"120px");
160 col.setAlign(
"right");
161 cols.appendChild(col);
163 col =
new Column(
null,
null,
"400px");
164 cols.appendChild(col);
167 private void deleteBudget() {
168 ZkossUtils.confirmDeletion(Application.getString(
"lBudget") +
": " + number,
new Command() {
170 public Object execute(Context context) {
173 Iterator<Budget> itb = or.getBudgets().iterator();
174 while(itb.hasNext()) {
175 Budget b = itb.next();
176 if(b.getBudgetNumber() == number) {
178 b.setOrderReference(
null);
188 private Component getActions(
final Budget b) {
189 Hlayout hbox =
new Hlayout();
191 hbox.appendChild(
new Image(Images.getImage(
"ok")));
192 hbox.appendChild(
new Label(Application.getString(
"lAccepted")));
193 }
else if(b.isRefused()) {
194 hbox.appendChild(
new Image(Images.getImage(
"cancel")));
195 hbox.appendChild(
new Label(Application.getString(
"lRefused")));
196 }
else if(b.isDelivered()) {
197 hbox.appendChild(
new Label(Application.getString(
"lDelivered")));
198 hbox.appendChild(
new Image(Images.getImage(
"forward")));
199 Toolbarbutton accept =
new Toolbarbutton(Application.getString(
"lAccepted"), Images.getImage(
"ok"));
200 accept.addEventListener(Events.ON_CLICK,
new EventListener() {
202 public void onEvent(Event event)
throws Exception {
203 b.setDelivered(
true);
209 hbox.appendChild(accept);
210 Toolbarbutton refused =
new Toolbarbutton(Application.getString(
"lRefused"), Images.getImage(
"cancel"));
211 refused.addEventListener(Events.ON_CLICK,
new EventListener() {
213 public void onEvent(Event event)
throws Exception {
214 b.setDelivered(
true);
215 b.setAccepted(
false);
220 hbox.appendChild(refused);
222 hbox.appendChild(
new Label(Application.getString(
"lPending")));
223 hbox.appendChild(
new Image(Images.getImage(
"forward")));
224 Toolbarbutton delivered =
new Toolbarbutton(Application.getString(
"lDelivered"), Images.getImage(
"mail_send"));
225 delivered.addEventListener(Events.ON_CLICK,
new EventListener() {
227 public void onEvent(Event event)
throws Exception {
228 b.setDelivered(
true);
229 b.setAccepted(
false);
234 hbox.appendChild(delivered);
static Application getApplication()
void initFrom(OrderReference orderReference, long number)
long getNextBudgetNumber()
Set< OrderReference > getOrderReferences()
void setBudget(Object selnumber)
void setWorkOrder(WorkOrder workOrder)
Columns getColumns(boolean create)
Rows getRows(boolean create)
void setRowCount(int rows)
GridLayout addComponent(HtmlBasedComponent comp)