parent
ceac59c8d3
commit
9c5679af2c
@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface TripBillApprovalDao extends BaseDao<TripBillApproval> {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.TripBillApprovalDao;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class TripBillApprovalDaoJPA extends BaseDaoJPA<TripBillApproval> implements TripBillApprovalDao {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "TRIP_BILL_APPROVAL")
|
||||
public class TripBillApproval extends RequirementBase {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package info.bukova.isspst.services.tripbill;
|
||||
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.services.requirement.RequirementBaseService;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface TripBillApprovalService extends RequirementBaseService<TripBillApproval> {
|
||||
|
||||
public TripBillApproval createApproval(TripBill bill);
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package info.bukova.isspst.services.tripbill;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.data.RequirementState;
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
import info.bukova.isspst.services.requirement.RequirementBaseServiceImpl;
|
||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<TripBillApproval> implements TripBillApprovalService {
|
||||
|
||||
@Autowired
|
||||
private RequirementTypeService reqTypeService;
|
||||
|
||||
@Override
|
||||
public TripBillApproval createApproval(TripBill bill) {
|
||||
if (bill.getApproval() != null) {
|
||||
throw new IsspstException("Approval already exists");
|
||||
}
|
||||
|
||||
TripBillApproval approval = new TripBillApproval();
|
||||
approval.setCentre(bill.getRequirement().getCentre());
|
||||
approval.setWorkgroup(bill.getRequirement().getWorkgroup());
|
||||
approval.setReqDate(new Date());
|
||||
approval.setType(reqTypeService.getTypeById(Constants.REQTYPE_BUSINESSTRIP));
|
||||
approval.setState(RequirementState.NEW);
|
||||
bill.setApproval(approval);
|
||||
return approval;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
||||
public void add(TripBillApproval entity) {
|
||||
entity.setCreated(new Date());
|
||||
entity.setOwnedBy(getLoggedInUser());
|
||||
addWorkflow(entity);
|
||||
dao.add(entity);
|
||||
|
||||
postAdd(entity);
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package info.bukova.isspst.ui.tripbill;
|
||||
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.services.requirement.TripRequirementService;
|
||||
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
||||
import info.bukova.isspst.services.tripbill.TripBillService;
|
||||
import info.bukova.isspst.ui.requirement.RequirementSubpage;
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.ExecutionArgParam;
|
||||
import org.zkoss.bind.annotation.GlobalCommand;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.bind.annotation.NotifyChange;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class TripBillSummaryVM extends RequirementSubpage<TripBillApproval> {
|
||||
|
||||
@WireVariable
|
||||
private TripBillApprovalService tripBillApprovalService;
|
||||
@WireVariable
|
||||
private TripBillService tripBillService;
|
||||
@WireVariable
|
||||
private TripRequirementService tripRequirementService;
|
||||
private TripBill bill;
|
||||
|
||||
@Init(superclass = true)
|
||||
public void initBillSummary(@ExecutionArgParam("bill") TripBill bill) {
|
||||
service = tripBillApprovalService;
|
||||
|
||||
if (bill.getApproval() != null) {
|
||||
setDataBean(bill.getApproval());
|
||||
}
|
||||
|
||||
this.bill = bill;
|
||||
}
|
||||
|
||||
public TripBill getBill() {
|
||||
return bill;
|
||||
}
|
||||
|
||||
public void setBill(TripBill bill) {
|
||||
this.bill = bill;
|
||||
}
|
||||
|
||||
public List<TripBill> getBills() {
|
||||
List<TripBill> bills = new ArrayList<TripBill>();
|
||||
|
||||
for (TripBill b : tripRequirementService.getBills(bill.getRequirement())) {
|
||||
if (b.getId() != bill.getId()) {
|
||||
tripBillService.loadLazyData(b);
|
||||
bills.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
return bills;
|
||||
}
|
||||
|
||||
@Command
|
||||
public void showBill(@BindingParam("bill") TripBill bill) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("selected", bill);
|
||||
Window win = (Window) Executions.createComponents("tripBill.zul", null, params);
|
||||
win.doModal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@GlobalCommand
|
||||
@NotifyChange("dataBean")
|
||||
public void reload() {
|
||||
setDataBean(tripBillApprovalService.getById(bill.getApproval().getId()));
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?page title="${labels.TravelOrdersFormTitle}" contentType="text/html;charset=UTF-8"?>
|
||||
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
|
||||
<window id="billWin"
|
||||
closable="true"
|
||||
width="700px"
|
||||
height="450px"
|
||||
border="normal"
|
||||
position="center"
|
||||
apply="org.zkoss.bind.BindComposer"
|
||||
viewModel="@id('vm') @init('info.bukova.isspst.ui.tripbill.TripBillSummaryVM')">
|
||||
<caption
|
||||
src="/img/pickup-032.png"
|
||||
zclass="form-caption"
|
||||
label="${labels.TravelOrdersFormTitle}" />
|
||||
<hbox vflex="1">
|
||||
<vbox width="350px" vflex="1">
|
||||
<label value="@load(vm.bill.ownedBy)" style="font-weight: bold; font-size: larger"/>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormFrom}: "/>
|
||||
<label value="@load(vm.bill.requirement.from)"/>
|
||||
<label value="${labels.RequirementsFormTo}: "/>
|
||||
<label value="@load(vm.bill.requirement.to)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormStartDateTime}: "/>
|
||||
<label value="@load(vm.bill.requirement.tripDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormEndDate}: "/>
|
||||
<label value="@load(vm.bill.requirement.endDate) @converter('formatedDate', format=labels.DateFormat)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.RequirementsFormPurpose}: "/>
|
||||
<label value="@load(vm.bill.requirement.description)"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="${labels.TripBillTotal}:"/> <label value="@load(vm.bill.total) @converter(vm.standardBigDecimalConverter)"/>
|
||||
</hbox>
|
||||
<button label="${labels.TripBillSummaryDetail}"
|
||||
onClick="@command('showBill', bill=vm.bill)"
|
||||
sclass="nicebutton"/>
|
||||
<div visible="@load(not empty vm.bills)" vflex="1">
|
||||
<separator bar="true" width="100%"/>
|
||||
<label value="${labels.RequirementsFormPassengers}"/>
|
||||
<grid model="@load(vm.bills)" vflex="1">
|
||||
<columns>
|
||||
<column />
|
||||
<column width="90px"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<template name="model">
|
||||
<row>
|
||||
<label value="@load(each.ownedBy)"/>
|
||||
<button label="${labels.TripBillSummaryDetail}"
|
||||
sclass="nicebutton"
|
||||
onClick="@command('showBill', bill=each)"/>
|
||||
</row>
|
||||
</template>
|
||||
</rows>
|
||||
</grid>
|
||||
</div>
|
||||
</vbox>
|
||||
<include src="../../approveStatus.zul" vflex="1"/>
|
||||
</hbox>
|
||||
</window>
|
||||
|
||||
</zk>
|
Loading…
Reference in New Issue