Selaa lähdekoodia

TREEJS Fix filtr_id

Piotr Labudda 10 vuotta sitten
vanhempi
commit
a41f81c4e7
1 muutettua tiedostoa jossa 43 lisäystä ja 21 poistoa
  1. 43 21
      SE/superedit-TREEJS.php

+ 43 - 21
SE/superedit-TREEJS.php

@@ -168,14 +168,10 @@ function tree_callback__show_item_from_IN7_MK_BAZA_DYSTRYBUCJI(&$r, &$tree) {
 		$cls[] = 'search_id';
 	}
 	$cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : '';
-
-	echo'<dl'.$cls.'>';
-	echo'<dt>';
-
 	$out_id = ($r->ID < 10)? '&nbsp;'.$r->ID.'' : $r->ID;
-	echo'<a href="'."index.php?MENU_INIT=TREEJS&ZASOB_ID={$zasobID}&filtr_id={$r->ID}#TREE{$r->ID}" . '" class="item_id btn-box">'.$out_id.'</a>';
-
-	echo'<a href="'."index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$zasobID}#EDIT/{$r->ID}".'" class="btn btn-xs btn-link" title="'."Edit".'">'."E".'</a>';
+	$htmlTreeId = $tree->get_param('htmlTreeId');
+	$idLink = "index.php?MENU_INIT=TREEJS&ZASOB_ID={$zasobID}&filtr_id={$r->ID}#TREE{$r->ID}";
+	$editLink = "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$zasobID}#EDIT/{$r->ID}";
 
 	//if ($r->has_childrens) {
 	//	if (!$tree->get_param('rozwin')) {
@@ -201,19 +197,28 @@ function tree_callback__show_item_from_IN7_MK_BAZA_DYSTRYBUCJI(&$r, &$tree) {
 	}
 	$st_status_bg = ($st_status_bg)? 'background-color:'.$st_status_bg : '';
 
-	echo'<span class="desc">';
-		echo'<span class="btn-box" style="'.$st_status_bg.'">'.$r->A_STATUS.'</span>';
-		echo' <em style="color:#666;" title="'.$r->M_DIST_TYPE.'">'.((strlen($r->M_DIST_TYPE) > 5)? substr($r->M_DIST_TYPE, 0, 5).'...' : $r->M_DIST_TYPE).'</em>';
-		echo' <i style="color:red">'.$r->M_DIST_DESC.'</i>';
-		echo' <span>'.$r->M_DISTRIBUTOR.'</span>';
-		echo' <font size="-1">'.$r->M_DIST_INVENTOR.'</font>';
-	echo'</span>';
-
-	$htmlTreeId = $tree->get_param('htmlTreeId');
-	echo ' <button class="btn btn-xs btn-link" onclick="' . "return {$htmlTreeId}_ids(this, {$r->ID});" . '">IDS</button>';
-
-	echo'</dt>';
-	echo'</dl>'."\n";
+?>
+<dl<?php echo $cls; ?>>
+	<dt>
+		<a href="<?php echo $idLink; ?>"
+			 onClick="return <?php echo $htmlTreeId; ?>_filtr_id(<?php echo $r->ID; ?>);"
+			 class="item_id btn-box"><?php echo $out_id; ?></a>
+		<a href="<?php echo $editLink; ?>"
+			 title="Edit"
+			 class="btn btn-xs btn-link">E</a>
+		<span class="desc">
+			<span class="btn-box" style="<?php echo $st_status_bg; ?>"><?php echo $r->A_STATUS; ?></span>
+			<em title="<?php echo $r->M_DIST_TYPE; ?>"
+					style="color:#666;"><?php echo V::strShortUtf8($r->M_DIST_TYPE, 5); ?></em>
+			<i style="color:red"><?php echo $r->M_DIST_DESC; ?></i>
+			<span><?php echo $r->M_DISTRIBUTOR; ?></span>
+			<font size="-1"><?php echo $r->M_DIST_INVENTOR; ?></font>
+		</span>
+		<button onclick="return <?php echo $htmlTreeId; ?>_ids(this, <?php echo $r->ID; ?>);"
+					class="btn btn-xs btn-link">IDS</button>
+	</dt>
+</dl>
+<?php
 }
 
 
@@ -283,7 +288,7 @@ if(0){// RMME
 		</nobr>
 		<div class="btnseparator"></div>
 		<nobr>Filtruj ID
-			<input type="text" name="filtr_id" value="" class="i" size="4" onchange="<?php echo "return {$htmlTreeId}_filters(this);"; ?>">
+			<input type="text" id="<?php echo "{$htmlTreeId}_filters_filtr_id"; ?>" name="filtr_id" value="" class="i" size="4" onchange="<?php echo "return {$htmlTreeId}_filters(this);"; ?>">
 			<input type="image" src="icon/search.png" ale="Szukaj" title="Szukaj" onclick="<?php echo "return {$htmlTreeId}_filters(this);"; ?>">
 		</nobr>
 		<div class="btnseparator"></div>
@@ -660,6 +665,23 @@ function <?php echo $htmlTreeId; ?>_ids(btnNode, id) {
 	}
 	return false;
 }
+
+function <?php echo $htmlTreeId; ?>_filtr_id(id) {
+	if (id > 0) {
+		var filtrIdNode = jQuery('#<?php echo "{$htmlTreeId}_filters_filtr_id"; ?>').get(0);
+		if (!filtrIdNode) return;
+		filtrIdNode.value = id;
+		<?php echo $htmlTreeId; ?>_filters(filtrIdNode);
+		return false;
+	}
+}
+
+<?php if ($tree_filter->get_arg('filtr_id') > 0) : ?>
+jQuery(document).ready(function() {
+	<?php echo $htmlTreeId; ?>_filtr_id(<?php echo $tree_filter->get_arg('filtr_id'); ?>);
+});
+<?php endif; ?>
+
 </script>
 	<?php