19 package org.turro.erp.purchase;
21 import java.util.Date;
22 import org.turro.string.Strings;
23 import org.turro.erp.db.ErpPU;
24 import org.turro.erp.entity.*;
25 import org.turro.erp.humanres.HumanResourceCombobox;
26 import org.turro.jpa.Dao;
27 import org.turro.zkoss.grid.EditableCell;
28 import org.zkoss.zk.ui.Component;
29 import org.zkoss.zk.ui.util.GenericForwardComposer;
30 import org.zkoss.zul.Button;
31 import org.zkoss.zul.Datebox;
32 import org.zkoss.zul.Label;
33 import org.zkoss.zul.Textbox;
39 public class HoursEdit extends GenericForwardComposer {
41 private HoursGrid hoursGrid, hoursHistGrid;
43 private Textbox docnumber;
44 private Datebox docdate;
45 private Button doccreate;
46 private Label lWorkOrder, lOrderReference;
52 createReceipt(humanres.
getObjectValue(), docnumber.getValue(), docdate.getValue(), hi);
54 createOrder(humanres.
getObjectValue(), docnumber.getValue(), docdate.getValue(), hi);
59 if(hoursHistGrid !=
null) {
66 if(hoursHistGrid !=
null) {
73 if(hoursHistGrid !=
null) {
80 if(hoursHistGrid !=
null) {
114 private void updateButton() {
115 doccreate.setDisabled(
117 Strings.isEmpty(docnumber.getValue()) ||
118 docdate.getValue() ==
null ||
125 super.doAfterCompose(comp);
126 docdate.setValue(
new Date());
127 doccreate.setDisabled(
true);
131 private void createOrder(
HumanResource humanResource, String documentNumber, Date documentDate,
HoursItem hi) {
136 "select ru from RequiredUsage ru " +
138 "and humanResource = ?",
139 new Object[] { hi.
getTask(), humanResource });
144 ru.getTask().getRequiredUsages().add(ru);
146 ru.setPurchaseLag(0);
150 ru = dao.saveObject(ru);
156 oi = dao.saveObject(oi);
160 "select ru from RequiredUsage ru " +
162 "and resource = ? " +
163 "and humanResource = ? " +
164 "and aptitudeDegree = ?",
178 ru = dao.saveObject(ru);
184 oi = dao.saveObject(oi);
188 private void createReceipt(
HumanResource humanResource, String documentNumber, Date documentDate, HoursItem hi) {
190 if(hi.getResourceAptitude() ==
null) {
193 "select hru from HumanResourceUsage hru " +
195 "and humanResource = ?",
196 new Object[] { hi.getTask(), humanResource });
207 ru = dao.saveObject(ru);
213 oi = dao.saveObject(oi);
224 "select hru from HumanResourceUsage hru " +
226 "and resource = ? " +
227 "and humanResource = ? " +
228 "and aptitudeDegree = ?",
229 new Object[] { hi.getTask(), hi.getResourceAptitude().getResource(),
230 humanResource, hi.getResourceAptitude().getAptitudeDegree() });
242 ru = dao.saveObject(ru);
248 oi = dao.saveObject(oi);
HumanResourceAptitude getDefaultHumanResourceAptitude(Date date)
void setDocumentDate(Date documentDate)
ReceiptItem startReceipt(Date startWorking)
Set< ReceiptItem > getReceiptItems()
void setDocumentNumber(String documentNumber)
String getSomeDescription()
void setHumanResource(HumanResource resource)
void setHumanResourceAptitude(HumanResourceAptitude hro)
void setPurchaseMode(PurchaseMode purchaseMode)
void setUnits(double units)
void setResourceAptitude(ResourceAptitude ro)
void setDedication(double dedication)
void setPurchaseLag(double purchaseLag)
Set< RequiredUsage > getRequiredUsages()
String getSomeDescription()
void onChange $docnumber()
void onChanging $hoursHistGrid()
void onChanging $hoursGrid()
void onClick $doccreate()
void onChange $humanres()
void doAfterCompose(Component comp)
void onChange $hoursGrid()
void setDocumentDate(Date documentDate)
void refreshUsing(HumanResource humanResource, String documentNumber, Date documentDate)
ResourceAptitude getResourceAptitude()
OrderReference getOrderReference()
AptitudeDegree getAptitudeDegree()
Object getSingleResultOrNull(SqlClause sc)
EditableCell getCurrentCell()