|
@@ -316,11 +316,10 @@ function addPracownikToGroup(event) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
var pracownicyIdsArray = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
|
|
|
- console.log(pracownicyIdsArray);
|
|
|
- if (pracownicyIdsArray === null) {
|
|
|
- showTextListIdPracownikow = 'ID pracowników: nie wybrano';
|
|
|
+ if (pracownicyIdsArray === null || !pracownicyIdsArray || !pracownicyIdsArray.length) {
|
|
|
+ showTextListIdPracownikow = 'nie wybrano pracowników';
|
|
|
} else {
|
|
|
- showTextListIdPracownikow = 'ID pracowników: ' + pracownicyIdsArray;
|
|
|
+ showTextListIdPracownikow = '' + pracownicyIdsArray.length + ' pracowników';
|
|
|
}
|
|
|
|
|
|
var arrayGroupOptions = [];
|
|
@@ -396,13 +395,7 @@ function addPracownikToGroup(event) {
|
|
|
function addPracownikAllToGroup(event) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
- var pracownicyIdsArray = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
|
|
|
- console.log(pracownicyIdsArray);
|
|
|
- if (pracownicyIdsArray === null) {
|
|
|
- showTextListIdPracownikow = 'ID pracowników: nie wybrano';
|
|
|
- } else {
|
|
|
- showTextListIdPracownikow = 'ID pracowników: ' + pracownicyIdsArray;
|
|
|
- }
|
|
|
+ var showTextListIdPracownikow = 'wszystkich pracowników pasujących do kryteriów wyszukiwania';
|
|
|
|
|
|
var arrayGroupOptions = [];
|
|
|
var listGroupStorage = getItemLocalStorage('Bocian.biAuditForm.pracownicy.groups');
|
|
@@ -424,11 +417,6 @@ function addPracownikAllToGroup(event) {
|
|
|
showLoaderOnConfirm: true,
|
|
|
preConfirm: function (idGroup) {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
- // if ( !pracownicyIdsArray || pracownicyIdsArray === null || pracownicyIdsArray === 'undefined' ) {
|
|
|
- // reject('Wybierz pracowników');
|
|
|
- // } else if ( pracownicyIdsArray.length === 0 ) {
|
|
|
- // reject('Wybierz pracowników');
|
|
|
- // }
|
|
|
if (!idGroup) {
|
|
|
reject('Proszę wybrać nazwę grupy');
|
|
|
return;
|
|
@@ -500,22 +488,20 @@ function addKontrahenciToGroup(event) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
var kontrahenciIdsArray = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
|
|
|
-
|
|
|
- if (kontrahenciIdsArray === null) {
|
|
|
- showTextListIdKontrahentow = 'ID kontrahentów: nie wybrano';
|
|
|
+ if (kontrahenciIdsArray === null || !kontrahenciIdsArray || !kontrahenciIdsArray.length) {
|
|
|
+ showTextListIdKontrahentow = 'nie wybrano kontrahentów';
|
|
|
} else {
|
|
|
- showTextListIdKontrahentow = 'ID kontrahentów: ' + kontrahenciIdsArray;
|
|
|
+ showTextListIdKontrahentow = '' + kontrahenciIdsArray.length + ' kontrahentów';
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- var arrayGroupOptions = [];
|
|
|
- var listGroupStorage = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.groups');
|
|
|
- // utworzenie tablicy Optionsów grupy
|
|
|
- listGroupStorage.map(function(item) {
|
|
|
- if (item.ID !== undefined) {
|
|
|
- arrayGroupOptions[item.ID] = item.NAZWA;
|
|
|
- }
|
|
|
- });
|
|
|
+ var arrayGroupOptions = [];
|
|
|
+ var listGroupStorage = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.groups');
|
|
|
+ // utworzenie tablicy Optionsów grupy
|
|
|
+ listGroupStorage.map(function(item) {
|
|
|
+ if (item.ID !== undefined) {
|
|
|
+ arrayGroupOptions[item.ID] = item.NAZWA;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
swal({
|
|
|
title: 'Dodaj do grupy',
|
|
@@ -529,11 +515,13 @@ function addKontrahenciToGroup(event) {
|
|
|
preConfirm: function (idGroup) {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
- if (!idGroup) reject('Proszę wybrać nazwę grupy');
|
|
|
- if ( !kontrahenciIdsArray || kontrahenciIdsArray === null || kontrahenciIdsArray === 'undefined' ) {
|
|
|
- reject('Wybierz kontrahentów');
|
|
|
- } else if ( kontrahenciIdsArray.length === 0 ) {
|
|
|
+ if (!idGroup) {
|
|
|
+ reject('Proszę wybrać nazwę grupy');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!kontrahenciIdsArray || !kontrahenciIdsArray.length) {
|
|
|
reject('Wybierz kontrahentów');
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
window.fetch(URL_ADD_KONTRAHENCI_TO_GROUP, {
|
|
@@ -575,6 +563,94 @@ function addKontrahenciToGroup(event) {
|
|
|
//TODO: PIOTRKU CZY TU POWINIENEM COŚ JESZCZE OBSŁUŻYĆ
|
|
|
});
|
|
|
}
|
|
|
+function addKontrahenciAllToGroup(event) {
|
|
|
+ event.preventDefault();
|
|
|
+
|
|
|
+ var kontrahenciIdsArray = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
|
|
|
+
|
|
|
+ var showTextListIdKontrahentow = 'wszystkich kontrahentów pasujących do kryteriów wyszukiwania';
|
|
|
+
|
|
|
+ var arrayGroupOptions = [];
|
|
|
+ var listGroupStorage = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.groups');
|
|
|
+ // utworzenie tablicy Optionsów grupy
|
|
|
+ listGroupStorage.map(function(item) {
|
|
|
+ if (item.ID !== undefined) {
|
|
|
+ arrayGroupOptions[item.ID] = item.NAZWA;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ swal({
|
|
|
+ title: 'Dodaj do grupy',
|
|
|
+ input: 'select',
|
|
|
+ text: showTextListIdKontrahentow,
|
|
|
+ inputOptions: arrayGroupOptions,
|
|
|
+ inputPlaceholder: 'Wybierz grupę',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonText: 'Zapisz',
|
|
|
+ showLoaderOnConfirm: true,
|
|
|
+ preConfirm: function (idGroup) {
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ if (!idGroup) {
|
|
|
+ reject('Proszę wybrać nazwę grupy');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var filterFields = {}
|
|
|
+ var frm = document.getElementById('filtersFieldRemoveBtn-KONTRAHENCI').form
|
|
|
+ var fieldNameList = FIELD_LIST_KONTRAHENCI
|
|
|
+ fieldNameList.filter(function (fieldName) {
|
|
|
+ if (!frm[fieldName]) console.log('Err missing field: "'+fieldName+'"')
|
|
|
+ return (frm[fieldName]) ? true : false
|
|
|
+ }).map(function (fieldName) {
|
|
|
+ return [ fieldName, frm[fieldName].value ]
|
|
|
+ }).filter(function (filter) {
|
|
|
+ return ( filter[1].length > 0 )
|
|
|
+ }).map(function (filter) {
|
|
|
+ filterFields[ filter[0] ] = filter[1]
|
|
|
+ })
|
|
|
+ var filterIdGroup = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup');
|
|
|
+ if (filterIdGroup) filterFields[ 'filterIdGroup' ] = filterIdGroup
|
|
|
+
|
|
|
+ window.fetch(URL_ADD_KONTRAHENCI_TO_GROUP, {
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'contentType': 'applications/json'
|
|
|
+ },
|
|
|
+ credentials: 'same-origin',
|
|
|
+ body: JSON.stringify({
|
|
|
+ 'idGroup': idGroup,
|
|
|
+ 'type': 'filter',
|
|
|
+ 'filter': filterFields,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .then(function(response) {
|
|
|
+ return response.text();
|
|
|
+ })
|
|
|
+ .then(function(responseText) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ return JSON.parse(responseText);
|
|
|
+ } catch (e) {
|
|
|
+ throw responseText;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(function(result) {
|
|
|
+
|
|
|
+ if (result.type == 'success') {
|
|
|
+ p5UI__notifyAjaxCallback(result);
|
|
|
+ resolve(result.msg);
|
|
|
+ } else {
|
|
|
+ reject(result.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(function(error) {
|
|
|
+ console.log('request failed', error)
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ allowOutsideClick: false
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
|
|
|
function createGroupKontrahenci(event) {
|
|
@@ -1920,6 +1996,7 @@ global.removeItemArrayInArray = removeItemArrayInArray;
|
|
|
global.addPracownikToGroup = addPracownikToGroup;
|
|
|
global.addPracownikAllToGroup = addPracownikAllToGroup;
|
|
|
global.addKontrahenciToGroup = addKontrahenciToGroup;
|
|
|
+global.addKontrahenciAllToGroup = addKontrahenciAllToGroup;
|
|
|
|
|
|
global.showViewUploadFile = showViewUploadFile;
|
|
|
global.parseCsvFile = parseCsvFile;
|