- $app = Yii::app()
- $user = $app->user
- $homeUrl = $app->homeUrl
- $controller = $app->controller
- $userUpdateUrl = 'user/update/'.$user->id

%nav.navbar.navbar-fixed-top
  .navbar-menu.navbar-inner
    %a.brand(href="#{$homeUrl}")
      = Yii::app()->name
    %ul.nav.justify-content-center.navbar-nav
      %li(class="#{$controller instanceof DashboardController ? 'active' : ''}")
        %a(href="#{$homeUrl}")= onNull(paramdeep('menuTitles','dashboard'),Yii::t("app", "Home"))

      - if (user()->checkAccess('view_gates_status'))
        %li(class="#{$controller instanceof GatesStatusController ? 'active' : ''}")
          %a(href="#{$app->createUrl('gatesStatus')}")= onNull(paramdeep('menuTitles','gateStatus'),Yii::t("app", 'Gate Status'))

      - if (user()->checkAccess('view_alerts'))
        %li(class="#{$controller instanceof AlertController ? 'active' : ''}")
          %a(href="#{$app->createUrl('alert/search')}")= onNull(paramdeep('menuTitles','alerts'),Yii::t('app', 'Events'))

      - if (user()->checkAccess('view_map'))
        %li(class="#{$controller instanceof CartographyController ? 'active' : ''}")
          %a(href="#{$app->createUrl('cartography')}")= onNull(paramdeep('menuTitles','map'),Yii::t('app', 'Maps'))

      - if (user()->checkAccess('view_live'))
        %li(class="#{$controller instanceof LiveController ? 'active' : ''}")
          %a(href="#{$app->createUrl('live')}")= onNull(paramdeep('menuTitles','live'),Yii::t('app', 'Live'))

      - if (user()->checkAccess('verify_events') || user()->checkAccess('check_events_data') || user()->checkAccess('verify_all_events_view')|| user()->checkAccess('view_task_status'))
        %li(class="#{$controller instanceof ServiceController ? 'active' : ''}")
          %a(href="#{$app->createUrl('service')}")= onNull(paramdeep('menuTitles','services'),Yii::t('app', 'Tasks'))

      - if (user()->checkAccess('search_violations') || user()->checkAccess('search_violations_advanced') || user()->checkAccess('search_transits'))
        %li.dropdown
          %a.dropdown-toggle(data-toggle="dropdown" href="#")= onNull(paramdeep('menuTitles','search'),Yii::t('app', 'Search'))
          %ul.dropdown-menu
            - if (user()->checkAccess('search_violations'))
              %li(class="#{$controller instanceof SearchController ? 'active' : ''}")
                %a(href="#{$app->createUrl('search')}")= Yii::t('app', 'Events - Fast search')
            - if (user()->checkAccess('search_violations_advanced'))
              %li(class="#{$controller instanceof EventController ? 'active' : ''}")
                %a(href="#{$app->createUrl('event/admin')}")= Yii::t('app', 'Events - Advanced search')
            - if (user()->checkAccess('search_transits'))
              %li(class="#{$controller instanceof VehicleTraceController ? 'active' : ''}")
                %a(href="#{$app->createUrl('vehicleTrace/admin')}")= Yii::t('app', 'Transits')
            - if (user()->checkAccess('search_validated_events_reports'))
              %li(class="#{$controller instanceof ReportArchiveController ? 'active' : ''}")
                %a(href="#{$app->createUrl('reportArchive/index')}")= Yii::t('app', 'Validated Events - Report')

      - if($user->checkAccess('statistics'))
        %li.dropdown
          %a.dropdown-toggle(data-toggle="dropdown" href="#")= onNull(paramdeep('menuTitles','stats'),Yii::t('app', 'Stats'))
          %ul.dropdown-menu
            %li
              %a(href="#{$app->createUrl('stats')}")= Yii::t('app', 'Vehicles')
            %li
              %a(href="#{$app->createUrl('stats/DangerousGoods')}")= Yii::t('app', 'Dangerous Goods')
            - if($user->checkAccess('statistics_events_management'))
              %li
                %a(href="#{$app->createUrl('stats/eventsManagement')}")= Yii::t('app', 'Violations Management')
            - if($user->checkAccess('statistics_operators_statistics'))
              %li
                %a(href="#{$app->createUrl('stats/operatorsStatistics')}")= Yii::t('app', 'Operators Statistics')

      - if(paramdeep('ztl','active') && user()->checkAccess('ztl_view'))
        %li(class="#{($controller instanceof ZtlController || $controller instanceof ZtlEditorController) ? 'active' : ''}")
          %a(href="#{$app->createUrl('ztl/index')}")= onNull(paramdeep('menuTitles','ztl'),Yii::t('app', paramdeep('ztl','name')))

      - if($user->checkAccessLike('plate_list_*') || user()->checkAccess('plate_list_view'))
        %li(class="#{$controller instanceof PlateAuthorizationController ? 'active' : ''}")
          %a(href="#{$app->createUrl('plateAuthorization')}")= getBWListsLabels(paramdeep('menuTitles','plateAuthorizationWL'),paramdeep('menuTitles','plateAuthorizationBL'),paramdeep('menuTitles','plateAuthorizationBWL'))

      - if($user->checkAccess('diagnostic'))
        %li(class="#{$controller instanceof DiagnosticController ? 'active' : ''}")
          %a(href="#{$app->createUrl('diagnostic/search')}")= onNull(paramdeep('menuTitles','diagnostic'),Yii::t('app', 'Diagnostics'))

      - if($user->checkAccess('street_patrol'))
        %li(class="#{$controller instanceof StreetPatrolController ? 'active' : ''}")
          %a(href="#{$app->createUrl('streetPatrol')}")= onNull(paramdeep('menuTitles','streetPatrol'),Yii::t('app', 'Street Patrol'))

      - if($user->checkAccess('manage_gates') || $user->checkAccess('manage_auth') || $user->checkAccess('manage_users') || $user->checkAccess('manage_special_day') || $user->checkAccess('manage_time_schedule') || $user->checkAccess('export_history_report'))
        %li(class="#{$controller instanceof AdminController ? 'active' : ''}")
          %a(href="#{$app->createUrl('admin')}")= onNull(paramdeep('menuTitles','admin'),Yii::t('app', 'Admin'))

      

    %ul.nav.navbar-nav.justify-content-end
      - if ($user->isGuest)
        %li
          %a(href="#{$app->createUrl('session/login')}")= Yii::t('app', 'Login')
      - else
        %li
          -$noetbc = EventController::getNumOfEventsToBeClosed()
          -if($noetbc > 0)
            %a#action-logout(href="#{$app->createUrl('session/logout')}" onclick="return confirm('#{t('There are unconfirmed events, exit anyway?')}')")
              = Yii::t('app', 'Logout')
          -else
            %a#action-logout(href="#{$app->createUrl('session/logout')}")= Yii::t('app', 'Logout')
      - if((user()->isGuest && paramdeep('support','visible_to_guest')) || (!user()->isGuest && paramdeep('support','visible_to_user'))) 
        %li(class="#{$controller instanceof SupportController ? 'active' : ''}")
          %a(title="#{t('Support')}" href="#{$app->createUrl('support')}")
            .icon-question-sign
  .navbar-status
    .container
      - if (!user()->isGuest)
        -if(paramdeep('statusBar','showPoweredBy'))
          %ul.unstyled.inline.pull-left.powered-by
            %li
              %a(href="http://www.kria.biz" target='_blank')
                =t("powered by KRIA")
        .system-status-box 
          %ul.unstyled.inline.span7
            -if(paramdeep('statusBar','showAlerts') && user()->checkAccess('status_bar_view_alerts') && user()->checkAccess('view_alerts'))
              %li
                #alert-summary-bar        
            -if(paramdeep('statusBar','showViolations') && user()->checkAccess('status_bar_view_violations'))
              %li
                #violation-status-bar
            -if(paramdeep('statusBar','showTransits') && user()->checkAccess('status_bar_view_transits'))
              %li
                #stats-status-bar
            -if(paramdeep('statusBar','showSystemStatus') && user()->checkAccess('status_bar_view_status'))
              %li
                #system-status-bar
        %ul.unstyled.inline.pull-right     
          -if(paramdeep('statusBar','showClock') && user()->checkAccess('status_bar_view_clock'))
            %li
              %span
                #clock-bar
                  =new DateTimeEx()
          %li
            %span

              %a(href="#{$app->createUrl($userUpdateUrl)}")= $user->name
              -if(user()->checkAccess('manage_auth'))
                %a.icon-key(title="#{t('Assignments')}" href="#{url('auth/fastassign/user/user/'.$user->id)}")
              -if(DebugController::isInDebugMode())
                %a(href="#{url('debug')}" title="#{t('Debug')}")
                  .icon-bug
                %a(href="#{url('debug/runtime_config')}" title="#{t('Runtime configuration')}")
                  .icon-wrench
          %li
            %span
              -if(user()->checkAccess('create_events_report') || user()->checkAccess('show_sessions_details'))
                %a(href="#{Yii::app()->createAbsoluteUrl('workPeriod/index')}")
                  = Yii::t('app', 'Session #')
                  = Yii::app()->currentWorkPeriod->id
              -else
                = Yii::t('app', 'Session #')
                = Yii::app()->currentWorkPeriod->id
                