- $documents = $dataProvider->data
- $freshDocumentTimeout = 300

#report-archive-page

  .page-header
    %h2 Report Archive
  
  .row.form-box
    - $form = $this->beginWidget('bootstrap.widgets.TbActiveForm',             |
                array(                                                         |
                'id'=>'report-archive-search-form',                            |
                'action' => Yii::app()->createUrl($this->route),               |
              ))                                                               |
    %fieldset
      
      .row
        
        .span5
      
          #date-time-range-search.span(data-behavior="DateRangeInput" data-date-range-start-target='#search-date-start' data-date-range-end-target='#search-date-end')
            %label=t("Date/Time")
            .date-time-range-block.span(style="margin-left:0")
              =t("From")
              #search-date-start.input-append.date.datetime-picker
                %input(data-format="#{Yii::app()->params['datetimeselect_format'][Yii::app()->language]['view']}" type="text" name="ReportArchiveSearchForm[startDateTime]" value="#{$reportArchiveSearchForm->startDateTime}")
                  %span.add-on
                    %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
            .date-time-range-block.span
              =t("To")      
              #search-date-end.input-append.date.datetime-picker
                %input(data-format="#{Yii::app()->params['datetimeselect_format'][Yii::app()->language]['view']}" type="text" name="ReportArchiveSearchForm[endDateTime]"  value="#{$reportArchiveSearchForm->endDateTime}")
                  %span.add-on
                    %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
            
        .span5
            
          %label=t("Gate Group")
          %select#report-archive-gategroup-filter.selectpicker.span3(multiple="multiple" data-live-search="false" title="#{t('Select Gate Group...')}" name="ReportArchiveSearchForm[gateGroups][]")
            - foreach($gateGroups as $gateGroup)
              - if (isset($reportArchiveSearchForm->gateGroups) && in_array($gateGroup['ID'], $reportArchiveSearchForm->gateGroups))
                %option(value="#{$gateGroup->ID}" selected="selected")
                  = $gateGroup->name
              - else
                %option(value="#{$gateGroup->ID}")
                  = $gateGroup->name
              
      .row(style="margin-top:10px;")

        .span5
          
          %div(style="margin-left:30px")
            %label=t("ADI Code")
            
            .span(style="margin-left:0")
              =t("From")
              %input(type="text" style="width:70%" name="ReportArchiveSearchForm[ADIcodeFrom]" value="#{$reportArchiveSearchForm->ADIcodeFrom}")
                
            .span(style="margin-left:0")
              =t("To")
              %input(type="text" style="width:73%" name="ReportArchiveSearchForm[ADIcodeTo]" value="#{$reportArchiveSearchForm->ADIcodeTo}")
                
       
        - if(user()->checkAccess('report_archive_view_all')) 
          .span5
            
            %label=t("Users")
            %select#report-archive-users-filter.selectpicker.span3(multiple="multiple" data-live-search="false" title="#{t('Select Users...')}" name="ReportArchiveSearchForm[users][]")
              - foreach($users as $user)
                - if (isset($reportArchiveSearchForm->users) && in_array($user['id'], $reportArchiveSearchForm->users))
                  %option(value="#{$user->id}" selected="selected")
                    = $user->username
                - else
                  %option(value="#{$user->id}")
                    = $user->username
      
      .row    
      
        %button#search-for-report-archive.pull-right.btn(type="submit")
          = t("Filter")
                
    - $this->endWidget()
  
  .row
  
    - if (isset($dataProvider) && count($dataProvider->data)>0)
    
      .report-table-container(style="margin-top:10px")
        %table.table.table-striped.table-condensed
          %thead
            %tr
              %td=t('User')

              %td=t('Date')
              %td=t('Time')
              %td=t('Session')
              %td=t('Service')
              %td=t('Gate Group')
              %td=t('ADI Code From')
              %td=t('ADI Code To')
              %td=t('Report')
          %tbody
            - $now = new DateTime()
            - foreach($documents as $document)
          
              - $freshDocumentBtnClass = ""
              - if ( ($now->getTimestamp() - $document->CreationTime->getTimestamp()) < $freshDocumentTimeout )
                -  $freshDocumentBtnClass = "btn-info"
          
              %tr
                %td=$document->user->username
                
                %td=DateHelper::formatLocalDate($document->CreationTime)
                %td=DateHelper::formatISO9075Time($document->CreationTime)
                -if(empty($document->PeriodID))
                  %td = "-"
                - else
                  %td = $document->PeriodID
                - if(empty($document->serviceID))
                  %td = "-"
                - else
                  %td = $document->serviceID
                  
                %td=$document->gateGroup->name                   
                %td=$document->MinExtcode
                %td=$document->MaxExtcode
                %td
                  %a.btn.btn-small(class=$freshDocumentBtnClass href="#{Yii::app()->createAbsoluteUrl('reportArchive/showReport', array('reportID' => $document->ID))}" target='_blank')
                    =t("View")
                  
      .pagination
        - $this->widget('bootstrap.widgets.TbPager', array('pages' => $dataProvider->pagination))
    
    - else
      
      %h4= Yii::t("app", "No results")
        