- $status = $gate->statusClass
- $features = param('features')

- $liveUrl = null
- if(strlen($gate->live_url) > 0 && user()->checkAccess('view_live'))
  - $liveUrl = Yii::app()->createUrl('live/direct',array('id'=>$gate->ID))

.gate-container(data-behavior='GateStatus'
  data-gate-id="#{$gate->Gate}"
  data-alerts-container="##{$viewMode}-container"
  data-alerts-mode="#{$viewMode}")
  %header
    .gate-time(class=$status)
      %span.last-signal-time= $gate->lastSignalTime
      %span.last-signal-date= $gate->lastSignalDate
      -if(!$gate->isAlive())
        %span.last-signal-label= t('Last signal')
    .gate-description
      .gate-name.blacklink
        %p
          %a.events-alert-link
            %i.icon-road
            = $gate->Descrizione
            %br
            -if(paramdeep('gateStatus','showZtlStatus') && $gate->IsWhiteList)
              -if($gate->isZtlLimited())
                %i.color-red(style="font-size: smaller;" title="#{t('Limited access')}")=' '.strtoupper(t('Limited access'))
              -else
                %i.color-green(style="font-size: smaller;" title="#{t('Free access')}")=' '.strtoupper(t('Free access'))
        .gate-type
          -if(!empty($liveUrl))
            %a.icon-facetime-video(href="#{$liveUrl}" target="_blank" title="#{t('Live')}")
              = t($gate->DeviceModel)
          -else
            = t($gate->DeviceModel)
        .gate-matriculation-number
          = 'ID: '.$gate->Gate
  %article.gate-data-container
    - if ($features['alertManagement']===true && user()->checkAccess('gate_status_gates_view_alerts'))
      %section
        %table
          %tr
            %td.title(width="30%")
              %span.icon-rss
              = 'Stat. '.t('Events')
            %td(width="23%")  
              %span.event-summary.blacklink
                %a(href="#{Yii::app()->createAbsoluteUrl('alert/search',  array('types' => Alert::TYPE_INFO, 'gates' => $gate->Gate))}")
                  %b.info-icon(title="#{t('Info')}")
                    %i.icon-info
                    = $gate->getRecentlyAlertsCount(Alert::TYPE_INFO)
            %td(width="23%")  
              %span.event-summary.blacklink
                %a(href="#{Yii::app()->createAbsoluteUrl('alert/search',  array('types' => Alert::TYPE_WARNING, 'gates' => $gate->Gate))}")
                  %b.warning-icon(title="#{t('Warnings')}")
                    %i.icon-warning-sign
                    = $gate->getRecentlyAlertsCount(Alert::TYPE_WARNING)
            %td(width="23%")  
              %span.event-summary.blacklink
                %a(href="#{Yii::app()->createAbsoluteUrl('alert/search',  array('types' => Alert::TYPE_ALARM, 'gates' => $gate->Gate))}")
                  %b.alarm-icon(title="#{t('Alarms')}")
                    %i.icon-exclamation
                    = $gate->getRecentlyAlertsCount(Alert::TYPE_ALARM)
    -if(paramdeep('gateStatus','showViolations') && user()->checkAccess('gate_status_gates_view_violations'))
      %section
        %table
          %tr
            %td.title(width="30%")
              %span.icon-camera
              = 'Stat. '.t('Violations')
            %td(width="23%")  
              %b.alarm-icon(title="#{t('New').' ('.t('Last {0} days', array('{0}'=>$gate->lastViolationDays)).')'}")
                %span.icon-check-empty
                =$gate->recentlyViolations_New
            %td(width="23%")
              %b.warning-icon(title="#{t('Validated').' ('.t('Last {0} days', array('{0}'=>$gate->lastViolationDays)).')'}")
                %i.icon-check
                =$gate->recentlyViolations_Validated
            %td(width="23%")
              %b.info-icon(title="#{t('Exported').' ('.t('Last {0} days', array('{0}'=>$gate->lastViolationDays)).')'}")
                %i.icon-signout
                =$gate->recentlyViolations_Exported
    -if(paramdeep('gateStatus','showTransits') && user()->checkAccess('gate_status_gates_view_transits'))
      -$now = DateHelper::ensureObjectEx()
      %section
        %table
          %tr
            %td.title(width="30%")
              %span.icon-bar-chart
              = 'Stat. '.t('Transits')
            %td(width="23%")
              -$t = t("Today's transits").' ('.$now->getToday()->toDateString().')'
              %b(title="#{$t}")
                =t('D',array(),'gateStatus').' '
                =$gate->recentTransitsDay
            %td(width="23%")
              -$t = t("This week's transits")." (".($now->getFirstDayOfWeek()->toDateString())." -> ".($now->getLastDayOfWeek()->toDateString()).")"
              %b(title="#{$t}")
                =t('W',array(),'gateStatus').' '
                =$gate->recentTransitsWeek
            %td(width="23%")
              -$t = t("This month's transits")." (".ucwords($now->getMonthName())." $now->year)"
              %b(title="#{$t}")
                =t('M',array(),'gateStatus').' '
                =$gate->recentTransitsMonth
    