commit e081ca32f0023af1e930eebef65e9cb9c59909c9
Author: Lukas Cerny <luc.cerny@gmail.com>
Date:   Fri Jun 7 18:40:12 2019 +0200

    Fixed is not able to set lower number of sick day than is already taken

diff --git a/server/init.sql b/server/init.sql
index be6eab3..7a72bb7 100644
--- a/server/init.sql
+++ b/server/init.sql
@@ -117,8 +117,6 @@ DELIMITER ;
 -- Insert table end_user
 -- -----------------------------------------------------
 INSERT INTO end_user (first_name, last_name, no_vacations, no_sick_days, taken_sick_days, alert, token, email, photo, user_role, status) VALUES ('admin', 'admin', 0, NULL, 0, NULL, '', '', 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg', 'EMPLOYER', 'ACCEPTED');
-INSERT INTO end_user (first_name, last_name, no_vacations, no_sick_days, taken_sick_days, alert, token, email, photo, user_role, status) VALUES ('Jan', 'Novák', 0, 10, 0, '2019-12-6 16:30:00.000', '', '', 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg', 'EMPLOYEE', 'PENDING');
-INSERT INTO end_user (first_name, last_name, no_vacations, no_sick_days, taken_sick_days, alert, token, email, photo, user_role, status) VALUES ('Josef', 'Svoboda', 2, NULL, 3, NULL, '', '', 'https://st2.depositphotos.com/9223672/12056/v/950/depositphotos_120568236-stock-illustration-male-face-avatar-logo-template.jpg', 'EMPLOYEE', 'REJECTED');
 
 -- -----------------------------------------------------
 -- Insert table vacation_day
diff --git a/server/src/main/java/cz/zcu/yamanager/business/ApiManager.java b/server/src/main/java/cz/zcu/yamanager/business/ApiManager.java
index b789af6..003fb57 100644
--- a/server/src/main/java/cz/zcu/yamanager/business/ApiManager.java
+++ b/server/src/main/java/cz/zcu/yamanager/business/ApiManager.java
@@ -188,6 +188,11 @@ public class ApiManager implements Manager {
         }
 
         if (settings.getSickDayCount() != null) {
+
+            if (user.getTakenSickDayCount() > settings.getSickDayCount()) {
+                throw new IllegalArgumentException("settings.sick.day.lt.taken.error");
+            }
+
             if (settings.getSickDayCount().equals(defaultSettings.getSickDayCount())) {
                 user.setTotalSickDayCount(null);
             } else {
diff --git a/server/src/main/java/cz/zcu/yamanager/business/FileServiceImpl.java b/server/src/main/java/cz/zcu/yamanager/business/FileServiceImpl.java
index fbe6368..e570ec0 100644
--- a/server/src/main/java/cz/zcu/yamanager/business/FileServiceImpl.java
+++ b/server/src/main/java/cz/zcu/yamanager/business/FileServiceImpl.java
@@ -2,13 +2,21 @@ package cz.zcu.yamanager.business;
 
 import cz.zcu.yamanager.business.file.excel.*;
 import cz.zcu.yamanager.ws.rest.RESTFullException;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.springframework.stereotype.Component;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.*;
 
 import static cz.zcu.yamanager.business.file.excel.ExcelParser.parseXLSX;
 
+@Component
 public class FileServiceImpl implements FileService {
 
     private class Content {
@@ -55,6 +63,31 @@ public class FileServiceImpl implements FileService {
 
     @Override
     public FileExportResult createPDFFile() throws RESTFullException {
-        return new FileExportResult("unknown", new byte[0]);
+
+        PDDocument document = new PDDocument();
+        PDPage page1 = new PDPage(PDRectangle.A4);
+        document.addPage(page1);
+
+        try {
+            PDPageContentStream cos = new PDPageContentStream(document, page1);
+
+            cos.beginText();
+            cos.setFont(PDType1Font.HELVETICA, 12);
+            cos.newLineAtOffset(100, 10);
+            cos.showText("Test");
+            cos.endText();
+
+            cos.close();
+
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+            document.save(output);
+            document.close();
+
+            return new FileExportResult("export.pdf", output.toByteArray());
+
+        } catch (IOException e) {
+            throw new RESTFullException("", "");
+        }
     }
 }
diff --git a/server/src/main/java/cz/zcu/yamanager/business/mock/FileServiceMock.java b/server/src/main/java/cz/zcu/yamanager/business/mock/FileServiceMock.java
index ea11215..1ac60f7 100644
--- a/server/src/main/java/cz/zcu/yamanager/business/mock/FileServiceMock.java
+++ b/server/src/main/java/cz/zcu/yamanager/business/mock/FileServiceMock.java
@@ -17,7 +17,6 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.springframework.stereotype.Component;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -27,7 +26,7 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
-@Component
+
 public class FileServiceMock implements FileService {
 
     private List<String> content = new ArrayList<>();
diff --git a/server/src/main/resources/Message_cs.properties b/server/src/main/resources/Message_cs.properties
index e5469c1..d8161f3 100644
--- a/server/src/main/resources/Message_cs.properties
+++ b/server/src/main/resources/Message_cs.properties
@@ -24,4 +24,5 @@ vacation.null.error = Po\u010Det hodin dovolen\u00E9 mus\u00ED b\u00FDt zad\u00E
 role.null.error = Role mus\u00ED b\u00FDt zad\u00E1n.
 database.error = Vyskytl se probl\u00E9m s datab\u00E1z\u00ED.
 vacation.past.error = Nelze vybrat volno v minulosti.
-vacation.double.error = Nelze vybrat v\u00EDce voln pro stejn\u00FD den.
\ No newline at end of file
+vacation.double.error = Nelze vybrat v\u00EDce voln pro stejn\u00FD den.
+settings.sick.day.lt.taken.error = Nelze nastavit po\u010Det sick day men\u0161\u00ED ne\u017E je je aktu\u00E1ln\u011B vybr\u00E1no.
\ No newline at end of file
diff --git a/server/src/main/resources/Message_en.properties b/server/src/main/resources/Message_en.properties
index 4d53550..a0cad1d 100644
--- a/server/src/main/resources/Message_en.properties
+++ b/server/src/main/resources/Message_en.properties
@@ -24,4 +24,5 @@ vacation.null.error = The number of overtime hours has to be filled in.
 role.null.error = The role has to be filled in.
 database.error = There was a problem with the database.
 vacation.past.error = You cannot take a vacation in past.
-vacation.double.error = You cannot take a vacation at the same day.
\ No newline at end of file
+vacation.double.error = You cannot take a vacation at the same day.
+settings.sick.day.lt.taken.error = You cannot set a number of sick day lower than is taken at this moment.
\ No newline at end of file
