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

#stats-events-management-page
  .page-header
    %h2
      %i.icon-bar-chart
      = Yii::t("app", "Stats")

  %form.form-box#events-management-search-form(method="post" action=Yii::app()->createUrl($this->route))
    
    .row
    
      .span8
      
        .controls
    
          %h4
            %i.icon-time
            = t('When')
            %small= t('Choose a date range')
          
        .controls
          #date-time-range-search(data-behavior="DateRangeInput" data-date-range-start-target='#search-date-start' data-date-range-end-target='#search-date-end')
            #search-date-start.input-prepend.input-append.date.datetime-picker
              %span.add-on=t('From')
              %input(data-format="#{Yii::app()->params['datetimeselect_format'][Yii::app()->language]['view']}" type="text" name="EventsStatisticsSearchForm[startDateTime]" value="#{$eventsStatisticsSearchForm->startDateTime}")
                %span.add-on
                  %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
            #search-date-end.input-prepend.input-append.date.datetime-picker
              %span.add-on=t('To')
              %input(data-format="#{Yii::app()->params['datetimeselect_format'][Yii::app()->language]['view']}" type="text" name="EventsStatisticsSearchForm[endDateTime]"  value="#{$eventsStatisticsSearchForm->endDateTime}")
                %span.add-on
                  %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
        
            %span=t('Time Slot')
            #datepicker-start-time.input-prepend.input-append.time-picker
              %span.add-on= t('From')
              %input.span1(data-format="#{Yii::app()->params['timeselect_format'][Yii::app()->language]['view']}" type="text" name="EventsStatisticsSearchForm[startTimeSlot]"  value="#{$eventsStatisticsSearchForm->startTimeSlot}")
              %span.add-on
                %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
            #datepicker-end-time.input-prepend.input-append.time-picker
              %span.add-on= t('To')
              %input.span1(data-format="#{Yii::app()->params['timeselect_format'][Yii::app()->language]['view']}" type="text" name="EventsStatisticsSearchForm[endTimeSlot]"  value="#{$eventsStatisticsSearchForm->endTimeSlot}")
              %span.add-on
                %i(data-time-icon="icon-time" data-date-icon="icon-calendar")
                  
        .controls.search-options
          
          %input.btn(type='button'
            data-behavior='DatePickSetter'
            data-datepick-setter-mode='datetime'
            data-datepick-setter-range='7'
            data-datepick-setter-start-target="#search-date-start"
            data-datepick-setter-end-target="#search-date-end" value=t('Last 7 days'))
          
          %input.btn(type='button'
            data-behavior='DatePickSetter'
            data-datepick-setter-mode='datetime'
            data-datepick-setter-range='30'
            data-datepick-setter-start-target="#search-date-start"
            data-datepick-setter-end-target="#search-date-end" value=t('Last 30 days'))
            
          %input.btn(type='button'
            data-behavior='DatePickSetter'
            data-datepick-setter-mode='datetime'
            data-datepick-setter-range='60'
            data-datepick-setter-start-target="#search-date-start"
            data-datepick-setter-end-target="#search-date-end" value=t('Last 60 days'))
            
        .controls.submit-actions
          %input.btn(type='submit' value=t('Search'))
          %a.btn.print-btn(href="#" data-toggle="tooltip")
            =t('Print')
          %input.btn#events-management-export-violations(type="button" onclick="exportViolationReport('#{t('Approved Violations')}','#{t('Invalid Violations')}','#{t('Exported Violations')}','#{t('Total Violations')}','#{t('Pending Violations')}','#{t('Violations Management')}','#{t('byDate')}','#{t('byGate')}','#{t('byExport')}')" value=t('Export'))
            
      .span3
      
        .controls
        
          %h4
            %i.icon-map-marker
            = t('Where')
            %small= t('Gates')
          
          %select#stats-events-management-gate-filter.selectpicker.span3(multiple="multiple" data-live-search="false" title="#{t('Select Gate')}" name="EventsStatisticsSearchForm[gates][]")
            - foreach($gates as $gate)
              - if (isset($eventsStatisticsSearchForm->gates) && in_array($gate['Gate'], $eventsStatisticsSearchForm->gates))
                %option(value="#{$gate->Gate}" selected="selected")
                  = $gate->Descrizione
              - else
                %option(value="#{$gate->Gate}")
                  = $gate->Descrizione

  - if (isset($validationErrors))
    - $this->renderPartial('eventsManagement/_formValidationErrors', get_defined_vars())
  - else if (!is_null($violationsCountByTimespanStatsData))
    - $this->renderPartial('eventsManagement/_searchResults', get_defined_vars())