- if(isset(Yii::app()->params['showICETRATooltip']) && Yii::app()->params['showICETRATooltip']==="true")
  %script{:type => "text/javascript", :src  => "../../js/icetra.js"}

-$DIMENSIONE_IMMAGINI = 250
-$FATTORE_ZOOM = 6
-$ZOOM_SPEED = 0.3
-$OCR_PRECISION = 0
-$thirdColumnName="none"

- $hasSpeedBehaviour = false
- foreach ($eventBehaviors as $index => $eventBehavior)
  - if($eventBehavior->behavior->name == "spot speed")
    - $hasSpeedBehaviour = true
    - $thirdColumnName = t('Animation')
  - else
    - $thirdColumnName = "Video"

- $isWhitelist = false
- $isRed = false
- if($gateBehaviors != null && is_array($gateBehaviors))
  - foreach ($gateBehaviors as $index => $gateBehavior)
    -if($gateBehavior->is_whitelist)
      - $isWhitelist = true
      
- if($isWhitelist)
  -$plateAjaxUrl = CController::createUrl('event/ajaxWhitelistSmartTips')
  -$plateAjax = array('type' =>'POST','url' => $plateAjaxUrl,'update' => '#whitelist-smart-tips');

- $platesClass = paramdeep('validation','plate','alphanumeric') ? 'alphanumeric' : ''
- $nextEvent = $queue->getNextEvent ( $event );
- $previousEvent = $queue->getPreviousEvent ( $event );

- $ocrQualityClassHTML = "";
- if(isset(Yii::app()->params['showOcrTooltip']) && Yii::app()->params['showOcrTooltip']!=="false")
  - if (!$event->hasCorrectedPlate())
    - if (!is_null($event->ocrQuality))
      - $ocrQualityRate = round($event->ocrQuality, $OCR_PRECISION) . '%';
      - $ocrQualityClass = $event->ocrQualityClass;
      - $ocrQualityClassHTML = "ocrQuality" . ucfirst($ocrQualityClass);
      - $ocrQualityClassHTML .= " ocrQualityTooltip";
    - else
      - $ocrQualityRate = Yii::t('app', "Not Available");
      - $ocrQualityClassHTML = "ocrQualityTooltip";

#event-page

  .page-header
    %h2
      = Yii::t('app', 'Event #')
      = $event->ID
      %small
        - if (isset($event->service))
          = Yii::t('app', 'Task')
          = $event->service->ID

      %small
        = ($queue->getEventIndex($event) + 1)
        = Yii::t('app', 'of')
        = ($queue->getEventsCount())

      - if ($event->isExamined())
        %span.label= Yii::t('app', 'Examined')

      - if ($event->isValidated())
        %span.label= Yii::t('app', 'Validated')

      - if (Yii::app()->user->checkAccess('edit_event_behaviors'))
        .btn-group.pull-right(style="font-weight: initial;")
          %a.btn(href="#{Yii::app()->createAbsoluteUrl('event/indexFilter', array('service' => $service, 'scope' => $scope))}")
            = Yii::t("app", "All")
          %a.btn(href="#{Yii::app()->createAbsoluteUrl('event/indexFilter', array('service' => $service, 'scope' => $scope, 'toValidateOnly' => true))}")
            = Yii::t("app", "To Be Validated")

  - $form = $this->beginWidget('bootstrap.widgets.TbActiveForm',       |
          array(                                                       |
            'type' => 'horizontal',                                    |
            'action' => array('/event/update/'.$event->ID),            |
            'htmlOptions' => array(                                    |
              'id' => 'event-form',                                    |
              'data-event-id' => $event->ID,                           |
            ),                                                         |
          ))                                                           |

  %input(type="hidden" name="internal_gate" value="#{$event->Gate}")
  %input(type="hidden" name="internal_timestamp" value=tts($event->StartTime))
  -if(Yii::app()->params['photoEditingMode']==="facecrop" && Yii::app()->params['photoEditingMode']!=="none")
    %input(type="hidden" id="croppedImagesData" name="croppedImagesData" value="0")

  %table(style="width: 100%;")
    - if(Yii::app()->user->checkAccess('media_view_photo') || Yii::app()->user->checkAccess('media_view_video'))
      -$mainMediaCount = 3
      -$mainMediaColumnSize = 33

      %tr
        %td(style="text-align: center; width: #{$mainMediaColumnSize}px; background-color: #efefef;")
          %b
            =t('Plate')
        %td(style="text-align: center; width: #{$mainMediaColumnSize}px; background-color: #efefef;")
          %b
            =t('Transit images')
        %td(style="text-align: center; width: #{$mainMediaColumnSize}px; background-color: #efefef;")
          %b
            #{$thirdColumnName}
     
      %tr
        -if(user()->checkAccess('media_view_photo'))
          -$photoBW = $event->PreviewPhoto
          -if(Yii::app()->params['deviceType']=="section")
            -$photoBW2 = $event->getCorrectMediaById(1001)
          -if ($eventBehavior->behavior->isWhitelist)
            -$whitelistData = $event->getWhitelistData()
            - if($whitelistData['reference_bw'] != null)
              - $photoBW = $whitelistData['reference_bw']
          -$photoCOL= $event->PreviewColorPhoto
          -$extraPhotos = $event->PreviewExtraCameraPhoto;
          %td(style="width: #{$mainMediaColumnSize}px;")
            -if($photoBW!=null)
              %center
              -if(Yii::app()->params['photoEditingMode']==="obscure")
                %a(href="#modal-alert-photo-preview" data-toggle="modal")
                  -$plateRect = $photoBW->getPlateRectangle()
                  -if($plateRect!=null && $plateRect->width>0)
                    -$point = $plateRect->center
                    -$scala = $photoBW->width/$plateRect->width
                    -$scala /= 1.75
                    -$this->printAutozoomReverseImageScaleByHeight($photoBW->UrlEnhanced, $photoBW->width, $photoBW->height, $DIMENSIONE_IMMAGINI, $point->X, $point->Y, $scala, $ZOOM_SPEED)
                  -else
                    -$this->renderHtml("<div style=\"margin: 1px; border: 1px solid black; height: {$DIMENSIONE_IMMAGINI}px;\"><img src=\"$photoBW->UrlEnhanced\" style=\"height: {$DIMENSIONE_IMMAGINI}px;\" alt=\"\"></div>")
              -else
                %a(href="#{$photoBW->UrlEnhanced}" data-lightbox="alert-preview-#{$event->ID}")
                  -$plateRect = $photoBW->getPlateRectangle()
                  -if($plateRect!=null && $plateRect->width>0)
                    -$point = $plateRect->center
                    -$scala = $photoBW->width/$plateRect->width
                    -$scala /= 1.75
                    -$this->printAutozoomReverseImageScaleByHeight($photoBW->UrlEnhanced, $photoBW->width, $photoBW->height, $DIMENSIONE_IMMAGINI, $point->X, $point->Y, $scala, $ZOOM_SPEED)
                  -else
                    -$this->renderHtml("<div style=\"margin: 1px; border: 1px solid black; height: {$DIMENSIONE_IMMAGINI}px;\"><img src=\"$photoBW->UrlEnhanced\" style=\"height: {$DIMENSIONE_IMMAGINI}px;\" alt=\"\"></div>")
                   
          %td(style="width: #{$mainMediaColumnSize}px;")
         
            -$photosBWCOL = array()
            -if($photoBW2!=null)
              -$photosBWCOL[] = $photoBW2->getUrl(true)
            -if($photoCOL!=null)
              -$photosBWCOL[] = $photoCOL->getUrl(true)
            -if($photoBW!=null)
              -$photosBWCOL[] = $photoBW->getUrl(true)
            -foreach($extraPhotos as $extPhoto)      
              -$photosBWCOL[] = $extPhoto->getUrl(true)
            -if(count($photosBWCOL)>0)
              -$this->dragonImage($photosBWCOL, "100%", $DIMENSIONE_IMMAGINI."px")
    
        -if(user()->checkAccess('media_view_video'))
          -$video = $event->video_col
          -if($video==null)
            -$video = $event->video_bw
          -if($video==null)
            -$video = array_first($event->videos)
          -if($video!=null)
            %td(style="width: #{$mainMediaColumnSize}px;")
              %center
                -$this->renderVideo($video->url, null, $DIMENSIONE_IMMAGINI)

        - if($hasSpeedBehaviour)
          %td(style="width: #{$mainMediaColumnSize}px;")
            %center
              -$this->renderHtml("<script>var index=0;var imagesArray = {$event->getImagesForGif()};function changeBanner(){ document.getElementById(\"gif_img\").setAttribute(\"src\",imagesArray[index]);index=++index%2;}window.onload = function () {setInterval(changeBanner, 500)};</script><img style=\"border: 1px solid black; height:{$DIMENSIONE_IMMAGINI}px;\" id=\"gif_img\"/>")

    %tr
      %td(colspan="3")
        %table(style="width: 100%; background-color: #efefef; border-radius: 5px; padding: 10px; margin: 5px;")
          %tr
            %td(style="text-align: center; width: 25%;")
              %strong=t('Date Time')
              =DateHelper::formatShort($event->StartTime)
            %td(style="text-align: center; width: 50%;")
              %strong=t('Gate')
              =$event->GateDescription
            %td(style="text-align: center; width: 25%;")
              %strong=t('Device ID')
              =$event->gate->Gate        
    %tr
      %td(style="width: 33%;")
        .plate-info-container
          - if($isWhitelist)
            != $form->textFieldRow($event, 'Plate', array('class' => "touppercase span2 {$platesClass} platefield plate-white-list {$ocrQualityClassHTML}", 'id'=>'Plate', 'data-title' => Yii::t('app', 'Accuracy: ') . $ocrQualityRate))
          -else
            != $form->textFieldRow($event, 'Plate', array('class' => "touppercase span2 {$platesClass} platefield {$ocrQualityClassHTML}", 'data-title' => Yii::t('app', 'Accuracy: ') . $ocrQualityRate))
          -if(paramdeep('validation','plate','suggestions'))
            -$this->addPlateSuggestionsJS($event)
      %td(style="width: 33%;")
        - if($isWhitelist)
          != $form->dropDownListRow($event, 'custom_nationality', array_merge(array('' => ''), CountryList::localized()), array('class' => 'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Country...')))
        -else
          != $form->dropDownListRow($event, 'custom_nationality', array_merge(array('' => ''), CountryList::localized()), array('class' => 'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Country...')))
      %td(style="width: 33%;" rowspan="3")
        -if($isWhitelist)
          #whitelist-smart-tips
    %tr
      %td(style="width: 33%;")
        != $form->dropDownListRow($event, 'custom_vehicle_type', array_merge(array('' => ''), VehicleTypes::localizedForValidation()), array('class' => 'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Class...')))
      %td(style="width: 33%;")
        != $form->dropDownListRow($event, 'custom_plate_type',  array_merge(array('' => ''), CHtml::listData(CustomPlateType::model()->findAll(), 'type', 'label')), array('class' => 'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Plate Type...')))
    %tr
      %td(style="width: 33%;")
        != $form->dropDownListRow($event, 'custom_property_type', array_merge(array('' => ''), CHtml::listData(CustomPropertyType::model()->findAll(), 'type', 'label')), array('class' => 'span2 chzn-select', 'data-placeholder' => Yii::t('app', 'Custom Property...')))
      %td(style="width: 33%;")
        %center
          .control-group.input-append
            != $form->textField($event, 'Kemler', array('class'=>'span2'))
            .btn-group
              %button.btn.dropdown-toggle(type="button" data-toggle="dropdown")
                =t('Kemler-ONU')
                %span.caret
              %ul.dropdown-menu
                %li
                  %a(href="#" data-set-value="" data-set-target="#Event_Kemler")
                    =t('None')
                %li
                  %a(href="#" data-set-value="GENERIC" data-set-target="#Event_Kemler")
                    = t('Generic')
                %li.divider
                %li
                  %a#kemler-toggle(href="#")
                    = t('Search Kemler-ONU')
      
  #event-behaviors(style="width: 100%;")
    - if (Yii::app()->user->checkAccess('edit_event_behaviors'))
      %div
        %h5
        = Yii::t('app', 'Violations')
        -if(user()->checkAccess('event_behavior_create'))
          %a.icon-plus(href="#{url('EventBehavior/create', array('id_event'=>$event->ID))}")
        
        %ul.zebra.unstyled
          - foreach ($eventBehaviors as $index => $eventBehavior)
            %li.zebra-item
              - $this->renderPartial("_eventBehavior_old", array('eventBehavior' => $eventBehavior, 'event' => $event, 'form' => $form, 'index' => $index, 'suggestedCodes' => $suggestedCodes[$eventBehavior->behavior->tag]))
  - $this->endWidget()

  %footer.row
    .span12.gray-box
      .row
        .event-navigation.span3
          - $previousLink = Yii::app()->createUrl('event/edit', array('id' => $previousEvent->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly))
          - $nextLink = Yii::app()->createUrl('event/edit', array('id' => $nextEvent->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly))
  
          - if ($queue->isFirst($event))
            %a.btn.btn-large.disabled
              %i.icon-circle-arrow-left
          - else
            %a.btn.btn-large.cacheIgnore(href=$previousLink)
              %i.icon-circle-arrow-left

          - if($queue->isLast($event))
            %a.btn.btn-large.disabled
              %i.icon-circle-arrow-right
          - else
            %a.btn.btn-large.cacheIgnore(href=$nextLink)
              %i.icon-circle-arrow-right

        .event-buttons.span5.pull-right
          - if (!Yii::app()->user->checkAccess('edit_event_behaviors'))
            %button#suspend-btn.btn(type="button" data-confirm-text="#{Yii::t('app', 'Confirm')}"
              data-form-action=Yii::app()->createUrl('event/suspend', array('id' => $event->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly))
              data-target="#event-form")= Yii::t('app', 'Suspend')
          %button#save-btn.btn(type="button" data-confirm-text="#{Yii::t('app', 'Confirm')}"
            data-form-action=Yii::app()->createUrl('event/update', array('id' => $event->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly))
            data-target="#event-form")= Yii::t('app', 'Save & Next')
          -if(paramdeep('validation','showSaveAndReleaseButton'))
            %button#save-release-btn.btn(type="button" data-confirm-text="#{Yii::t('app', 'Confirm')}"
              data-form-action=Yii::app()->createUrl('event/updateRelease', array('id' => $event->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly))
              data-target="#event-form")= Yii::t('app', 'Save & Release')

  #overlay
    #modal-image

  #kemler-modal.modal.hide.fade(tabindex="-1")
  #whitelist-import-modal.modal.hide.fade(tabindex="-1")
    %p
      hallo!
-if(Yii::app()->params['photoEditingMode'] === 'obscure')
  #modal-alert-photo-preview.modal.hide.fade(style="top: 10%;width: 1000px;left: 30%;")
    .modal-header
      %button(type="button" class="close" data-dismiss="modal" aria-hidden="true")
        x
      %h3
        =Yii::t('app', 'Obscue and Selection System')
    .modal-body
      %script{:type => "text/javascript", :src  => "../../js/dragonImageObscure.js"}
      -$photosBWTotal = array()
      -for($i=0;$i<5;$i++)
        -if(!is_null($event->getCorrectMediaById(1000+$i)))
          -$photosBWTotal[] = $event->getCorrectMediaById(1000+$i)->url
      -$this->dragonImageObscure($photosBWTotal, "100%", "600px")
        
    .modal-footer
      %a.btn(href="#" data-dismiss="modal")
        =Yii::t('app', 'Close')
      %a#save-Obscure.btn.btn-primary(href="#" data-dismiss="modal")
        =Yii::t('app', 'Save & Close')

#missingPicOrCropDialog.modal.fade(tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true")
  .modal-dialog.modal-dialog-centered(role="document")
    .modal-content
      .modal-header
        %h5.modal-title
          Attenzione
      .modal-body#modalTitle
        Test
      .modal-footer
        %button.btn.btn-secondary(type="button" class="" data-dismiss="modal")
          OK