|
@@ -1,42 +1,20 @@
|
|
|
+console.log('test1... DBG:', DBG)
|
|
|
|
|
|
-if (!BASE_URLS) {
|
|
|
- throw "Brak BASE_URLS"
|
|
|
+// localStorage.setItem('Bocian.pracownicyIds', JSON.stringify(ids))
|
|
|
+// var ids = localStorage.getItem('Bocian.pracownicyIds')
|
|
|
+// localStorage.removeItem('Bocian.pracownicyIds')
|
|
|
+// localStorage.removeItem('Bocian.kontrahenciIds')
|
|
|
+// localStorage.removeItem('Bocian.depth') // TODO: zapis na stronie głównej i BiAuditRaport
|
|
|
+
|
|
|
+if (!URL_FETCH_TEST) {
|
|
|
+ throw "Brak zmiennej URL_FETCH_TEST"
|
|
|
}
|
|
|
-console.log('BASE_URLS',BASE_URLS);
|
|
|
|
|
|
$(window).on('hashchange', function() {
|
|
|
initLocalStorage();
|
|
|
rootChangeForm();
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-/* DATA FOR READ REAPORT */
|
|
|
-
|
|
|
-function urlFetchKontrahenciPowiazania() {
|
|
|
- // Documentation: https://github.com/github/fetch
|
|
|
- fetch(URL_FETCH_KONTRAHENCI_POWIAZANIA, {
|
|
|
- credentials: 'same-origin'
|
|
|
- })
|
|
|
- .then(function parseJSON(response) {
|
|
|
- return response.json()
|
|
|
- })
|
|
|
- .then(function(data) {
|
|
|
-
|
|
|
- var reaportItemsKontrahenciPowiazani = null;
|
|
|
- data.body.items.forEach (function(row) {
|
|
|
- reaportItemsKontrahenciPowiazani += '<tr><td><input type="checkbox" name="kontrID[]" value="'+row['ID']+'" /></td>'+
|
|
|
- '<td align="right">'+row["ID"]+'</td>';
|
|
|
- });
|
|
|
-
|
|
|
- $( "#body-reaport-kontrahenci-powiazani-tree" ).html(reaportItemsKontrahenciPowiazani);
|
|
|
-
|
|
|
- }).catch(function(error) {
|
|
|
- console.log('request failed', error)
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/* FORM DATA FOR GENERATAE REAPORT */
|
|
|
function loadCurrentDepthInInput(idInput) {
|
|
|
var depthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
|
|
@@ -98,141 +76,6 @@ function initLocalStorage() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Funkcja pozwala na wyświetlenie okienka importu
|
|
|
- */
|
|
|
-function showViewUploadFile( event, headerTitle, enumType, showCheckbox, csvFileExample ) {
|
|
|
- event.preventDefault();
|
|
|
-
|
|
|
- var enumType = enumType;
|
|
|
-
|
|
|
- if( csvFileExample !== undefined) { // przykład + instrukcja do pobrania
|
|
|
- csvFileExample = '<div><a href="'+csvFileExample+'" title="Pobierz przykład" download target="_balnk">Pobierz przykład</a></div>';
|
|
|
- }
|
|
|
-
|
|
|
- swal({
|
|
|
- title: 'Importuj plik csv',
|
|
|
- input: 'file',
|
|
|
- html: csvFileExample,
|
|
|
- inputAttributes: {
|
|
|
- 'accept': 'text/csv',
|
|
|
- 'aria-label': 'Upload csv file'
|
|
|
- },
|
|
|
- confirmButtonText: 'Importuj',
|
|
|
- preConfirm: function (file) {
|
|
|
- return new Promise(function (resolve, reject) {
|
|
|
- if (!file) {
|
|
|
- reject("Proszę wybrać plik csv");
|
|
|
- return
|
|
|
- }
|
|
|
- var input = document.querySelector('input[type="file"]');
|
|
|
-
|
|
|
- var data = new FormData()
|
|
|
- data.append('file', input.files[0])
|
|
|
- data.append('showCheckbox', showCheckbox);
|
|
|
-
|
|
|
- var responseParseFile = parseCsvFile( data, enumType );
|
|
|
- resolve('file imported')
|
|
|
- })
|
|
|
- },
|
|
|
- }).then(function (result) {
|
|
|
- console.log('result', result)
|
|
|
- }).catch(function (e) {
|
|
|
- console.log('catch: ', e)
|
|
|
- });
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Funkcja przekazuje dane z pliku csv do przeparsowania
|
|
|
- */
|
|
|
-function parseCsvFile( fileData, enumType ) {
|
|
|
- event.preventDefault();
|
|
|
-
|
|
|
-console.log( 'parseCsvFile fileData', fileData);
|
|
|
-
|
|
|
- fetch(URL_FORM_DATA_CSV_FILE_AJAX, {
|
|
|
- method: 'POST',
|
|
|
- credentials: 'same-origin',
|
|
|
- body: fileData
|
|
|
- })
|
|
|
- .then(function(response) {
|
|
|
- return response.json()
|
|
|
- }).then(function(json) {
|
|
|
-
|
|
|
- swal({
|
|
|
- title: 'Dane załadowane z pliku CSV',
|
|
|
- html: json.body.view,
|
|
|
- width: Math.round(window.innerWidth * 0.9),
|
|
|
- allowOutsideClick: false, // TODO: btn Anuluj na dole?
|
|
|
- showCloseButton: true,
|
|
|
- confirmButtonText: 'Zapisz',
|
|
|
- preConfirm: function (dataForm) {
|
|
|
- return new Promise(function (resolve, reject) {
|
|
|
- if (!dataForm) {
|
|
|
- reject("Formularz nie zawiera danych do zapisania");
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // zapisanie danych
|
|
|
- var responseSaveData = saveFormCsvFileAjaxAction(enumType);
|
|
|
- resolve('data save from form')
|
|
|
- })
|
|
|
- },
|
|
|
- }).then(function (result) {
|
|
|
-
|
|
|
- console.log('result', result)
|
|
|
- }).catch(function (e) {
|
|
|
- console.log('catch: ', e)
|
|
|
- });
|
|
|
-
|
|
|
- }).catch(function(ex) {
|
|
|
- console.log('parsing failed', ex)
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Funkcja zapisuje dane z formularza do wgrania pliku csv
|
|
|
- */
|
|
|
-function saveFormCsvFileAjaxAction(enumType) {
|
|
|
- event.preventDefault();
|
|
|
-
|
|
|
- var formDataFrom = $("#formDataFromCsv").serialize();
|
|
|
-
|
|
|
- formDataFrom = formDataFrom.replace(/%5B/g,"[");
|
|
|
- formDataFrom = formDataFrom.replace(/%5D/g,"]");
|
|
|
-
|
|
|
-//var formDataFrom = $("#formDataFromCsv").serializeArray();
|
|
|
-console.log('dane z formularza formDataFrom ', formDataFrom );
|
|
|
-
|
|
|
- fetch(URL_SAVE_FORM_CSV_FILE_AJAX, {
|
|
|
- method: 'POST',
|
|
|
- credentials: 'same-origin',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- formData: formDataFrom,
|
|
|
- enumType: enumType
|
|
|
- })
|
|
|
- })
|
|
|
- .then(function(response) {
|
|
|
- return response.json()
|
|
|
- }).then(function(json) {
|
|
|
- console.log('parsed json', json)
|
|
|
-
|
|
|
- if (response.type == 'success') {
|
|
|
-
|
|
|
- p5UI__notifyAjaxCallback(response.msg);
|
|
|
- }
|
|
|
-
|
|
|
- // return json;
|
|
|
- }).catch(function(ex) {
|
|
|
- console.log('parsing failed', ex)
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
function defaultBIAuditLocalStorage() {
|
|
|
localStorage.removeItem('Bocian.biAuditForm.pracownicyIds');
|
|
@@ -244,8 +87,6 @@ function defaultBIAuditLocalStorage() {
|
|
|
setItemLocalStorage('Bocian.biAuditForm.depth', 2);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
function generateBiAuditRaport(event) {
|
|
|
event.preventDefault();
|
|
|
|
|
@@ -286,12 +127,12 @@ function generateBiAuditRaport(event) {
|
|
|
}
|
|
|
})
|
|
|
.then(function(result) {
|
|
|
-
|
|
|
+ result
|
|
|
if (result.type == 'success') {
|
|
|
|
|
|
p5UI__notifyAjaxCallback(result);
|
|
|
defaultBIAuditLocalStorage();
|
|
|
- window.setTimeout(window.location.href = "/SE/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA", 6000);
|
|
|
+ window.setTimeout(window.location.href = "https://bravecom.yellowgroup.pl/SE/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA", 4000);
|
|
|
resolve(result.msg);
|
|
|
|
|
|
} else {
|
|
@@ -304,42 +145,29 @@ function generateBiAuditRaport(event) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/**
|
|
|
- * Popup z opcja przeniesienia pracowników do innej grupy
|
|
|
- */
|
|
|
function addPracownikToGroup(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 arrayGroupOptions = [];
|
|
|
- var listGroupStorage = getItemLocalStorage('Bocian.biAuditForm.pracownicy.groups');
|
|
|
- // utworzenie tablicy Optionsów grupy
|
|
|
- listGroupStorage.map(function(item) {
|
|
|
- if (item.ID !== undefined) {
|
|
|
- arrayGroupOptions[item.ID] = item.NAZWA;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
swal({
|
|
|
title: 'Przenieś do grupy',
|
|
|
input: 'select',
|
|
|
text: showTextListIdPracownikow,
|
|
|
- inputOptions: arrayGroupOptions,
|
|
|
+ inputOptions: getItemLocalStorage('Bocian.biAuditForm.pracownicy.groups'),
|
|
|
inputPlaceholder: 'Wybierz grupę',
|
|
|
showCancelButton: true,
|
|
|
confirmButtonText: 'Zapisz',
|
|
|
showLoaderOnConfirm: true,
|
|
|
preConfirm: function (idGroup) {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
- console.log('idGrupy value', idGroup);
|
|
|
+ console.log('value', idGroup);
|
|
|
|
|
|
if ( !pracownicyIdsArray || pracownicyIdsArray === null || pracownicyIdsArray === 'undefined' ) {
|
|
|
reject('Wybierz pracowników');
|
|
@@ -371,7 +199,7 @@ function addPracownikToGroup(event) {
|
|
|
}
|
|
|
})
|
|
|
.then(function(result) {
|
|
|
-
|
|
|
+ result
|
|
|
if (result.type == 'success') {
|
|
|
p5UI__notifyAjaxCallback(result);
|
|
|
resolve(result.msg);
|
|
@@ -390,35 +218,22 @@ function addPracownikToGroup(event) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Popup z opcja przeniesienia kontrahentów do innej grupy
|
|
|
- */
|
|
|
function addKontrahenciToGroup(event) {
|
|
|
event.preventDefault();
|
|
|
|
|
|
var kontrahenciIdsArray = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
|
|
|
|
|
|
if (kontrahenciIdsArray === null) {
|
|
|
- showTextListIdKontrahentow = 'ID kontrahentów: nie wybrano';
|
|
|
+ showTextListIdKontrahentow = 'ID pracowników: nie wybrano';
|
|
|
} else {
|
|
|
- showTextListIdKontrahentow = 'ID kontrahentów: ' + kontrahenciIdsArray;
|
|
|
+ showTextListIdKontrahentow = 'ID pracowników: ' + pracownicyIdsArray;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- 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: 'Przenieś do grupy',
|
|
|
input: 'select',
|
|
|
text: showTextListIdKontrahentow,
|
|
|
- inputOptions: arrayGroupOptions,
|
|
|
+ inputOptions: getItemLocalStorage('Bocian.biAuditForm.kontrahenci.groups'),
|
|
|
inputPlaceholder: 'Wybierz grupę',
|
|
|
showCancelButton: true,
|
|
|
confirmButtonText: 'Zapisz',
|
|
@@ -469,7 +284,7 @@ function addKontrahenciToGroup(event) {
|
|
|
},
|
|
|
allowOutsideClick: false
|
|
|
}).then(function (groupKontrahenciData) {
|
|
|
- //TODO: PIOTRKU CZY TU POWINIENEM COŚ JESZCZE OBSŁUŻYĆ
|
|
|
+ //TODO: pIOTRKU CZY TU POWINIENEM COŚ JESZCZE OBSŁUŻYĆ
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -509,24 +324,21 @@ function createGroupKontrahenci(event) {
|
|
|
}
|
|
|
})
|
|
|
.then(function(result) {
|
|
|
-
|
|
|
+ result
|
|
|
if (result.type == 'success') {
|
|
|
- p5UI__notifyAjaxCallback(result);
|
|
|
- resolve(result.body);
|
|
|
+ p5UI_notifyAjaxCallback(result);
|
|
|
+ resolve(result.msg);
|
|
|
} else {
|
|
|
-
|
|
|
- reject("Proszę podać inną nazwę grupy");
|
|
|
+ reject(result.msg);
|
|
|
}
|
|
|
})
|
|
|
- .catch(function(error) {
|
|
|
- console.log('request failed', error)
|
|
|
- })
|
|
|
+ ;
|
|
|
})
|
|
|
},
|
|
|
allowOutsideClick: false
|
|
|
}).then(function (groupKontrahenciData) {
|
|
|
//TODO: aktualizacja fitrów na widoku -> SPrawdzić co dostaniemy w odpowiedzi po dodaniu filtra grupy
|
|
|
- groupsKontrahenci = '<button class="btn btn-default" title="'+groupKontrahenciData['nazwa']+'" data-group-filter="'+groupKontrahenciData['id']+'">'+groupKontrahenciData['nazwa']+'</button>';
|
|
|
+ groupsKontrahenci = '<button class="btn btn-default" title="'+groupKontrahenciData['NAZWA']+'" data-group-filter="'+groupKontrahenciData['ID']+'">'+groupKontrahenciData['NAZWA']+'</button>';
|
|
|
$('#group-kontrahenci').append(groupsKontrahenci);
|
|
|
});
|
|
|
|
|
@@ -567,15 +379,15 @@ function createGroupPracownicy(event) {
|
|
|
}
|
|
|
})
|
|
|
.then(function(result) {
|
|
|
-
|
|
|
+ result
|
|
|
if (result.type == 'success') {
|
|
|
- p5UI__notifyAjaxCallback(result);
|
|
|
+ p5UI_notifyAjaxCallback(result);
|
|
|
resolve(result.msg);
|
|
|
} else {
|
|
|
reject(result.msg);
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
+ })
|
|
|
+ ;
|
|
|
})
|
|
|
},
|
|
|
allowOutsideClick: false
|
|
@@ -588,13 +400,48 @@ function createGroupPracownicy(event) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+// // Documentation: https://github.com/github/fetch
|
|
|
+// fetch(URL_FETCH_TEST, {
|
|
|
+// credentials: 'same-origin'
|
|
|
+// })
|
|
|
+// .then(function parseJSON(response) {
|
|
|
+// return response.json()
|
|
|
+// })
|
|
|
+// .then(function(data) {
|
|
|
+// //$( ".container" ).append( data.body.view );
|
|
|
+// console.log('request succeeded with JSON response', data)
|
|
|
+// }).catch(function(error) {
|
|
|
+// console.log('request failed', error)
|
|
|
+// })
|
|
|
+//
|
|
|
+// fetch(URL_FETCH_TEST_KRS, {
|
|
|
+// credentials: 'same-origin'
|
|
|
+// })
|
|
|
+// .then(function parseJSON(response) {
|
|
|
+// return response.json()
|
|
|
+// })
|
|
|
+// .then(function(data) {
|
|
|
+// console.log('request succeeded with JSON response', data)
|
|
|
+// }).catch(function(error) {
|
|
|
+// console.log('request failed', error)
|
|
|
+// })
|
|
|
+//
|
|
|
+// fetch(URL_FETCH_TEST_CEIDG, {
|
|
|
+// credentials: 'same-origin'
|
|
|
+// })
|
|
|
+// .then(function parseJSON(response) {
|
|
|
+// return response.json()
|
|
|
+// })
|
|
|
+// .then(function(data) {
|
|
|
+// console.log('request succeeded with JSON response', data)
|
|
|
+// }).catch(function(error) {
|
|
|
+// console.log('request failed', error)
|
|
|
+// })
|
|
|
|
|
|
function rootChangeForm() {
|
|
|
-//todo: do przeniesienia
|
|
|
-urlFetchKontrahenciPowiazania();
|
|
|
+
|
|
|
var valueUrl = global.location.hash;
|
|
|
|
|
|
-console.log('URL', valueUrl);
|
|
|
switch (valueUrl) {
|
|
|
case '#KONTRAHENCI':
|
|
|
$( ".container-bi_audit_form_kontrahenci_raport" ).html( VIEW_KONTRAHENCI );
|
|
@@ -605,25 +452,17 @@ console.log('URL', valueUrl);
|
|
|
break;
|
|
|
|
|
|
case '#PRACOWNICY':
|
|
|
- $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
|
|
|
+ $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
|
|
|
urlFetchPracownicy(1);
|
|
|
- fetchGroupPracownicy();
|
|
|
+ fetchGroupPracownicy()
|
|
|
$( ".container-bi_audit_form_kontrahenci_raport" ).hide();
|
|
|
$( ".container-bi_audit_form_pracownicy_raport" ).show();
|
|
|
break;
|
|
|
|
|
|
- // case '#REAPORT':
|
|
|
- // $( ".container-bi_audit_form_raport_data" ).html( VIEW_TREE_REAPORT );
|
|
|
- // urlFetchKontrahenciPowiazania();
|
|
|
- // $( ".container-bi_audit_form_kontrahenci_raport" ).hide();
|
|
|
- // $( ".container-bi_audit_form_pracownicy_raport" ).hide();
|
|
|
- // $( ".container-bi_audit_form_raport_data" ).show();
|
|
|
- // break;
|
|
|
-
|
|
|
default:
|
|
|
- $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
|
|
|
+ $( ".container-bi_audit_form_pracownicy_raport" ).html( VIEW_PRACOWNICY );
|
|
|
urlFetchPracownicy(1);
|
|
|
- fetchGroupPracownicy();
|
|
|
+ fetchGroupPracownicy()
|
|
|
$( ".container-bi_audit_form_kontrahenci_raport" ).hide();
|
|
|
$( ".container-bi_audit_form_pracownicy_raport" ).show();
|
|
|
break;
|
|
@@ -657,29 +496,6 @@ function getAddressData(objectValue) {
|
|
|
return listData;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/**
|
|
|
- * Get name name group
|
|
|
- */
|
|
|
-function getNameGroupById(store, filterIdGroup) {
|
|
|
-
|
|
|
- var NAZWA = '';
|
|
|
- if (!store || filterIdGroup === 0 ) {
|
|
|
- NAZWA = 'Wszyscy';
|
|
|
- } else {
|
|
|
-
|
|
|
- $(store).each(function() {
|
|
|
- if ( parseInt(filterIdGroup) === parseInt(this.ID) ) {
|
|
|
- NAZWA = this.NAZWA;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return NAZWA;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
function urlFetchKontrahenci(page) {
|
|
|
var page = page || getItemLocalStorage('Bocian.biAuditForm.kontrahenci.pagination.page');
|
|
|
|
|
@@ -700,7 +516,6 @@ function urlFetchKontrahenci(page) {
|
|
|
})
|
|
|
.then(function(data) {
|
|
|
|
|
|
-
|
|
|
var listItemsKontrahenci = null;
|
|
|
data.body.items.forEach (function(row) {
|
|
|
listItemsKontrahenci += '<tr><td><input type="checkbox" name="kontrID[]" value="'+row['ID']+'" /></td>'+
|
|
@@ -738,30 +553,17 @@ function urlFetchKontrahenci(page) {
|
|
|
|
|
|
if (data.body.pagination !== undefined) {
|
|
|
Pagination.Init(document.getElementById('pagination-kontrahenci'), {
|
|
|
- url: BASE_URLS+'index.php?_route=UrlAction_Bocian#KONTRAHENCI',
|
|
|
+ url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_Bocian#KONTRAHENCI',
|
|
|
id_pagination: 'pagination-kontrahenci',
|
|
|
type: 'KONTRAHENCI',
|
|
|
- limit: data.body.pagination.limit,
|
|
|
total_items: data.body.pagination.total_items, // pages size
|
|
|
size: data.body.pagination.size, // pages size
|
|
|
page: page, // selected page
|
|
|
step: 1 // pages before and after current
|
|
|
});
|
|
|
|
|
|
- var paginationShowNextCount = 1;
|
|
|
- if ( parseInt(data.body.pagination.current) !== 1) {
|
|
|
- paginationShowNextCount = parseInt(data.body.pagination.limit) * (parseInt(data.body.pagination.current) - 1 ) + 1;
|
|
|
- }
|
|
|
- $('#paginationShowNextCount-KONTRAHENCI').text(paginationShowNextCount);
|
|
|
- $('#smad-filter-desc-kontrahenci').text(data.body.pagination.total_items);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- var groupSelectData = getNameGroupById(getItemLocalStorage('Bocian.biAuditForm.kontrahenci.groups'), filterIdGroup);
|
|
|
- $('#smad-filter-head-title-kontrahenci').text(groupSelectData);
|
|
|
- console.log('kontrahenci groupSelectData: ', groupSelectData);
|
|
|
-
|
|
|
-
|
|
|
$( "#body-kontrahenci" ).html(listItemsKontrahenci);
|
|
|
checkAll('KONTRAHENCI');
|
|
|
catchEventCheckbox('KONTRAHENCI');
|
|
@@ -823,35 +625,23 @@ function urlFetchPracownicy(page) {
|
|
|
|
|
|
if (data.body.pagination.size) {
|
|
|
Pagination.Init(document.getElementById('pagination-pracownicy'), {
|
|
|
- url: BASE_URLS+'index.php?_route=UrlAction_Bocian#PRACOWNICY',
|
|
|
+ url: 'https://bravecom.yellowgroup.pl/SE/index.php?_route=UrlAction_Bocian#PRACOWNICY',
|
|
|
id_pagination: 'pagination-pracownicy',
|
|
|
type: 'PRACOWNICY',
|
|
|
- limit: data.body.pagination.limit,
|
|
|
total_items: data.body.pagination.total_items, // pages size
|
|
|
size: data.body.pagination.size, // pages size
|
|
|
page: data.body.pagination.current, // selected page
|
|
|
step: 1 // pages before and after current
|
|
|
});
|
|
|
-
|
|
|
- var paginationShowNextCount = 1;
|
|
|
- if ( parseInt(data.body.pagination.current) !== 1) {
|
|
|
- paginationShowNextCount = parseInt(data.body.pagination.limit) * (parseInt(data.body.pagination.current) - 1 ) + 1;
|
|
|
- }
|
|
|
- $('#paginationShowNextCount-PRACOWNICY').text(paginationShowNextCount);
|
|
|
- $('#smad-filter-desc-pracownicy').text(data.body.pagination.total_items);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // wyświetlenie wybranej grupy w naglówku nad tabela
|
|
|
- var groupSelectData = getNameGroupById(getItemLocalStorage('Bocian.biAuditForm.pracownicy.groups'), filterIdGroup);
|
|
|
- $('#smad-filter-head-title-pracownicy').text(groupSelectData);
|
|
|
-
|
|
|
- // zaladaowanie listy pracowników
|
|
|
$( "#body-pracownicy" ).html( listItemsPracownik);
|
|
|
checkAll('PRACOWNICY');
|
|
|
catchEventCheckbox('PRACOWNICY');
|
|
|
checkedChoiseItems('PRACOWNICY', getItemLocalStorage('Bocian.biAuditForm.pracownicyIds') );
|
|
|
|
|
|
+ // $( ".container-bi_audit_raport" ).append( data.body.view );
|
|
|
+ console.log('request succeeded with JSON responsePRACOWNICY', data)
|
|
|
}).catch(function(error) {
|
|
|
console.log('request failed', error)
|
|
|
})
|
|
@@ -902,9 +692,6 @@ function checkAll(type) {
|
|
|
|
|
|
deleteListIdBiAuditReaport(type, allValsUnChecked);
|
|
|
}
|
|
|
-
|
|
|
- // update count selected IDs
|
|
|
- updateCountItemCheckedByType(type.toLowerCase());
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -913,18 +700,11 @@ function checkAll(type) {
|
|
|
*/
|
|
|
function checkedChoiseItems(type, store) {
|
|
|
|
|
|
- updateCountItemCheckedByType(type.toLowerCase());
|
|
|
-
|
|
|
var idElement = 'smad-table-' + type;
|
|
|
|
|
|
// if id element exist
|
|
|
if (document.getElementById(idElement)) {
|
|
|
|
|
|
- // if not checked
|
|
|
- if (!store) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
// checked again if user selected Item (pracownicy/kontrahent)
|
|
|
for (i = 0; i < store.length; i++) {
|
|
|
$('#body-'+type.toLowerCase() +' input[type=checkbox] ').map(function(k, v) {
|
|
@@ -936,6 +716,7 @@ function checkedChoiseItems(type, store) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //$('#checkAll-' + type).on('bind', function() {
|
|
|
$('#smad-table-' + type + ' input[type=checkbox]').on( 'load', function() {
|
|
|
var itemsCHecked = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
|
|
|
|
|
@@ -971,10 +752,12 @@ function checkedChoiseItems(type, store) {
|
|
|
|
|
|
deleteListIdBiAuditReaport(type, allValsUnChecked);
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
function catchEventCheckbox(type) {
|
|
|
|
|
|
$('#smad-table-' + type + ' input[type="checkbox"]').on('change', function() {
|
|
@@ -994,9 +777,6 @@ function catchEventCheckbox(type) {
|
|
|
|
|
|
deleteListIdBiAuditReaport(type, allValsUnChecke);
|
|
|
}
|
|
|
-
|
|
|
- // update count selected IDs
|
|
|
- updateCountItemCheckedByType(type.toLowerCase());
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -1071,11 +851,6 @@ function fetchGroupPracownicy() {
|
|
|
}
|
|
|
|
|
|
var filterIdGroup = getItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup');
|
|
|
- var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup', filterIdGroup);
|
|
|
-
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
|
|
|
-
|
|
|
var groupsPracownicy = '';
|
|
|
var activeButton = '';
|
|
|
|
|
@@ -1085,10 +860,8 @@ function fetchGroupPracownicy() {
|
|
|
});
|
|
|
|
|
|
$("#group-pracownicy").append(groupsPracownicy);
|
|
|
- updateCountItemCheckedByType('pracownicy');
|
|
|
|
|
|
- // detect filter group
|
|
|
- detectChoiseFilter();
|
|
|
+ console.log('request succeeded with JSON fetchGroupPracownicy', data.body.itmesGroupPracownicy)
|
|
|
}).catch(function(error) {
|
|
|
console.log('request failed', error)
|
|
|
});
|
|
@@ -1110,11 +883,6 @@ function fetchGroupKontrahenci() {
|
|
|
}
|
|
|
|
|
|
var filterIdGroup = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup');
|
|
|
- var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup', filterIdGroup);
|
|
|
-
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
|
|
|
-
|
|
|
var groupsKontrahenci = '';
|
|
|
var activeButton = '';
|
|
|
|
|
@@ -1124,17 +892,13 @@ function fetchGroupKontrahenci() {
|
|
|
});
|
|
|
|
|
|
$("#group-kontrahenci").append(groupsKontrahenci);
|
|
|
- updateCountItemCheckedByType('kontrahenci');
|
|
|
|
|
|
- // detect filter group
|
|
|
- detectChoiseFilter();
|
|
|
console.log('request succeeded with JSON fetchGroupKontrahenci', data.body.itemsGroupKontrahenci);
|
|
|
}).catch(function(error) {
|
|
|
console.log('request failed', error)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function detectChoiseFilter() {
|
|
|
|
|
|
$('#group-kontrahenci').on('click', 'button', function(evt) {
|
|
@@ -1144,13 +908,6 @@ function detectChoiseFilter() {
|
|
|
|
|
|
// pobranie id grupy kliknietego buttonu
|
|
|
var filterIdGroup = $(this).attr("data-group-filter");
|
|
|
- // aktaulna wartość zagłebienia
|
|
|
- var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
- //reset LocalStorage
|
|
|
- defaultBIAuditLocalStorage();
|
|
|
- // ustawienie ostaniej wartości zagłebienia przed resete
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
|
|
|
-
|
|
|
// ustawić id grupy do sesyjnej
|
|
|
setItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup', parseInt(filterIdGroup));
|
|
|
// wywylac funckje pobrania danych
|
|
@@ -1164,13 +921,6 @@ function detectChoiseFilter() {
|
|
|
|
|
|
// pobranie id grupy kliknietego buttonu
|
|
|
var filterIdGroup = $(this).attr("data-group-filter");
|
|
|
- // aktaulna wartość zagłebienia
|
|
|
- var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
- //reset LocalStorage
|
|
|
- defaultBIAuditLocalStorage();
|
|
|
- // ustawienie ostaniej wartości zagłebienia przed resete
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
|
|
|
-
|
|
|
// ustawić id grupy do sesyjnej
|
|
|
setItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup', parseInt(filterIdGroup));
|
|
|
// wywylac funckje pobrania danych
|
|
@@ -1221,7 +971,6 @@ function removeItemInArray(arr, item) {
|
|
|
* item - array list items
|
|
|
*/
|
|
|
function removeItemArrayInArray(arr, itemsArray) {
|
|
|
-
|
|
|
for(var i = arr.length; i--;) {
|
|
|
for(var j = itemsArray.length; j--;) {
|
|
|
if(arr[i] === itemsArray[j]) {
|
|
@@ -1233,58 +982,6 @@ function removeItemArrayInArray(arr, itemsArray) {
|
|
|
return arr;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Cleart list local storage by type
|
|
|
- * typeNameLocalStorage - name (praconwicy/kontrahenci)
|
|
|
- */
|
|
|
-function clearListLocalStorageByType(typeNameLocalStorage) {
|
|
|
-
|
|
|
- if (typeNameLocalStorage === 'pracownicy') {
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.pracownicyIds', []);
|
|
|
- }
|
|
|
-
|
|
|
- if (typeNameLocalStorage === 'kontrahenci') {
|
|
|
- setItemLocalStorage('Bocian.biAuditForm.kontrahenciIds', []);
|
|
|
-
|
|
|
- }
|
|
|
- // update count selected item
|
|
|
- updateCountItemCheckedByType(typeNameLocalStorage);
|
|
|
- // unchecked checkbox
|
|
|
- $('#smad-table-'+typeNameLocalStorage.toUpperCase()+' form').find(':checkbox').prop('checked', false);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Update count selected pracowniyc/kontrahenci
|
|
|
- */
|
|
|
-function updateCountItemCheckedByType(typeNameLocalStorage) {
|
|
|
- var countId = 0;
|
|
|
-
|
|
|
- if (typeNameLocalStorage === 'pracownicy') {
|
|
|
- var countPracownicy = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
|
|
|
-
|
|
|
- if (countPracownicy !== null || countPracownicy !== undefined) {
|
|
|
- return countId;
|
|
|
- }
|
|
|
-
|
|
|
- countId = Object.keys(countPracownicy).length;
|
|
|
- $('#count-selected-item-pracownicy').text(countId);
|
|
|
- }
|
|
|
-
|
|
|
- if (typeNameLocalStorage === 'kontrahenci') {
|
|
|
- var countKontrahenci = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
|
|
|
-
|
|
|
-
|
|
|
- if (countKontrahenci !== null || countKontrahenci !== undefined) {
|
|
|
- return countId;
|
|
|
- }
|
|
|
-
|
|
|
- countId = Object.keys(countKontrahenci).length;
|
|
|
- $('#count-selected-item-kontrahenci').text(countId);
|
|
|
- }
|
|
|
-
|
|
|
- return countId;
|
|
|
-}
|
|
|
-
|
|
|
// Pagination
|
|
|
var Pagination = {
|
|
|
|
|
@@ -1300,7 +997,6 @@ var Pagination = {
|
|
|
Pagination.url = data.url;
|
|
|
Pagination.id_pagination = data.id_pagination;
|
|
|
Pagination.type = data.type;
|
|
|
- Pagination.limit = data.limit;
|
|
|
Pagination.total_items = data.total_items;
|
|
|
Pagination.size = data.size || 2;
|
|
|
Pagination.page = data.page || 1;
|
|
@@ -1408,15 +1104,9 @@ var Pagination = {
|
|
|
Pagination.Bind();
|
|
|
},
|
|
|
|
|
|
-
|
|
|
// find pagination type
|
|
|
Start: function() {
|
|
|
- Pagination.code = '';
|
|
|
- if ( Pagination.type === 'KONTRAHENCI' ) {
|
|
|
- Pagination.code = '<div class="foot-info tblAjax__footer__toolbar__info footer_pagination_menu_items"><p>Wiersze od <span id="paginationShowNextCount-KONTRAHENCI"></span> do ' + Pagination.total_items + ' z ' + Pagination.total_items + '</p></div>';
|
|
|
- } else if ( Pagination.type === 'PRACOWNICY' ) {
|
|
|
- Pagination.code = '<div class="foot-info tblAjax__footer__toolbar__info footer_pagination_menu_items"><p>Wiersze od <span id="paginationShowNextCount-PRACOWNICY"></span> do ' + Pagination.total_items + ' z ' + Pagination.total_items + '</p></div>';
|
|
|
- }
|
|
|
+ Pagination.code = '<div class="foot-info tblAjax__footer__toolbar__info footer_pagination_menu_items"><p>Wiersze od 1 do ' + Pagination.total_items + ' z ' + Pagination.total_items + '</p></div>';
|
|
|
Pagination.code += '<nav aria-label="Page navigation" class="footer_pagination_menu_items"><ul class="btn-group tblAjax__footer__toolbar__pagination smad-pagination">';
|
|
|
Pagination.First();
|
|
|
Pagination.Prev();
|
|
@@ -1425,7 +1115,7 @@ var Pagination = {
|
|
|
if ( Pagination.type === 'KONTRAHENCI' ) {
|
|
|
Pagination.page = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.pagination.page') || 1;
|
|
|
}
|
|
|
- else if ( Pagination.type === 'PRACOWNICY' ) {
|
|
|
+ else if ( Pagination.type === 'PRACOWNICY' ){
|
|
|
Pagination.page = getItemLocalStorage('Bocian.biAuditForm.pracownicy.pagination.page') || 1;
|
|
|
}
|
|
|
|
|
@@ -1503,7 +1193,6 @@ global.checkAll = checkAll;
|
|
|
global.checkedChoiseItems = checkedChoiseItems;
|
|
|
global.catchEventCheckbox = catchEventCheckbox;
|
|
|
global.clearSelectedCheckbox = clearSelectedCheckbox;
|
|
|
-global.getNameGroupById = getNameGroupById;
|
|
|
global.createGroupPracownicy = createGroupPracownicy;
|
|
|
global.createGroupKontrahenci = createGroupKontrahenci;
|
|
|
global.selectPage = selectPage;
|
|
@@ -1528,8 +1217,3 @@ global.removeItemInArray = removeItemInArray;
|
|
|
global.removeItemArrayInArray = removeItemArrayInArray;
|
|
|
|
|
|
global.addPracownikToGroup = addPracownikToGroup;
|
|
|
-global.addKontrahenciToGroup = addKontrahenciToGroup;
|
|
|
-
|
|
|
-global.showViewUploadFile = showViewUploadFile;
|
|
|
-global.parseCsvFile = parseCsvFile;
|
|
|
-global.clearListLocalStorageByType = clearListLocalStorageByType;
|