<?php $user = $period->user; ?>
<?php $generationTime = DateHelper::formatDateTime($period->report_generation_date); ?>
<?php $this->setPageTitle(t("Report #{period_id} - {user_fullName} - {generationTime}", array('{period_id}' => $period->id, '{user_fullName}' => $user->fullName, '{generationTime}' => $generationTime) )); ?>
<?php $vars = array("period" => $period, "perPage" => 34); ?>
<?php $title_page_spec = paramdeep('report_spec', 'title_page_spec');; ?>
<?php $table_spec = paramdeep('report_spec', 'table_spec');; ?>
<?php $table_invalid_spec = paramdeep('report_spec', 'table_invalid_spec'); ; ?>
<?php foreach ($eventsByGateGroup as $aGroup) { ?>
  <?php $gateGroup = $aGroup['gateGroup'];; ?>
  <?php $events = $aGroup['events'];; ?>
  <?php $counterOK = 0; ?>
  <?php $counterNO = 0; ?>
  <?php foreach($events as $event) { ?>
    <?php if ($event->ext_code != ExtCode::NULL_EXT_CODE)     { ?>
      <?php $counterOK++; ?>
    <?php } else   { ?>
      <?php $counterNO++; ?>
    <?php } ?>
  <?php } ?>
  <?php $appLanguage = Yii::app()->language; ?>
  <?php if(isEmpty($title_page_spec)) { ?>
    <?php $this->renderPartial("_titlePage_{$appLanguage}", array_merge(array("gateGroup" => $gateGroup, "events" => $events, "cntOk"=>"$counterOK", "cntNo"=>"$counterNO"), $vars)); ?>
  <?php } else { ?>
    <?php $this->renderPartial("_titlePage_{$appLanguage}_{$title_page_spec}", array_merge(array("gateGroup" => $gateGroup, "events" => $events, "cntOk"=>"$counterOK", "cntNo"=>"$counterNO"), $vars)); ?>
  <?php } ?>
  <hr class="report" />
  <?php if(isEmpty($table_spec)) { ?>
    <?php $this->renderPartial("_table", array_merge(array('events' => $events), $vars)); ?>
  <?php } else { ?>
    <?php $this->renderPartial("_table_{$table_spec}", array_merge(array('events' => $events), $vars)); ?>
  <?php } ?>
  <hr class="report break" />
  <?php if(isEmpty($table_invalid_spec)) { ?>
    <?php $this->renderPartial("_tableInvalid", array_merge(array('events' => $events), $vars)); ?>
  <?php } else { ?>
    <?php $this->renderPartial("_tableInvalid_{$table_invalid_spec}", array_merge(array('events' => $events), $vars)); ?>
  <?php } ?>
<?php } ?>
