Merge branch 'Verze_1.0'

Conflicts:
	src/main/java/info/bukova/isspst/services/requirement/TripRequirementService.java
	src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java
	src/main/java/info/bukova/isspst/ui/requirement/TripRequirementForm.java
	src/main/webapp/WEB-INF/locales/zk-label.properties
Verze_2.0
Josef Rokos 10 years ago
commit e01e32f10c

@ -3,10 +3,19 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripRequirement;
import java.util.List;
public interface TripRequirementService extends RequirementBaseService<TripRequirement>
{
public void loadPassangers(TripRequirement entity);
public TripBill getTripBill(TripRequirement requirement);
/**
* Vrátí seznam vyúčtování, která josu vázána k požadavku
*
* @param entity požadavek
* @return seznam vyúčtování
*/
public List<TripBill> getBills(TripRequirement entity);
}

@ -5,10 +5,13 @@ import info.bukova.isspst.data.*;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.tripbill.TripBillService;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import org.hibernate.Hibernate;
import java.util.Date;
import org.hibernate.LazyInitializationException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
@ -34,6 +37,23 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
return tr;
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())")
public void update(TripRequirement entity) {
super.update(entity);
if (entity.getState() == RequirementState.APPROVED) {
TripBill newBill = tripBillService.createTripBill(entity);
for (TripBill bill : getBills(entity)) {
bill.getBillItems().clear();
bill.getBillItems().addAll(newBill.getBillItems());
tripBillService.calculate(bill);
tripBillService.update(bill);
}
}
}
@Override
@Transactional
@LazyLoader("form")
@ -53,16 +73,10 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
@Override
@Transactional
public TripBill getTripBill(TripRequirement requirement) {
Query q = dao.getQuery("from TripBill tb where tb.requirement = :req");
q.setParameter("req", requirement);
List<TripBill> result = q.list();
if (result.size() > 0) {
return result.get(0);
}
return null;
public List<TripBill> getBills(TripRequirement entity) {
Query q = queryDao.getQuery("from TripBill bill where bill.requirement = :req");
q.setParameter("req", entity);
return q.list();
}
@Transactional

@ -1,5 +1,7 @@
package info.bukova.isspst.ui.requirement;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.data.User;
@ -16,11 +18,15 @@ import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;
import java.util.List;
public class TripRequirementForm extends FormWithUpload<TripRequirement> {
public class TripRequirementForm extends FormViewModel<TripRequirement> {
@WireVariable
private UserService userService;
@ -35,6 +41,30 @@ public class TripRequirementForm extends FormWithUpload<TripRequirement> {
@WireVariable
private DocumentFileStorage documentStorage;
private List<Workgroup> centres;
@Override
@NotifyChange("errMessages")
@Command
public void save(@BindingParam("window") Window win) {
final Window editWin = win;
if (getDataBean().getState() == RequirementState.APPROVED) {
Messagebox.show(StringUtils.localize("TripRequirementChangeWarn"), StringUtils.localize("TripRequirementSave"), Messagebox.YES
| Messagebox.NO, Messagebox.QUESTION, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (((Integer) event.getData()).intValue() == Messagebox.YES) {
TripRequirementForm.super.save(editWin);
} else {
editWin.detach();
}
}
});
} else {
super.save(win);
}
}
private List<User> users;
private List<User> passengers;
private User selUser;

@ -233,6 +233,9 @@ TripBillTotal=Celkem
TripRequirement=Požadavek na služební cestu
ShowTripBill=Zobrazit vyúčtování
TripRequirementChangeWarn=Editací schváleného požadavku se znovu vygeneruje vyúčtování. Opravdu chcete záznam uložit?
TripRequirementSave=Uložit požadavek?
CentresForRequirements=Střediska, pro která lze vkládat požadavky
WorkgroupMembership=Členství v komisích
LogedInUser=Přihlášený uživatel:

@ -51,6 +51,6 @@
<div id="mainData">
<u:include src="${gridZul}" />
</div>
<div id="footer"> Verze 1.3 </div>
<div id="footer"> Verze 1.5 </div>
</div>
</html>
Loading…
Cancel
Save