134 lines
4.2 KiB
JavaScript
134 lines
4.2 KiB
JavaScript
function addCostBearer2SupportConceptsToGroupBooking() {
|
|
var url = getAddSupportConceptsLink();
|
|
|
|
var selectedGroups = [];
|
|
var selectedSupportConcepts = [];
|
|
|
|
var scOidString = "";
|
|
var groupOidString = "";
|
|
|
|
$("#group-booking-supportconcepts input:checked").each(function () {
|
|
selectedSupportConcepts.push($(this).attr("value"));
|
|
});
|
|
|
|
$("#group-booking-groups input:checked").each(function () {
|
|
selectedGroups.push($(this).attr("value"));
|
|
});
|
|
|
|
for (var i = 0; i < selectedSupportConcepts.length; i++) {
|
|
scOidString += selectedSupportConcepts[i];
|
|
|
|
if (i < selectedSupportConcepts.length - 1) {
|
|
scOidString += ",";
|
|
}
|
|
}
|
|
|
|
for (var j = 0; j < selectedGroups.length; j++) {
|
|
groupOidString += selectedGroups[j];
|
|
|
|
if (j < selectedGroups.length - 1) {
|
|
groupOidString += ",";
|
|
}
|
|
}
|
|
|
|
$.get(url, {pRelOids: scOidString, pGroupOids: groupOidString}).done(updateGroupBookingCb2ScList);
|
|
}
|
|
|
|
function updateGroupBookingCb2ScList(result) {
|
|
var list = $("#selected-cb2sc-list");
|
|
|
|
if (isEmptyOrSpaces(result) || result === "SessionTimeout") {
|
|
window.location.href = getRedirectLink();
|
|
return;
|
|
}
|
|
|
|
var groupBookingSelectionObject = $.parseJSON(result);
|
|
|
|
var resultList = groupBookingSelectionObject.SelectedRelations;
|
|
|
|
list.empty();
|
|
|
|
$.each(resultList,
|
|
function (index, customListItem) {
|
|
var html = '<div class="list-group-item" id="relation-item-' + customListItem.Value + '"><div class="row"><div class="col"><span>' + customListItem.Text1 + '<br /><span class="' + customListItem.TextColor + '">' + customListItem.Text2 + '</span></span></div><div class="col-auto my-auto"><button type="button" class="btn btn-primary" onclick="removeCb2ScRelation(' + customListItem.Value + ')"><span class="fas fa-times-circle"></span></button></div></div>';
|
|
|
|
list.append(html);
|
|
});
|
|
|
|
updateGroupBookingGroupList(groupBookingSelectionObject);
|
|
}
|
|
|
|
function removeCb2ScRelation(relOid) {
|
|
$("#relation-item-" + relOid).remove();
|
|
|
|
if ($("#cb2sc-checkbox-"+ relOid).length) {
|
|
$("#cb2sc-checkbox-" + relOid).prop("checked", false);
|
|
}
|
|
|
|
if($("#selected-cb2sc-list").find(".list-group-item") === 0) {
|
|
deactivateGroupBookingForm();
|
|
|
|
$("#group-booking-supportconcepts input:checked").each(function() {
|
|
$(this).prop("checked", false);
|
|
});
|
|
}
|
|
|
|
$.get(getRemoveCb2ScRelFromGroupBookingUrl(), { pRelOid: relOid }).done(updateGroupBookingGroupList);
|
|
}
|
|
|
|
function updateGroupBookingGroupList(groupBookingSelectionObject) {
|
|
var groupOids = groupBookingSelectionObject.GroupOids === undefined ? [] : groupBookingSelectionObject.GroupOids;
|
|
var relOids = [];
|
|
|
|
if (groupBookingSelectionObject.SelectedRelations !== undefined){
|
|
for (var i = 0; i < groupBookingSelectionObject.SelectedRelations.length; i++) {
|
|
relOids.push(parseInt(groupBookingSelectionObject.SelectedRelations[i].Value, 10));
|
|
}
|
|
}
|
|
|
|
$("#group-booking-supportconcepts input").each(function() {
|
|
var value = $(this).val();
|
|
|
|
$(this).prop("checked", isInArray(value, relOids));
|
|
});
|
|
|
|
$("#group-booking-groups input").each(function() {
|
|
var value = $(this).val();
|
|
|
|
$(this).prop("checked", isInArray(value, groupOids));
|
|
});
|
|
|
|
if (relOids.length === 0 && groupOids.length === 0) {
|
|
deactivateGroupBookingForm();
|
|
} else {
|
|
activateGroupBookingForm();
|
|
}
|
|
}
|
|
|
|
function addEmployeeToGroupBooking() {
|
|
var url = getAddEmployeesToGroupBookingUrl();
|
|
|
|
var selectedEmployees = [];
|
|
|
|
var oidString = "";
|
|
|
|
$("#employee-list input:checked").each(function() {
|
|
var oid = $(this).val();
|
|
|
|
selectedEmployees.push(oid);
|
|
});
|
|
|
|
for (var i = 0; i < selectedEmployees.length; i++) {
|
|
oidString += selectedEmployees[i];
|
|
|
|
if (i < selectedEmployees.length - 1) {
|
|
oidString += ",";
|
|
}
|
|
}
|
|
|
|
$.get(url, { pEmployeeOids: oidString }).done(function(numberOfSelectedEmployees) {
|
|
$("#selected-employees-count-badge").text(numberOfSelectedEmployees);
|
|
|
|
$("#create-button").prop("disabled", numberOfSelectedEmployees === "0" ? true : false);
|
|
});
|
|
} |