- $countryList = CountryList::localized()
- $globalMode = false

- $liste = array()
- if($plateList == null)
  - $isBlack = false
  - $globalMode = true
  - $liste = PlateList::getCurrentUserLists()
  - $liste = array_remap($liste, function($k, $v){ return $v->code; });
- else
  - $isBlack = $plateList->mode == PlateList::MODE_BLACK_LIST
  - $liste[$plateList->code] = $plateList

-if(Yii::app()->params['listsType']=="black")
  - $isBlack = true

- if(!$globalMode)
  - if($isBlack)
    - $imgurl = $plateList->getImageUrl('/images/list_black.png')
  - else
    - $imgurl = $plateList->getImageUrl('/images/list_white.png')

%script{:type => "text/javascript",
        :src  => "../js/columnReorderer.js"}



#plateauthsstatus-search-page

  - $context = array('plateListId'=>$plateListId,'status'=>$status,'search'=>$search,'timeRange'=>$timeRange,'whitelistStatusDataProvider_page'=>$_REQUEST[whitelistStatusDataProvider_page],'sort'=>$sort,'category'=>$category)
  - $currentUrl = Yii::app()->createAbsoluteUrl($this->route,$context)
  
  .page-header
    %table(width="100%")
      %tr
        %td
          %h2
            -if(!$globalMode)
              -if($isBlack)
                %i.icon-file-text
              -else
                %i.icon-file-text-alt
            -else
              .icon-globe
            -if($isBlack)
              =t('Listed vehicles')
            -else
              =t('Manage plate authorizations')  
          %h4
            -if(!$globalMode)
              =$plateList->getListTitleComplete()
            -else
              =t("All lists")
        %td
          -if(!empty($imgurl))
            %img(src="#{$imgurl}" width="100" align="right")
    
  .row(style="margin-bottom: 20px;")
    .form-box 
      - $form = $this->beginWidget('bootstrap.widgets.TbActiveForm',       |
                  array(                                                     |
                  'id'=>'plateauthstatus-search-form',                                  |
                  'action' => Yii::app()->createUrl($this->route),           |
                  'method'=>'GET',                                  |
                  'htmlOptions'=>array('style'=>'margin-bottom: 0px;'),                                  |
                ))                                                           |
      %span
        %fieldset
          %input(type="hidden" name="plateListId" value="#{$plateListId}")
          %b=t('Search')
          %input(type="text" name="search" value="#{$search}" class="span2" title="#{t('You can use % as a wildcard')}")
          - if(!$isBlack)
            %b=t('Time interval')
            != CHtml::dropDownList('timeRange', $timeRange, $timeRanges, array('style'=>'width: 120px;'));
            %b=t('Status')
            != CHtml::dropDownList('status', $status, $statuses, array('style'=>'width: 120px;'));
          - if($isBlack)
            %b=t('Alert type')
            != CHtml::dropDownList('category', $category, $categories, array('style'=>'width: 120px;'));
          %b=t('Sort')
          != CHtml::dropDownList('sort', $sort, $sortList, array('class'=>'span2'));
          %b=t('#')
          != CHtml::dropDownList('pagination', $pagination, array(20=>20,50=>50,100=>100,200=>200), array('style'=>'width: 70px;'));

          %a.btn.btn-small(href="#{url('plateAuthorization/whitelistStatus', array('plateListId'=>$plateListId))}" title="#{t('Remove filters')}" style="margin-bottom: 10px;")
            %i.icon-remove
            
          %button.btn.btn-small(type="submit" name="submit_search" autofocus="autofocus" style="margin-bottom: 10px;")
            = t("Search")

          - if(user()->checkAccess('plate_auth_status_export') || user()->checkAccess('plate_auth_renew'))
            .btn-group.pull-right
              %a.btn.btn-small.dropdown-toggle(data-toggle="dropdown" href="#")
                = Yii::t("app", "Actions")
                %span.caret
              %ul.dropdown-menu(id="multi-plate-actions")
                - if (user()->checkAccess('plate_auth_status_export'))
                  %li
                    %a(href="#" id="multi-plate-action-export")
                      = Yii::t("app", ("Export"))
                - if (user()->checkAccess('plate_auth_renew'))
                  %li
                    %a(href="#" id="multi-plate-action-renew")
                      = Yii::t("app", ("Renew"))

          -if(user()->checkAccess('plate_auth_status_export'))
            %button.pull-right.btn.btn-small(type="submit" id="submit_export" name="submit_export" style="margin-left: 5px;display: none;")
              = t("Export")
              
          -if(user()->checkAccess('plate_auth_renew'))
            %button.pull-right.btn.btn-small(type="submit" id="submit_renew_many" name="submit_renew_many" style="display: none;")
              = t("Renew")
  
      - $this->endWidget()

  .row
    
    - if (isset($dataProvider) && count($dataProvider->data)>0)

      - $permessi = $dataProvider->data
      .tableContainer
        %table.table.table-condensed.span12(id="resultTable")
          %thead
            %tr
              %th
              %th
                = t('List')
              %th
                = t('Name')
              %th
                = t('Surname')
              %th
              %th
                = t('Plate')
              -if($isBlack)  
                %th
                  = t('Model')
                %th
                  = t('Vehicle class')
                %th
                  = t('Alert type')
                %th
                  = t('Notes')
              -if(!$isBlack)
                %th
                  = t('Gate')
                %th
                  = t('Time Schedule')
                %th
                  = t('Start date')
                %th
                  = t('End date')
                %th
                  = t('Status')
              %th
                = t('Actions')
              
          %tbody
            - foreach($permessi as $permessoRow)
              - $permesso = $this->createPermessoFromRow($permessoRow, $currentUrl)
              - $lista = $liste[$permesso->IDLista]
              %tr
                %td
                  %a(href="#{$permesso->url_view}" title="#{t('View')}")
                    %i.icon-eye-open
                %td
                  -if($permesso->ListaIsBlack)
                    %i.icon-file-text
                  -else
                    %i.icon-file-text-alt
                  =$permesso->Lista
                %td                  
                  -if(user()->checkAccess('plate_auth_insert') && user()->checkAccess('plate_auth_insert_wizard'))
                    %a(href="#{url('plateAuthorization/whiteListWizard',array('plateListId'=>$permesso->IDLista,'ownerId'=>$permesso->IDUtente,'step'=>2))}")
                      =$permesso->Nome
                  -else
                    =$permesso->Nome
                %td
                  -if(user()->checkAccess('plate_auth_insert') && user()->checkAccess('plate_auth_insert_wizard'))
                    %a(href="#{url('plateAuthorization/whiteListWizard',array('plateListId'=>$permesso->IDLista,'ownerId'=>$permesso->IDUtente,'step'=>2))}")
                      =$permesso->Cognome
                  -else
                    =$permesso->Cognome
                %td
                  -$this->printCountryFlag($permesso->Nationality)
                %td
                  -if(user()->checkAccess('plate_auth_insert') && user()->checkAccess('plate_auth_insert_wizard'))
                    %a(href="#{url('plateAuthorization/whiteListWizard',array('plateListId'=>$permesso->IDLista,'ownerId'=>$permesso->IDUtente,'vehicleId'=>$permesso->IDVeicolo,'step'=>3))}")
                      =$permesso->Targa
                  -else
                    =$permesso->Targa
                -if($isBlack)
                  %td
                    #{$permesso->DescrizioneVeicolo}
                  %td
                    %img.vehicle-class-icon-small(src="#{Yii::app()->baseUrl}/images/vehicle-classes/#{$permesso->Classe != "" ? $permesso->Classe : "vehicle"}.png")
                  %td
                    #{$permesso->Categoria}
                  %td
                    #{$permesso->Note}
                -if(!$isBlack)
                  %td
                    !=SystemInfoHelper::getPlateAuthGateCoolName($permesso->IDGate,$permesso->IDGate_type)
                  %td
                    !=SystemInfoHelper::getTimeScheduleCoolName($permesso->IDTime)
                  %td
                    -if(user()->checkAccess('plate_auth_insert') && user()->checkAccess('plate_auth_insert_wizard'))
                      %a(href="#{url('plateAuthorization/whiteListWizard',array('plateListId'=>$permesso->IDLista,'ownerId'=>$permesso->IDUtente,'vehicleId'=>$permesso->IDVeicolo,'validityPeriodId'=>$permesso->IDAbbonamento,'step'=>4))}")
                        =$permesso->DataInizio
                    -else
                      =$permesso->DataInizio
                  %td
                    -if(user()->checkAccess('plate_auth_insert') && user()->checkAccess('plate_auth_insert_wizard'))
                      %a(href="#{url('plateAuthorization/whiteListWizard',array('plateListId'=>$permesso->IDLista,'ownerId'=>$permesso->IDUtente,'vehicleId'=>$permesso->IDVeicolo,'validityPeriodId'=>$permesso->IDAbbonamento,'step'=>4))}")
                        =$permesso->DataFine
                    -else
                      =$permesso->DataFine
                  %td
                    %font(color="#{$permesso->statusColor}")
                      =$permesso->statusText
                %td
                  -$this->printPrintBtn($permesso)
                  -if($lista->editable && Yii::app()->user->checkAccess('plate_auth_enable'))
                    -if($permesso->Enabled == 1)
                      %a(href="#{$permesso->url_revoke}" title="#{t('Revoke')}")
                        %i.icon-pause
                    -else
                      -if($lista->editable && Yii::app()->user->checkAccess('plate_auth_activate')) 
                        %a(href="#{$permesso->url_activate}" title="#{t('Activate')}")
                          %i.icon-play
                  -if($lista->editable && $permesso->ToBeConfirmed == 1 && Yii::app()->user->checkAccess('plate_auth_confirmed'))
                    %a(href="#{$permesso->url_confirm}" title="#{t('Confirm')}")
                      %i.icon-unlock-alt
                  -if($lista->editable && ($permesso->aboutToExpire || $permesso->expired) && Yii::app()->user->checkAccess('plate_auth_renew'))
                    %a(href="#{$permesso->url_renew}" title="#{t('Renew')}")
                      %i.icon-repeat
                  -if($lista->editable && Yii::app()->user->checkAccess('plate_auth_delete'))
                    %a(href="#{$permesso->url_delete}" title="#{t('Delete')}" onclick="return confirm('#{t('Are you sure you want to delete this item?')}')")
                      %i.icon-trash
        
      - if (isset($dataProvider->pagination))
        .pagination.pagination-links-container
          - $this->widget('bootstrap.widgets.TbPager', array('pages' => $dataProvider->pagination))
        =t("Results").": $totalResults"
    - else
    
      %h4= Yii::t("app", "No results")

- if($isBlack)
  %script{:type => "text/javascript"}
    !="moveColumn($('#resultTable'), 2, 8);"
    !="moveColumn($('#resultTable'), 2, 8);"