BrightSide Workbench Full Report + Source Code
PendingTasksGrid.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.task;
20 
21 import org.turro.erp.entity.HumanResource;
22 import org.turro.zkoss.grid.PagingGrid;
23 import org.zkoss.zk.ui.ext.AfterCompose;
24 import org.zkoss.zul.Column;
25 import org.zkoss.zul.Include;
26 import org.zkoss.zul.Row;
27 
32 public class PendingTasksGrid extends PagingGrid implements AfterCompose {
33 
34  private PendingTaskSet tasks;
35  private HumanResource humanResource;
36 
38  return humanResource;
39  }
40 
41  public void setHumanResource(HumanResource humanResource) {
42  this.humanResource = humanResource;
43  if(humanResource != null) {
44  setTasks(new PendingTaskSet(humanResource));
45  }
46  }
47 
48  public void setTasks(PendingTaskSet tasks) {
49  this.tasks = tasks;
50  refresh();
51  }
52 
53  public void printWorksheet() {
54  WorksheetReport wsr = new WorksheetReport();
55  wsr.setOperator(humanResource);
56  wsr.setSendToParticipants(false);
57  wsr.setWorkloads(tasks);
58  wsr.print();
59  }
60 
61  public void sendWorksheet() {
62  WorksheetReport wsr = new WorksheetReport();
63  wsr.setOperator(humanResource);
64  wsr.setSendToParticipants(true);
65  wsr.setWorkloads(tasks);
66  wsr.print();
67  }
68 
69  @Override
70  public void afterCompose() {
71  addColumns();
72  }
73 
74  public void refresh() {
75  getRows(true).getChildren().clear();
76  addRows();
77  }
78 
79  private void addRows() {
80  for(Workload workload : tasks) {
81  Row r = new Row();
82  if(workload.getOrderItem().isEmpty()) {
83  r.setSclass("invalid");
84  }
85  getRows(true).appendChild(r);
86  Include inc = new Include("/WEB-INF/_zul/erp/task/pendingTask.zul");
87  inc.setDynamicProperty("orderItem", workload.getOrderItem());
88  inc.setDynamicProperty("workload", workload);
89  inc.setWidth("100%");
90  inc.setHeight("100%");
91  r.appendChild(inc);
92  }
93  }
94 
95  private void addColumns() {
96  getColumns(true).appendChild(new Column());
97  getColumns().setVisible(false);
98  }
99 
100 }
void setTasks(PendingTaskSet tasks)
void setHumanResource(HumanResource humanResource)
void setOperator(HumanResource operator)
void setWorkloads(WorkloadSet workloads)
void setSendToParticipants(boolean sendToParticipants)
Columns getColumns(boolean create)
Rows getRows(boolean create)