|
@@ -70,7 +70,14 @@ function updateLocalStorageBiAuditDepth(idInput) {
|
|
|
(formItemsPraconwicyKontrahenci.totalPracownicy === 0 && formItemsPraconwicyKontrahenci.totalKontrahenci != 0 ) ||
|
|
|
(formItemsPraconwicyKontrahenci.totalPracownicy != 0 && formItemsPraconwicyKontrahenci.totalKontrahenci === 0 )
|
|
|
) {
|
|
|
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Krytyczne wielkości danych do przeszukania. Czy jesteś pewien? Optymalna wartość głębokość powiazań to: 4.' });
|
|
|
+ p5UI__notifyAjaxCallback({ type: 'error', msg: messageCriticalSearchData });
|
|
|
+
|
|
|
+ $('.bottom--message-warning-critical-search').text(messageCriticalSearchData);
|
|
|
+
|
|
|
+ console.log('popup i dodanie komunikatu niżej');
|
|
|
+ } else {
|
|
|
+ $('.bottom--message-warning-critical-search').text('');
|
|
|
+ console.log('popup i dodanie wyczysc komunikatu ');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -329,53 +336,84 @@ function generateBiAuditRaport(event) {
|
|
|
// validate
|
|
|
if (!depthValue || depthValue === 0) {
|
|
|
p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie podano wartości dla głębokości powiązań' });
|
|
|
- } else if (!pracownicyIdsArray || pracownicyIdsArray.length === 0) {
|
|
|
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie wybrano pracowników' });
|
|
|
- } else if (!kontrahenciIdsArray || kontrahenciIdsArray.length === 0) {
|
|
|
- p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie wybrano kontrahentów' });
|
|
|
+ } else if ( (!pracownicyIdsArray || pracownicyIdsArray.length === 0) && (!kontrahenciIdsArray || kontrahenciIdsArray.length === 0) ) {
|
|
|
+ p5UI__notifyAjaxCallback({ type: 'error', msg: 'Nie wybrano pozycji do analizy' });
|
|
|
} else {
|
|
|
- // send
|
|
|
- window.fetch(URL_GENERATE_BI_AUDIT_RAPORT_AJAX, {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- credentials: 'same-origin',
|
|
|
- body: JSON.stringify({
|
|
|
- pracownicyIds: pracownicyIdsArray,
|
|
|
- kontrahenciIds: kontrahenciIdsArray,
|
|
|
- depthValue: depthValue,
|
|
|
- analizaOnlyTargets: analizaOnlyTargets
|
|
|
- })
|
|
|
- })
|
|
|
- .then(function(response) {
|
|
|
- console.log('Firsst then', response);
|
|
|
- return response.text();
|
|
|
- })
|
|
|
- .then(function(responseText) {
|
|
|
- try {
|
|
|
- return JSON.parse(responseText);
|
|
|
- } catch (e) {
|
|
|
- throw responseText;
|
|
|
- }
|
|
|
- })
|
|
|
- .then(function(result) {
|
|
|
+ var generateReaport = true; // generuj raport
|
|
|
|
|
|
- if (result.type == 'success') {
|
|
|
+ // if not choise 'pracowniocy' or 'kontrahenci'
|
|
|
+ if ( (!pracownicyIdsArray || pracownicyIdsArray.length === 0) || (!kontrahenciIdsArray || kontrahenciIdsArray.length === 0) ) {
|
|
|
|
|
|
- p5UI__notifyAjaxCallback(result);
|
|
|
- defaultBIAuditLocalStorage();
|
|
|
- updateTopCounters();
|
|
|
- window.setTimeout(URL_TABLE_POWIAZANIA, 6000);
|
|
|
- resolve(result.msg);
|
|
|
+ var messageConfirm = '';
|
|
|
+ // check selected items
|
|
|
+ if ( !pracownicyIdsArray || pracownicyIdsArray.length === 0 ) {
|
|
|
+ messageConfirm = 'Nie wybrano pracownika/ów! Czas przygotowania raportu może wydłużyć się ze względu na sprawdzenie powiązania ze wszystkimi pracownikami w systemie. Czy jesteś pewny? ';
|
|
|
+ }
|
|
|
+ if ( !kontrahenciIdsArray || kontrahenciIdsArray.length === 0 ) {
|
|
|
+ messageConfirm = 'Nie wybrano kontrahenta/ów! Czas przygotowania raportu może wydłużyć się ze względu na sprawdzenie powiązania ze wszystkimi kontrahentami w systemie. Czy jesteś pewny? ';
|
|
|
+ }
|
|
|
+
|
|
|
+ // show confirm window with message
|
|
|
+ if (confirm(messageConfirm)) {
|
|
|
+ generateReaport = true;
|
|
|
+ } else { // cancel
|
|
|
+ generateReaport = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (generateReaport === true) {
|
|
|
+ // send
|
|
|
+ window.fetch(URL_GENERATE_BI_AUDIT_RAPORT_AJAX, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ credentials: 'same-origin',
|
|
|
+ body: JSON.stringify({
|
|
|
+ pracownicyIds: pracownicyIdsArray,
|
|
|
+ kontrahenciIds: kontrahenciIdsArray,
|
|
|
+ depthValue: depthValue,
|
|
|
+ analizaOnlyTargets: analizaOnlyTargets
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .then(function(response) {
|
|
|
+ console.log('Firsst then', 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);
|
|
|
+ defaultBIAuditLocalStorage();
|
|
|
+ updateTopCounters();
|
|
|
+ // unchecked checkbox pracownicy
|
|
|
+ $('#smad-table-PRACOWNICY form').find(':checkbox').prop('checked', false);
|
|
|
+ // unchecked checkbox kontrahenci
|
|
|
+ $('#smad-table-KONTRAHENCI form').find(':checkbox').prop('checked', false);
|
|
|
+ //
|
|
|
+ $('#count-selected-item-kontrahenci').text('0');
|
|
|
+ $('#count-selected-item-pracownicy').text('0');
|
|
|
+
|
|
|
+ window.setTimeout(URL_TABLE_POWIAZANIA, 6000);
|
|
|
+ resolve(result.msg);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ reject(result.msg);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(function(error) {
|
|
|
+ console.log('request failed', error)
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- reject(result.msg);
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(function(error) {
|
|
|
- console.log('request failed', error)
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1684,16 +1722,28 @@ function updateTopCounters() {
|
|
|
var countKontrahenci = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
|
|
|
var totalPracownicy = (countPracownicy) ? Object.keys(countPracownicy).length : 0;
|
|
|
var totalKontrahenci = (countKontrahenci) ? Object.keys(countKontrahenci).length : 0;
|
|
|
+ var depthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
|
|
|
console.warn({totalPracownicy: totalPracownicy, totalKontrahenci: totalKontrahenci})
|
|
|
$('.top--count-selected-item-pracownicy').text(totalPracownicy ? '('+totalPracownicy+')' : '');
|
|
|
$('.top--count-selected-item-kontrahenci').text(totalKontrahenci ? '('+totalKontrahenci+')' : '');
|
|
|
$('.bottom--count-selected-item-pracownicy').text(totalPracownicy ? "Wybrano: (" + totalPracownicy + ") pracownika/ów" : '');
|
|
|
$('.bottom--count-selected-item-kontrahenci').text(totalKontrahenci ? "Wybrano: (" + totalKontrahenci + ") kontrahenta/ów" : '');
|
|
|
|
|
|
+
|
|
|
// disable button generate reaport if not choise 'praconwicy' or 'kontrahenci'
|
|
|
if ( totalPracownicy === 0 && totalKontrahenci === 0 ) {
|
|
|
$('.smad-generate-reaport-button').addClass('disabled');
|
|
|
} else {
|
|
|
+
|
|
|
+ if ( ( totalPracownicy === 0 || totalKontrahenci === 0 ) && parseInt(depthValue) > 4) {
|
|
|
+ $('.bottom--message-warning-critical-search').text(messageCriticalSearchData);
|
|
|
+ console.log('dodanie komunikatu niżej');
|
|
|
+ } else {
|
|
|
+ console.log('wyczyc komunikatu niżej');
|
|
|
+ $('.bottom--message-warning-critical-search').text('');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$('.smad-generate-reaport-button').removeClass('disabled');
|
|
|
}
|
|
|
}
|
|
@@ -2108,3 +2158,6 @@ global.addKontrahenciAllToGroup = addKontrahenciAllToGroup;
|
|
|
global.showViewUploadFile = showViewUploadFile;
|
|
|
global.parseCsvFile = parseCsvFile;
|
|
|
global.clearListLocalStorageByType = clearListLocalStorageByType;
|
|
|
+
|
|
|
+// message
|
|
|
+global.messageCriticalSearchData = 'Krytyczne wielkości danych do przeszukania. Optymalna wartość głębokość szukania powiaząń to: 4';
|