Explorar el Código

testy fix small bugs

Piotr Labudda hace 11 años
padre
commit
4422fe06b4
Se han modificado 1 ficheros con 16 adiciones y 9 borrados
  1. 16 9
      SE/procesy/testy.php

+ 16 - 9
SE/procesy/testy.php

@@ -1177,6 +1177,9 @@ a.btn-test-praktyczny {background-color:#B3EBFB;}
 	}
 
 	function this_print_tree_rec( $user_menu_tree, &$user_menu, $parent_id = null ) {
+		if (empty($user_menu_tree) || !is_array($user_menu_tree)) {
+			return;
+		}
 		$cls = ($parent_id === null)? ' class="user-menu-tree tree-wrap"' : '';
 		echo '<ul' . $cls . '>';
 		$list_total = count($user_menu_tree);
@@ -1204,20 +1207,24 @@ a.btn-test-praktyczny {background-color:#B3EBFB;}
 		echo '</ul>';
 	}
 
-	function this_tree_fetch_data_rec(&$user_menu, $user_menu_tree_flat) {
-		$sql_ids = array();
-		$sql_ids = array_keys($user_menu_tree_flat);
-		// add tree parent proces info
-		if (!empty($sql_ids)) {
+	function this_tree_fetch_data_rec(&$userMenu, $userMenuTreeFlat) {
+		$sqlIds = array();
+		foreach ($userMenuTreeFlat as $kStanowiskoId => $vMenu) {
+			if ($kStanowiskoId > 0) {
+				$sqlIds[] = $kStanowiskoId;
+			}
+		}
+		if (!empty($sqlIds)) {
+			$db = DB::getDB();
 			$sql = "select
 					z.`ID`, z.`PARENT_ID`, z.`DESC`, z.`OPIS`, z.`TYPE`
 				from `CRM_LISTA_ZASOBOW` as z
 				where
-					z.`ID` in (" . implode(", ", $sql_ids) . ")
+					z.`ID` in (" . implode(", ", $sqlIds) . ")
 			";
-			$res = DB::query( $sql );
-			while ($r = DB::fetch( $res )) {
-				$user_menu[$r->ID] = $r;
+			$res = $db->query($sql);
+			while ($r = $db->fetch($res)) {
+				$userMenu[$r->ID] = $r;
 			}
 		}
 	}