<?php include 'menu.php';?>
					<?php
						//$lvl - max vrenost userove role
						foreach ($page_nav as $key => $nav_item) {
							//process parent nav
							if(in_array($lvl, $nav_item["nivo"])) {
							//proveravam koji je nivo korisnik, odnosno koju rolu ima
							$nav_htm = '';
							$url = isset($nav_item["url"]) ? $nav_item["url"] : "javascript:;";
							$url_target = isset($nav_item["url_target"]) ? 'target="'.$nav_item["url_target"].'"' : "";
							$icon_badge = isset($nav_item["icon_badge"]) ? '<em>'.$nav_item["icon_badge"].'</em>' : '';
							$icon = isset($nav_item["icon"]) ? '<i class="fa fa-lg fa-fw '.$nav_item["icon"].'">'.$icon_badge.'</i>' : "";
							$nav_title = isset($nav_item["title"]) ? $nav_item["title"] : "(No Name)";
							$label_htm = isset($nav_item["label_htm"]) ? $nav_item["label_htm"] : "";
							$nav_htm .= '<a class="'.$nav_item["class"].'" href="'.$url.'" '.$url_target.' title="'.$nav_title.'">'.$icon.' <span class="title">'.$nav_title.'</span>
							<span class="'.$nav_item["span"].'"></span>
							</span>'.$label_htm.'</a>';

							if (isset($nav_item["sub"]) && $nav_item["sub"])
								$nav_htm .= process_sub_nav($nav_item["sub"]);

							echo '<li '.(isset($nav_item["active"]) ? 'class = "active"' : '').'>'.$nav_htm.'</li>';
							}
						}
						function process_sub_nav($nav_item) {
							$sub_item_htm = "";
							if (isset($nav_item["sub"]) && $nav_item["sub"]) {
								$sub_nav_item = $nav_item["sub"];
								$sub_item_htm = process_sub_nav($sub_nav_item);
							} else {
								$sub_item_htm .= '<ul class="sub-menu">';
								foreach ($nav_item as $key => $sub_item) {
									$url = isset($sub_item["url"]) ? $sub_item["url"] : "#";
									$url_target = isset($sub_item["url_target"]) ? 'target="'.$sub_item["url_target"].'"' : "";
									$icon = isset($sub_item["icon"]) ? '<i class="fa fa-lg fa-fw '.$sub_item["icon"].'"></i>' : "";
									$nav_title = isset($sub_item["title"]) ? $sub_item["title"] : "(No Name)";
									$label_htm = isset($sub_item["label_htm"]) ? $sub_item["label_htm"] : "";
									$sub_item_htm .=
										'<li '.(isset($sub_item["active"]) ? 'class = "active"' : '').'>
											<a  class="ajaxify"
id="'.$sub_item["idlink"].'"											href="'.$url.'" '.$url_target.'>'.$icon.' '.$nav_title.$label_htm.'</a>
											'.(isset($sub_item["sub"]) ? process_sub_nav($sub_item["sub"]) : '').'
										</li>';
								}
								$sub_item_htm .= '</ul>';
							}
							return $sub_item_htm;
						}
?>
