19 package org.turro.erp.time;
22 import java.io.FileNotFoundException;
23 import java.io.FileOutputStream;
24 import java.io.InputStream;
25 import java.util.Date;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import org.amic.util.date.CheckDate;
29 import org.apache.commons.io.input.ReaderInputStream;
30 import org.turro.elephant.context.Application;
31 import org.turro.elephant.context.ElephantContext;
32 import org.turro.elephant.impl.util.FileUtil;
33 import org.turro.elephant.util.ZkossUtils;
34 import org.zkoss.text.DateFormats;
35 import org.zkoss.util.media.Media;
36 import org.zkoss.zk.ui.Component;
37 import org.zkoss.zk.ui.event.Event;
38 import org.zkoss.zk.ui.select.SelectorComposer;
39 import org.zkoss.zk.ui.select.annotation.Listen;
40 import org.zkoss.zk.ui.select.annotation.Wire;
41 import org.zkoss.zul.Button;
42 import org.zkoss.zul.Filedownload;
43 import org.zkoss.zul.Fileupload;
44 import org.zkoss.zul.Hlayout;
45 import org.zkoss.zul.Image;
46 import org.zkoss.zul.Label;
47 import org.zkoss.zul.Tab;
48 import org.zkoss.zul.Vbox;
56 @Wire
private Image logo;
58 @Wire
private Tab tabHr;
59 @Wire
private Tab tabTask;
60 @Wire
private Tab tabReport;
61 @Wire
private Tab tabKey;
62 @Wire
private Hlayout info;
68 @Wire
private Label currDay;
70 @Wire
private Vbox numberBox;
73 private Date currDate =
new Date();
74 private String key, secret;
76 @Listen(
"onChange = #hrList")
79 if(selected !=
null) {
80 taskList.setHumanResource(selected);
81 info.getChildren().clear();
82 info.appendChild(
new Label(selected.
getName()));
83 tabTask.setSelected(
true);
87 @Listen(
"onChange = #taskList")
89 Object obj = evt.getData();
96 tabHr.setSelected(
true);
100 @Listen(
"onUser = #taskList")
102 if(selected !=
null) {
108 tabHr.setSelected(
true);
112 @Listen(
"onCancel = #taskList")
114 tabHr.setSelected(
true);
117 @Listen(
"onClick = #import")
122 Media media = Fileupload.get(
true);
124 FileOutputStream fos =
new FileOutputStream(file);
125 if(media.inMemory()) {
126 fos.write(media.isBinary() ? media.getByteData() : media.getStringData().getBytes());
128 byte[] buffer =
new byte[102400];
129 InputStream is = media.isBinary() ? media.getStreamData() :
new ReaderInputStream(media.getReaderData());
131 while((r = is.read(buffer)) != -1) {
132 fos.write(buffer, 0, r);
139 tabHr.setSelected(
true);
141 }
catch (Exception ex) {
146 @Listen(
"onClick = #export")
152 Filedownload.save(file,
"text/xml");
155 tcu.deleteCompleted();
157 }
catch (FileNotFoundException ex) {
162 tabHr.setSelected(
true);
166 @Listen(
"onClick = #logo")
169 tabKey.setSelected(
true);
172 @Listen(
"onClick = button.kbabutton")
174 hrList.setFocus(
true);
178 @Listen(
"onClick = #prevDay")
180 currDate =
new CheckDate(currDate).addDays(-1).getDate();
181 currDay.setValue(DateFormats.format(currDate,
true));
185 @Listen(
"onClick = #nextDay")
187 currDate =
new CheckDate(currDate).addDays(1).getDate();
188 currDay.setValue(DateFormats.format(currDate,
true));
192 @Listen(
"onClick = #back")
195 tabHr.setSelected(
true);
198 @Listen(
"onClick = button.kbnbutton")
200 secret += ((Button) evt.getTarget()).getLabel();
201 if(secret.equals(key)) {
202 tabReport.setSelected(
true);
203 currDay.setValue(DateFormats.format(currDate,
true));
205 }
else if(key.length() <= secret.length()) {
206 tabHr.setSelected(
true);
212 super.doAfterCompose(comp);
213 key = numberBox.getStyle().substring(numberBox.getStyle().indexOf(
";key:") + 5);
214 hrList.setFocus(
true);
IConstructor getConstructor()
static Application getApplication()
static String getRealPath(String path)
static File getFolderFile(File file)
void setStartsWith(String startsWith)
static final String XML_HUMANRESOURCE
void onHumanResourceSelect(Event evt)
void doAfterCompose(Component comp)
static final String XML_TIMECONTROL
XMLTimeControl end(XMLTimeControl tc)
void setHumanResource(XMLHumanResource humanResource)