فهرست منبع

usuwanie pracowników okienko

michalzmijewski 7 سال پیش
والد
کامیت
d38d61c0c8
1فایلهای تغییر یافته به همراه74 افزوده شده و 0 حذف شده
  1. 74 0
      tools/Bocian.php.view.js

+ 74 - 0
tools/Bocian.php.view.js

@@ -1038,6 +1038,7 @@ function removeKontrahenciFromGroup(event){
 	}
 	swal({
 	  title: removeTitle,
+		text: showTextListIdKontrahentow,
 	  showCancelButton: true,
 	  confirmButtonText: 'Submit',
 	  showLoaderOnConfirm: true,
@@ -1105,6 +1106,79 @@ function removePracownikFromGroup(event){
 		showTextListIdPracownikow = '' + pracownicyIdsArray.length + ' osób';
 	}
 	var groupId = localStorage.getItem("Bocian.biAuditForm.pracownicy.filterIdGroup");
+	var removeTitle = "Czy chcesz usunąć z "
+	if(groupId === "0"){
+		removeTitle+= "systemu";
+	} else {
+		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;
+			}
+		});
+		removeTitle+= "grupy ";
+		removeTitle+= arrayGroupOptions[groupId];
+	}
+	swal({
+	  title: removeTitle,
+		text: showTextListIdPracownikow,
+	  showCancelButton: true,
+	  confirmButtonText: 'Submit',
+	  showLoaderOnConfirm: true,
+		preConfirm: function () {
+	    return new Promise(function (resolve, reject) {
+
+				if (!pracownicyIdsArray || !pracownicyIdsArrayi.length) {
+					reject('Wybierz osoby');
+					return;
+				}
+
+				window.fetch(URL_ADD_KONTRAHENCI_TO_GROUP, {
+					method: 'POST',
+					header: {
+						'contentType': 'applications/json'
+					},
+					credentials: 'same-origin',
+					body: JSON.stringify({
+						'idGroup': getItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup'),
+						'pracownicyIds': getItemLocalStorage('Bocian.biAuditForm.pracownicyIds'),
+					})
+				})
+				.then(function(response) {
+					return response.text();
+				})
+				.then(function(responseText) {
+
+					try {
+						return JSON.parse(responseText);
+					} catch (e) {
+						throw responseText;
+					}
+				})
+				.then(function(result) {
+					result
+					if (result.type == 'success') {
+						p5UI__notifyAjaxCallback(result);
+						resolve(result.msg);
+					} else {
+						reject(result.msg);
+					}
+				})
+				;
+	    })
+	  },
+	  allowOutsideClick: false
+	}).then((result) => {
+	  if (result.value) {
+	    swal({
+	      type: 'success',
+	      title: 'Ajax request finished!',
+	      html: 'Submitted email: ' + result.value
+	    })
+	  }
+	});
 
 }