Merge branch 'master' of https://git.bukova.info/repos/git/isspst
This commit is contained in:
@@ -33,7 +33,7 @@ import java.util.Map;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public final static long DB_VERSION = 3;
|
||||
public final static long DB_VERSION = 4;
|
||||
|
||||
public final static String DEF_ADMIN = "admin";
|
||||
public final static String DEF_ADMIN_PASSWD = "admin";
|
||||
|
||||
@@ -7,6 +7,15 @@ import org.zkoss.util.resource.Labels;
|
||||
|
||||
public class StringUtils
|
||||
{
|
||||
public static boolean isNullOrEmpty(String str)
|
||||
{
|
||||
return ((str == null) || (str.isEmpty()));
|
||||
}
|
||||
|
||||
public static boolean isNullOrTrimmedEmpty(String str)
|
||||
{
|
||||
return ((str == null) || (str.trim().isEmpty()));
|
||||
}
|
||||
|
||||
public static String nullToEmptyString(String str)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ public class SettingsData {
|
||||
private List<Vehicle> vehicles;
|
||||
private Map<Integer, BigDecimal[]> refunds;
|
||||
private String stampFile;
|
||||
private String logoFile;
|
||||
|
||||
public SettingsData() {
|
||||
newReqTemplate = new MailMessage();
|
||||
@@ -140,4 +141,13 @@ public class SettingsData {
|
||||
this.stampFile = stampFile;
|
||||
}
|
||||
|
||||
public String getLogoFile()
|
||||
{
|
||||
return logoFile;
|
||||
}
|
||||
|
||||
public void setLogoFile(String logoFile)
|
||||
{
|
||||
this.logoFile = logoFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -15,10 +16,14 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.Analyze;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.Index;
|
||||
import org.hibernate.search.annotations.Indexed;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
@Entity
|
||||
@Table(name = "TRIP_BILL")
|
||||
@@ -32,6 +37,11 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
||||
private Date resultMessageDate;
|
||||
@Column(name = "SIGN_DATE")
|
||||
private Date signDate;
|
||||
|
||||
@Column(name = "RESULT_MESSAGE")
|
||||
@Field(index = Index.YES, analyze = Analyze.YES)
|
||||
private String resultMessage;
|
||||
|
||||
@Column(name = "FREE_MEALS")
|
||||
private boolean freeMeals;
|
||||
@Column(name = "FREE_HOUSING")
|
||||
@@ -85,6 +95,16 @@ public class TripBill extends BaseData implements EntityWithAttachment {
|
||||
this.signDate = signDate;
|
||||
}
|
||||
|
||||
public String getResultMessage()
|
||||
{
|
||||
return resultMessage;
|
||||
}
|
||||
|
||||
public void setResultMessage(String resultMessage)
|
||||
{
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
|
||||
public boolean isFreeMeals() {
|
||||
return freeMeals;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@@ -47,4 +52,22 @@ public class UsersAddress {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(this.street);
|
||||
list.add(this.houseNumber);
|
||||
final String s1 = StringUtils.joinNotEmpty(list, " ");
|
||||
|
||||
list.clear();
|
||||
list.add(this.zipCode);
|
||||
list.add(this.city);
|
||||
final String s2 = StringUtils.joinNotEmpty(list, " ");
|
||||
|
||||
list.clear();
|
||||
list.add(s1);
|
||||
list.add(s2);
|
||||
final String s = StringUtils.joinNotEmpty(list, ", ");
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package info.bukova.isspst.reporting;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.AuthItem;
|
||||
import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.TripBill;
|
||||
@@ -13,8 +11,13 @@ import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
import info.bukova.isspst.storage.FileStorage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.mysql.jdbc.StringUtils;
|
||||
|
||||
public class ParamFiller {
|
||||
|
||||
@Autowired
|
||||
@@ -45,6 +48,7 @@ public class ParamFiller {
|
||||
|
||||
if ((definition.getDataSet().get(0) instanceof TripBill)
|
||||
&& definition.getReport().isSingleRecord()) {
|
||||
|
||||
if (userService.getUserSettings().getSignatureFile() != null
|
||||
&& !userService.getUserSettings().getSignatureFile().isEmpty()) {
|
||||
definition.setParam("P_USER_SIGNATURE", storage.serverPath(userService.getUserSettings().getSignatureFile()));
|
||||
@@ -52,17 +56,25 @@ public class ParamFiller {
|
||||
|
||||
TripBill tb = (TripBill)definition.getDataSet().get(0);
|
||||
tripReqService.loadAuthItems(tb.getRequirement());
|
||||
|
||||
AuthItem lastButOneAuth = tb.getRequirement().getAuthorization().get(0);
|
||||
definition.setParam("P_PREV_APPROVE_DATE", lastButOneAuth.getAuthDate());
|
||||
|
||||
User lastButOneUser = lastButOneAuth.getApprover();
|
||||
UserSettingsData prevApproverSettings = userService.getUserSettings(lastButOneUser);
|
||||
|
||||
if (prevApproverSettings != null && !StringUtils.isNullOrEmpty(prevApproverSettings.getSignatureFile())) {
|
||||
definition.setParam("P_PREV_APPROVER_SIGNATURE", storage.serverPath(prevApproverSettings.getSignatureFile()));
|
||||
}
|
||||
|
||||
|
||||
AuthItem lastAuth = tb.getRequirement().getAuthorization().get(tb.getRequirement().getAuthorization().size() - 1);
|
||||
|
||||
definition.setParam("P_APPROVE_DATE", lastAuth.getAuthDate());
|
||||
|
||||
User u = lastAuth.getApprover();
|
||||
|
||||
UserSettingsData approverSettings = userService.getUserSettings(u);
|
||||
|
||||
if (approverSettings != null
|
||||
&& approverSettings.getSignatureFile() != null
|
||||
&& !approverSettings.getSignatureFile().isEmpty()) {
|
||||
if (approverSettings != null && !StringUtils.isNullOrEmpty(approverSettings.getSignatureFile())) {
|
||||
definition.setParam("P_APPROVER_SIGNATURE", storage.serverPath(approverSettings.getSignatureFile()));
|
||||
}
|
||||
}
|
||||
@@ -74,6 +86,15 @@ public class ParamFiller {
|
||||
definition.setParam("P_STAMP", storage.serverPath(settingService.getSettings().getStampFile()));
|
||||
}
|
||||
}
|
||||
|
||||
definition.setParam("P_LOGO", storage.serverPath(settingService.getSettings().getLogoFile()));
|
||||
|
||||
Address mainAddress = settingService.getSettings().getMainAddress();
|
||||
|
||||
if (mainAddress != null) {
|
||||
String addr = (StringUtils.isNullOrEmpty(mainAddress.getCompany()) ? "" : mainAddress.getCompany());
|
||||
definition.setParam("P_MAIN_ADDRESS", addr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -126,6 +126,13 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
|
||||
sq.executeUpdate();
|
||||
}
|
||||
|
||||
if (dbVersion < 4)
|
||||
{
|
||||
sql = "UPDATE TRIP_BILL SET RESULT_MESSAGE = 'Zpráva z pracovní cesty' WHERE (RESULT_MESSAGE Is NULL) ";
|
||||
sq = this.dao.getSession().createSQLQuery(sql);
|
||||
sq.executeUpdate();
|
||||
}
|
||||
|
||||
this.updateDatabaseVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package info.bukova.isspst.ui.settings;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.Address;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.data.SettingsData;
|
||||
@@ -77,7 +78,24 @@ public class GlobalSettingsVM extends DocumentViewModel
|
||||
storage.removeFile(settings.getStampFile());
|
||||
settings.setStampFile(null);
|
||||
}
|
||||
|
||||
|
||||
@Command
|
||||
@NotifyChange({ "settings", "logoImg" })
|
||||
public void uploadLogo(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent upEvent) {
|
||||
int i = upEvent.getMedia().getName().lastIndexOf(".");
|
||||
String fileName = "LogoImageFile" + upEvent.getMedia().getName().substring(i);
|
||||
storage.saveFile(upEvent.getMedia().getByteData(), fileName);
|
||||
settings.setLogoFile(fileName);
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange("logoImg")
|
||||
public void removeLogo()
|
||||
{
|
||||
storage.removeFile(settings.getLogoFile());
|
||||
settings.setLogoFile(null);
|
||||
}
|
||||
|
||||
public List<String> getRequirementFields() {
|
||||
return ReflectionTools.getEntityFields(Requirement.class);
|
||||
}
|
||||
@@ -144,7 +162,7 @@ public class GlobalSettingsVM extends DocumentViewModel
|
||||
}
|
||||
|
||||
public RenderedImage getStampImg() {
|
||||
if (settings.getStampFile() == null || settings.getStampFile().isEmpty()) {
|
||||
if (StringUtils.isNullOrEmpty(settings.getStampFile())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -155,4 +173,16 @@ public class GlobalSettingsVM extends DocumentViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public RenderedImage getLogoImg() {
|
||||
if (StringUtils.isNullOrEmpty(settings.getLogoFile())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return ImageIO.read(storage.file(settings.getLogoFile()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
import info.bukova.isspst.services.tripbill.TripBillApprovalService;
|
||||
import info.bukova.isspst.services.tripbill.TripBillService;
|
||||
import info.bukova.isspst.ui.FormWithUpload;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
@@ -18,9 +22,6 @@ import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TripBillForm extends FormWithUpload<TripBill> {
|
||||
|
||||
@WireVariable
|
||||
@@ -63,8 +64,16 @@ public class TripBillForm extends FormWithUpload<TripBill> {
|
||||
@Override
|
||||
@Command
|
||||
@NotifyChange("errMessages")
|
||||
public void save(@BindingParam("window") Window win) {
|
||||
public void save(@BindingParam("window") Window win)
|
||||
{
|
||||
if (StringUtils.isNullOrTrimmedEmpty(this.getDataBean().getResultMessage()))
|
||||
{
|
||||
Messagebox.show(StringUtils.localize("ErrFillTripBillResultMessageText"), StringUtils.localize("Error"), Messagebox.OK, Messagebox.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
final Window editWin = win;
|
||||
|
||||
if (getDataBean().getApproval() == null && !isBillDisabled()) {
|
||||
Messagebox.show(StringUtils.localize("TripBillSaveApprove"), StringUtils.localize("TripBillSave"), Messagebox.YES
|
||||
| Messagebox.NO, Messagebox.QUESTION, new EventListener<Event>() {
|
||||
|
||||
Reference in New Issue
Block a user