|
|
@ -7,10 +7,14 @@ import info.bukova.isspst.data.TripBill;
|
|
|
|
import info.bukova.isspst.data.TripBillApproval;
|
|
|
|
import info.bukova.isspst.data.TripBillApproval;
|
|
|
|
import info.bukova.isspst.data.TripRequirement;
|
|
|
|
import info.bukova.isspst.data.TripRequirement;
|
|
|
|
import info.bukova.isspst.data.User;
|
|
|
|
import info.bukova.isspst.data.User;
|
|
|
|
|
|
|
|
import info.bukova.isspst.mail.MailMessage;
|
|
|
|
|
|
|
|
import info.bukova.isspst.mail.Mailer;
|
|
|
|
|
|
|
|
import info.bukova.isspst.mail.MessageBuilder;
|
|
|
|
import info.bukova.isspst.services.LazyLoader;
|
|
|
|
import info.bukova.isspst.services.LazyLoader;
|
|
|
|
|
|
|
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
|
|
|
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
|
|
|
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
|
|
|
import info.bukova.isspst.services.tripbill.TripBillService;
|
|
|
|
import info.bukova.isspst.services.tripbill.TripBillService;
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
import org.hibernate.Hibernate;
|
|
|
|
import org.hibernate.Hibernate;
|
|
|
|
import org.hibernate.LazyInitializationException;
|
|
|
|
import org.hibernate.LazyInitializationException;
|
|
|
|
import org.hibernate.Query;
|
|
|
|
import org.hibernate.Query;
|
|
|
@ -27,11 +31,17 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private RequirementTypeService reqTypeService;
|
|
|
|
private RequirementTypeService reqTypeService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private WorkgroupService workgroupService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private TripBillService tripBillService;
|
|
|
|
private TripBillService tripBillService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TripBillApprovalService tripBillApprovalService;
|
|
|
|
private TripBillApprovalService tripBillApprovalService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private Mailer mailer;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MessageBuilder messageBuilder;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private GlobalSettingsService settingsService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected TripRequirement createEntity() {
|
|
|
|
protected TripRequirement createEntity() {
|
|
|
@ -125,12 +135,19 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
|
|
|
|
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
|
|
|
|
if (entity.getBillForPassengers() != null && entity.getBillForPassengers()) {
|
|
|
|
for (User u : entity.getPassengers()) {
|
|
|
|
for (User u : entity.getPassengers()) {
|
|
|
|
if (!u.equals(entity.getOwnedBy())) {
|
|
|
|
if (!u.equals(entity.getOwnedBy())) {
|
|
|
|
TripBill passBill = tripBillService.createTripBill(entity);
|
|
|
|
TripBill passBill = tripBillService.createPassengersBill(entity);
|
|
|
|
tripBillService.add(passBill);
|
|
|
|
tripBillService.add(passBill);
|
|
|
|
passBill.setOwnedBy(u);
|
|
|
|
passBill.setOwnedBy(u);
|
|
|
|
tripBillService.update(passBill);
|
|
|
|
tripBillService.update(passBill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!entity.getPassengers().isEmpty() && settingsService.getSettings().getConfReqTripPassenger() != null) {
|
|
|
|
|
|
|
|
MailMessage message = messageBuilder.buildMessage(settingsService.getSettings().getConfReqTripPassenger(), entity);
|
|
|
|
|
|
|
|
message.setFrom(userService.getCurrent().getEmail());
|
|
|
|
|
|
|
|
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
|
|
|
|
|
|
|
|
mailer.send(message);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|