BrightSide Workbench Full Report + Source Code
OrderGroupEdit.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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 
19 package org.turro.erp.purchase;
20 
21 import java.util.Date;
22 import org.turro.erp.db.ErpPU;
23 import org.turro.erp.entity.OrderItem;
24 import org.turro.jpa.Dao;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.util.GenericForwardComposer;
27 import org.zkoss.zul.Checkbox;
28 import org.zkoss.zul.Datebox;
29 import org.zkoss.zul.Textbox;
30 import org.zkoss.zul.Window;
31 
36 public class OrderGroupEdit extends GenericForwardComposer {
37 
38  private OrderItemModel.OrderItemSummary orderItemSummary;
39  private Window draftcoGroupForm;
40  private Textbox docnumber;
41  private Datebox docdate;
42  private Checkbox sent;
43 
44  public void onUser(Event event) {
45  orderItemSummary = (OrderItemModel.OrderItemSummary) event.getData();
46  docdate.setValue(orderItemSummary.getOrder(0).getDocumentDate());
47  docnumber.setValue(orderItemSummary.getOrder(0).getDocumentNumber());
48  sent.setChecked(orderItemSummary.getOrder(0).isSent());
49  }
50 
51  public void onOK() {
52  onSave();
53  }
54 
55  public void onSave() {
56  Dao dao = new ErpPU();
57  for(Object o : orderItemSummary.orders) {
58  OrderItem oi = (OrderItem) o;
59  oi.setDocumentDate(docdate.getValue());
60  oi.setDocumentNumber(docnumber.getValue());
61  oi.setSent(sent.isChecked());
62  if(oi.isSent() && oi.getDocumentDate() == null) {
63  oi.setDocumentDate(new Date());
64  }
65  dao.saveObject(oi);
66  }
67  draftcoGroupForm.detach();
68  }
69 
70  public void onCancel() {
71  draftcoGroupForm.detach();
72  }
73 
74 }
void setDocumentDate(Date documentDate)
Definition: OrderItem.java:129
void setDocumentNumber(String documentNumber)
Definition: OrderItem.java:145
void setSent(boolean sent)
Definition: OrderItem.java:269