| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898 |
- // @required var BASE_URL
- // @required var TASK
- // @required var USER
- // @required var TYPE
- // @required var ProblemsTableId
- // @required var ProjectsTableId
- var activeCount = 0;
- var allCount = 0;
- var acceptedCount = 0;
- var picker;
- var position = 0;
- var wordLen = 0;
- var projectId;
- var author;
- var state = [];
- var loaded;
- renderForm();
- /*$(document).on('click', '#save', function() {
- $("#save").prop('disabled', true);
- save();
- });*/
- function setSort() {
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- var i = 0;
- var idx = [];
- $("#sortable").find(".singleTask").each(function() {
- i++;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).data("id") + `</ID>
- <SORT_PRIO xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + i + `</SORT_PRIO>
- </PROBLEMS>
- </Insert>
- `;
- idx.push($(this).data("id"));
- });
- req += `</Transaction>`;
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- //console.log(req);
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "xml",
- success: function(data) {
- //console.log("sorted");
- //console.log(data);
- $.notify("Sortowanie zsynchronizowane", "success");
- }
- });
- var temp = [];
- $.each(idx, function(i, e){
- var index = getIndexById(e);
- temp.push(state[index]);
- });
- $.each(state, function(i, e){
- if(e['percent'] == "100%")
- temp.push(e);
- });
- state = [];
- state = temp;
- render();
- }
- function createLink(name, id, target) {
- var link;
- if (TYPE == "PROBLEM") {
- link = BASE_URL + 'index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ProblemsTableId + "#EDIT/" + id;
- }
- if (TYPE == "PROJECT") {
- link = BASE_URL + 'index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ProjectsTableId + "#EDIT/" + id;
- }
- $(target).attr("href", link);
- }
- function getDetails(value) {
- var date = false;
- var worker = false;
- $.each(value.split(" "), function(i, e) {
- if (e.substr(0, 1) == "@") {
- var query = e.substr(1);
- if (query != "" && isNaN(query.substr(0, 1)) && !worker) {
- worker = query;
- }
- if (query != "" && !isNaN(query.substr(0, 1)) && !date) {
- date = moment(query).format('YYYY-MM-DD HH:mm:ss');
- }
- }
- });
- return {
- worker: worker,
- date: date
- };
- }
- //Deleted function to save changes.
- /*function save() {
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- var saveQuery = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS ` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">` + TASK + `</ID>
- `;
- $("#left").find("input").each(function() {
- saveQuery += '<' + $(this).attr("name") + ' xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + $(this).val() + '</' + $(this).attr("name") + '>\n';
- });
- $("#left").find("select").each(function() {
- saveQuery += '<' + $(this).attr("name") + ' xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + $(this).find("option:selected").text() + '</' + $(this).attr("name") + '>\n';
- });
- saveQuery += `
- </PROBLEMS>
- </Insert>
- </Transaction>
- `;
- //console.log(saveQuery);
- $.ajax({
- url: link,
- data: saveQuery,
- type: 'POST',
- contentType: "text/xml",
- dataType: "text",
- success: function(data) {
- //console.log(data);
- $.notify("Zapisano!", "success");
- $("#save").prop('disabled', false);
- renderForm();
- },
- error: function(xhr, ajaxOptions, thrownError) {
- $.notify("Brak połączenia z bazą danych", "error");
- }
- });
- }*/
- function updateProgress() {
- var proc;
- var procAcc;
- allCount = state.length;
- activeCount = 0;
- acceptedCount = 0;
- $.each(state, function(i, e){
- if (e["percent"] != "100%") {
- activeCount++;
- }
- if (e["status"] == "OFF_HARD") {
- acceptedCount++;
- }
- });
- if (allCount != 0) {
- proc = Math.round((allCount - activeCount) / allCount * 100 / 10) * 10;
- procAcc = Math.round((acceptedCount) / allCount * 100 / 10) * 10;
- } else {
- proc = 0;
- procAcc = 0;
- }
- $("#completed").css('width', proc - procAcc + "%").attr('aria-valuenow', proc - procAcc).text(proc + '%');
- $("#accepted").css('width', procAcc + "%").attr('aria-valuenow', procAcc).text(procAcc + '%');
- if (proc == 0) {
- $("#completed").text("");
- }
- if (procAcc == 0) {
- $("#accepted").text("");
- }
- }
- function getCaretPosition(ctrl) {
- var start, end;
- if (ctrl.setSelectionRange) {
- start = ctrl.selectionStart;
- end = ctrl.selectionEnd;
- } else if (document.selection && document.selection.createRange) {
- var range = document.selection.createRange();
- start = 0 - range.duplicate().moveStart('character', -100000);
- end = start + range.text.length;
- }
- return {
- start: start,
- end: end
- }
- }
- $(document).on('dblclick', '#sortable li', function(e) {
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- var index = getIndexById($(this).data("id"));
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).data("id") + `</ID>`;
- if (state[index]["status"] == "NORMAL") {
- state[index]["status"] = "WAITING";
- req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">WAITING</A_STATUS>';
- } else if (state[index]["status"] == "WAITING") {
- state[index]["status"] = "NORMAL";
- req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">NORMAL</A_STATUS>';
- }
- req += `</PROBLEMS>
- </Insert>
- </Transaction>`;
- render();
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "text",
- success: function(data) {}
- });
- });
- function autoCom() {
- var hide = true;
- $(".eInput").autocomplete({
- source: function(request, response) {
- $.ajax({
- url: BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:ADMIN_USERS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>ADM_ACCOUNT</ogc:PropertyName><ogc:Literal>*' + request.term + '*</ogc:Literal></ogc:PropertyIsLike></ogc:Filter>&maxFeatures=10',
- dataType: "xml",
- success: function(xmlResponse) {
- var data = $("featureMember", xmlResponse).map(function() {
- if ($("ID", this).text() != 0)
- return {
- value: $("ADM_ACCOUNT", this).text(),
- id: $("ID", this).text()
- };
- });
- response(data);
- }
- });
- },
- search: function() {
- if (hide) return false;
- },
- select: function(event, ui) {
- var text = this.value;
- this.value = text.substring(0, position) + " @" +
- ui.item.value + " " + text.substring(position + wordLen + 2);
- return false;
- },
- focus: function() {
- return false;
- },
- minLength: 0
- }).bind("keyup", function() {
- hide = true;
- $(this).autocomplete("close");
- var caret = getCaretPosition(this);
- var val = this.value;
- val += " ";
- var result = /\S+$/.exec(val.slice(0, val.indexOf(' ', caret.end)));
- var lastWord = result ? result[0] : null;
- if (lastWord != null && lastWord.substring(0, 1) == "@") {
- wordLen = lastWord.length;
- var query = lastWord.substr(1);
- if (isNaN(query.substring(0, 1)) && query != "") {
- hide = false;
- if (val.substr(0, caret.end).lastIndexOf(" ") > 0) {
- position = val.substr(0, caret.end).lastIndexOf(" ");
- } else {
- position = 0;
- }
- }
- if (!isNaN(query.substring(0, 1)) && query != "") {
- if (val.substr(0, caret.end).lastIndexOf(" ") > 0) {
- position = val.substr(0, caret.end).lastIndexOf(" ");
- } else {
- position = 0;
- }
- $(picker).data("DateTimePicker").show();
- }
- }
- $(this).autocomplete("search", query);
- });
- }
- $(document).on('keydown', '.hours', function(e) {
- var textarea = this;
- if (e.which == 13) {
- $(textarea).prop("disabled", true);
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).parents("li").data('id') + `</ID>
- <L_APPOITMENT_PERIOD xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(textarea).val()+ `</L_APPOITMENT_PERIOD>
- </PROBLEMS>
- </Insert>`;
- req += '</Transaction>';
- var id = getIndexById($(this).parents("li").data('id'));
- var period = $(this).val();
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "xml",
- success: function(data) {
- $.notify("Zapisano!", "success");
- state[id]["period"] = period;
- render();
- }
- });
- }
- });
- $(document).on('keydown', '.editable', function(e) {
- var textarea = this;
- if (e.keyCode == 13) {
- $(textarea).prop("disabled", true);
- var details = getDetails($(this).val());
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).parents("li").data('id') + `</ID>`;
- if (details.worker != false)
- req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.worker + '</L_APPOITMENT_USER>';
- else
- req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + USER + '</L_APPOITMENT_USER>';
- if (details.date != false)
- req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.date + '</A_PROBLEM_DATE>';
- else
- req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + moment().format('YYYY-MM-DD HH:mm:ss') + '</A_PROBLEM_DATE>';
- req += `<A_PROBLEM_DESC xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).val() + `</A_PROBLEM_DESC>
- <CUSTOMER_ADMIN_USER xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">BRAK</CUSTOMER_ADMIN_USER>
- </PROBLEMS>
- </Insert>`;
- req += '</Transaction>';
- var id = getIndexById($(this).parents("li").data('id'));
- var desc = $(this).val();
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "xml",
- success: function(data) {
- state[id]["desc"] = desc;
- if (details.worker != false) {
- state[id]["worker"] = details.worker
- } else {
- state[id]["worker"] = USER;
- }
- render();
- $.notify("Zapisano!", "success");
- }
- });
- return false;
- }
- });
- $(document).on('keydown', '.eInput', function(e) {
- if (e.keyCode == 13) {
- if ($(this).val() != "") {
- var details = getDetails($(this).val());
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">`;
- if (TYPE == "PROBLEM") {
- req += `<PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + TASK + `</PARENT_ID>`;
- }
- if (TYPE == "PROJECT") {
- req += `<PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">0</PARENT_ID>`;
- }
- if (details.worker != false) {
- req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.worker + '</L_APPOITMENT_USER>';
- } else {
- req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + USER + '</L_APPOITMENT_USER>';
- }
- if (details.date != false) {
- req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.date + '</A_PROBLEM_DATE>';
- } else {
- req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + moment().format('YYYY-MM-DD HH:mm:ss') + '</A_PROBLEM_DATE>';
- }
- req += `<ID_PROJECT xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + ProjectId + `</ID_PROJECT>`;
- req += `<L_APPOITMENT_PERIOD xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">0</L_APPOITMENT_PERIOD>`;
- req += `<A_PROBLEM_DESC xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).val() + `</A_PROBLEM_DESC>
- <CUSTOMER_ADMIN_USER xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">BRAK</CUSTOMER_ADMIN_USER>
- </PROBLEMS>
- </Insert>`;
- req += '</Transaction>';
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- var info = this;
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "xml",
- success: function(data) {
- var temp = {};
- temp["id"] = $(data).find("FeatureId").attr("fid").substr($(data).find("FeatureId").attr("fid").indexOf('.') + 1);
- temp["desc"] = $(info).val();
- temp["percent"] = "0%";
- temp["period"] = "0";
- temp["status"] = "WAITING";
- temp["worker"] = (details.worker != false ? details.worker : USER);
- temp["owner"] = USER;
- state.push(temp);
- $(".eInput").val("");
- updateProgress();
- render();
- setSort();
- }
- });
- }
- return false;
- }
- });
- $(document).on('click', '.delTask', function() {
- if ($(this).parents(".singleTask").find(".aCheck").data("state") == "1") {
- $.notify("Nie możesz zmieniać stanu zatwierdzonych zadań", "danger");
- return true;
- }
- if ($(this).parents(".singleTask").data("step") == 2) {
- allCount--;
- } else {
- allCount--;
- activeCount--;
- }
- var id = $(this).closest(".singleTask").data("id");
- var index = getIndexById(id);
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">`;
- req += `<ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + id + `</ID>`;
- req += `<A_STATUS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">DELETED</A_STATUS>
- </PROBLEMS>
- </Insert>`;
- req += '</Transaction>';
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "xml",
- success: function(data) {
- }
- });
- state.splice(index, 1);
- render();
- });
- $(document).on('click', '#showMore', function() {
- if ($("#doneList").is(":visible")) {
- $("#doneList").slideUp("fast");
- $(this).html("Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span>");
- } else {
- $("#doneList").slideDown("fast");
- $(this).html("Ukryj wykonane zadania <span class='glyphicon glyphicon-chevron-up'></span>");
- }
- });
- $(document).on('click', '.aCheck', function() {
- var node = this;
- var id = getIndexById($(node).parents("li").data("id"));
- if (state[id]["owner"] != USER) {
- $.notify("Tylko zleceniodawca może zatwierdzać postęp prac.", "danger");
- return true;
- }
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + id + `</ID>`;
- if (state[id]['status'] != "OFF_HARD") {
- req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">OFF_HARD</A_STATUS>';
- state[id]['status'] = "OFF_HARD";
- } else {
- req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">WAITING</A_STATUS>';
- state[id]['status'] = "WAITING";
- }
- req += `</PROBLEMS>
- </Insert>
- </Transaction>`;
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "text",
- success: function(data) {
- setSort();
- updateProgress();
- render();
- }
- });
- });
- function getIndexById(id){
- for (var i = 0; i < state.length; i++) {
- if (state[i]['id'] == id) {
- return i;
- }
- }
- return false;
- }
- $(document).on('click', '.check', function() {
- var node = this;
- var id = $(node).parents("li").data("id");
- var index = getIndexById(id);
- if (state[index]['status'] == "OFF_HARD") {
- $.notify("Nie możesz zmieniać stanu zatwierdzonych zadań", "danger");
- return true;
- }
- if(state[index]['childs'] != false){
- $.notify("Zmieniać status można tylko wtedy, jeżeli zadanie nie ma podzadań.", "danger");
- return;
- }
- var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
- var req = `
- <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/PROBLEMS"
- xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:4326&"
- xmlns:gml="http://www.opengis.net/gml">
- `;
- req += `
- <Insert xmlns="http://www.opengis.net/wfs">
- <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
- <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(node).parents("li").data("id") + `</ID>`;
- if (state[index]['percent'] != "100%") {
- req += '<A_PROBLEM_COMPLETE_PERCENT xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">100%</A_PROBLEM_COMPLETE_PERCENT>';
- state[index]['percent'] = "100%";
- } else {
- req += '<A_PROBLEM_COMPLETE_PERCENT xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">0%</A_PROBLEM_COMPLETE_PERCENT>';
- state[index]['percent'] = "0%";
- }
- req += `</PROBLEMS>
- </Insert>
- </Transaction>`;
- $.ajax({
- url: link,
- data: req,
- type: 'POST',
- contentType: "text/xml",
- dataType: "text",
- success: function(data) {
- setSort();
- }
- });
- updateProgress();
- render();
- });
- function stripHTML(dirtyString) {
- var container = document.createElement('div');
- var text = document.createTextNode(dirtyString);
- container.appendChild(text);
- return container.innerHTML; // innerHTML will be a xss safe string
- }
- function renderForm() {
- $("#left").empty();
- var link, link2;
- if (TYPE == "PROBLEM") {
- link = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&TYPENAME=p5_default_db:PROBLEMS&REQUEST=DescribeFeatureTypeAdvanced";
- link2 = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>" + TASK + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
- }
- if (TYPE == "PROJECT") {
- link = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&TYPENAME=p5_default_db:IN7_MK_BAZA_DYSTRYBUCJI&REQUEST=DescribeFeatureTypeAdvanced";
- link2 = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:IN7_MK_BAZA_DYSTRYBUCJI&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>" + TASK + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
- }
- var field = '';
- $.get(link, function(fields) {
- $.get(link2, function(data) {
- author = $(data).find("A_RECORD_CREATE_AUTHOR").text();
- if (TYPE == "PROBLEM") {
- ProjectId = $(data).find("ID_PROJECT").text();
- }
- if (TYPE == "PROJECT") {
- ProjectId = TASK;
- }
- if (TYPE == "PROBLEM") {
- var breadcrumb = `
- <ol class="breadcrumb">
- ` + ($(data).find("ID_PROJECT").text() != 0 ? "<li><a href='" + BASE_URL + "index.php?_route=UrlAction_TaskManager&ID_PROJECT=" + $(data).find("ID_PROJECT").text() + "'> Projekt " + $(data).find("ID_PROJECT").text() + "</a></li>" : "") + `
- ` + ($(data).find("PARENT_ID").text() != 0 ? "<li><a href='" + BASE_URL + "index.php?_route=UrlAction_TaskManager&ID_PROBLEM=" + $(data).find("PARENT_ID").text() + "'> Zadanie " + $(data).find("PARENT_ID").text() + "</a></li>" : "") + `
- <li class="active">Zadanie ` + $(data).find("ID").text() + ` </li>
- </ol>`;
- }
- if (TYPE == "PROJECT") {
- var breadcrumb = `
- <ol class="breadcrumb">
- <li class=active> Projekt ` + TASK + `</li>
- </ol>`;
- }
- $("#left").append(breadcrumb);
- field += '';
- $(fields).find("sequence").find("element").each(function() {
- var show = true;
- if ($(this).attr('name') == "ID") {
- show = false;
- }
- if (show) {
- field += '<div class="form-group">';
- field += '<label class="col-xs-12 col-sm-12 col-md-12 control-label" for="' + $(this).attr('name') + '">';
- if ($(this).attr('p5:label')) {
- field += $(this).attr('p5:label');
- } else {
- field += $(this).attr('name');
- }
- field += ' <i class="glyphicon glyphicon-info-sign frm-help" data-toggle="popover" data-trigger="hover" title="" data-content="' + stripHTML($(this).attr('p5:description')) + '" data-original-title="' + $(this).attr('name') + '">';
- field += '</i>';
- field += '</label>';
- field += '<div class="col-xs-12 col-sm-12 col-md-12">';
- var value = $(data).find($(this).attr('name')).text();
- if ($(this).attr('p5:allow_write') == "true") {
- if ($(this).attr('type') == "gml:LineStringPropertyType") {
- field += '...';
- } else if ($(this).attr('type') == "xsd:string" || $(this).attr('type') == "xsd:integer" || true) {// || true due to changes of saving system.
- field += '<input readOnly name="' + $(this).attr('name') + '" type="text" value="' + $(data).find($(this).attr('name')).text() + '" maxlength="255" class="form-control">';
- } else if ($(this).attr('type') == "xsd:dateTime") {
- field += '<div class="input-group"><input name="' + $(this).attr('name') + '" readOnly type="text" value="' + value + '" maxlength="255" class="se_type-datetime form-control" data-format="yyyy-MM-dd hh:mm"><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></div>';
- } else {
- field += '<select name="' + $(this).attr('name') + '" class="form-control"><option></option>';
- $(fields).find("simpleType[name='" + $(this).attr('type').replace("p5_default_db:", "") + "']").find("enumeration").each(function() {
- if (value == $(this).attr("value")) {
- field += '<option selected=SELECTED >' + $(this).attr("value") + '</option>';
- } else {
- field += '<option >' + $(this).attr("value") + '</option>';
- }
- });
- field += "</select>";
- }
- } else {
- field += $(data).find($(this).attr('name')).text();
- }
- field += '</div>';
- field += '<div class=clearfix></div></div>';
- }
- });
- field += '<div class="form-group">';
- field += '<div class="col-xs-offset-0 col-xs-12 col-sm-offset-3 col-sm-9 col-md-offset-2 col-md-10">';
- field += '</div></div>';
- field += '<a><button type="submit" class="btn btn-primary" id=save tabindex="20">Edytuj</button></a>';
- $("#left").append(field);
- $("#left").append("<div class=clearfix></div>");
- createLink("PROBLEMS", TASK, $("#save").parents("a"));
- //renderTaskManager();
- getData();
- });
- });
- }
- $(document).ajaxStop(function() {
- if (loaded) return;
- loaded = true;
- renderTaskManager();
- });
- function getData() {
- if (TYPE == "PROBLEM") {
- link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>' + TASK + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:Not><ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>Deleted</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not></ogc:And></ogc:Filter>&sortBy=SORT_PRIO+A';
- }
- if (TYPE == "PROJECT") {
- link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>ID_PROJECT</ogc:PropertyName><ogc:Literal>' + TASK + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>0</ogc:Literal></ogc:PropertyIsEqualTo><ogc:Not><ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>DELETED</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not></ogc:And></ogc:Filter>&sortBy=SORT_PRIO+A';
- }
- $.get(link, function(data) {
- loaded = false;
- //console.log(data);
- var count = $(data).find("featureMember").length;
- $(data).find("featureMember").each(function(e) {
- if ($(this).find("ID").text() == 0) {
- return;
- }
- var temp = {};
- temp["id"] = $(this).find("ID").text();
- temp["desc"] = $(this).find("A_PROBLEM_DESC").text();
- temp["percent"] = $(this).find("A_PROBLEM_COMPLETE_PERCENT").text();
- temp["status"] = $(this).find("A_STATUS").text();
- temp["worker"] = $(this).find("L_APPOITMENT_USER").text();
- temp["period"] = $(this).find("L_APPOITMENT_PERIOD").text();
- temp["owner"] = $(this).find("A_RECORD_CREATE_AUTHOR").text();
- temp["childs"] = false;
- var linkChilds = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>" + temp["id"] + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
- $.get(linkChilds, function(data) {
- if ($(data).find("ID").text() != '0') {
- temp["childs"] = true;
- }
- state.push(temp);
- });
- });
- });
- }
- function render() {
- var resultActive = "";
- var resultDone = "";
- //console.log(state);
- $.each(state, function(i, e) {
- var result = "";
- var css = "";
- if (e["percent"] != "100%") {
- if (e['status'] == "NORMAL") {
- css = "background: linear-gradient(to right, #73fb73 0%, #73fb73 " + e["percent"] + ", #bdefbd " + e["percent"] + ", #bdefbd 100%);";
- } else if (e['status'] == "WAITING") {
- css = "background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.1) " + e["percent"] + ", transparent " + e["percent"] + ", transparent 100%);";
- }
- }
- result += "<li class=singleTask data-id=" + e["id"] + " style='"+css+"'>";
- result += "<span class='glyphicon glyphicon-option-vertical ico'></span>";
- if (e["percent"] == "100%") {
- result += "<span class=check style='background-color:#333333'></span>";
- if (e['status'] != "OFF_HARD") {
- result += "<span class=aCheck></span>";
- } else {
- result += "<span class=aCheck style=background-color:green;></span>";
- }
- } else {
- result += "<span class=check></span>";
- }
- result += "<input type=text "+(e["childs"] ? "DISABLED" : "")+" class='form-control hours' value='"+e["period"]+"' style=width:40px;float:left;padding:0px;height:25px;>"
- result += "<textarea " + (USER != e["owner"] || e['status'] == "OFF_HARD" ? "DISABLED" : "") + " class=editable>" + e['desc'] + "</textarea>";
- result += `<div class="dropdown" style=display:inline;>
- <span class="glyphicon glyphicon glyphicon-menu-hamburger" data-toggle="dropdown"></span>
- <ul class="dropdown-menu dropdown-menu-right">
- <li><a href=` + BASE_URL + `index.php?_route=UrlAction_TaskManager&ID_PROBLEM=` + e['id'] + `>Szczegóły</a></li>
- <li><p style="cursor:pointer;padding:3px 20px;" class=delTask>Usuń</p></li>
- </ul>
- </div>`;
- result += ((e['owner'] != USER) ? " <span class='glyphicon glyphicon-user user' title='Zlecone przez inną osobę'></span>" : "") + "</li>";
- if (e['percent'] == "100%") {
- resultDone += result;
- } else {
- resultActive += result;
- }
- });
- resultActive += "<div class=clearfix></div>";
- resultDone += "<div class=clearfix></div>";
- $("#sortable").html(resultActive);
- $("#doneList").html(resultDone);
- }
- function loadStats(){
- var link;
- if (TYPE == "PROBLEM") {
- link = BASE_URL + "index.php?_route=UrlAction_TaskManager&_task=getStatsAjax&TYPE=PROBLEM&ID="+TASK;
- } else {
- link = BASE_URL + "index.php?_route=UrlAction_TaskManager&_task=getStatsAjax&TYPE=PROBLEM&ID="+TASK;
- }
- $.get(link, function(data) {
- data = data[0];
- var result = "<td>L. wykonanych podzadań: "+data["CHILDS_DONE_COUNT"]+"/"+data["CHILDS_COUNT"]+"</td><td></td>";
- $("#line1", ".stats").html(result);
- });
- }
- function renderTaskManager() {
- $("#right").append("<div class=taskList ></div>");
- if (false) {// TODO
- $("#right").append("<h2>Statystyki</h2><div class=stats></div>");
- $(".stats").append("<div class=table-responsive><table class=table><tr id=line1></tr><tr id=line2></tr></table></div>");
- loadStats();
- }
- $(".taskList").append("<div class=progress></div>");
- $(".progress").append("<div id=accepted class='progress-bar progress-bar-success progress-bar-striped' role=progressbar style=width:9%>0%</div>");
- $(".progress").append("<div id=completed class='progress-bar progress-bar-info progress-bar-striped' role=progressbar style=width:9%>0%</div>");
- $(".taskList").append("<ul id='sortable'></ul>");
- // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Zaprojektować podstawowy layout skryptu</div></li>");
- // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Stworzyć tasklistę, dodać przesuwaunie i flagowanie</div></li>");
- // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Dodać po lewej stronie formularz</div></li>");
- // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Połączyć z API</div></li>");
- $(".taskList").append("<div id=add><span class='glyphicon glyphicon-plus addIco'></span> <textarea class=eInput id=datepicker placeholder='Dodaj zadanie'></textarea><div class=clearfix></div></div>");
- picker = $("<input/>", {
- type: 'text',
- style: 'width:0px;height:0px;outline:none;overflow:0;border:0;margin:0px;padding:0px;',
- id: "date",
- }).datetimepicker({
- defaultDate: false,
- useCurrent: false,
- widgetPositioning: {
- horizontal: 'auto',
- vertical: 'bottom'
- }
- })
- $('.taskList').append(picker);
- $(".taskList").append("<div id=showMore >Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span></div>");
- $(".taskList").append("<ul id='doneList'></ul>");
- var link;
- $('.editable').autosize();
- $("#doneList").hide();
- updateProgress();
- $(picker).on("dp.change", function(e) {
- var date = e.date;
- date = date.format('YYYY-MM-DD');
- var text = $(".eInput").val();
- var result = text.substring(0, position) + " @" + date + " " + text.substring(position + wordLen + 2);
- $(".eInput").val(result);
- $(picker).data("DateTimePicker").hide();
- });
- $(function() {
- $("#sortable").sortable({
- stop: function(event, ui) {
- setSort();
- },
- handle: ".ico"
- });
- autoCom();
- $('.eInput').autosize();
- });
- render();
- }
|