BrightSide Workbench Full Report + Source Code
ReceiptEdit.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.erp.purchase;
19 
20 import org.turro.elephant.context.Application;
21 import org.turro.erp.entity.ReceiptItem;
22 import org.turro.zkoss.input.ExpressionInput;
23 import org.turro.zkoss.input.Percentbox;
24 import org.zkoss.zk.ui.event.Event;
25 import org.zkoss.zk.ui.util.GenericForwardComposer;
26 import org.zkoss.zul.*;
27 
32 public class ReceiptEdit extends GenericForwardComposer {
33 
34  private ReceiptItem receiptItem;
35  private Window riForm;
36  private Textbox description, docnumber;
37  private Datebox start, docdate;
38  private Timebox time;
39  private ExpressionInput units, cost, tax;
40  private Percentbox dedication;
41  private Label reslabel, resvalue;
42  private Row dedicrow, startworkrow, costrow;
43 
44  public void onUser(Event event) {
45  receiptItem = (ReceiptItem) event.getData();
46  description.setValue(receiptItem.getDescription());
47  start.setValue(receiptItem.getStartWorking());
48  time.setValue(receiptItem.getStartWorking());
49  cost.setValue(receiptItem.getCost());
50  tax.setValue(receiptItem.getTax());
51  units.setValue(receiptItem.getUnits());
52  dedication.setValue(receiptItem.getDedication());
53  costrow.setVisible(true);
54  if(receiptItem.getHumanResource() != null) {
55  reslabel.setValue(Application.getString("lHumanResource"));
56  resvalue.setValue(receiptItem.getHumanResource().getName());
57  startworkrow.setVisible(true);
58  dedicrow.setVisible(true);
59  if(!receiptItem.getHumanResource().isInternal()) {
60  costrow.setVisible(true);
61  }
62  } else if(receiptItem.getResource() != null) {
63  reslabel.setValue(Application.getString("lResource"));
64  resvalue.setValue(receiptItem.getResource().getName());
65  startworkrow.setVisible(true);
66  dedicrow.setVisible(false);
67  if(!receiptItem.getResource().isInternal()) {
68  costrow.setVisible(true);
69  }
70  } else {
71  reslabel.setValue(Application.getString("lProduct"));
72  resvalue.setValue(receiptItem.getIProduct().getProductName());
73  startworkrow.setVisible(false);
74  dedicrow.setVisible(false);
75  costrow.setVisible(true);
76  }
77  }
78 
79  public void onOK() {
80  onSave();
81  }
82 
83  public void onSave() {
84  receiptItem.setDocumentNumber(docnumber.getValue());
85  receiptItem.setDocumentDate(docdate.getValue());
86  receiptItem.setDescription(description.getValue());
87  receiptItem.setStartWorking(time.getValue());
88  receiptItem.setCost(((Number) cost.getNumber()).doubleValue());
89  receiptItem.setTax(((Number) tax.getNumber()).doubleValue());
90  receiptItem.setUnits(((Number) units.getNumber()).doubleValue());
91  if(receiptItem.getHumanResource() != null) {
92  receiptItem.setDedication(dedication.getValue());
93  } else {
94  receiptItem.setDedication(1.0d);
95  }
96  riForm.detach();
97  }
98 
99  public void onCancel() {
100  riForm.detach();
101  }
102 
103  public void onChange$start() {
104  time.setValue(start.getValue());
105  }
106 
107  public void onChange$time() {
108  start.setValue(time.getValue());
109  }
110 
111 }
static String getString(String key)
void setDedication(double dedication)
void setDescription(String description)
void setDocumentNumber(String documentNumber)
void setStartWorking(Date startWorking)
void setDocumentDate(Date documentDate)