<?php $events = array_sort($events, function($a,$b){ $a = new DateTimeEx($a->StartTime); return $a->compare(new DateTimeEx($b->StartTime)); });; ?>
<?php $totalEvents = count($events); ?>
<?php $validEvents = array_filter($events, function($e){return $e->ext_code != ExtCode::NULL_EXT_CODE;});; ?>
<?php $firstEvent = array_first($validEvents);; ?>
<?php $lastEvent = array_last($validEvents);; ?>
<?php $gates = $gateGroup->gates; ?>
<header class="report">
  <h2><?php echo htmlspecialchars("ACCERTAMENTO VIOLAZIONI AI LIMITI DI VELOCITA' - Art. 142 CdS",ENT_QUOTES,'UTF-8'); ?></h2>
  <h2><?php echo htmlspecialchars("COMUNE DI VICENZA POLIZIA LOCALE",ENT_QUOTES,'UTF-8'); ?></h2>
  <?php $logos = paramdeep('logos','report'); ?>
  <?php $loginLogoStyle = paramdeep('logosStyles','report'); ?>
  <img <?php echo MtHaml\Runtime::renderAttributes(array(array('class', 'login-logo'), array('src', ((Yii::app()->baseUrl) . '/images/' . $logos)), array('style', $loginLogoStyle)), 'html5', 'UTF-8'); ?> />
  <h2><?php echo htmlspecialchars('Eventi Validati - Verbale cumulativo',ENT_QUOTES,'UTF-8'); ?></h2>
</header>
<section class="reportcontent">
  <p>
    Si dà atto che il presente registro di rilevamento, compilato in data
    <?php echo htmlspecialchars(DateHelper::formatDateTime($period->report_generation_date),ENT_QUOTES,'UTF-8'); ?>
    dal sottoscritto Verbalizzante
    <?php echo htmlspecialchars($period->user->fullName,ENT_QUOTES,'UTF-8'); ?>
    è composto da n°
    <?php echo htmlspecialchars(ceil($cntOk / $perPage) + ceil($cntNo / $perPage) + 1,ENT_QUOTES,'UTF-8'); ?>
    pagine e contiene
    <?php echo htmlspecialchars($totalEvents,ENT_QUOTES,'UTF-8'); ?>
    Accertamenti di Infrazione art. 142 CdS
    <?php if(count($validEvents)>0) { ?>
      tra il codice n°
      <?php echo htmlspecialchars($firstEvent->ext_code,ENT_QUOTES,'UTF-8'); ?>
      e il codice n°
      <?php echo htmlspecialchars($lastEvent->ext_code,ENT_QUOTES,'UTF-8'); ?>
    <?php } ?>
    <?php if(count($validEvents)>0) { ?>
      dal giorno
      <?php echo htmlspecialchars(DateHelper::formatDate($firstEvent->StartTime) ,ENT_QUOTES,'UTF-8'); ?>
      alle ore
      <?php echo htmlspecialchars(DateHelper::formatTime($firstEvent->StartTime, 'medium') ,ENT_QUOTES,'UTF-8'); ?>
      al giorno
      <?php echo htmlspecialchars(DateHelper::formatDate($lastEvent->StartTime) ,ENT_QUOTES,'UTF-8'); ?>
      alle ore
      <?php echo htmlspecialchars(DateHelper::formatTime($lastEvent->StartTime,  'medium') ,ENT_QUOTES,'UTF-8'); ?>
    <?php } ?>
    rilevati nel gruppo di varchi
    <?php echo htmlspecialchars($gateGroup->address,ENT_QUOTES,'UTF-8'); ?>
    composto da
    <?php echo htmlspecialchars(count($gates),ENT_QUOTES,'UTF-8'); ?>
    varchi:
    <?php $gggc = 0; ?>
    <?php foreach($gates as $g) { ?>
      <?php if($gggc>0) { ?>
        <?php echo htmlspecialchars(',',ENT_QUOTES,'UTF-8'); ?>
      <?php } ?>
      <?php echo htmlspecialchars("{$g->Gate} ({$g->Descrizione})",ENT_QUOTES,'UTF-8'); ?>
      <?php $gggc++; ?>
    <?php } ?>
  </p>
</section>
