<?php debug_backtrace() || die ("Direct access not permitted"); ?>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="<?php echo DOCBASE; ?>admin/"><img src="/admin/images/logoNew.png" style="width:70px;" /> <?php //echo SITE_TITLE; ?></a>
        <div class="pull-right hidden-xs" id="info-header">
            <?php echo $texts['CONNECTED_AS']; ?> <i class="fa fa-user"></i> <?php echo "<b>".$_SESSION['user']['login']."</b> (".$_SESSION['user']['type'].")"; ?>&nbsp;
            <a href="<?php echo DOCBASE; ?>admin/login.php?action=logout"><i class="fa fa-power-off"></i> <?php echo $texts['LOG_OUT']; ?></a>
        </div>
    </div>
    <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav side-nav">
            <li>
                <a href="<?php echo DOCBASE; ?>admin/"<?php if(strpos($_SERVER['SCRIPT_NAME'], "admin/index.php") !== false) echo " class=\"active\""; ?>>
                    <i class="fa fa-dashboard"></i> <?php echo $texts['DASHBOARD']; ?>
                </a>
            </li>

			<?php $achat = array('bc','be','br','facture_achat','facture_avoir'); ?>
			<li class="dropdown">
                <a data-target="#module-menu4" data-toggle="collapse" href="#"><i class="fa fa-cart-plus"></i>  Achat <i class="fa fa-angle-down"></i></a>
                <ul class="<?php if(in_array($dirname, $achat)) echo "in"; else echo "collapse"; ?>" role="menu" id="module-menu4">

				<li><a href="/admin/modules/bc/index.php?view=list" <?php getActive('bc',$dirname); ?>><i class="fa fa-shopping-basket"></i> Bon de commande</a></li>
				<li><a href="/admin/modules/be/index.php?view=list" <?php getActive('be',$dirname); ?>><i class="fa fa-sign-in"></i> BE Achat</a></li>
				<li><a href="/admin/modules/br/index.php?view=list" <?php getActive('br',$dirname); ?>><i class="fa fa-sign-out"></i> BS Achat</a></li>
                </ul>
            </li>


			<?php $production = array('bf','stock','stock_vente','mouvement_stock'); ?>
			<li class="dropdown">
                <a data-target="#module-menu6" data-toggle="collapse" href="#"><i class="fa fa-cart-plus"></i>  Production <i class="fa fa-angle-down"></i></a>
                <ul class="<?php if(in_array($dirname, $production)) echo "in"; else echo "collapse"; ?>" role="menu" id="module-menu6">

				<li><a href="/admin/modules/bf/index.php?view=list" <?php getActive('bf',$dirname); ?>><i class="fa fa-industry"></i> Bon de fabrication</a></li>
				<li><a href="/admin/stock/"  <?php getActive('stock',$dirname); ?>><i class="fa fa-random " ></i> Inventaire achat</a></li>
				<li><a href="/admin/stock_vente/"  <?php getActive('stock_vente',$dirname); ?>><i class="fa fa-random " ></i> Inventaire vente</a></li>
				<li><a href="/admin/mouvement_stock/"  <?php getActive('mouvement_stock',$dirname); ?>><i class="fa fa-cubes " ></i> Mouvement de stock</a></li>
				
                </ul>
            </li>
			<?php $Vente = array('bl','brv','facture','facture_avoir_vente'); ?>
			<li class="dropdown">
                <a data-target="#module-menu5" data-toggle="collapse" href="#"><i class="fa fa-cart-arrow-down"></i>  Vente <i class="fa fa-angle-down"></i></a>
                <ul class="<?php if(in_array($dirname, $Vente)) echo "in"; else echo "collapse"; ?>" role="menu" id="module-menu5">

				<li><a href="/admin/modules/bl/index.php?view=list"  <?php getActive('bl',$dirname); ?>><i class="fa fa-sign-in" ></i> BL Vente</a></li>				
				<li><a href="/admin/modules/brv/index.php?view=list"  <?php getActive('brv',$dirname); ?>><i class="fa fa-sign-out" ></i> BR Vente</a></li>
				</ul>
            </li>			


		


			
			
			<?php
			
				function getActive($dir,$name)
				{
					if($name == $dir){
						echo "class='active'";
					}
				}
				

			?>
			
			

			 <?php
                    // foreach($modules as $module){

                        // $title = $module->getTitle();
                        // $name = $module->getName();
                        // $dir = $module->getDir();
                        // $icon = $module->getIcon();
                        // $link = $dir."/index.php?view=list";
                        
                        // if($icon == "") $icon = "puzzle-piece";
                        
                        // $classname = ($dirname == $name) ? " class=\"active\"" : "";
                        
                        // if(!in_array("no_access", $module->getPermissions($_SESSION['user']['type'])))
                            // echo "<li><a href=\"".$link."\"".$classname."><i class=\"fa fa-".$icon."\"></i> ".$title."</a></li>";
                    // }
			?>


            <?php
            if($_SESSION['user']['type'] == "administrator"){ ?>
                
                <?php
            } ?>
        </ul>
    </div>
</nav>
