Explorar o código

updated procesEditor

Piotr Labudda %!s(int64=9) %!d(string=hai) anos
pai
achega
1d18c90564
Modificáronse 2 ficheiros con 217 adicións e 87 borrados
  1. 46 13
      SE/se-lib/Route/UrlAction/ProcesEditor.php
  2. 171 74
      SE/static/procesEditor.js

+ 46 - 13
SE/se-lib/Route/UrlAction/ProcesEditor.php

@@ -56,24 +56,26 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 			}
 	}
 
-	public function getSingleResAjaxReponseCallback(){
+	public function getSingleResAjaxReponseCallback() {
 		if (!isset($_POST['data'])) throw new Exception("data is not set.");
-		$data = $_POST['data'];
+		$ids = V::get('data', null, $_POST, 'uint_array');
+		if (empty($ids)) throw new Exception("data is not correct.");
 		$sqlWhereIdIn = array();
-		foreach ($data as $value) {
+		foreach ($ids as $value) {
 			$sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT);
-											}
-			$sqlWhereIdIn = (!empty($sqlWhereIdIn)) ? "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")" : "1=1";
+		}
+		$sqlWhereIdIn = "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")";
 		$rows = DB::getPDO()->fetchAll("
-		select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
-		from CRM_LISTA_ZASOBOW g
-			left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
-			left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
-			left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
-		where {$sqlWhereIdIn}");
+			select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
+			from CRM_LISTA_ZASOBOW g
+				left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
+				left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
+				left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
+			where {$sqlWhereIdIn}
+		");
 		return $rows;
 	}
-	public function getSingleResAjaxAction(){
+	public function getSingleResAjaxAction() {
 		Response::sendTryCatchJson(array($this, 'getSingleResAjaxReponseCallback'));
 	}
 
@@ -108,8 +110,10 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 			<div id='sidebar-wrapper'><div id="side"></div></div>
 			<div id='page-content-wrapper'>
 				<div id="left" style='width:40px;'>
+
 					<button class='lButton btn btn-default' id="btnZasoby" style="top:150px"><p>Zasoby</p></button>
 					<button class='lButton btn btn-default' style="top:315px" id="btnProcesy"><p>Procesy</p></button>
+					<!--<button class='lButton btn btn-default' id="btnPhotos" style="top:480px"><p>Zdjęcia</p></button>-->
 				</div>
 				<div id="main" style="margin-left:40px">
 					<center>Uruchamianie aplikacji.</center>
@@ -118,7 +122,8 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 		</div>
 		<script>var BASE_URL = '<?= Request::getPathUri(); ?>';var mainProces_id = <?= $id; ?>;</script>
 		<script src="static/sweetalert2.min.js"></script>
-		<script src="static/procesEditor.js?v=13"></script>
+		<script src="static/procesEditor.js?v=16"></script>
+
 <?php
 	}
 
@@ -246,6 +251,34 @@ ul {
 	display:inline-block;
 }
 
+#dropPic{
+	height:250px;
+	border-radius:5px;
+	border-style:solid;
+	border-color:#ededed;
+	background-color: #fbfbfb;
+	border-width:1px;
+}
+
+.upload-drop-zone {
+  height: 100px;
+  border-width: 2px;
+  margin-bottom: 0px;
+}
+
+/* skin.css Style*/
+.upload-drop-zone {
+  color: #ccc;
+  border-style: dashed;
+  border-color: #ccc;
+  line-height: 100px;
+  text-align: center
+}
+.upload-drop-zone.drop {
+  color: #222;
+  border-color: #222;
+}
+
 .anim-refresh {
     -animation: spin .7s infinite linear;
     -webkit-animation: spin2 .7s infinite linear;

+ 171 - 74
SE/static/procesEditor.js

@@ -58,13 +58,7 @@ $(document).ready(function() {
 
     function loadResources() {
         $("#main").html("<center>Pobieranie danych o zasobach.</center>");
-        //console.log("res!");
-        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,ID';
-        //console.log("link "+link);
-
         sFiltr += `
           <GetFeature xmlns="http://www.opengis.net/wfs/2.0"
           xmlns:p5_default_db="` + BASE_URL + `wfs/default_db"
@@ -72,19 +66,27 @@ $(document).ready(function() {
           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>`;
-
-        $.each(state, function(i, e) {
-            var id = e["id"];
-            sFiltr += '<ogc:PropertyIsEqualTo><ogc:PropertyName>ID_PROCES</ogc:PropertyName><ogc:Literal>' + id + '</ogc:Literal></ogc:PropertyIsEqualTo>';
-
+          xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">`;
+        sFiltr += '  <ogc:Filter>';
+        sFiltr += '    <ogc:And>';
+        sFiltr += '      <ogc:Or>';
+        $.each(state, function(idx, procesItem) {
+          sFiltr += '        <ogc:PropertyIsEqualTo><ogc:PropertyName>ID_PROCES</ogc:PropertyName><ogc:Literal>' + procesItem["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);
+        sFiltr += '      </ogc:Or>';
+        sFiltr += '      <ogc:Not>';
+        sFiltr += '        <ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>DELETED</ogc:Literal></ogc:PropertyIsEqualTo>';
+        sFiltr += '      </ogc:Not>';
+        sFiltr += '    </ogc:And>';
+        sFiltr += '  </ogc:Filter>';
+        sFiltr += '</GetFeature>';
+
+        var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003';
+        link += '&REQUEST=GetFeature';
+        link += '&TYPENAME=p5_default_db:CRM_WSKAZNIK';
+        link += '&sortBy=SORT_PRIO+A,ID';
+
+        var wskazniki = new Array();
         $.ajax({
             url: link,
             data: sFiltr,
@@ -94,69 +96,73 @@ $(document).ready(function() {
             success: function(data) {
                 //console.log(data);
                 $.each($(data).find("featureMember"), function() {
-                    if ($(this).find("ID").text() == 0)
-                        return;
-                    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);
-
+                    if ($(this).find("ID").text() == 0) return;
+                    var wsk = new Array();
+                    wsk["ID"] = $(this).find("ID").text();
+                    wsk["ID_ZASOB"] = $(this).find("ID_ZASOB").text();
+                    wsk["ID_PROCES"] = $(this).find("ID_PROCES").text();
+                    wsk["SORT_PRIO"] = $(this).find("SORT_PRIO").text();
+                    wsk["ID_PRZYPADEK"] = $(this).find("ID_PRZYPADEK").text();
+                    wsk["OPIS_ZASOB"] = $(this).find("OPIS_ZASOB").text();
+                    wskazniki.push(wsk);
                 });
                 //console.log(res);
-                var sFiltr2 = [];
-                $.each(res, function(index, value) {
-                    var id = res[index]["ID_ZASOB"];
-                    sFiltr2.push(id);
+                var idsZasobyToFetch = [];
+                $.each(wskazniki, function(index, wsk) {
+                    idsZasobyToFetch.push(wsk["ID_ZASOB"]);
                 });
-                if (sFiltr2.length > 0) {
-                  //sFiltr2 = JSON.stringify(sFiltr2);
-                  //console.log(sFiltr2);
-                  //console.log(link2);
+                if (idsZasobyToFetch.length > 0) {
+                  //idsZasobyToFetch = JSON.stringify(idsZasobyToFetch);
+                  //console.log(idsZasobyToFetch);
                   var zasobInfo = new Array();
-                  var link2 = BASE_URL+"index.php?_route=UrlAction_ProcesEditor&_task=getSingleResAjax";
-                  $.post(link2, {data: sFiltr2}, function(data2){
-                    //console.log("data");
-                    // console.log(data2);
-                    $.each(data2, function(i, e) {
-                        zasobInfo[e["ID"]] = new Array();
-                        zasobInfo[e["ID"]]["DESC"] = e["DESC"];
-                        zasobInfo[e["ID"]]["OPIS"] = e["OPIS"];
-                        zasobInfo[e["ID"]]["TYPE"] = e["TYPE"];
-                        zasobInfo[e["ID"]]["TREE"] = [];
-                        for(var i=3;i>0;i--){
-                          if(e["p"+i+"_ID"] != null){
-                            var temp = {};
-                            temp["ID"] = e["p"+i+"_ID"];
-                            temp["DESC"] = e["p"+i+"_DESC"];
-                            zasobInfo[e["ID"]]["TREE"].push(temp);
-                          }
+                  $.ajax({
+                    type: 'POST',
+                    url: BASE_URL+"index.php?_route=UrlAction_ProcesEditor&_task=getSingleResAjax",
+                    data: {data: idsZasobyToFetch},
+                    dataType: 'json'
+                  })
+                  .done(function(jsonZasobyTree) {
+                    $.each(jsonZasobyTree, function(idx, zasob) {
+                      zasobInfo[zasob["ID"]] = new Array();
+                      zasobInfo[zasob["ID"]]["DESC"] = zasob["DESC"];
+                      zasobInfo[zasob["ID"]]["OPIS"] = zasob["OPIS"];
+                      zasobInfo[zasob["ID"]]["TYPE"] = zasob["TYPE"];
+                      zasobInfo[zasob["ID"]]["TREE"] = [];
+                      for (var i = 3; i > 0; i--) {
+                        if (zasob["p"+i+"_ID"] != null) {
+                          var temp = {};
+                          temp["ID"] = zasob["p"+i+"_ID"];
+                          temp["DESC"] = zasob["p"+i+"_DESC"];
+                          zasobInfo[zasob["ID"]]["TREE"].push(temp);
+                        }
                       }
                     });
-                    //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 = "prof";
-                        } else {
-                            type = "res";
-                        }
-                        var id = res[index]["ID_PROCES"];
 
-                        var temp = {};
-                        temp["id_zasob"] = res[index]["ID_ZASOB"]
-                        temp["id"] = res[index]["ID"];
-                        temp["id_przypadek"] = res[index]["ID_PRZYPADEK"];
-                        temp["komentarz"] = res[index]["OPIS_ZASOB"];
-                        temp["desc"] = zasobInfo[res[index]["ID_ZASOB"]]["DESC"];
-                        temp["opis"] = zasobInfo[res[index]["ID_ZASOB"]]["OPIS"];
-                        temp["tree"] = zasobInfo[res[index]["ID_ZASOB"]]["TREE"];
-                        //console.log(temp);
-                        state[getIndexById(id)][type].push(temp);
+                    $.each(wskazniki, function(index, wsk) {
+                      var type,
+                        idZasob = wsk["ID_ZASOB"];
+                      if (!zasobInfo[idZasob]) {
+                        $("#main").html("<center>Generowanie widoku.</center>");
+                        render(state, $("#main"));
+                        return;
+                      }
+                      if (zasobInfo[idZasob]["TYPE"] == "DZIAL" || zasobInfo[idZasob]["TYPE"] == "STANOWISKO" || zasobInfo[idZasob]["TYPE"] == "PODMIOT") {
+                        type = "prof";
+                      } else {
+                        type = "res";
+                      }
+                      var id = wsk["ID_PROCES"];
+
+                      var temp = {};
+                      temp["id_zasob"] = idZasob
+                      temp["id"] = wsk["ID"];
+                      temp["id_przypadek"] = wsk["ID_PRZYPADEK"];
+                      temp["komentarz"] = wsk["OPIS_ZASOB"];
+                      temp["desc"] = zasobInfo[idZasob]["DESC"];
+                      temp["opis"] = zasobInfo[idZasob]["OPIS"];
+                      temp["tree"] = zasobInfo[idZasob]["TREE"];
+                      //console.log(temp);
+                      state[getIndexById(id)][type].push(temp);
                     });
 
                     $("#main").html("<center>Generowanie widoku.</center>");
@@ -608,6 +614,31 @@ $(document).ready(function() {
         }
 
 
+    });
+
+    $(document).on('click', '#btnPhotos', function(e) {
+        e.preventDefault();
+        $(".lButton").removeClass("btn-primary");
+        if (dialog == 0) {
+            photos();
+            $(this).addClass("btn-primary");
+            $("#wrapper").removeClass("toggled");
+            dialog = 3;
+        } else if (dialog == 3) {
+            $("#wrapper").addClass("toggled");
+            dialog = 0;
+        } else {
+            $("#wrapper").addClass("toggled");
+            $(this).addClass("btn-primary");
+            setTimeout(function() {
+                photos();
+                $("#wrapper").removeClass("toggled");
+
+            }, 500);
+            dialog = 3;
+        }
+
+
     });
 
     $(document).on('click', '#btnProcesy', function(e) {
@@ -1147,7 +1178,73 @@ $(document).ready(function() {
     });
 
 
+    $(document).on('change', '#inp', function() {
+      if (this.files && this.files[0]) {
+        var link = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003";
+
+        var name = this.files[0].name;
+        var FR = new FileReader();
+        FR.onload = function(e) {
+          var contentBase64 = e.target.result;
+          var xml = `<Transaction
+    xmlns="http://www.opengis.net/wfs"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    version="1.0.0"
+    service="WFS"
+    xmlns:p5_objects="https://biuro.biall-net.pl/wfs/objects"
+    xmlns:gml="http://www.opengis.net/gml">
+    <Insert xmlns="http://www.opengis.net/wfs">
+      <File xmlns="https://biuro.biall-net.pl/wfs/objects">
+        <name xmlns="https://biuro.biall-net.pl/wfs/objects">`+name+`</name>
+        <content xmlns="https://biuro.biall-net.pl/wfs/objects">`+contentBase64+`</content>
+      </File>
+    </Insert>
+  </Transaction>`;
+
+
+          $.ajax({
+              url: link,
+              data: xml,
+              type: 'POST',
+              contentType: "text/xml",
+              dataType: "xml",
+              success: function(data) {
+                console.log(data);
+              }
+          });
+        };
+        FR.readAsDataURL( this.files[0] );
+      }
+    });
+
+    function photos() {
+        var side = $("#side");
+        $(side).empty();
 
+        var form = `
+          <h4>Wrzuć pliki do swojego schowka</h4>
+          <input id="inp" type='file'>
+
+          <div class="progress">
+            <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
+              <span class="sr-only">60% Complete</span>
+            </div>
+          </div>
+          </div>
+          <h4>Pliki w schowku</h4>`;
+          console.log("test");
+          $(side).append(form);
+          var schowek = '<ul>';
+          schowek += '<li>';
+          schowek += 'Test';
+          schowek += '</li>';
+
+          schowek += '</ul>';
+          console.log(schowek);
+          console.log("test");
+
+          $(side).append(schowek);
+      }
 
     function zasoby() {
         var side = $("#side");