|
|
@@ -2517,53 +2517,50 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
function genTree(parent_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>PARENT_ID</ogc:PropertyName><ogc:Literal>' + parent_id + '</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:Filter>&sortBy=SORT_PRIO+A,ID';
|
|
|
- $.ajax({
|
|
|
- url: link,
|
|
|
- success: function(data) {
|
|
|
- var i = 0;
|
|
|
- $.each($(data).find("featureMember"), function() {
|
|
|
- var temp = {};
|
|
|
- if ($(this).find("ID").text() == "0")
|
|
|
- return;
|
|
|
- var parentIndex = getIndexById(parent_id);
|
|
|
- temp["id"] = $(this).find("ID").text();
|
|
|
- temp["desc"] = $(this).find("DESC").text();
|
|
|
- temp["opis"] = $(this).find("OPIS").text();
|
|
|
- temp["parent_id"] = $(this).find("PARENT_ID").text();
|
|
|
- temp["depth"] = state[parentIndex]["depth"] + 1;
|
|
|
- temp["step"] = 0;
|
|
|
- temp["prof"] = new Array();
|
|
|
- temp["res"] = new Array();
|
|
|
- temp["goto"] = {};
|
|
|
- temp["goto"]["id"] = $(this).find("IF_TRUE_GOTO").text();
|
|
|
- temp["goto"]["flag"] = $(this).find("IF_TRUE_GOTO_FLAG").text();
|
|
|
- temp["stepDesc"] = "";
|
|
|
- i++;
|
|
|
- state.splice(parentIndex + i, 0, temp);
|
|
|
- // var linkImg = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_IMAGE&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_ID</ogc:PropertyName><ogc:Literal>' + temp["id"] + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_TABLE</ogc:PropertyName><ogc:Literal>CRM_PROCES</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>';
|
|
|
- // $.get(linkImg, function(imgData) {
|
|
|
- // var temp = Array();
|
|
|
- // $.each($(imgData).find("featureMember"), function() {
|
|
|
- // temp.push({
|
|
|
- // "src": base64_decode($(this).find("IMAGE").text()),
|
|
|
- // "title": $(this).find("NAME").text(),
|
|
|
- // "id": $(this).find("ID").text(),
|
|
|
- // });
|
|
|
- // })
|
|
|
- // state[getIndexById(temp["id"])]["img"] = temp;
|
|
|
- // });
|
|
|
- genTree($(this).find("ID").text());
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ 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,ID';
|
|
|
+ // '<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,ID';
|
|
|
+ p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
|
|
|
+ 'Filter': '<ogc:PropertyIsEqualTo><ogc:PropertyName>' + "PARENT_ID" + '</ogc:PropertyName><ogc:Literal>' + parent_id + '</ogc:Literal></ogc:PropertyIsEqualTo>',
|
|
|
+ 'sortBy': 'SORT_PRIO+A,ID',
|
|
|
+ }).then(function (features) {
|
|
|
+ var feature = null
|
|
|
+ for (var i = 0, total = features.length; i < total; i++) {
|
|
|
+ feature = features[i]
|
|
|
+ var temp = {}
|
|
|
+ var parentIndex = getIndexById(parent_id);
|
|
|
+ temp["id"] = feature['ID']
|
|
|
+ temp["desc"] = feature['DESC'] || ''
|
|
|
+ temp["opis"] = feature['OPIS'] || ''
|
|
|
+ temp["parent_id"] = feature['PARENT_ID'] || 0
|
|
|
+ temp["depth"] = state[parentIndex]["depth"] + 1;
|
|
|
+ temp["step"] = 0;
|
|
|
+ temp["prof"] = new Array();
|
|
|
+ temp["res"] = new Array();
|
|
|
+ temp["goto"] = {};
|
|
|
+ temp["goto"]["id"] = feature['IF_TRUE_GOTO'] || 0
|
|
|
+ temp["goto"]["flag"] = feature['IF_TRUE_GOTO_FLAG'] || ''
|
|
|
+ temp["stepDesc"] = "";
|
|
|
+ state.splice(parentIndex + (i + 1), 0, temp)
|
|
|
+ // var linkImg = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_IMAGE&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_ID</ogc:PropertyName><ogc:Literal>' + temp["id"] + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_TABLE</ogc:PropertyName><ogc:Literal>CRM_PROCES</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>';
|
|
|
+ // $.get(linkImg, function(imgData) {
|
|
|
+ // var temp = Array();
|
|
|
+ // $.each($(imgData).find("featureMember"), function() {
|
|
|
+ // temp.push({
|
|
|
+ // "src": base64_decode($(this).find("IMAGE").text()),
|
|
|
+ // "title": $(this).find("NAME").text(),
|
|
|
+ // "id": $(this).find("ID").text(),
|
|
|
+ // });
|
|
|
+ // })
|
|
|
+ // state[getIndexById(temp["id"])]["img"] = temp;
|
|
|
+ // });
|
|
|
+ genTree(feature['ID']);
|
|
|
+ }
|
|
|
+ }).catch(function (e) {
|
|
|
+ console.log('Error', e)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
function base64_decode(input) {
|
|
|
-
|
|
|
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
|
|
var output = "";
|
|
|
var chr1, chr2, chr3;
|
|
|
@@ -2591,7 +2588,6 @@ $(document).ready(function() {
|
|
|
if (enc4 != 64) {
|
|
|
output = output + String.fromCharCode(chr3);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
var string = "";
|
|
|
@@ -2599,9 +2595,7 @@ $(document).ready(function() {
|
|
|
var c = c1 = c2 = 0;
|
|
|
|
|
|
while (i < output.length) {
|
|
|
-
|
|
|
c = output.charCodeAt(i);
|
|
|
-
|
|
|
if (c < 128) {
|
|
|
string += String.fromCharCode(c);
|
|
|
i++;
|
|
|
@@ -2615,27 +2609,19 @@ $(document).ready(function() {
|
|
|
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
|
|
i += 3;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return string;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//Pierwszy render, tworzy potrzebna strukture
|
|
|
function showPreview() {
|
|
|
- if (mainProces_id == -1)
|
|
|
- newSteps = -1;
|
|
|
- else
|
|
|
- newSteps = 0;
|
|
|
+ newSteps = (mainProces_id == -1) ? -1 : 0
|
|
|
changes = false;
|
|
|
$("#clearBtn").hide();
|
|
|
lastSearch = "";
|
|
|
filtr = 0;
|
|
|
selectedArea = false;
|
|
|
state = [];
|
|
|
-
|
|
|
newRes = 0;
|
|
|
deletedId = [];
|
|
|
deletedRes = [];
|
|
|
@@ -2673,22 +2659,29 @@ $(document).ready(function() {
|
|
|
} else {
|
|
|
$("#main").html("<center>Synchronizowanie danych z serwerem.</center>");
|
|
|
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>';
|
|
|
- $.get(link, function(data) {
|
|
|
- var temp = {};
|
|
|
+ p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
|
|
|
+ 'featureID': 'CRM_PROCES.' + id,
|
|
|
+ }).then(function (features) {
|
|
|
+ if (!features) throw "Nie odnaleziono rekordu id = " + id
|
|
|
+ if (!features.length) throw "Nie odnaleziono rekordu id = " + id
|
|
|
+ if (1 !== features.length) throw "Bład: API zwróciło za dużo rekordów"
|
|
|
+ return features[0]
|
|
|
+ console.log('fetched features', features)
|
|
|
+ }).then(function (feature) {
|
|
|
+ var temp = {};
|
|
|
loaded = false;
|
|
|
temp["id"] = mainProces_id;
|
|
|
temp["depth"] = 0;
|
|
|
- temp["parent_id"] = $(data).find("featureMember").find("PARENT_ID").text();
|
|
|
+ temp["parent_id"] = feature["PARENT_ID"]
|
|
|
temp["step"] = 0;
|
|
|
temp["goto"] = {};
|
|
|
- temp["goto"]["id"] = $(data).find("featureMember").find("IF_TRUE_GOTO").text();
|
|
|
- temp["goto"]["flag"] = $(data).find("featureMember").find("IF_TRUE_GOTO_FLAG").text();
|
|
|
+ temp["goto"]["id"] = feature["IF_TRUE_GOTO"]
|
|
|
+ temp["goto"]["flag"] = feature["IF_TRUE_GOTO_FLAG"]
|
|
|
temp["stepDesc"] = "";
|
|
|
temp["prof"] = Array();
|
|
|
temp["res"] = Array();
|
|
|
- temp["desc"] = $(data).find("featureMember").find("DESC").text();
|
|
|
- temp["opis"] = $(data).find("featureMember").find("OPIS").text()
|
|
|
+ temp["desc"] = feature["DESC"]
|
|
|
+ temp["opis"] = feature["OPIS"]
|
|
|
|
|
|
state[0] = temp;
|
|
|
// var linkImg = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:CRM_IMAGE&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_ID</ogc:PropertyName><ogc:Literal>' + mainProces_id + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>REMOTE_TABLE</ogc:PropertyName><ogc:Literal>CRM_PROCES</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>';
|
|
|
@@ -2704,7 +2697,10 @@ $(document).ready(function() {
|
|
|
// state[0]["img"] = temp;
|
|
|
// });
|
|
|
genTree(mainProces_id);
|
|
|
- });
|
|
|
+ }).catch(function (e) {
|
|
|
+ console.log('Error', e)
|
|
|
+ })
|
|
|
+
|
|
|
actSite = "preview";
|
|
|
}
|
|
|
}
|