Vytvořením požadavku na služební cestu se odešle e-mail spolucestujícím.

closes #235
Verze_2.0
Josef Rokos 10 years ago
parent 4d74b0a3fe
commit dc0607c072

@ -15,6 +15,7 @@ public class SettingsData {
private MailMessage authReqTemplate; private MailMessage authReqTemplate;
private MailMessage confReqTemplate; private MailMessage confReqTemplate;
private MailMessage confReqTripPassenger; private MailMessage confReqTripPassenger;
private MailMessage reqPassenger;
private Address mainAddress; private Address mainAddress;
private List<Address> shippingAddrs; private List<Address> shippingAddrs;
private String bankName; private String bankName;
@ -30,6 +31,7 @@ public class SettingsData {
authReqTemplate = new MailMessage(); authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage(); confReqTemplate = new MailMessage();
confReqTripPassenger = new MailMessage(); confReqTripPassenger = new MailMessage();
reqPassenger = new MailMessage();
mainAddress = new Address(); mainAddress = new Address();
shippingAddrs = new ArrayList<Address>(); shippingAddrs = new ArrayList<Address>();
vehicles = new ArrayList<Vehicle>(); vehicles = new ArrayList<Vehicle>();
@ -160,4 +162,12 @@ public class SettingsData {
public void setConfReqTripPassenger(MailMessage confReqTripPassenger) { public void setConfReqTripPassenger(MailMessage confReqTripPassenger) {
this.confReqTripPassenger = confReqTripPassenger; this.confReqTripPassenger = confReqTripPassenger;
} }
public MailMessage getReqPassenger() {
return reqPassenger;
}
public void setReqPassenger(MailMessage reqPassenger) {
this.reqPassenger = reqPassenger;
}
} }

@ -77,6 +77,21 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
} }
} }
@Override
protected void postAdd(TripRequirement entity) {
super.postAdd(entity);
sendMailToPassengers(entity, settingsService.getSettings().getReqPassenger());
}
private void sendMailToPassengers(TripRequirement entity, MailMessage messageTemplate) {
if (entity.getBillForPassengers() != null && !entity.getPassengers().isEmpty() && messageTemplate != null) {
MailMessage message = messageBuilder.buildMessage(messageTemplate, entity);
message.setFrom(userService.getCurrent().getEmail());
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
mailer.send(message);
}
}
@Override @Override
@Transactional @Transactional
@LazyLoader("form") @LazyLoader("form")
@ -142,12 +157,7 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
} }
} }
if (!entity.getPassengers().isEmpty() && settingsService.getSettings().getConfReqTripPassenger() != null) { sendMailToPassengers(entity, settingsService.getSettings().getConfReqTripPassenger());
MailMessage message = messageBuilder.buildMessage(settingsService.getSettings().getConfReqTripPassenger(), entity);
message.setFrom(userService.getCurrent().getEmail());
message.setTo(userService.getEmailsForSend(entity.getPassengers()));
mailer.send(message);
}
} }
} }
} }

@ -168,6 +168,7 @@ NewRequirement=Nový požadavek
AuthRequirement=Dílčí schválení AuthRequirement=Dílčí schválení
ConfirmRequirement=Schválení ConfirmRequirement=Schválení
ConfirmTripPassengers=Schválení SC - spolucestující ConfirmTripPassengers=Schválení SC - spolucestující
ReqTripPassengers=SC - spolucestujici
InsertField=Vložit pole InsertField=Vložit pole
EnableRequirements=Povolit zadávání požadavků EnableRequirements=Povolit zadávání požadavků
ShippingAddresses=Dodací adresy: ShippingAddresses=Dodací adresy:

@ -7,6 +7,7 @@
<tab label="${labels.NewRequirement}"/> <tab label="${labels.NewRequirement}"/>
<tab label="${labels.AuthRequirement}"/> <tab label="${labels.AuthRequirement}"/>
<tab label="${labels.ConfirmRequirement}"/> <tab label="${labels.ConfirmRequirement}"/>
<tab label="${labels.ReqTripPassengers}"/>
<tab label="${labels.ConfirmTripPassengers}"/> <tab label="${labels.ConfirmTripPassengers}"/>
</tabs> </tabs>
<tabpanels> <tabpanels>
@ -91,6 +92,31 @@
</rows> </rows>
</grid> </grid>
</tabpanel> </tabpanel>
<tabpanel>
<grid>
<columns>
<column hflex="min"/>
<column/>
</columns>
<rows>
<row>
<label value="${labels.MailSubject}" />
<textbox
value="@bind(vm.settings.reqPassenger.subject)"
width="100%"
maxlength="@load(vm.lengthText)"
readonly="@load(not vm.canSave)" />
</row>
<row spans="2">
<vbox>
<ckeditor toolbar="Basic" value="@bind(vm.settings.reqPassenger.text)" width="460px" height="180px" if="${vm.canSave}" />
<html content="@load(vm.settings.confReqTemplate.text)" width="460px" height="180px" if="${not vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsPassenger, position=after_start" disabled="@load(not vm.canSave)"/>
</vbox>
</row>
</rows>
</grid>
</tabpanel>
<tabpanel> <tabpanel>
<grid> <grid>
<columns> <columns>
@ -138,4 +164,9 @@
<menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.confReqTripPassenger)"/> <menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.confReqTripPassenger)"/>
</template> </template>
</menupopup> </menupopup>
<menupopup id="fieldsPassenger" children="@load(vm.requirementFields)">
<template name="children">
<menuitem label="@load(each) @converter(vm.locConverter)" onClick="@command('insertField', field=each, message=vm.settings.reqPassenger)"/>
</template>
</menupopup>
</zk> </zk>
Loading…
Cancel
Save