<?php
/*
 * SubNav Builder
 * Pass an array of arrays with array($name, $url, $isActive)
 *
 * Example:
 *
 * <?= $this->partial('partials/sub-nav.phtml', array('items' => array(
 *     array('Profile', '/profile', true),
 *     array('Admin', '/admin')
 * ))) ?>
 */
?>
<script>
	function handleEventTracking(actionVal, categoryVal, labelVal) {
	    analytics.track(actionVal, {
            category: categoryVal,
	        action: actionVal,
	        label: labelVal
	    });
	}
</script>
<nav class="main-subnav hidden-print">
    <?php foreach ($this->items as $item): ?>
        <?php
            $isActive = count($item) > 2 && $item[2];
            $shouldTrack = $item[1] == '/conflicts' || $item[1] == '/conflicts/new';
            $eventAction = 'Go to Conflict Manager';
            $eventCategory = 'Navigation';
            $eventLabel = 'Subnav';
            $addCollaboratorBadge = count($item) > 2 && $item[1] == '/accounting/collaborators';
        ?>
        <a href="<?= $item[1] ?>" <?php if ($isActive): ?>class="active"<?php endif; ?> <?php if ($shouldTrack): ?>onclick='handleEventTracking("<?= $eventAction ?>", "<?= $eventCategory ?>", "<?= $eventLabel ?>")'<?php endif; ?> ><?= $item[0] ?></a>
        <?php if ($addCollaboratorBadge) { ?>
            <span class="badge">NEW</span>
        <?php } ?>
    <?php endforeach;?>
</nav>
