소스 검색

added PorcesView

Piotr Labudda 9 년 전
부모
커밋
c06e8705b6

+ 177 - 0
SE/se-lib/Route/UrlAction/ProcesView.php

@@ -0,0 +1,177 @@
+<?php
+
+Lib::loadClass('RouteBase');
+Lib::loadClass('ProcesHelper');
+Lib::loadClass('Config');
+Lib::loadClass('UI');
+Lib::loadClass('Request');
+Lib::loadClass('ProcesHelper');
+Lib::loadClass('Response');
+
+class Route_UrlAction_ProcesView extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
+
+	public function getAllAjaxAction(){
+		try {
+				$rows = DB::getPDO()->fetchAll("
+					select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `TYPE`
+					from CRM_PROCES
+					WHERE `PARENT_ID`>=0
+						AND `A_STATUS` <> 'DELETED'
+						AND `ID` <> `PARENT_ID`
+					ORDER BY `SORT_PRIO` ASC, `ID` DESC
+				");
+				$state = array();
+				foreach($rows as $key => $value){
+					$id = intval($value["ID"]);
+					$parent_id = intval($value["PARENT_ID"]);
+					$state[$id]["ID"] = $value["ID"];
+					$state[$id]["DESC"] = $value["DESC"];
+					$state[$id]["OPIS"] = $value["OPIS"];
+					$state[$id]["TYPE"] = $value["TYPE"];
+					if(intval($value["PARENT_ID"]) != 0)
+						$state[$id]["PARENT_ID"] = intval($value["PARENT_ID"]);
+					else
+						$state[$id]["PARENT_ID"] = "#";
+					$state[$id]["active"] = false;
+					$state[$id]["details"] = false;
+					if(!isset($state[$id]["childs"]))
+						$state[$id]["childs"] = array();
+
+					if(!isset($state[$value["PARENT_ID"]])){
+						$state[$parent_id]["active"] = false;
+						$state[$parent_id]["details"] = false;
+						$state[$parent_id]["childs"] = array();
+					}
+					$temp = array();
+					$temp["ID"] = $id;
+					array_push($state[$parent_id]["childs"], $temp);
+
+				}
+				//print_r($state);
+				Response::sendJsonExit($state);
+			} catch (Exception $e) {
+				UI::alert('danger', "Error: " . $e->getMessage());
+			}
+	}
+
+	public function handleAuth() {
+		if (!User::logged()) {
+			//throw new HttpException('Unauthorized', 401);
+			User::authByRequest();
+		}
+		// zapisać jsona w sesji
+	}
+
+	public function defaultAction() {
+
+
+		UI::gora();
+		UI::menu();
+		try {
+				$this->showView();
+		} catch (Exception $e) {
+			UI::alert('danger', "Error: " . $e->getMessage());
+		}
+
+		UI::dol();
+	}
+
+	public function showView() {
+
+		echo "<div class=container-fluid>";
+		echo "<div class=row>";
+		echo "<div class=col-md-12 style=padding-top:15px;><a id=toggleMenu style=cursor:pointer;>Przełącz menu</a><a style=float:right;cursor:pointer; id=toggleView>Przełącz na widok drzewa</a></div>";
+		echo "<div class=col-md-12 id=view>";
+		echo "";
+		echo "</div>";
+		echo "</div>";
+		echo "<script>var BASE_URL = '".Request::getPathUri()."';var ProcesTableId=".ProcesHelper::getZasobTableID('CRM_PROCES').";</script>";
+		echo '<script src="static/sweetalert2.min.js"></script>';
+		echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
+		echo '<link rel="stylesheet" href="static/jstree-theme/style.min.css" />';
+		echo '<script src="static/jstree.min.js"></script>';
+		echo '<script src="static/procesView.js?v=1"></script>';
+    $this->showViewCss();
+
+	}
+
+  public function showViewCss() {
+  ?>
+  <style type="text/css">
+  .singleAdv{
+  float:left;
+	padding-bottom:20px;
+	display:block;
+
+
+	overflow-y:scroll;
+  cursor:pointer;
+  width:460px;
+  }
+
+	#procCon{
+		display:block;
+		height:100%;
+	}
+
+  .textTable{
+  	float:left;
+  	width:400px;
+
+    overflow:hidden;
+  	display:inline-block;
+  }
+
+  .glyph{
+    opacity:0.4;
+  }
+  .glyph:hover{
+    opacity:1;
+  }
+
+	.detailsTable{
+		color:black;
+		display:inline-block;
+		padding:4px;
+		padding-top:1px;
+		padding-bottom:1px;
+		border-width:1px;
+		border-color:grey;
+	}
+
+	.detailsTable2{
+		color:black;
+		display:inline-block;
+		padding:3px;
+		padding-top:0px;
+		padding-bottom:0px;
+		border-width:1px;
+		border-color:grey;
+		height:24px; line-height:22px; border:1px solid #fff;
+	}
+
+  #ulproc{
+      background-color: white;
+      overflow-y: scroll;
+      height: 70% !important;
+  		border-style:solid;
+  		border-width:1px;
+  		border-color:grey;
+      margin-top: 10px;
+      border-radius: 5px;
+      padding-bottom: 10px;
+      border-style: solid;
+      border-width: 1px;
+      border-color: #e5e5e5;
+      color: black;
+      padding-left: 0px;
+      font-family: tahoma;
+      font-size: 13px;
+  }
+#tree { overflow:hidden; border:1px solid #ddd; }
+  </style>
+  <?php
+  }
+
+
+}

BIN
SE/static/jstree-theme/32px.png


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
SE/static/jstree-theme/style.min.css


BIN
SE/static/jstree-theme/throbber.gif


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
SE/static/jstree.min.js


+ 413 - 0
SE/static/procesView.js

@@ -0,0 +1,413 @@
+$(document).ready(function(){
+  var state = {};
+  var panels = true;
+  var menuShow = false;
+  var sTimeout = false;
+  $("#SE-menu").hide();
+  $("#SE-menu-sub").hide();
+
+  function translate(objId){
+    var data = [];
+      $.each(state[objId]["childs"], function(indexChilds, childs){
+        var temp = {};
+        var id = childs["ID"];
+        var style = "";
+        switch(state[id]["TYPE"]){
+          case "PROCES_INIT":    style = 'style="background-color:#ffe5e5;color:#333"';break;
+          case "PROCES":         style = 'style="background-color:#ededed;color:#333"';break;
+          case "PROCES_GROUP_1": style = 'style="background-color:#9999cc;color:#fff"';break;
+          case "PROCES_GROUP_2": style = 'style="background-color:#d8d8b2;color:#fff"';break;
+          default:               style = 'style="background-color:#ededed;color:#333"';break;
+        }
+        temp["id"] = id;
+        temp["text"] = "<span class=detailsTable2 "+style+" >"+id+"</span> "+state[id]["DESC"];
+        temp["parent"] = state[id]["PARENT_ID"];
+        data.push(temp);
+        //console.log(data);
+        $.merge(data, translate(id));
+      });
+      return data;
+  }
+
+
+    $(document).on('keyup', '#search', function(e) {
+      if(sTimeout) { clearTimeout(sTimeout); }
+      sTimeout = setTimeout(function () {
+        var val = $('#search').val();
+        $('#tree').jstree(true).search(val, false);
+
+      }, 250);
+    });
+
+  function renderTree(){
+    // jQuery.jstree.defaults.core.themes.responsive = true;
+    $('#view').empty();
+    $("#view").append("<input id=search type=next class=form-control>")
+    $('#view').append("<div id=tree></div>");
+    $('#tree').jstree({
+  "core" : {
+    "animation" : 0,
+    "check_callback" : true,
+    "themes" : { "stripes" : false, "dots": false },
+    'data' : translate(0)
+  },
+  "types" : {
+    "root" : {
+      "icon" : "/static/3.3.2/assets/images/tree_icon.png",
+      "valid_children" : ["default"]
+    },
+    "default" : {
+      "valid_children" : ["default","file"]
+    },
+    "file" : {
+      "icon" : "glyphicon glyphicon-file",
+      "valid_children" : []
+    }
+  },
+  "plugins" : [
+    "contextmenu", "dnd", "search",
+   "types"
+  ],
+  "search": {
+        // search config
+        "show_only_matches": true,
+        },
+  "contextmenu":{
+    "items": function(node) {
+        var tree = $("#tree").jstree(true);
+        var id = node.id;
+        return {
+            "ProcesEditor": {
+                "separator_before": false,
+                "separator_after": false,
+                "label": "Edytor procesów",
+                "action": function (obj) {
+                  window.location = BASE_URL+'index.php?_route=UrlAction_procesEditor&id='+id;
+                }
+            },
+            "EditProces": {
+                "separator_before": false,
+                "separator_after": false,
+                "label": "Edytuj proces",
+                "action": function (obj) {
+                  window.location = BASE_URL+'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/'+id;
+                }
+            },
+            "AddPytania": {
+                "separator_before": false,
+                "separator_after": true,
+                "label": "Edytuj pytania",
+                "action": function (obj) {
+                  window.location = BASE_URL+'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces='+id;
+                }
+            },
+
+            "ProcesMap": {
+                "separator_before": false,
+                "separator_after": false,
+                "label": "Mapa procesu",
+                "action": function (obj) {
+                  window.location = BASE_URL+'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces='+id;
+                }
+            },
+            "ListView": {
+                "separator_before": false,
+                "separator_after": false,
+                "label": "Widok listy",
+                "action": function (obj) {
+                  window.location = BASE_URL+'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces='+id;
+                }
+            },
+            "AddResource": {
+                "separator_before": true,
+                "separator_after": false,
+                "label": "Dodaj zasób",
+                "action": function (obj) {
+                  window.location = BASE_URL+'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID='+id;
+                }
+            },
+            "AddChild": {
+                "separator_before": false,
+                "separator_after": false,
+                "label": "Dodaj dziecko",
+                "action": function (obj) {
+                  window.location = BASE_URL+'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID='+id+'#CREATE';
+                }
+            },
+
+
+
+        };
+    }
+}
+});
+
+  }
+
+  function renderPanels(){
+
+    $("#view").empty();
+
+    var next = 0;
+    var result = "";
+    var depth = 0;
+    var previous = false;
+    result += "<div id=ulproc><div id=procCon>";
+    while(next !== false){
+      depth++;
+
+      //console.log(next);
+      result += "<div class=singleAdv data-depth=0 id=depth0 data-parent="+next+" ><ul  class='singleAdvList list-group' list-group'  style=margin-bottom:0px;>";
+      var details = false;
+      //console.log("next: ", next);
+      //console.log("prev: ", previous);
+      if(previous !== false)
+      //console.log("x", state[previous]["details"]);
+      if(previous !== false && state[previous]["details"] == true){
+        //console.log("ok");
+        result += getDetails(state[next]);
+        details = true;
+        next = false;
+      }
+
+      if(!details ){
+          if(state[next]["childs"].length > 0){
+          $.each(state[next]["childs"], function(i, e){
+              if(state[next]["active"] == e["ID"])
+                result += getView(state[e["ID"]], true);
+              else
+                result += getView(state[e["ID"]], false);
+          });
+          previous = next;
+          next = state[next]["active"];
+        } else {
+          result += getDetails(state[next]);
+          next = false;
+
+        }
+    }
+
+      result += "</ul></div>";
+
+
+    }
+    result += "<div class=clearfix></div></div></div>";
+    $("#ulproc").scrollTop(0);
+    $("#view").html(result);
+    $("#procCon").css("width", depth * 460);
+    $("#ulproc").scrollLeft(depth * 460);
+    $(".singleAdv").css("height", $( window ).height()-100 + "px");
+
+
+    //console.log(result);
+
+  }
+
+  function render(){
+    if(panels){
+      console.log("panels");
+      renderPanels();
+    }else{
+      console.log("drzewo");
+      renderTree();
+    }
+  }
+
+  function updateParent(id, parent, item){
+    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/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&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:CRM_PROCES&amp;SRSNAME=EPSG:4326&amp;"
+xmlns:gml="http://www.opengis.net/gml">
+<Insert xmlns="http://www.opengis.net/wfs">
+<CRM_PROCES xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">
+<ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">`+id+`</ID>
+<PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">`+parent+`</PARENT_ID>
+</CRM_PROCES>
+</Insert>
+</Transaction>`;
+console.log(req);
+$.ajax({
+    url: link,
+    data: req,
+    type: 'POST',
+    contentType: "text/xml",
+    dataType: "text",
+    success: function(data) {
+      return true;
+    },
+    error: function(xhr, ajaxOptions, thrownError) {
+        $(item).sortable('cancel');
+        $.notify("Brak połączenia z bazą danych", "error");
+    }
+  });
+
+  }
+
+  function getDetails(e){
+    console.log("test", e);
+    var result = "";
+    result += '<div class="panel panel-primary">';
+    result += '<div class="panel-heading"><h3 class="panel-title">[' + e["ID"] + '] ' + e["DESC"] + '</h3></div>';
+    result += '<div class="panel-body pbody">';
+    result += '<b>Opis: </b>' + e["OPIS"];
+
+    result += '</div>';
+    result += '</div>';
+    return result;
+  }
+
+  function getView(data, active){
+    var result = "";
+    var childs = true;
+    var type = 0;
+    var style = "";
+    switch(data["TYPE"]){
+      case "PROCES_INIT":    style = 'style="background-color:#ffe5e5;color:#333"';break;
+      case "PROCES":         style = 'style="background-color:#ededed;color:#333"';break;
+      case "PROCES_GROUP_1": style = 'style="background-color:#9999cc;color:#fff"';break;
+      case "PROCES_GROUP_2": style = 'style="background-color:#d8d8b2;color:#fff"';break;
+      default:               style = 'style="background-color:#ededed;color:#333"';break;
+    }
+
+    result += "<li class='list-group-item liProc "+(active ? "active" : "")+"'; ";
+    result += "data-opis='" + data["OPIS"] + "' data-desc='" + data["DESC"] + "'  data-id=" + data["ID"] + " >";
+    result += '<div class="textTable">'
+    result += "<span class=detailsTable "+style+">" + data["ID"] + "</span> "
+    result += data["DESC"] + "</div>"
+    result += "<div style=float:right;><span class='glyph glyphicon gl glyphicon-triangle-right'></span>";
+    result += "<div class='dropdown '>";
+    result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenu"+data["ID"]+"'></span>";
+    result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenu'+data["ID"]+'">';
+    result += '<li><a href="'+BASE_URL+'index.php?_route=UrlAction_procesEditor&id='+data["ID"]+'">Edytor procesu</a></li>';
+    result += '<li><a href="'+BASE_URL+'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/'+data["ID"]+'">Edytuj proces</a></li>';
+    result += '<li><a href="'+BASE_URL+'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID='+data["ID"]+'">Dodaj zasób</a></li>';
+    result += '<li><a href="'+BASE_URL+'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces='+data["ID"]+'">Edytuj Pytania</a></li>';
+    result += '<li><a href="'+BASE_URL+'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces='+data["ID"]+'">Mapa procesu</a></li>';
+    result += '<li><a href="'+BASE_URL+'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces='+data["ID"]+'">Widok listy</a></li>';
+    result += '<li><a href="'+BASE_URL+'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID='+data["ID"]+'#CREATE">Dodaj dziecko</a></li>';
+    //result += '<li><a href="'+BASE_URL+''+$(this).find("ID").text()+'">Widok listy</a></li>';
+    result += '<li><a href="" class=details>Szczegóły</a></li>';
+    result += '</ul>';
+    result += "</div>";
+    result += '</div><div class=clearfix></div></li>';
+
+    if (!childs) {
+        result += getDetails(parent);
+    }
+    return result;
+  }
+
+  $(document).on('click', '.details', function(e) {
+    e.preventDefault();
+    $(this).parents(".singleAdv").nextAll(".singleAdv").remove();
+    $(this).parents(".singleAdv").find(".active").removeClass("active");
+    $(this).find(".gl").removeClass("glyphicon-triangle-right");
+    $(this).find(".gl").addClass("glyphicon-refresh");
+    $(this).find(".gl").addClass("anim-refresh");
+    $('.dropdown.open .dropdown-toggle').dropdown('toggle');
+    var parent = $(this).closest(".liProc");
+    var parent_id = $(parent).data("id");
+    var parentOfParent_id = $(this).closest(".singleAdv").data("parent");
+    state[parentOfParent_id]["active"] = parent_id;
+    state[parentOfParent_id]["details"] = true;
+
+    render();
+    initSortable();
+  });
+
+  $(document).on('click', '.dropdown-toggle', function(e) {
+    e.stopPropagation();
+  });
+
+  $(document).on('click', '.dropdown', function(e) {
+    e.stopPropagation();
+  });
+
+  $(document).on('click', '#toggleMenu' ,function(e){
+    e.preventDefault();
+    if(!menuShow){
+    $("#SE-menu").show();
+    $("#SE-menu-sub").show();
+    menuShow = true;
+  }else{
+    menuShow = false;
+    $("#SE-menu").hide();
+    $("#SE-menu-sub").hide();
+  }
+  });
+
+  $(document).on('click', '#toggleView' ,function(e){
+    e.preventDefault();
+    if(!panels){
+    panels = true;
+    render();
+  }else{
+    panels = false;
+    render();
+  }
+  });
+
+  $(document).on('click', '.liProc', function() {
+      $(this).parents(".singleAdv").nextAll(".singleAdv").remove();
+      $(this).parents(".singleAdv").find(".active").removeClass("active");
+      $(this).find(".gl").removeClass("glyphicon-triangle-right");
+      $(this).find(".gl").addClass("glyphicon-refresh");
+      $(this).find(".gl").addClass("anim-refresh");
+      $(this).addClass("active");
+      var parent = this;
+      var parent_id = $(this).data("id");
+      var parentOfParent_id = $(this).closest(".singleAdv").data("parent");
+      //console.log(link);
+      var childs = true;
+      state[parentOfParent_id]["active"] = parent_id;
+      state[parentOfParent_id]["details"] = false;
+      render();
+      initSortable();
+  });
+
+function initSortable(){
+  $( ".singleAdvList" ).sortable({
+  items: "li",
+  connectWith: ".singleAdvList",
+  beforeStop: function(ev, ui) {
+      if($(ui.item).data("id") == $(ui.placeholder).closest(".singleAdv").data("parent") || $(ui.item).hasClass("active")){
+        $(this).sortable('cancel');
+        $.notify("Nielogiczny ruch.", "error");
+      }
+
+    },
+    stop: function(ev, ui) {
+      updateParent($(ui.item).data("id"),$(ui.item).closest(".singleAdv").data("parent"), this);
+      },
+  }).disableSelection();
+
+}
+
+function start(){
+  var link = BASE_URL + 'index.php?_route=UrlAction_ProcesView&_task=getAllAjax';
+  var result = "";
+  var side = $("#view");
+  var tempF = {};
+  tempF["active"] = false;
+  tempF["details"] = false;
+  tempF["childs"] = [];
+  state[0] = tempF;
+
+  $.get(link, function(data) {
+      //console.log("x");
+      //console.log(data);
+      state = data;
+      render();
+    });
+}
+start();
+
+
+});

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.