-# Remove data of users who do not have made any decision
- $usersValidationDecisionsByTimespanStatsData = array_filter(                 |
                                                                               |
    $usersValidationDecisionsByTimespanStatsData, function($item) {            |
                                                                               |
            if (array_sum($item['data']) > 0)                                  |
              return true;                                                     |
                                                                               |
            return false;                                                      |
                                                                               |
   });                                                                         |

- $searchGateList = ""
- foreach($gates as $gate)
  - if (isset($eventsStatisticsSearchForm->gates) && in_array($gate['ID'], $eventsStatisticsSearchForm->gates))
    - $searchGateList.= $gate->Descrizione . ", "
- $searchGateList = rtrim($searchGateList, ", ")
  
- $encodedApprovedViolationsCountByTimespanStatsData = CJSON::encode($approvedViolationsCountByTimespanStatsData)
- $encodedInvalidViolationsCountByTimespanStatsData = CJSON::encode($invalidViolationsCountByTimespanStatsData)
- $encodedUsersApprovedViolationsCountByTimespanStatsData = CJSON::encode($usersApprovedViolationsCountByTimespanStatsData)
- $encodedUsersInvalidViolationsCountByTimespanStatsData = CJSON::encode($usersInvalidViolationsCountByTimespanStatsData)
- $encodedValidationDecisionsByTimespanStatsData = CJSON::encode($validationDecisionsByTimespanStatsData)
- $encodedUsersValidationDecisionsByTimespanStatsData = CJSON::encode($usersValidationDecisionsByTimespanStatsData)

.stats-operators-statistics-search-results

  %div.print-only(style="margin-left: 1cm;margin-top: 1cm;margin-bottom:2cm")
    %h1(style="text-align:center;margin-bottom: 1cm;")
      = t('Operators Statistics')
    %p(style="font-size:22px;")
      %strong
        =t('Date') . ":"
      =t('From')
      =$eventsStatisticsSearchForm->startDateTime
      =t('To')
      =$eventsStatisticsSearchForm->endDateTime
      - if (isset($eventsStatisticsSearchForm->gates))
        %br
        %br
        %strong
          =t('Gates') . ":"
        =$searchGateList
    
  %h3(style="text-align:center")
    = t('Operators Statistics Overview')

  .row.stats-operators-statistics-overview-container
   
    .span12
      #approved-vs-invalid-violations-trend-graph-container
        %canvas#approved-vs-invalid-violations-trend-graph(style="height:70%;width:40%;")
        
  .row.stats-operators-statistics-overview-container
   
    .span12
      #users-approved-vs-invalid-violations-graph-container
        %canvas#users-approved-vs-invalid-violations-graph(style="height:70%;width:40%;")
  
  .row.stats-operators-statistics-overview-container
  
    -# show this chart only if there's any non-zero value
    - if (array_sum($validationDecisionsByTimespanStatsData) > 0)
  
      .span12
        #approved-vs-invalid-events-reasons-graph-container
          %canvas#validation-decisions-trend-graph(style="height:70%;width:40%;")
  
  -# Add a page break here, only when printing
  %div.display#break_page(style="page-break-after:always")
  
  .stats-operators-statistics-details-container
  
    - if (!empty($usersValidationDecisionsByTimespanStatsData))
      
      %h3(style="text-align:center")
        = t('Invalid Violations Reasons Statistics: Users Details')
    
      - foreach(array_values($usersValidationDecisionsByTimespanStatsData) as $index => $userData)
        .row
          .span12
            %canvas(id="user-validation-decisions-trend-graph-".$userData['user']['id'] style="height:70%;width:40%;")
  
  %input#approved-violations-count-by-timespan-graph-data(type='hidden' value="#{$encodedApprovedViolationsCountByTimespanStatsData}")
  %input#invalid-violations-count-by-timespan-graph-data(type='hidden' value="#{$encodedInvalidViolationsCountByTimespanStatsData}")
  %input#users-approved-violations-count-by-timespan-graph-data(type='hidden' value="#{$encodedUsersApprovedViolationsCountByTimespanStatsData}")
  %input#users-invalid-violations-count-by-timespan-graph-data(type='hidden' value="#{$encodedUsersInvalidViolationsCountByTimespanStatsData}")
  %input#validation-decisions-by-timespan-graph-data(type='hidden' value="#{$encodedValidationDecisionsByTimespanStatsData}")
  %input#users-validation-decisions-by-timespan-graph-data(type='hidden' value="#{$encodedUsersValidationDecisionsByTimespanStatsData}")