diff --git a/src/Billing/Utils.js b/src/Billing/Utils.js
index fd6289c..5dbee95 100644
--- a/src/Billing/Utils.js
+++ b/src/Billing/Utils.js
@@ -41,7 +41,7 @@ function include(filename) {
* @return {Array
+
+
+
+
+
+
@@ -38,3 +46,4 @@
!= include('javascript'); ?>
+!= include('pdfbackuper-js'); ?>
diff --git a/src/PdfBackuper/pdfbackuper-js.html b/src/PdfBackuper/pdfbackuper-js.html
new file mode 100644
index 0000000..c5c66cd
--- /dev/null
+++ b/src/PdfBackuper/pdfbackuper-js.html
@@ -0,0 +1,9 @@
+
+
diff --git a/src/RenameGroup/appsscript.json b/src/RenameGroup/appsscript.json
index 8e61bec..12d8846 100644
--- a/src/RenameGroup/appsscript.json
+++ b/src/RenameGroup/appsscript.json
@@ -5,7 +5,7 @@
{
"userSymbol": "Utils",
"libraryId": "1WquYtBor0ObwHMo1oIhKnCgboR5zBx2wjh5Hu-rbb0oSA5cY0d2PM6dZ",
- "version": 87
+ "version": 89
}
]
},
diff --git a/src/SheetRedirect/appsscript.json b/src/SheetRedirect/appsscript.json
index 56d9438..6794902 100644
--- a/src/SheetRedirect/appsscript.json
+++ b/src/SheetRedirect/appsscript.json
@@ -5,7 +5,7 @@
{
"userSymbol": "Utils",
"libraryId": "1WquYtBor0ObwHMo1oIhKnCgboR5zBx2wjh5Hu-rbb0oSA5cY0d2PM6dZ",
- "version": 87
+ "version": 89
}
]
},
diff --git a/src/Statistics/Stat.js b/src/Statistics/Stat.js
index 8bd0735..607ab26 100644
--- a/src/Statistics/Stat.js
+++ b/src/Statistics/Stat.js
@@ -6,7 +6,7 @@
*/
function process(formObject) {
var errorMsg = {fromErr:'',toErr:''};
- var from,to;
+ var from, to, group, groupHumanReadableName;
from = Utils.validate(errorMsg,formObject.fromBox,{
actions:['validateDate',],
@@ -30,9 +30,24 @@ function process(formObject) {
errorMsg.fromErr = '*datum od je větší než datum do';
}
+ group = formObject.selectBox;
+ if (group == null) {
+ group = '';
+ }
+ if (group != '') {
+ group = Utils.validate(errorMsg,formObject.selectBox,{
+ actions:['notUnique'],
+ actionObjs:[{uniqueArray:getGroups()}],
+ actionErrors:[{selectErr:'*zadejte validní skupinu'}]
+ });
+ groupHumanReadableName = group;
+ } else {
+ groupHumanReadableName = "Všechny Skupiny";
+ }
+
if(Utils.isObjErrorFree(errorMsg)) {
- errorMsg.success = createStatistics(from,to);
- Utils.log('Generated stats in time span ' + from + ' - ' + to );
+ errorMsg.success = createStatistics(from,to, group, groupHumanReadableName);
+ Utils.log('Generated stats for group ' + groupHumanReadableName + ' in time span ' + from + ' - ' + to );
}
return errorMsg;
diff --git a/src/Statistics/Utils.js b/src/Statistics/Utils.js
index 7fb6c0d..1ea6ceb 100644
--- a/src/Statistics/Utils.js
+++ b/src/Statistics/Utils.js
@@ -56,6 +56,13 @@ function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
+/**
+ * @return {Array} array with name of all groups
+ */
+function getGroups() {
+ return Utils.sort(Utils.convertObjectsToArrayByProperty(Utils.findGroups(['group']), 'group'));
+}
+
/**
* Creates presentable HTML for a browser
* *cannot be run from library, becaouse of filename
diff --git a/src/Statistics/WriteStats.js b/src/Statistics/WriteStats.js
index 25c1c85..edb92e6 100644
--- a/src/Statistics/WriteStats.js
+++ b/src/Statistics/WriteStats.js
@@ -2,13 +2,21 @@
* Creates statistics spreadsheet in user's google drive and generates data into it
*
* @param from from which day stats are going to be created
- * @param to to which day stats are going to be created
+ * @param to to which day stats are going to be created
+ * @param groups stats are going to be created only for this group if not empty
+ * @param groupHumanReadableName group name or an identifier for all groups
* @return {string} url of new spreadsheet
*/
-function createStatistics(from, to) {
- let spreadsheetData = Utils.extractAllSpreadsheetData(from, to); // can throw timeout
+function createStatistics(from, to, group, groupHumanReadableName) {
+ groupSet = null;
+ if (group != '') {
+ groupSet = new Set([group])
+ }
+
+ let spreadsheetData = Utils.extractAllSpreadsheetData(from, to, groupSet); // can throw timeout
const ss = Utils.createSpreadsheet({
- type: 'Statistika'
+ type: 'Statistika',
+ details: groupHumanReadableName
});
const clientsSheet = ss.getActiveSheet();
const clientsSheet2 = ss.insertSheet('Klienti Počet návštěv');
@@ -25,9 +33,9 @@ function createStatistics(from, to) {
return !eventsMap[item['event']];
});
- writeStats(spreadsheetData, clientsSheet, 'event', from, to, false);
- writeStats(spreadsheetData, clientsSheet2, 'event', from, to, true);
- writeStats(spreadsheetData, assistantsSheet, 'employee', from, to, false);
+ writeStats(spreadsheetData, clientsSheet, 'event', from, to, false, groupHumanReadableName);
+ writeStats(spreadsheetData, clientsSheet2, 'event', from, to, true, groupHumanReadableName);
+ writeStats(spreadsheetData, assistantsSheet, 'employee', from, to, false, groupHumanReadableName);
return ss.getUrl();
}
@@ -40,8 +48,9 @@ function createStatistics(from, to) {
* @param from from which data to write stats
* @param to to which data to write stats
* @param onlyCount measure occurences count instead of duration
+ * @param groupHumanReadableName group name or an identifier for all groups
*/
-function writeStats(spreadsheetData, sheet, type, from, to, onlyCount) {
+function writeStats(spreadsheetData, sheet, type, from, to, onlyCount, groupHumanReadableName) {
const months = Utils.getMonthsNames();
// stats = {
// "John": {
@@ -133,7 +142,7 @@ function writeStats(spreadsheetData, sheet, type, from, to, onlyCount) {
color: '#E2F3FF'
});
}
- writeToCell(sheet, sortedFoundNames.length + 8, 1, '* Statistika v časovém období: ' + Utils.getFormatedDate(from, true) + ' - ' + Utils.getFormatedDate(
+ writeToCell(sheet, sortedFoundNames.length + 8, 1, '* Statistika pro ' + groupHumanReadableName + ' v časovém období: ' + Utils.getFormatedDate(from, true) + ' - ' + Utils.getFormatedDate(
to, true));
}
diff --git a/src/Statistics/appsscript.json b/src/Statistics/appsscript.json
index 56d9438..6794902 100644
--- a/src/Statistics/appsscript.json
+++ b/src/Statistics/appsscript.json
@@ -5,7 +5,7 @@
{
"userSymbol": "Utils",
"libraryId": "1WquYtBor0ObwHMo1oIhKnCgboR5zBx2wjh5Hu-rbb0oSA5cY0d2PM6dZ",
- "version": 87
+ "version": 89
}
]
},
diff --git a/src/Statistics/main.html b/src/Statistics/main.html
index cd65eb4..cdb2f03 100644
--- a/src/Statistics/main.html
+++ b/src/Statistics/main.html
@@ -19,6 +19,14 @@
+
+
+
+
+
+
@@ -38,3 +46,4 @@
!= include('javascript'); ?>
+!= include('statistics-js'); ?>
diff --git a/src/Statistics/statistics-js.html b/src/Statistics/statistics-js.html
new file mode 100644
index 0000000..c5c66cd
--- /dev/null
+++ b/src/Statistics/statistics-js.html
@@ -0,0 +1,9 @@
+
+
diff --git a/src/TableScript/appsscript.json b/src/TableScript/appsscript.json
index 56d9438..6794902 100644
--- a/src/TableScript/appsscript.json
+++ b/src/TableScript/appsscript.json
@@ -5,7 +5,7 @@
{
"userSymbol": "Utils",
"libraryId": "1WquYtBor0ObwHMo1oIhKnCgboR5zBx2wjh5Hu-rbb0oSA5cY0d2PM6dZ",
- "version": 87
+ "version": 89
}
]
},
diff --git a/src/Update/appsscript.json b/src/Update/appsscript.json
index 56d9438..6794902 100644
--- a/src/Update/appsscript.json
+++ b/src/Update/appsscript.json
@@ -5,7 +5,7 @@
{
"userSymbol": "Utils",
"libraryId": "1WquYtBor0ObwHMo1oIhKnCgboR5zBx2wjh5Hu-rbb0oSA5cY0d2PM6dZ",
- "version": 87
+ "version": 89
}
]
},
diff --git a/src/Utils/SpreadSheet.js b/src/Utils/SpreadSheet.js
index 1825f88..388d945 100644
--- a/src/Utils/SpreadSheet.js
+++ b/src/Utils/SpreadSheet.js
@@ -14,7 +14,7 @@ function createSpreadsheet(obj) {
break;
case 'Statistika':
case 'Fakturace':
- filename = obj.type + '_' + getFormatedDate(new Date());
+ filename = obj.type + '_' + getFormatedDate(new Date()) + '_' + obj.details;
break;
default:
return;
@@ -41,15 +41,19 @@ function createSpreadsheet(obj) {
*
* @param from from which date to start extracting
* @param to to which date extract data
+ * @param groups to which groups to extract data from
* @return {Array} array of extracted data
*/
-function extractAllSpreadsheetData(from, to) {
+function extractAllSpreadsheetData(from, to, groups) {
const result = [];
const stopTimer = measureTime();
findFiles([], {
type: 'Rozpis'
}).filter(function(file) {
+ if (groups != null && !groups.has(file.group)) {
+ return false;
+ }
return isWeekWithinDates(from, to, file.year, file.week);
}).forEach(function(item) {
const ss = openSpreadsheet(item.id);