|
|
@@ -0,0 +1,1176 @@
|
|
|
+$(document).ready(function() {
|
|
|
+ $("#main").after("<button type=button id=saveBtn class='btn btn-default text-center'>Zapisz zmiany</button>");
|
|
|
+ var deletedId = new Array();
|
|
|
+ var generatedId = new Array();
|
|
|
+ var deletedRes = new Array();
|
|
|
+ var perms = [
|
|
|
+ [1, "Kto wykonuje", "X"],
|
|
|
+ [2, "Tylko do odczytu", "R"],
|
|
|
+ [3, "Odczyt, zapis, wykonanie", "R,W,X"],
|
|
|
+ [4, "Odczyt, zapis, wykonanie, tworzenie", "R,W,X,C"],
|
|
|
+ [5, "Odczyt i wyknanie", "R,X"],
|
|
|
+ [6, "Tylko do odczytu", "R"],
|
|
|
+ [7, "MAPA PROCESU - opis mapy procesu", ""],
|
|
|
+ [9, "Tylko do tworzenia rekordu", "C"],
|
|
|
+ [10, "Tylko tworzenie i czytanie rekordów bez edycji", "R,X,C"],
|
|
|
+ [11, "Tylko edycja rekordu - ustalanie nowej wartosci", "W"],
|
|
|
+ [12, "Tylko edycja i dodanie rekordu - ustalanie nowej wartosci", "W,C"],
|
|
|
+ [13, "Nowy rekord i edycja z pominieciem A_ADM_COMPANY", "R,W,X,C,S"],
|
|
|
+ [14, "Widok tylko swoich danych z rekordu", "W,O"],
|
|
|
+ [15, "Edycja rekordów dla super admina", "R,W,C,S"],
|
|
|
+ [16, "Widok i dodawanie rekordów tylko dla swojego ADM_COMPANY", "C,O"],
|
|
|
+ [17, "Super widok wszystkich rekordow niezaleznie od uprawnien rekordu", "R,V"],
|
|
|
+ [18, "Administracja Edycja i widok wszystkich rekordow z pominieciem A", "R,W,X,S,V"],
|
|
|
+ [19, "Administracja Edycja Tworzenie i widok wszystkich rekordow z pom", "R,W,X,C,S,V"],
|
|
|
+ [20, "Export", "R,X,E"],
|
|
|
+ [21, "Widzenie tylko swoich rekordów", "O"]
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ var loaded = false;
|
|
|
+ var tab = new Array(); //tablica kolejnosci
|
|
|
+ //var mainProces_id = 1; //id procesu glownego. Potem bedzie przypisywane z linku
|
|
|
+ var actSite = "none";
|
|
|
+ showPreview();
|
|
|
+
|
|
|
+ var filtr = 0;
|
|
|
+ var selectedArea = false;
|
|
|
+ var sZasoby;
|
|
|
+ var lastSearch = "";
|
|
|
+ var newSteps = 0;
|
|
|
+ var newRes = 0;
|
|
|
+
|
|
|
+ $("#main").hide();
|
|
|
+ $("#saveBtn").hide();
|
|
|
+
|
|
|
+ function loadResources() {
|
|
|
+ var res = new Array();
|
|
|
+
|
|
|
+ var sFiltr = "";
|
|
|
+ var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_WSKAZNIK&SRSNAME=EPSG:3003&sortBy=SORT_PRIO+A';
|
|
|
+ //console.log("link "+link);
|
|
|
+
|
|
|
+ sFiltr += `
|
|
|
+ <GetFeature xmlns="http://www.opengis.net/wfs/2.0"
|
|
|
+ xmlns:p5_default_db="` + BASE_URL + `wfs/default_db"
|
|
|
+ xmlns:ogc="http://www.opengis.net/ogc"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ service="WFS"
|
|
|
+ version="2.0.2"
|
|
|
+ xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
|
|
|
+ <ogc:Filter>
|
|
|
+ <ogc:And>
|
|
|
+ <ogc:Or>`;
|
|
|
+
|
|
|
+ $("#main").children().each(function(index) {
|
|
|
+ var id = $(this).data("id");
|
|
|
+ sFiltr += '<ogc:PropertyIsEqualTo><ogc:PropertyName>ID_PROCES</ogc:PropertyName><ogc:Literal>' + id + '</ogc:Literal></ogc:PropertyIsEqualTo>';
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ sFiltr += '</ogc:Or><ogc:Not><ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>DELETED</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not></ogc:And></ogc:Filter></GetFeature>';
|
|
|
+ //console.log("x "+sFiltr);
|
|
|
+ $.ajax({
|
|
|
+ url: link,
|
|
|
+ data: sFiltr,
|
|
|
+ type: 'POST',
|
|
|
+ contentType: "text/xml",
|
|
|
+ dataType: "xml",
|
|
|
+ success: function(data) {
|
|
|
+ //console.log(data);
|
|
|
+ $.each($(data).find("featureMember"), function() {
|
|
|
+ var result = new Array();
|
|
|
+ result["ID"] = $(this).find("ID").text();
|
|
|
+ result["ID_ZASOB"] = $(this).find("ID_ZASOB").text();
|
|
|
+ result["ID_PROCES"] = $(this).find("ID_PROCES").text();
|
|
|
+ result["SORT_PRIO"] = $(this).find("SORT_PRIO").text();
|
|
|
+ result["ID_PRZYPADEK"] = $(this).find("ID_PRZYPADEK").text();
|
|
|
+ result["OPIS_ZASOB"] = $(this).find("OPIS_ZASOB").text();
|
|
|
+
|
|
|
+ res.push(result);
|
|
|
+
|
|
|
+ });
|
|
|
+ //console.log(res);
|
|
|
+ var sFiltr2 = "";
|
|
|
+
|
|
|
+ var link2 = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_LISTA_ZASOBOW&SRSNAME=EPSG:3003';
|
|
|
+
|
|
|
+ sFiltr2 += `
|
|
|
+ <GetFeature xmlns="http://www.opengis.net/wfs/2.0"
|
|
|
+ xmlns:p5_default_db="` + BASE_URL + `wfs/default_db"
|
|
|
+ xmlns:ogc="http://www.opengis.net/ogc"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ service="WFS"
|
|
|
+ version="2.0.2"
|
|
|
+ xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
|
|
|
+ <ogc:Filter>
|
|
|
+ <ogc:Or>`;
|
|
|
+ $.each(res, function(index, value) {
|
|
|
+ var id = res[index]["ID_ZASOB"];
|
|
|
+ sFiltr2 += `
|
|
|
+ <ogc:PropertyIsEqualTo>
|
|
|
+ <ogc:PropertyName>ID</ogc:PropertyName>
|
|
|
+ <ogc:Literal>` + id + `</ogc:Literal>
|
|
|
+ </ogc:PropertyIsEqualTo>`;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ sFiltr2 += `
|
|
|
+ </ogc:Or>
|
|
|
+ </ogc:Filter>
|
|
|
+ </GetFeature>`;
|
|
|
+ //console.log(sFiltr2);
|
|
|
+ //console.log(link2);
|
|
|
+ var zasobInfo = new Array();
|
|
|
+ $.ajax({
|
|
|
+ url: link2,
|
|
|
+ data: sFiltr2,
|
|
|
+ type: 'POST',
|
|
|
+ contentType: "text/xml",
|
|
|
+ dataType: "xml",
|
|
|
+ success: function(data2) {
|
|
|
+ //console.log("data");
|
|
|
+ //console.log(data2);
|
|
|
+ $.each($(data2).find("featureMember"), function() {
|
|
|
+ //console.log();
|
|
|
+ zasobInfo[$(this).find("ID").text()] = new Array();
|
|
|
+ zasobInfo[$(this).find("ID").text()]["DESC"] = $(this).find("DESC").text();
|
|
|
+ zasobInfo[$(this).find("ID").text()]["OPIS"] = $(this).find("OPIS").text();
|
|
|
+ zasobInfo[$(this).find("ID").text()]["TYPE"] = $(this).find("TYPE").text();
|
|
|
+ });
|
|
|
+ //console.log(res);
|
|
|
+ $.each(res, function(index, value) {
|
|
|
+ var type;
|
|
|
+ if (zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "DZIAL" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "STANOWISKO" || zasobInfo[res[index]["ID_ZASOB"]]["TYPE"] == "PODMIOT") {
|
|
|
+ type = $("#proc" + res[index]["ID_PROCES"]).find(".professions");
|
|
|
+ } else {
|
|
|
+ type = $("#proc" + res[index]["ID_PROCES"]).find(".resources");
|
|
|
+
|
|
|
+ }
|
|
|
+ $(type).append("<li data-zasob=" + res[index]["ID_ZASOB"] + " data-id=" + res[index]["ID"] + " data-przypadek=" + res[index]["ID_PRZYPADEK"] + " data-komentarz='" + res[index]["OPIS_ZASOB"] + "'><b>" + zasobInfo[res[index]["ID_ZASOB"]]["DESC"] + "</b> " + zasobInfo[res[index]["ID_ZASOB"]]["OPIS"] + " [" + res[index]["ID_ZASOB"] + "] <span aria-hidden='true' class='glyphicon glyphicon-edit btnEdit' title='Edytuj wskaźnik' style=font-size:12px;></span> <span class='glyphicon glyphicon-remove-sign delRes' title='Usuń wskaźnik' style=color:red;font-size:12px; aria-hidden='true' ></span> <span class='glyphicon glyphicon-arrow-up uArrowRes' title='Przesuń wskaźnik w górę' aria-hidden='true'></span> <span class='glyphicon glyphicon-arrow-down dArrowRes' title='Przesuń wskaźnik w dół' aria-hidden='true'></span></li>");
|
|
|
+ $(type).parents("dl").show();
|
|
|
+ updateArrows(type);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).ajaxStop(function() {
|
|
|
+ if (loaded)
|
|
|
+ return;
|
|
|
+ //alert("OK");
|
|
|
+ loaded = true;
|
|
|
+ $(".drop").find("dl").hide();
|
|
|
+ loadResources();
|
|
|
+
|
|
|
+ $("#main").show();
|
|
|
+ $("#saveBtn").show();
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //Saveaction
|
|
|
+ $(document).on('click', '#saveBtn', function() {
|
|
|
+ $("#saveBtn").prop('disabled', true);
|
|
|
+ //console.log("Saving has been started");
|
|
|
+ var genReq = `
|
|
|
+ <Transaction
|
|
|
+ xmlns="http://www.opengis.net/wfs"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ version="1.0.0"
|
|
|
+ service="WFS"
|
|
|
+ xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/CRM_PROCES"
|
|
|
+ xsi:schemaLocation="` + BASE_URL + `wfs/default_db/CRM_PROCES ` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/CRM_PROCES/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:CRM_PROCES&SRSNAME=EPSG:4326&"
|
|
|
+ xmlns:gml="http://www.opengis.net/gml">
|
|
|
+ `;
|
|
|
+
|
|
|
+ $("#main").children().each(function() {
|
|
|
+ if ($(this).data("id") < 0) {
|
|
|
+
|
|
|
+ genReq += `
|
|
|
+ <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
+ <CRM_PROCES xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">
|
|
|
+ <PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">-1</PARENT_ID>
|
|
|
+ </CRM_PROCES>
|
|
|
+ </Insert>`;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ genReq += '</Transaction>';
|
|
|
+ //console.log("genReq: " + genReq)
|
|
|
+ var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
|
|
|
+ //console.log(link);
|
|
|
+ $.ajax({
|
|
|
+ url: link,
|
|
|
+ data: genReq,
|
|
|
+ type: 'POST',
|
|
|
+ contentType: "text/xml",
|
|
|
+ dataType: "text",
|
|
|
+ success: function(data) {
|
|
|
+ //console.log("x: " + data);
|
|
|
+ $(data).find("[fid]").each(function(i, e) {
|
|
|
+ var newId = $(e).attr("fid").substr($(e).attr("fid").indexOf('.') + 1);
|
|
|
+ generatedId.push(newId);
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //console.log(generatedId[0]);
|
|
|
+ var i = 0;
|
|
|
+ var newIdTab = Array();
|
|
|
+ //console.log(generatedId);
|
|
|
+ $("#main").children().each(function() {
|
|
|
+
|
|
|
+ if ($(this).data("id") < 0) {
|
|
|
+ newIdTab[$(this).data("id")] = generatedId[i];
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ //console.log(newIdTab);
|
|
|
+
|
|
|
+
|
|
|
+ var request = `
|
|
|
+ <Transaction
|
|
|
+ xmlns="http://www.opengis.net/wfs"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ version="1.0.0"
|
|
|
+ service="WFS"
|
|
|
+ xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/CRM_PROCES"
|
|
|
+ xsi:schemaLocation="` + BASE_URL + `wfs/default_db/CRM_PROCES ` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/CRM_PROCES/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:CRM_PROCES&SRSNAME=EPSG:4326&"
|
|
|
+ xmlns:gml="http://www.opengis.net/gml">
|
|
|
+ `;
|
|
|
+
|
|
|
+ $("#main").children().each(function() {
|
|
|
+ request += `
|
|
|
+ <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
+ <CRM_PROCES xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">
|
|
|
+ `;
|
|
|
+ if ($(this).data("id") >= 0)
|
|
|
+ request += '<ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + $(this).data("id") + '</ID>';
|
|
|
+ else
|
|
|
+ request += '<ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + newIdTab[$(this).data("id")] + '</ID>';
|
|
|
+
|
|
|
+
|
|
|
+ if ($(this).data("parent_id") != false) {
|
|
|
+ if ($(this).data("parent_id") >= 0)
|
|
|
+ request += '<PARENT_ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + $(this).data("parent_id") + '</PARENT_ID>';
|
|
|
+ else
|
|
|
+ request += '<PARENT_ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + newIdTab[$(this).data("parent_id")] + '</PARENT_ID>';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ request += '<SORT_PRIO xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + $(this).data("SORT_PRIO") + '</SORT_PRIO>';
|
|
|
+ }
|
|
|
+ request += '<DESC xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + $(this).find(".hdesc").text() + '</DESC>';
|
|
|
+ request += '<OPIS xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + $(this).find(".sdesc").text() + '</OPIS>';
|
|
|
+
|
|
|
+
|
|
|
+ request += `
|
|
|
+ </CRM_PROCES>
|
|
|
+ </Insert>
|
|
|
+ `;
|
|
|
+ var id;
|
|
|
+ if ($(this).data("id") >= 0)
|
|
|
+ id = $(this).data("id");
|
|
|
+ else
|
|
|
+ id = newIdTab[$(this).data("id")];
|
|
|
+
|
|
|
+
|
|
|
+ var sort_prio = 0;
|
|
|
+ $(this).find(".professions,.resources").find("li").each(function() {
|
|
|
+ sort_prio++;
|
|
|
+
|
|
|
+ request += `
|
|
|
+ <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
+ <CRM_WSKAZNIK xmlns="` + BASE_URL + `wfs/default_db/CRM_WSKAZNIK">
|
|
|
+ `;
|
|
|
+ if ($(this).data("id") >= 0) {
|
|
|
+ request += '<ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + $(this).data("id") + '</ID>';
|
|
|
+ }
|
|
|
+ request += '<ID_ZASOB xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + $(this).data("zasob") + '</ID_ZASOB>';
|
|
|
+ request += '<ID_PROCES xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + id + '</ID_PROCES>';
|
|
|
+ request += '<ID_PRZYPADEK xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + $(this).data("przypadek") + '</ID_PRZYPADEK>';
|
|
|
+
|
|
|
+ var opis = $(this).data("komentarz");
|
|
|
+
|
|
|
+ opis = opis.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
|
+ request += '<SORT_PRIO xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + sort_prio + '</SORT_PRIO>';
|
|
|
+ request += '<OPIS_ZASOB xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + opis + '</OPIS_ZASOB>';
|
|
|
+ request += `
|
|
|
+</CRM_WSKAZNIK>
|
|
|
+</Insert>
|
|
|
+`;
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $.each(deletedId, function(key, value) {
|
|
|
+ request += `
|
|
|
+ <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
+ <CRM_PROCES xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">
|
|
|
+ `;
|
|
|
+
|
|
|
+ request += '<ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">' + value + '</ID>';
|
|
|
+ request += '<PARENT_ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">-1</PARENT_ID>';
|
|
|
+ request += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/CRM_PROCES">DELETED</A_STATUS>';
|
|
|
+
|
|
|
+ request += `
|
|
|
+ </CRM_PROCES>
|
|
|
+ </Insert>
|
|
|
+ `;
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $.each(deletedRes, function(key, value) {
|
|
|
+ request += `
|
|
|
+ <Insert xmlns="http://www.opengis.net/wfs">
|
|
|
+ <CRM_WSKAZNIK xmlns="` + BASE_URL + `wfs/default_db/CRM_WSKAZNIK">
|
|
|
+ `;
|
|
|
+
|
|
|
+ request += '<ID xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">' + value + '</ID>';
|
|
|
+ request += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/CRM_WSKAZNIK">DELETED</A_STATUS>';
|
|
|
+
|
|
|
+ request += `
|
|
|
+ </CRM_WSKAZNIK>
|
|
|
+ </Insert>
|
|
|
+ `;
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ request += '</Transaction>';
|
|
|
+
|
|
|
+ //console.log(request); console.log(link);
|
|
|
+ $.ajax({
|
|
|
+ url: link,
|
|
|
+ data: request,
|
|
|
+ type: 'POST',
|
|
|
+ contentType: "text/xml",
|
|
|
+ dataType: "text",
|
|
|
+ success: function(data) {
|
|
|
+ //console.log(data);
|
|
|
+ deletedRes = [];
|
|
|
+ deletedId = [];
|
|
|
+ showPreview();
|
|
|
+
|
|
|
+ $("#saveBtn").prop('disabled', false);
|
|
|
+ },
|
|
|
+ error: function(xhr, ajaxOptions, thrownError) {
|
|
|
+ $.notify("Brak połączenia z bazą danych", "error");
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+ error: function(xhr, ajaxOptions, thrownError) {
|
|
|
+ $.notify("Brak połączenia z bazą danych", "error");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $(document).on('click', '.btnEdit', function() {
|
|
|
+
|
|
|
+ var zasob = $(this).parents("li");
|
|
|
+ var permsOpt = "";
|
|
|
+ $.each(perms, function(key, value) {
|
|
|
+ if ($(zasob).data("przypadek") == value[0])
|
|
|
+ permsOpt = permsOpt + "<option value=" + value[0] + " selected=selected>[" + value[2] + "] " + value[1] + "</option>";
|
|
|
+ else
|
|
|
+ permsOpt = permsOpt + "<option value=" + value[0] + ">[" + value[2] + "] " + value[1] + "</option>";
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ swal({
|
|
|
+ showCancelButton: true,
|
|
|
+ title: 'Uprawnienia',
|
|
|
+ html: 'Uprawnienia<br><select class=form-control id="swal-input1">' + permsOpt + '</select>' +
|
|
|
+ 'Komentarz<br><input class=form-control id="swal-input2" class="swal2-input" value="' + $(zasob).data("komentarz") + '">',
|
|
|
+ preConfirm: function() {
|
|
|
+ return new Promise(function(resolve) {
|
|
|
+
|
|
|
+ resolve([
|
|
|
+ $('#swal-input1').val(),
|
|
|
+ $('#swal-input2').val()
|
|
|
+ ]);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).then(function(result) {
|
|
|
+ $(zasob).data("przypadek", result[0]);
|
|
|
+ $(zasob).data("komentarz", result[1]);
|
|
|
+ }).catch(function(e) {})
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //Buttony i ich zadania
|
|
|
+ $(document).on('click', '.step', function() {
|
|
|
+ newSteps--;
|
|
|
+ var main = false;
|
|
|
+
|
|
|
+ if ($(this).parents(".drop").data("id") === mainProces_id)
|
|
|
+ main = true;
|
|
|
+
|
|
|
+ $(this).parents(".drop").after("<div class='drop container-fluid' id='proc" + newSteps + "'></div>");
|
|
|
+
|
|
|
+ $("#proc" + newSteps).data("id", newSteps);
|
|
|
+ $("#proc" + newSteps).append("<div class='col-sm-1 options' id=opt" + newSteps + "></div>");
|
|
|
+
|
|
|
+ $("#opt" + newSteps).append("<span class='glyphicon glyphicon-remove-sign ico del' title='Usuń krok' style=color:red; aria-hidden='true'></span>");
|
|
|
+ //Arrows
|
|
|
+ $("#opt" + newSteps).append("<span class='glyphicon glyphicon-arrow-up ico uArrow' title='Przesuń krok w górę' aria-hidden='true'></span>");
|
|
|
+ $("#opt" + newSteps).append("<span class='glyphicon glyphicon-arrow-down ico dArrow' title='Przesuń krok w dół' aria-hidden='true'></span>");
|
|
|
+ $("#opt" + newSteps).append("<span class='glyphicon glyphicon-arrow-right ico rArrow' title='Przesuń krok w prawo' aria-hidden='true'></span>");
|
|
|
+ $("#opt" + newSteps).append("<span class='glyphicon glyphicon-arrow-left ico lArrow' title='Przesuń krok w lewo' aria-hidden='true'></span>");
|
|
|
+
|
|
|
+ //
|
|
|
+ $("#opt" + newSteps).append("<div class='clearfix'></div>");
|
|
|
+ $("#proc" + newSteps).append("<div class='col-sm-10 desc' id='desc" + newSteps + "' ><h4 class=changed><span class='stepDesc'></span><span class=hdesc>Nowy krok</span> <span class=ids>{?}</span></h4><span class=sdesc>Opis nowego kroku</span></div>");
|
|
|
+ $("#proc" + newSteps).append("<div class='clearfix'></div>");
|
|
|
+ $("#desc" + newSteps).append("<dl class='dl-horizontal'><dt>Stanowiska</dt><dd><ul class=professions></ul></dd></dl>");
|
|
|
+ $("#desc" + newSteps).append("<dl class='dl-horizontal'><dt>Użyte zasoby</dt><dd><ul class=resources></ul></dd></dl>");
|
|
|
+ if (!main)
|
|
|
+ $("#proc" + newSteps).data("parent_id", $(this).parents(".drop").data("parent_id"));
|
|
|
+ else
|
|
|
+ $("#proc" + newSteps).data("parent_id", mainProces_id);
|
|
|
+
|
|
|
+ $("#desc" + newSteps).append("<br><span class=step>Dodaj nowy krok</span>");
|
|
|
+
|
|
|
+ tab.push(newSteps);
|
|
|
+ var parent_id = $("#proc" + newSteps).data("parent_id");
|
|
|
+ //console.log(parent_id);
|
|
|
+ $("#proc" + newSteps).data("depth", $("#proc" + parent_id).data("depth") + 1);
|
|
|
+ //var depthWidth = 20 * $("#proc" + this.id).data("depth");
|
|
|
+ //$("#proc" + this.id).css("padding-left", depthWidth + "px");
|
|
|
+ $("#proc" + newSteps).find("dl").hide();
|
|
|
+
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('keyup', '#sZasoby', function() {
|
|
|
+
|
|
|
+ if ($(this).val() != lastSearch) {
|
|
|
+ lastSearch = $(this).val();
|
|
|
+ clearTimeout(sZasoby);
|
|
|
+ sZasoby = setTimeout(function() {
|
|
|
+ searchRes();
|
|
|
+ }, 300);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ function updateArrows(node){
|
|
|
+ $(node).find("li").each(function(){
|
|
|
+ if($(this).prev().length == 0){
|
|
|
+ $(this).find(".uArrowRes").hide();
|
|
|
+ }else {
|
|
|
+ $(this).find(".uArrowRes").show();
|
|
|
+ }
|
|
|
+ if($(this).next().length == 0){
|
|
|
+ $(this).find(".dArrowRes").hide();
|
|
|
+ }else{
|
|
|
+ $(this).find(".dArrowRes").show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).on('click', '.uArrowRes', function() {
|
|
|
+ var node = $(this).parents("li");
|
|
|
+ node.insertBefore(node.prev());
|
|
|
+ updateArrows(node.parents("ul"));
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.dArrowRes', function() {
|
|
|
+ var node = $(this).parents("li");
|
|
|
+ node.insertAfter(node.next());
|
|
|
+ updateArrows(node.parents("ul"));
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.uArrow', function() {
|
|
|
+ var node = $(this).parent().parent();
|
|
|
+ node.insertBefore(node.prev());
|
|
|
+
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.dArrow', function() {
|
|
|
+ var node = $(this).parent().parent();
|
|
|
+ node.insertAfter(node.next());
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.rArrow', function() {
|
|
|
+ var node = $(this).parent().parent();
|
|
|
+ $(node).data("depth", $(node).data("depth") + 1);
|
|
|
+ //var depthWidth = 20 * $(node).data("depth");
|
|
|
+ // $(node).css("padding-left", depthWidth + "px");
|
|
|
+ updateAll();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.lArrow', function() {
|
|
|
+ var node = $(this).parent().parent();
|
|
|
+ $(node).data("depth", $(node).data("depth") - 1);
|
|
|
+ //var depthWidth = 20 * $(node).data("depth");
|
|
|
+ //$(node).css("padding-left", depthWidth + "px");
|
|
|
+ updateAll();
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '#btnZasoby', function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+ zasoby();
|
|
|
+ $("#wrapper").toggleClass("toggled");
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', 'body', function() {
|
|
|
+ if (selectedArea != false) {
|
|
|
+ var content = $(selectedArea).val();
|
|
|
+
|
|
|
+
|
|
|
+ var type;
|
|
|
+ if ($(selectedArea).parent().hasClass("hdesc")) {
|
|
|
+ type = "DESC";
|
|
|
+ $(selectedArea).parents("h4").addClass("changed");
|
|
|
+ }
|
|
|
+ if ($(selectedArea).parent().hasClass("sdesc")) {
|
|
|
+ $(selectedArea).parents(".sdesc").addClass("changed");
|
|
|
+ type = "OPIS";
|
|
|
+ }
|
|
|
+
|
|
|
+ var id = (selectedArea).parents(".drop").data("id");
|
|
|
+ var post = '<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xmlns:p5_default_db_13051="' + BASE_URL + '" service="WFS" xsi:schemaLocation="' + BASE_URL + ' ' + BASE_URL + 'dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db_13051:TEST_PERMS&SRSNAME=EPSG:3003" xmlns:gml="http://www.opengis.net/gml"> <Update xmlns="http://www.opengis.net/wfs" typeName="p5_default_db_13051:CRM_PROCES"> <Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">' + content + '</Name> <Value xmlns="http://www.opengis.net/wfs"></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="CRM_PROCES.' + id + '"/></Filter></Update></Transaction>';
|
|
|
+
|
|
|
+
|
|
|
+ //console.log("Nowy "+type+" dla id "+id+" to "+content);
|
|
|
+
|
|
|
+ if (content == "" && type == "OPIS") {
|
|
|
+ $(selectedArea).parent().after("<span class=sDescAdd>Dodaj opis</span>");
|
|
|
+ }
|
|
|
+ if (content == "" && type == "DESC") {
|
|
|
+ $(selectedArea).parent().after("<span class=hDescAdd>Dodaj opis</span>");
|
|
|
+ }
|
|
|
+ $(selectedArea).parent().html(content);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ selectedArea = false;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $(document).on('click', '.hdesc', function() {
|
|
|
+ if ($(this).find("textarea").is(selectedArea))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.sdesc', function() {
|
|
|
+ if ($(this).find("textarea").is(selectedArea))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $(document).on('dblclick', '.sdesc', function() {
|
|
|
+ if (selectedArea)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if ($(this).find("textarea").length == 0) {
|
|
|
+
|
|
|
+ var content = $(this).html();
|
|
|
+
|
|
|
+ $(this).empty();
|
|
|
+ $(this).append("<textarea>" + content + "</textarea>");
|
|
|
+
|
|
|
+ selectedArea = $(this).find("textarea");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.sDescAdd', function() {
|
|
|
+ if (selectedArea)
|
|
|
+ return;
|
|
|
+
|
|
|
+ var action = $(this).parents(".drop").find(".sdesc");
|
|
|
+
|
|
|
+ if ($(action).find("textarea").length == 0) {
|
|
|
+
|
|
|
+ //alert($(action).text());
|
|
|
+ $(action).empty();
|
|
|
+ $(action).append("<textarea placeholder='Opis kroku'></textarea>");
|
|
|
+ $(this).remove();
|
|
|
+ selectedArea = $(action).find("textarea");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.hDescAdd', function() {
|
|
|
+ if (selectedArea)
|
|
|
+ return;
|
|
|
+
|
|
|
+ var action = $(this).parents(".drop").find(".hdesc");
|
|
|
+
|
|
|
+ if ($(action).find("textarea").length == 0) {
|
|
|
+
|
|
|
+ //alert($(action).text());
|
|
|
+ $(action).empty();
|
|
|
+ $(action).append("<textarea placeholder='Tytuł kroku'></textarea>");
|
|
|
+ $(this).remove();
|
|
|
+ selectedArea = $(action).find("textarea");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('dblclick', '.hdesc', function() {
|
|
|
+ if ($(this).find("textarea").length == 0) {
|
|
|
+
|
|
|
+
|
|
|
+ var content = $(this).html();
|
|
|
+
|
|
|
+ $(this).empty();
|
|
|
+ $(this).append("<textarea>" + content + "</textarea>");
|
|
|
+ selectedArea = $(this).find("textarea");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.del', function() {
|
|
|
+ var node = $(this).parent().parent();
|
|
|
+ swal({
|
|
|
+ title: 'Usuwanie kroku',
|
|
|
+ text: "Czy napewno chcesz usunąć ten krok?",
|
|
|
+ type: 'warning',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#d33',
|
|
|
+ confirmButtonText: 'Tak, usuń ten krok'
|
|
|
+ }).then(function() {
|
|
|
+ deletedId.push($(node).data("id"));
|
|
|
+ node.remove();
|
|
|
+
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+
|
|
|
+ //Parent_id = -1,
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $(document).on('click', '.delRes', function() {
|
|
|
+ //var parent = $(this).parents(".drop");
|
|
|
+ var child = $(this).parents("li");
|
|
|
+ var li =
|
|
|
+ swal({
|
|
|
+ title: 'Usuwanie wskaźnika',
|
|
|
+ text: "Czy napewno chcesz usunąć ten wskaźnik?",
|
|
|
+ type: 'warning',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#d33',
|
|
|
+ confirmButtonText: 'Tak, usuń ten wskaźnik'
|
|
|
+ }).then(function() {
|
|
|
+ deletedRes.push($(child).data("id"));
|
|
|
+ child.remove();
|
|
|
+
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+
|
|
|
+ //Parent_id = -1,
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //
|
|
|
+ $(document).on('click', '.fbutton', function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+ $(".fbutton").removeClass("btn-success");
|
|
|
+
|
|
|
+ if ($(this).data("type") == filtr) {
|
|
|
+ filtr = 0;
|
|
|
+ //console.log("Odznaczono");
|
|
|
+ } else {
|
|
|
+ filtr = $(this).data("type");
|
|
|
+ $(this).addClass("btn-success");
|
|
|
+ }
|
|
|
+ if (filtr === 0)
|
|
|
+ $("#xBtn").prop("disabled", true);
|
|
|
+ else
|
|
|
+ $("#xBtn").prop("disabled", false);
|
|
|
+
|
|
|
+ searchRes();
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('click', '.showMore', function() {
|
|
|
+ var target = $(this).parent().find(".more");
|
|
|
+ var id = $(this).data("id");
|
|
|
+ if ($(target).parent().hasClass("resSelected")) {
|
|
|
+ $(".more").empty();
|
|
|
+ $(target).parent().removeClass("resSelected");
|
|
|
+ $(target).parent().find(".gIco").addClass("glyphicon-chevron-down");
|
|
|
+ $(target).parent().find(".gIco").removeClass("glyphicon-chevron-up");
|
|
|
+ } else {
|
|
|
+ $(".more").parent().removeClass("resSelected");
|
|
|
+ $(".more").parent().find(".gIco").addClass("glyphicon-chevron-down");
|
|
|
+ $(".more").parent().find(".gIco").removeClass("glyphicon-chevron-up");
|
|
|
+ $(".more").empty();
|
|
|
+ $(target).parent().addClass("resSelected");
|
|
|
+ $(target).parent().find(".gIco").removeClass("glyphicon-chevron-down");
|
|
|
+ $(target).parent().find(".gIco").addClass("glyphicon-chevron-up");
|
|
|
+
|
|
|
+ var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_LISTA_ZASOBOW&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>' + id + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>KOMORKA</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>&sortBy=SORT_PRIO+A';
|
|
|
+ //console.log(link);
|
|
|
+ $.get(link, function(data) {
|
|
|
+ $.each($(data).find("featureMember"), function() {
|
|
|
+ if ($(this).find("ID").text() != 0) {
|
|
|
+ var type = 0;
|
|
|
+ $(target).append("<div class='drag hov' data-id=" + $(this).find("ID").text() + " data-type=" + type + " data-opis='<b>" + $(this).find("DESC").text() + "</b> " + $(this).find("OPIS").text() + " [" + $(this).find("ID").text() + "] '>" + $(this).find("DESC").text() + " [" + $(this).find("ID").text() + "]</div>");
|
|
|
+ $('.drag').draggable({
|
|
|
+ appendTo: 'body',
|
|
|
+ helper: 'clone',
|
|
|
+ stack: "div",
|
|
|
+ distance: 0,
|
|
|
+ cursor: "copy"
|
|
|
+ });
|
|
|
+ $(".drop").droppable({
|
|
|
+ tolerance: 'pointer',
|
|
|
+ accept: '.drag',
|
|
|
+ drop: function(event, ui) {
|
|
|
+ addResource(ui, this);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ function searchRes() {
|
|
|
+ var id = lastSearch;
|
|
|
+ var link;
|
|
|
+ //console.log("Szukam");
|
|
|
+ switch (filtr) {
|
|
|
+ case 0:
|
|
|
+ link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_LISTA_ZASOBOW&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:Or><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!"><ogc:PropertyName>DESC</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike></ogc:Or></ogc:Filter>&maxFeatures=100';
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_LISTA_ZASOBOW&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:Or><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!"><ogc:PropertyName>DESC</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike></ogc:Or><ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>STANOWISKO</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>PODMIOT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>DZIAL</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:And></ogc:Filter>&maxFeatures=100';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_LISTA_ZASOBOW&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:Or><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!"><ogc:PropertyName>DESC</ogc:PropertyName><ogc:Literal>*' + id + '*</ogc:Literal></ogc:PropertyIsLike></ogc:Or><ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>KOMORKA</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>TYPE</ogc:PropertyName><ogc:Literal>TABELA</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:And></ogc:Filter>&maxFeatures=100&sortBy=TYPE+A';
|
|
|
+ //console.log(link);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ link = "";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $.get(link, function(data) {
|
|
|
+ var side = $("#side");
|
|
|
+ //console.log(data);
|
|
|
+ $(side).find("#ulcon").empty();
|
|
|
+
|
|
|
+ $.each($(data).find("featureMember"), function() {
|
|
|
+ if ($(this).find("ID").text() * 1 == 0) {
|
|
|
+ $(side).find("#ulcon").append("<div><center>Brak wyników wyszukiwania</center></div>");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var type = 0;
|
|
|
+ if ($(this).find("TYPE").text() == "DZIAL" || $(this).find("TYPE").text() == "PODMIOT" || $(this).find("TYPE").text() == "STANOWISKO")
|
|
|
+ type = 1;
|
|
|
+ if (filtr != 2 || $(this).find("TYPE").text() != "TABELA")
|
|
|
+ $(side).find("#ulcon").append("<div class='drag hov' data-id=" + $(this).find("ID").text() + " data-type=" + type + " data-opis='<b>" + $(this).find("DESC").text() + "</b> " + $(this).find("OPIS").text() + " [" + $(this).find("ID").text() + "] '>" + $(this).find("DESC").text() + " [" + $(this).find("ID").text() + "]</div>");
|
|
|
+ else {
|
|
|
+ $(side).find("#ulcon").append("<div ><span class='drag click' data-id=" + $(this).find("ID").text() + " data-type=" + type + " data-opis='<b>" + $(this).find("DESC").text() + "</b> " + $(this).find("OPIS").text() + " [" + $(this).find("ID").text() + "] '>#</span> <div style=width:80%;float:left; data-id=" + $(this).find("ID").text() + " class=showMore><span class=tabelaName>" + $(this).find("DESC").text() + "</span> [" + $(this).find("ID").text() + "]</div><span class='gIco glyphicon glyphicon-chevron-down' style:float:left;></span><div style=clear:both;></div><div class=more ></div></div>");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ $('.drag').draggable({
|
|
|
+ appendTo: 'body',
|
|
|
+ helper: 'clone',
|
|
|
+ stack: "div",
|
|
|
+ distance: 0,
|
|
|
+ cursor: "copy"
|
|
|
+ });
|
|
|
+ $(".drop").droppable({
|
|
|
+ tolerance: 'pointer',
|
|
|
+ accept: '.drag',
|
|
|
+ drop: function(event, ui) {
|
|
|
+ addResource(ui, this);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function zasoby() {
|
|
|
+ var side = $("#side");
|
|
|
+ $(side).empty();
|
|
|
+ $(side).append("<h3>Zarządzaj zasobami<h3>");
|
|
|
+
|
|
|
+
|
|
|
+ $(side).append("<div class='form-group' ><input type='text' class=form-control id=sZasoby placeholder='Szukaj zasobów'></div>");
|
|
|
+
|
|
|
+ $(side).append("<div class='btn-group' style=width:100% id=filtry></div>");
|
|
|
+ $("#filtry").append("<button type='button' data-type=1 class='fbutton btn btn-default input-block-level ' style=width:40%>Stanowiska</button>");
|
|
|
+ $("#filtry").append("<button type='button' data-type=2 class='fbutton btn btn-default input-block-level ' style=width:40%>Komórki</button>");
|
|
|
+ $("#filtry").append("<button type='button' data-type=0 class='fbutton btn btn-danger input-block-level' id=xBtn style=width:20% disabled>X</button>");
|
|
|
+
|
|
|
+ $(side).append("<div id=ulcon></div>");
|
|
|
+ //$(side).find("#ulcon").append("<div class='drag' data-id=1 data-type=1 >[STANOWISKO] Ulotkarz</div>");
|
|
|
+ //$(side).find("#ulcon").append("<div class='drag' data-id=2 data-type=1 >[STANOWISKO] Programista PHP</div>");
|
|
|
+ //$(side).find("#ulcon").append("<div class='drag' data-id=3 data-type=2 >[ZASÓB] Komputer</div>");
|
|
|
+ $('.drag').draggable({
|
|
|
+ appendTo: 'body',
|
|
|
+ helper: 'clone',
|
|
|
+ stack: "div",
|
|
|
+ distance: 0,
|
|
|
+ cursor: "copy"
|
|
|
+ });
|
|
|
+ $(".drop").droppable({
|
|
|
+ tolerance: 'pointer',
|
|
|
+ accept: '.drag',
|
|
|
+ drop: function(event, ui) {
|
|
|
+ addResource(ui, this);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function addResource(ui, target) {
|
|
|
+ var permsOpt = "";
|
|
|
+ $.each(perms, function(key, value) {
|
|
|
+ permsOpt = permsOpt + "<option value=" + value[0] + ">[" + value[2] + "] " + value[1] + "</option>";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ swal({
|
|
|
+ showCancelButton: true,
|
|
|
+ title: 'Uprawnienia',
|
|
|
+ html: 'Uprawnienia<br><select class=form-control id="swal-input1">' + permsOpt + '</select>' +
|
|
|
+ 'Komentarz<br><input class=form-control id="swal-input2" class="swal2-input">',
|
|
|
+ preConfirm: function() {
|
|
|
+ return new Promise(function(resolve) {
|
|
|
+
|
|
|
+ resolve([
|
|
|
+ $('#swal-input1').val(),
|
|
|
+ $('#swal-input2').val()
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).then(function(result) {
|
|
|
+ //console.log("Dodaj zasob " + ui.draggable.data("id") + " do " + $(target).data("id") + " i uprawnienia id " + result[0] + " komentarz: " + result[1]); //
|
|
|
+ newRes--;
|
|
|
+ if (ui.draggable.data("type") == 1) {
|
|
|
+ $(target).find(".professions").append("<li class=changed data-zasob=" + ui.draggable.data("id") + " data-id=" + newRes + " data-przypadek=" + result[0] + " data-komentarz='" + result[1] + "'>" + ui.draggable.data("opis") + " <span aria-hidden='true' class='glyphicon glyphicon-edit btnEdit' style=font-size:10px;></span> <span class='glyphicon glyphicon-remove-sign delRes' style=color:red;font-size:10px; aria-hidden='true' ></span><span class='glyphicon glyphicon-arrow-up uArrowRes' title='Przesuń wskaźnik w górę' aria-hidden='true'></span> <span class='glyphicon glyphicon-arrow-down dArrowRes' title='Przesuń wskaźnik w dół' style=display:none; aria-hidden='true'></span></li>");
|
|
|
+ $(target).find(".professions").parents("dl").show();
|
|
|
+ updateArrows($(target).find(".professions"));
|
|
|
+ } else {
|
|
|
+ $(target).find(".resources").append("<li class=changed data-zasob=" + ui.draggable.data("id") + " data-id=" + newRes + " data-przypadek=" + result[0] + " data-komentarz='" + result[1] + "'>" + ui.draggable.data("opis") + " <span aria-hidden='true' class='glyphicon glyphicon-edit btnEdit' style=font-size:10px;> <span class='glyphicon glyphicon-remove-sign delRes' style=color:red;font-size:10px; aria-hidden='true' ></span><span class='glyphicon glyphicon-arrow-up uArrowRes' title='Przesuń wskaźnik w górę' aria-hidden='true'></span> <span class='glyphicon glyphicon-arrow-down dArrowRes' style=display:none; title='Przesuń wskaźnik w dół' aria-hidden='true'></span></li>");
|
|
|
+ $(target).find(".resources").parents("dl").show();
|
|
|
+ updateArrows($(target).find(".resources"));
|
|
|
+ }
|
|
|
+ }).catch(function(e) {})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //Po uzyciu uArrow lub dArrow tworzy nowa kolejnosc
|
|
|
+ function updateX() {
|
|
|
+ tab = [];
|
|
|
+ $.each($("#main").children(), function(index) {
|
|
|
+ tab.push($(this).data("id") * 1);
|
|
|
+ });
|
|
|
+ //console.log(tab);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //Najwazniejsza funkcja odpalana po kazdej zmianie. Sprawdza, czy wszystkie funkcje maja rodzica,
|
|
|
+ //jezeli nie to przesuwa w lewo obiekt
|
|
|
+ //Odpowiada tez za ukrywanie guzikow i wywowalanie funkcji generacji krokow
|
|
|
+ function updateAll() {
|
|
|
+ $("#main").children().each(function(index) {
|
|
|
+ if (getParentNode($(this).data("id")) != "NONE" && getParentNode($(this).data("id")) != false && getParentNode($(this).data("id")) != $(this).data("parent_id")) {
|
|
|
+ $(this).data("parent_id", getParentNode($(this).data("id")));
|
|
|
+ console.log("Ustawiono nowe parent_id na " + $(this).data("parent_id") + " dla " + $(this).data("id")); //
|
|
|
+ } else if (getParentNode($(this).data("id")) === false) {
|
|
|
+ var node = this;
|
|
|
+ $(node).data("depth", $(node).data("depth") - 1);
|
|
|
+ //var depthWidth = 20 * $(node).data("depth");
|
|
|
+ //$(node).css("padding-left", depthWidth + "px");
|
|
|
+ updateAll();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (checkParentNode($(this).data("id"), "right") === false) {
|
|
|
+ $(this).find(".rArrow").hide();
|
|
|
+ } else {
|
|
|
+ $(this).find(".rArrow").show();
|
|
|
+ }
|
|
|
+ if (checkParentNode($(this).data("id"), "left") === false) {
|
|
|
+ $(this).find(".lArrow").hide();
|
|
|
+ } else {
|
|
|
+ $(this).find(".lArrow").show();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tab[1] == $(this).data("id"))
|
|
|
+ $(this).find(".uArrow").hide();
|
|
|
+ else
|
|
|
+ $(this).find(".uArrow").show();
|
|
|
+
|
|
|
+ if ($(this).next().length == 0) {
|
|
|
+ $(this).find(".dArrow").hide();
|
|
|
+ } else {
|
|
|
+ $(this).find(".dArrow").show();
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ stepsGenerator();
|
|
|
+ }
|
|
|
+
|
|
|
+ //Generuje kroki, sprawdza tez czy kolejnosc krokow w danym rodzicow zostala zmieniona
|
|
|
+ //Jezeli tak to mozna wyslac ajaxem zmiane kolejnosci dla sort_prio
|
|
|
+ function stepsGenerator() {
|
|
|
+ $("#main").children().each(function(index) {
|
|
|
+ $(this).data("step", 0);
|
|
|
+ if ($(this).data("id") == mainProces_id) {
|
|
|
+ $(this).data("stepDesc", "");
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $("#proc" + $(this).data("parent_id")).data("step", $("#proc" + $(this).data("parent_id")).data("step") + 1);
|
|
|
+
|
|
|
+ $(this).data("SORT_PRIO", $("#proc" + $(this).data("parent_id")).data("step"));
|
|
|
+
|
|
|
+ $(this).data("stepDesc", $("#proc" + $(this).data("parent_id")).data("stepDesc") + $("#proc" + $(this).data("parent_id")).data("step") + ". ");
|
|
|
+ //console.log($(this).data("stepDesc"));
|
|
|
+ $(this).find(".stepDesc").text($(this).data("stepDesc"));
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //Prosta funkcja sprawdzajaca pozycje danego obiektu
|
|
|
+ function getX(id) {
|
|
|
+ //alert("id "+id)
|
|
|
+ var result;
|
|
|
+ $.each(tab, function(index, value) {
|
|
|
+ if (value == id)
|
|
|
+ result = index;
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Na potrzeby guzikow dorobilem funkcje sprawdzajaca id rodzica po przesunieciu (przewidywanie).
|
|
|
+ //Jezeli nie znajdzie zwraca false, a wtedy blokuje sie odpowiednia strzalka
|
|
|
+ function checkParentNode(id, check) {
|
|
|
+ var x = getX(id);
|
|
|
+ //console.log(tab);
|
|
|
+ var result = false;
|
|
|
+ while (x > 0) {
|
|
|
+ x--;
|
|
|
+
|
|
|
+ if (check == "right")
|
|
|
+ if ($("#proc" + tab[x]).data("depth") == $("#proc" + id).data("depth")) {
|
|
|
+ result = tab[x];
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (check == "left")
|
|
|
+ if ($("#proc" + tab[x]).data("depth") == $("#proc" + id).data("depth") - 2) {
|
|
|
+ result = tab[x];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (check == "right" && $("#proc" + tab[x]).data("depth") < $("#proc" + id).data("depth"))
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Zwraca id rodzica, jezeli nie ma zwraca false
|
|
|
+ function getParentNode(id) {
|
|
|
+ var x = getX(id);
|
|
|
+ if (mainProces_id == id)
|
|
|
+ return "NONE";
|
|
|
+
|
|
|
+ var result = false;
|
|
|
+ while (x > 0) {
|
|
|
+ x--;
|
|
|
+
|
|
|
+ var depth = $("#proc" + tab[x]).data("depth") - $("#proc" + id).data("depth");
|
|
|
+
|
|
|
+ if ($("#proc" + tab[x]).data("depth") == $("#proc" + id).data("depth") - 1) {
|
|
|
+ result = tab[x];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($("#proc" + tab[x]).data("depth") - $("#proc" + id).data("depth") == -2)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ function genTree(parent_id, last) {
|
|
|
+
|
|
|
+ var link = BASE_URL + '/wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_PROCES&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>' + parent_id + '</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:Filter>&sortBy=SORT_PRIO+A';
|
|
|
+ //console.log(link);
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: link,
|
|
|
+ success: function(data) {
|
|
|
+
|
|
|
+ //console.log(data);
|
|
|
+
|
|
|
+
|
|
|
+ $.each($(data).find("featureMember"), function() {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ($(this).find("ID").text() == "0")
|
|
|
+ return;
|
|
|
+
|
|
|
+ $(last).after("<div class='drop container-fluid' id='proc" + $(this).find("ID").text() + "'></div>");
|
|
|
+ $("#proc" + $(this).find("ID").text()).data("id", $(this).find("ID").text() * 1);
|
|
|
+ $("#proc" + $(this).find("ID").text()).append("<div class='col-sm-1 options' id=opt" + $(this).find("ID").text() + "></div>");
|
|
|
+
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<span class='glyphicon glyphicon-remove-sign ico del' title='Usuń krok' aria-hidden='true'></span>");
|
|
|
+ //Arrows
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<span class='glyphicon glyphicon-arrow-up ico uArrow' aria-hidden='true' title='Przesuń krok w górę'></span>");
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<span class='glyphicon glyphicon-arrow-down ico dArrow' aria-hidden='true' title='Przesuń krok w dół'></span>");
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<span class='glyphicon glyphicon-arrow-right ico rArrow' aria-hidden='true' title='Przesuń krok w prawo'></span>");
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<span class='glyphicon glyphicon-arrow-left ico lArrow' aria-hidden='true' title='Przesuń krok w lewo'></span>");
|
|
|
+
|
|
|
+ //
|
|
|
+ $("#opt" + $(this).find("ID").text()).append("<div class='clearfix'></div>");
|
|
|
+ $("#proc" + $(this).find("ID").text()).append("<div class='col-sm-10 desc' id='desc" + $(this).find("ID").text() + "' ><h4 class=changable><span class='stepDesc'></span><span class=hdesc>" + $(this).find("DESC").text() + "</span> <span class=ids>{" + $(this).find("ID").text() + "}</span></h4><span class='sdesc changable'>" + $(this).find("OPIS").text() + "</span></div>");
|
|
|
+ if ($(this).find("DESC").text() == "") {
|
|
|
+ $("#proc" + $(this).find("ID").text()).find(".hdesc").after("<span class=hDescAdd>Dodaj tytuł</span>");
|
|
|
+ }
|
|
|
+ if ($(this).find("OPIS").text() == "") {
|
|
|
+ $("#proc" + $(this).find("ID").text()).find(".sdesc").after("<span class=sDescAdd>Dodaj opis</span>");
|
|
|
+ }
|
|
|
+ $("#proc" + $(this).find("ID").text()).append("<div class='clearfix'></div>");
|
|
|
+ $("#desc" + $(this).find("ID").text()).append("<dl class='dl-horizontal'><dt>Stanowiska</dt><dd><ul class=professions></ul></dd></dl>");
|
|
|
+ $("#desc" + $(this).find("ID").text()).append("<dl class='dl-horizontal'><dt>Użyte zasoby</dt><dd><ul class=resources></ul></dd></dl>");
|
|
|
+ $("#proc" + $(this).find("ID").text()).data("parent_id", $(this).find("PARENT_ID").text());
|
|
|
+ $("#desc" + $(this).find("ID").text()).append("<br><span class=step>Dodaj nowy krok</span>");
|
|
|
+ //tab.push($(this).find("ID").text()*1);
|
|
|
+
|
|
|
+ var parent_id = $("#proc" + $(this).find("ID").text()).data("parent_id");
|
|
|
+ $("#proc" + $(this).find("ID").text()).data("depth", $("#proc" + $(this).find("PARENT_ID").text()).data("depth") + 1);
|
|
|
+ last = $("#proc" + $(this).find("ID").text());
|
|
|
+ genTree($(this).find("ID").text(), last);
|
|
|
+ //var depthWidth = 20 * $("#proc" + this.id).data("depth");
|
|
|
+ //$("#proc" + this.id).css("padding-left", depthWidth + "px");
|
|
|
+
|
|
|
+ //alert("add");
|
|
|
+
|
|
|
+ updateX();
|
|
|
+ updateAll();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //Pierwszy render, tworzy potrzebna strukture
|
|
|
+ function showPreview() {
|
|
|
+
|
|
|
+ filtr = 0;
|
|
|
+ selectedArea = false;
|
|
|
+
|
|
|
+
|
|
|
+ lastSearch = "";
|
|
|
+ newSteps = 0;
|
|
|
+ newRes = 0;
|
|
|
+
|
|
|
+ tab = [];
|
|
|
+ deletedId = [];
|
|
|
+ $("#main").empty();
|
|
|
+ $("#main").hide();
|
|
|
+ var id = mainProces_id;
|
|
|
+ var link = BASE_URL + '/wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_PROCES&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>' + id + '</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:Filter>';
|
|
|
+ //console.log(link);
|
|
|
+ $.get(link, function(data) {
|
|
|
+ loaded = false;
|
|
|
+ //console.log(data);
|
|
|
+
|
|
|
+ $("#main").append("<div class='drop container-fluid' id='proc" + mainProces_id + "'></div>");
|
|
|
+ $("#proc" + mainProces_id).data("id", mainProces_id);
|
|
|
+ $("#proc" + mainProces_id).data("depth", 0);
|
|
|
+ $("#proc" + mainProces_id).data("parent_id", false);
|
|
|
+ $("#proc" + mainProces_id).append("<div class='col-sm-1 options' id=opt" + mainProces_id + "><span aria-hidden='true' class='glyphicon glyphicon-menu-hamburger ico' title='Pokaż listę zasobów' id=btnZasoby></span></div>");
|
|
|
+ $("#proc" + mainProces_id).append("<div class='col-sm-10 desc' id='desc" + mainProces_id + "' ><h4 class=changable><span class=hdesc>" + $(data).find("featureMember").find("DESC").text() + "</span> <span class=ids>{" + mainProces_id + "}</span></h4><span class='sdesc changable'>" + $(data).find("featureMember").find("OPIS").text() + "</span></div>");
|
|
|
+ if ($(data).find("featureMember").find("DESC").text() == "") {
|
|
|
+ $("#proc" + mainProces_id).find(".hdesc").after("<span class=hDescAdd>Dodaj Tytuł</span>");
|
|
|
+ }
|
|
|
+ if ($(data).find("featureMember").find("OPIS").text() == "") {
|
|
|
+ $("#proc" + mainProces_id).find(".sdesc").after("<span class=sDescAdd>Dodaj opis</span>");
|
|
|
+ }
|
|
|
+ $("#proc" + mainProces_id).append("<div class='clearfix'></div>");
|
|
|
+ $("#desc" + mainProces_id).append("<dl class='dl-horizontal'><dt>Stanowiska</dt><dd><ul class=professions></ul></dd></dl>");
|
|
|
+ $("#desc" + mainProces_id).append("<dl class='dl-horizontal'><dt>Użyte zasoby</dt><dd><ul class=resources></ul></dd></dl>");
|
|
|
+ $("#desc" + mainProces_id).append("<br><span class=step>Dodaj nowy krok</span>");
|
|
|
+ tab.push(mainProces_id);
|
|
|
+ genTree(mainProces_id, $("#proc" + mainProces_id));
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ actSite = "preview";
|
|
|
+
|
|
|
+ }
|
|
|
+});
|