فهرست منبع

Zasoby Tree: fix alias info

Piotr Labudda 10 سال پیش
والد
کامیت
80471d5e0d
4فایلهای تغییر یافته به همراه141 افزوده شده و 19 حذف شده
  1. 55 0
      SE/procesy/ajax.php
  2. 1 0
      SE/procesy/zasob.php
  3. 27 4
      SE/procesy5.php
  4. 58 15
      SE/se-lib/Tree.php

+ 55 - 0
SE/procesy/ajax.php

@@ -1,9 +1,64 @@
 <?php
 <?php
 
 
 Lib::loadClass('DB_Image');
 Lib::loadClass('DB_Image');
+Lib::loadClass('Http');
 
 
 if (!class_exists('Lib')) die('404');
 if (!class_exists('Lib')) die('404');
 
 
+function ajax_get_alias_info() {
+	header('Content-Type: text/html; charset=utf8');//utf8
+	$idZasob = V::get('idZasob', 0, $_REQUEST, 'int');
+	if (!$idZasob) die('Wrong param');
+	$sql = <<<SQL
+		select z.`ID`
+			,	z.`ALIAS_ID`
+			,	z.`ALIAS_MODE`
+			,	za.`DESC` as `ALIAS_DESC`
+			,	zap.`DESC` as `ALIAS_PARENT_DESC`
+			,	zv.`CHILDS`
+			,	zv.`PATH`
+		from `CRM_LISTA_ZASOBOW` z
+			join `CRM_LISTA_ZASOBOW_ALIASY_view` zv on(zv.`ID`=z.`ID`)
+			left join `CRM_LISTA_ZASOBOW` za on(za.`ID`=z.`ALIAS_ID`)
+			left join `CRM_LISTA_ZASOBOW` zap on(zap.`ID`=za.`PARENT_ID`)
+		where z.`ID`='{$idZasob}'
+SQL;
+	$db = DB::getDB();
+	$res = $db->query($sql);
+	$info = $db->fetch($res);
+	if (!$info) {
+		echo 'Brak danych';
+	} else {
+		$outLines = array();
+		if ($info->ALIAS_ID > 0) {
+			$js = "return treeAddToFiltr(this, {$info->ALIAS_ID});";
+			$outAliasedId = '<a href="#" onclick="' . $js . '" title="Dodaj do filtra ' . $info->ALIAS_ID . '">' . $info->ALIAS_ID . '</a>';
+			$outAliasType = ('VIRTUAL' == $info->ALIAS_MODE)? "ALIAS WIRTUALNY" : "ALIAS";
+			$outTitle = "{$outAliasType} DO [{$info->ALIAS_ID}] {$info->ALIAS_PARENT_DESC}/{$info->ALIAS_DESC}";
+			$outLabel = "{$outAliasType} DO [{$outAliasedId}] " . V::strShortUtf8($info->ALIAS_PARENT_DESC, 16, '...') . '/' . V::strShortUtf8($info->ALIAS_DESC, 16, '...');
+			$outLines[] = '<span title="'.$outTitle.'">'.$outLabel.'</span>';
+		}
+		if (!empty($info->PATH)) {
+			$outLines[] = 'Ścieżka: ' . $info->PATH;
+		}
+		if (!empty($info->CHILDS)) {
+			$outChilds = array();
+			$childs = explode(',', $info->CHILDS);
+			foreach($childs as $child) {
+				$js = "return treeAddToFiltr(this, {$child});";
+				$outChilds[] = '<a href="#" onclick="' . $js . '">' . $child . '</a>';
+			}
+			$outLines[] = 'Aliasy: ' . implode(', ', $outChilds);
+		}
+	}
+	if (empty($outLines)) {
+		echo 'Brak danych';//Http::sendHeaderByCode(404);
+	} else {
+		echo implode('<br>', $outLines) . '<br/>';
+	}
+	exit;
+}
+
 function ajax_get_subtree() {
 function ajax_get_subtree() {
 	header('Content-Type: text/html; charset=utf8');//utf8
 	header('Content-Type: text/html; charset=utf8');//utf8
 
 

+ 1 - 0
SE/procesy/zasob.php

@@ -485,6 +485,7 @@ echo'<br />';
 			$tree->_limit = 300;
 			$tree->_limit = 300;
 			$tree->_deep_limit = 2;
 			$tree->_deep_limit = 2;
 		}
 		}
+
 		if ($tree_zasoby_filter->get_arg('filtr_id') != 0) {
 		if ($tree_zasoby_filter->get_arg('filtr_id') != 0) {
 			$tree->showSubTree( $tree_zasoby_filter->get_arg('filtr_id') );
 			$tree->showSubTree( $tree_zasoby_filter->get_arg('filtr_id') );
 		} else if ($tree_zasoby_filter->get_arg('filtr_search_id') > 0) {
 		} else if ($tree_zasoby_filter->get_arg('filtr_search_id') > 0) {

+ 27 - 4
SE/procesy5.php

@@ -171,6 +171,7 @@ function lay_procesy_gora() {
 	<title><?php echo $title; ?></title>
 	<title><?php echo $title; ?></title>
 	<meta name="author" content="Piotr Labudda <piotrl86@gmail.com>" />
 	<meta name="author" content="Piotr Labudda <piotrl86@gmail.com>" />
 	<link rel="stylesheet" href="stuff/bootstrap/css/bootstrap.min.css" type="text/css" />
 	<link rel="stylesheet" href="stuff/bootstrap/css/bootstrap.min.css" type="text/css" />
+	<link rel="stylesheet" href="stuff/jquery-ui-smoothness/jquery-ui-1.10.4.custom.min.css" type="text/css">
 	<link rel="stylesheet" href="stuff/main.css" type="text/css" />
 	<link rel="stylesheet" href="stuff/main.css" type="text/css" />
 	<style type="text/css">
 	<style type="text/css">
 .popover-with-html .popover-heading {display:none;}
 .popover-with-html .popover-heading {display:none;}
@@ -179,6 +180,7 @@ function lay_procesy_gora() {
 	<script src="stuff/jquery-2.1.0.min.js"></script>
 	<script src="stuff/jquery-2.1.0.min.js"></script>
 	<script src="stuff/jquery-plugins.js"></script>
 	<script src="stuff/jquery-plugins.js"></script>
 	<script src="stuff/bootstrap/js/bootstrap.min.js"></script>
 	<script src="stuff/bootstrap/js/bootstrap.min.js"></script>
+	<script src="stuff/jquery-ui-1.10.4.custom.min.js"></script>
 	<script>
 	<script>
 jQuery(document).ready(function(){
 jQuery(document).ready(function(){
 	jQuery(".popover-with-html").popover({
 	jQuery(".popover-with-html").popover({
@@ -2643,12 +2645,33 @@ function tree_callback__show_item_from_CRM_LISTA_ZASOBOW( &$r, &$tree ) {
 	else echo "(1)";
 	else echo "(1)";
 
 
 	echo'<span class="desc">';
 	echo'<span class="desc">';
+	{
+		$outAliasStyle = 'color:#999';
+		$outAliasTitle = 'ALIAS INFO';
+		$outAliasLink .= '<i class="glyphicon glyphicon-share-alt"></i>';
 		if ($r->ALIAS_ID > 0) {
 		if ($r->ALIAS_ID > 0) {
-			if($r->ALIAS_MODE=='VIRTUAL')
-				echo '<span title="' . htmlspecialchars($r->ALIAS_NAME) . '">' . "(<font color=green>ALIAS WIRTUALNY DO ".'<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</font></a>'.")" . '</span>';
-			else 
-				echo '<span title="' . htmlspecialchars($r->ALIAS_NAME) . '">' . "(ALIAS DO ".'<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</a>'.")" . '</span>';
+			$outAliasLink .= "{$r->ALIAS_ID}";
+			// '<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</a>'
+			// '<a href="#TREE'.$r->ALIAS_ID.'">'.$r->ALIAS_ID.'</a>'
+			if ('VIRTUAL' == $r->ALIAS_MODE) {
+				$outAliasStyle = 'color:#CA06E2';
+				$outAliasTitle = "ALIAS WIRTUALNY DO {$r->ALIAS_ID}";
+			} else {
+				$outAliasStyle = 'color:#FF6900';
+				$outAliasTitle = "ALIAS DO {$r->ALIAS_ID}";
+			}
 		}
 		}
+		echo '<span style="' . $outAliasStyle . '">
+			<a href="#"
+				style="' . $outAliasStyle . '"
+				title="' . $outAliasTitle . '"
+				data-id="' . $r->ID . '"
+				onclick="return showZasobAliasTooltip(this);"
+			>' . "{$outAliasLink}" . '</a>'
+			. ' <span class="alias-description"></span>'
+			. '</span>'
+		;
+	}
 		echo '<b>'.$r->TYPE.'</b>';
 		echo '<b>'.$r->TYPE.'</b>';
 		$bold=false;
 		$bold=false;
 		if ((!empty($_GET['arg1']) && $_GET['arg1'] == $r->ID)
 		if ((!empty($_GET['arg1']) && $_GET['arg1'] == $r->ID)

+ 58 - 15
SE/se-lib/Tree.php

@@ -377,20 +377,6 @@ class Tree {
 					)
 					)
 				) as PARENT_TYPE
 				) as PARENT_TYPE
 			";
 			";
-
-			$sql->select[] = "IF(t.`ALIAS_ID` > 0
-					, concat_ws('\n'
-						, (select concat_ws('.', zap.`DESC`, za.`DESC`)
-								from `CRM_LISTA_ZASOBOW` as za
-									left join `CRM_LISTA_ZASOBOW` as zap on(zap.`ID`=za.`PARENT_ID`)
-								where za.`ID`=t.`ALIAS_ID`
-								limit 1
-							)
-						, (select av.`PATH` from `CRM_LISTA_ZASOBOW_ALIASY_view` av where av.`ID`=t.`ID`)
-					)
-					, ''
-				) as ALIAS_NAME
-			";
 		}
 		}
 
 
 		$sql->filter = array();
 		$sql->filter = array();
@@ -729,7 +715,64 @@ jQuery(document).ready(function(){
 	jQuery('.wsk-help').popover({trigger:'hover', html:true, placement:'top'});
 	jQuery('.wsk-help').popover({trigger:'hover', html:true, placement:'top'});
 	//jQuery('.wsk-long-desc').modal();
 	//jQuery('.wsk-long-desc').modal();
 });
 });
-			</script>
+
+function showZasobAliasTooltip(n) {
+	var $n = jQuery(n);
+	if ($n.data('id') <= 0) return false;
+	var $aliasDescNode = $n.parent().find('.alias-description');
+	if (!$aliasDescNode.length) return false;
+	if (!$aliasDescNode.html()) {
+		$aliasDescNode.html(' loading ...<br/>');
+	}
+	console.log('display: ', $aliasDescNode.children().css('display'));
+	if ('block' == $aliasDescNode.children().css('display')) {
+		$aliasDescNode.children().css('display', 'none');
+		return false;
+	} else if ('none' == $aliasDescNode.children().css('display')) {
+		$aliasDescNode.children().css('display', 'block');
+	}
+
+	jQuery.ajax({
+		data: null,
+		type: "GET",
+		url: 'procesy5.php?function_init=ajax_get_alias_info&HEADER_NOT_INIT=YES&idZasob=' + $n.data('id'),
+	})
+	.done(function(data, textStatus, jqXHR){
+		if ('Brak danych' == data) {
+			$n.parent().attr('title', $n.attr('title') + ' - Brak danych');
+			$n.css({color: '#ddd'});
+			$n.attr('onclick', 'return false;');
+			$aliasDescNode.html('');
+		} else {
+			$aliasDescNode.html('<div style="padding-left:40px">' + data + '</div>');
+		}
+	})
+	.fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
+		$aliasDescNode.html("Error");
+	})
+	.always(function(data, textStatus, jqXHR) {
+	});
+
+	return false;
+}
+
+function treeAddToFiltr(n, idZasob) {
+	idZasob = parseInt(idZasob);
+	if (!idZasob) return false;
+	var $filters = jQuery(n).parents('.tree-wrap:first').prevAll('.filters:first');
+	if (!$filters.length) return false;
+	var $filtrIdInput = $filters.find('input[name="filtr_id"]');
+	if (!$filtrIdInput.length) return false;
+	var filtrVal = $filtrIdInput.val();
+	if (!filtrVal.length) {
+		$filtrIdInput.val(idZasob);
+	} else {
+		$filtrIdInput.val(filtrVal + ',' + idZasob);
+	}
+	$filtrIdInput.get(0).form.submit();
+	return false;
+}
+</script>
 		<?php
 		<?php
 	}
 	}