{*
 **********************************************************
 * Developed by: Team Theme Metro
 * Website: http://www.thememetro.com
 **********************************************************
*}


{if $enablemegamenu}

<li class="home-item">
	<a href="{if $loggedin}{$WEB_ROOT}/clientarea.php{else}{if $themesettings.headersetting.CustomLogoLink}{$themesettings.headersetting.CustomLogoLink}{else}{$WEB_ROOT}/{/if}{/if}">
	{if $themesettings.headersetting.enablehomeicon}<i class="fas fa-home"></i>{/if}<span class="mtext menu-name">{$LANG.clientareanavhome}</span></a>					
</li>

{foreach $navbar as $item}
{assign var='extras' value=$item->getExtras()}			
<li data-menuItemName="{$item->getName()}" class="{$item->getid()} {if $item->hasChildren()}panel{/if}{if $item->getClass()} {$item->getClass()}{/if} {$extras['parentclass']}">
	<a {if $item->hasChildren()}class="accordion-toggle" data-toggle="collapse dropdown" href="javascript:;"{else}href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>

	{if $item->hasIcon()}<i class="{$item->getIcon()}"></i>{/if}

	<span class="mtext menu-name">{$item->getLabel()}</span>

	{if $item->hasBadge()} <span class="badge">{$item->getBadge()}</span>{/if}

	{if $item->hasChildren()}<span class="fa arrow"></span>{/if}

	</a>
{if $item->hasChildren()}
{assign var=haschild value=0}

	{if $extras['parentclass']=='dropdown-megamenu'}
	{assign var=haschild value=1}
	{/if}

<ul class="collapse nav{if $extras['parentclass']=='dropdown-megamenu'} dropdown-mega{/if}">
	

				{assign var=count value=0}
				{assign var=totalchild value=count($item->getChildren())}				
				{foreach $item->getChildren() as $item}	
				{if $haschild}

				{assign var='extras' value=$item->getExtras()}
			<li class="{$extras['parentclass']}">						
				<a {if $item->hasChildren()}class="accordion-toggle" data-toggle="collapse dropdown" href="javascript:;"{else}href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
					{if $item->hasIcon()}
						<i class="{$item->getIcon()}"></i>
					{/if}
					<span class="mtext menu-name">{$item->getLabel()}</span>
					{if $item->hasChildren()}<span class="fa arrow"></span>{/if}
				</a>
				{if $item->hasBadge()}
					<div class="html-item">{$item->getBadge()|unescape:'html'}</div>
				{/if}

		{if $item->hasChildren()}
			<ul class="nav collapse">
				{foreach $item->getChildren() as $childItem}
				{assign var='extras' value=$childItem->getExtras()}
					<li data-menuItemName="{$childItem->getName()}"{if $childItem->getClass() || $extras['parentclass']} class="{$childItem->getClass()} {$extras['parentclass']}"{/if}>
						<a href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
							{if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
							<span class="mtext menu-name">{$childItem->getLabel()}</span>
							{if $childItem->hasBadge()} 
								<span class="badge">
									{$childItem->getBadge()}
								</span>
							{/if}
						</a>
					</li>
				{/foreach}
			</ul>
		{/if}
	</li>					

	
	{else}
        {assign var='extras' value=$item->getExtras()}
        	{if $item->hasChildren()}
				<li class="mega-menu">        	
					<div class="menu-small-box {$extras['parentclass']}">
					{if $item->getUri()|strstr:"#"}
						<div class="item-with-icons">
							{if $item->hasIcon()}
							<span class="item-icon">
								<i class="{$item->getIcon()}"></i>
							</span>
							{/if}
							<h4 class="menu-name">{$item->getLabel()}</h4>
						</div>
					{else}						
						<a href="{$item->getUri()}"{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if} class="item-heading">
							<div class="item-with-icons no-margin">
								{if $item->hasIcon()}
									<span class="item-icon">
										<i class="{$item->getIcon()}"></i>
									</span>
								{/if}
								<h4 class="menu-name">{$item->getLabel()}</h4>
							</div>
						</a>
					{/if}
					{if $item->hasBadge()}
						<div>{$item->getBadge()|unescape:'html'}</div>
					{/if}
					</div>
				</li>
				{if $item->hasChildren()}
					{foreach $item->getChildren() as $childItem}
					{assign var='extras' value=$childItem->getExtras()}
						<li data-menuItemName="{$childItem->getName()}"{if $childItem->getClass() || $extras['parentclass']} class="{$childItem->getClass()} {$extras['parentclass']}"{/if}>
							<a href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
								{if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
								<span class="mtext menu-name">{$childItem->getLabel()}</span>
								{if $childItem->hasBadge()} 
									<span class="badge">
										{$childItem->getBadge()}
									</span>
								{/if}
							</a>
						</li>
					{/foreach}
				{/if}
			
        	{else}
	        	<li data-menuItemName="{$item->getName()}"{if $item->getClass() || $extras['parentclass']} class="{$item->getClass()} {$extras['parentclass']}"{/if}>
					<a href="{$item->getUri()}"{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
						{if $item->hasIcon()}<i class="{$item->getIcon()}"></i> {/if}
						<span class="mtext menu-name">{$item->getLabel()}</span>
						{if $item->hasBadge()} 
							<span class="badge">
								{$item->getBadge()}
							</span>
						{/if}
					</a>
				</li>
        	{/if}
	        			
    {/if}
		{assign var=count value=$count+1}
{/foreach}

</ul>
{/if}

</li>
{/foreach}




{else} 
{foreach $navbar as $item}
    <li data-menuItemName="{$item->getName()}" class="{$item->getid()} {if $item->hasChildren()}panel{/if}{if $item->getClass()} {$item->getClass()}{/if}">
        <a {if $item->hasChildren()}class="accordion-toggle" data-toggle="collapse dropdown" href="javascript:;"{else}href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
            {if $item->hasIcon()}<i class="{$item->getIcon()}"></i>{/if}
            <span class="mtext">{$item->getLabel()}</span>
            {if $item->hasBadge()}&nbsp;<span class="badge">{$item->getBadge()}</span>{/if}
            {*{if $item->hasChildren()}&nbsp;<b class="caret"></b>{/if}*}
			{if $item->hasChildren()}<span class="fa arrow"></span>{/if}
        </a>
        {if $item->hasChildren()}
            <ul class="collapse nav">
            {foreach $item->getChildren() as $childItem}
                <li data-menuItemName="{$childItem->getName()}"{if $childItem->getClass()} class="{$childItem->getClass()}"{/if}>
                    <a href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
                        {if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i>&nbsp;{/if}
                        {$childItem->getLabel()}
                        {if $childItem->hasBadge()}&nbsp;<span class="badge">{$childItem->getBadge()}</span>{/if}
                    </a>
                </li>
            {/foreach}
            </ul>
        {/if}
    </li>
{/foreach}
{/if}