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

-if(Yii::app()->params['photoEditingMode']=="all")
  -$secondStepName = t('Transits all')
-if(Yii::app()->params['photoEditingMode']=="none")
  -$secondStepName = t('Transits')
-if(Yii::app()->params['photoEditingMode']=="select")
  -$secondStepName = t('Transits select')
-if(Yii::app()->params['photoEditingMode']=="facecrop")
  -$secondStepName = t('Images Selection Crop')
-if(Yii::app()->params['photoEditingMode']=="obscure")
  -$secondStepName = t('Transits obscure')

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

- $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.span11
    .span5
      %h5(class="progress-title")
        Completed Task
        = ($queue->getEventIndex($event) + 1)
        = Yii::t('app', 'of')
        = ($queue->getEventsCount())
      %div
        .progress
          .bar.bar-success(style="width:#{(intval((($queue->getEventIndex($event)+1)/($queue->getEventsCount()))*100))}%;")
            .progress-value
    .span3(style="text-align:center;")
      %h4(style="margin-top: 0px;margin-bottom: 19px;")
        = Yii::t('app', 'Event #')
        = $event->ID
        %small
          - if (isset($event->service))
            = Yii::t('app', 'Task')
            = $event->service->ID
      -if ($event->isExamined())
        %span.label= Yii::t('app', 'Examined')
      -if ($event->isValidated())
        %span.label= Yii::t('app', 'Validated')
    .span2(style="margin-top: 33px;")
      -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' => Yii::app()->createUrl('event/update', array('id' => $event->ID, 'service' => $service, 'scope' => $scope, 'toValidateOnly' => $toValidateOnly)),            |
            '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(isset(Yii::app()->params['photoEditingMode']) && Yii::app()->params['photoEditingMode'] !== "none")
    %input(type="hidden" id="croppedImagesData" name="croppedImagesData" value="0")

  .container
    - if(Yii::app()->user->checkAccess('media_view_photo') || Yii::app()->user->checkAccess('media_view_video'))
      -$mainMediaCount = 3
      -$mainMediaColumnSize = 33

      .row
        .span12
          .tabbable
            %ul#step.nav.nav-tabs
              %li.active
                %a(href="#plate" data-toggle="tab")
                  =t('Event Check')
              %li.hide
                %a(href="#transit" data-toggle="tab")
                  =$secondStepName
              %li.hide
                %a(href="#video" data-toggle="tab")
                  #{$thirdColumnName}
              %li.hide
                %a(href="#final_check" data-toggle="tab")
                  =t('Final_check')
            .tab-content
              -if(user()->checkAccess('media_view_photo'))
                -$photoBW = $event->PreviewPhoto
                -if(Yii::app()->params['deviceType']=="section")
                  -$photoBW2 = $event->getCorrectMediaById(1001)
                -$photoCOL= $event->PreviewColorPhoto
                -$extraPhotos = $event->PreviewExtraCameraPhoto;
                #plate.tab-pane.active
                  .span6(style="margin-left:0px;")
                    -if($photoBW!=null)
                      #photoBW1_frame.alert.alert-error(style="margin-bottom:0px;width:84.5%;position:relative;")
                        =t('Start Section Vehicle Image')
                        -$plateRect = $photoBW->getPlateRectangle()
                        -if($plateRect!=null && $plateRect->width>0)
                          -$point = $plateRect->center
                          -$scala = $photoBW->width/$plateRect->width
                          -$scala /= 1.75
                          -$this->dragonImageSingle($photoBW->UrlEnhanced, "500px", $DIMENSIONE_IMMAGINI."px", array(), array("style" => "border: 2px solid #000;border-radius: 5px;margin-top: 10px;"),$point->X, $point->Y)
                        -else
                          -$this->renderHtml("<div class=\"info\" ><img src=\"$photoBW->UrlEnhanced\" style=\"height: {$DIMENSIONE_IMMAGINI}px;\" alt=\"\"></div>")
                    -if($photoBW2!=null)
                      #photoBW2_frame.alert.alert-error(style="margin-bottom:0px;width:84.5%;margin-top:10px;position:relative;")
                        =t('End Section Vehicle Image')
                        -$plateRect = $photoBW2->getPlateRectangle()
                        -if($plateRect!=null && $plateRect->width>0)
                          -$point = $plateRect->center
                          -$scala = $photoBW2->width/$plateRect->width
                          -$scala /= 1.75
                          -$this->dragonImageSingle($photoBW2->UrlEnhanced, "500px", $DIMENSIONE_IMMAGINI."px", array(), array("style" => "border: 2px solid #000;border-radius: 5px;margin-top: 10px;"),$point->X, $point->Y)
                        -else
                          -$this->renderHtml("<div class=\"info\" ><img src=\"$photoBW->UrlEnhanced\" style=\"height: {$DIMENSIONE_IMMAGINI}px;\" alt=\"\"></div>")
                  .span6(style="margin-left:0px;margin-left:-30px;")
                    -if(($photoBW!=null) && ($photoBW2!=null))
                      %svg(id="Checker_frame" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 614 515" style="overflow:visible")
                        %style(type="text/css")
                          =".shape-error{fill:#f2dede;}"
                          =".shape-success{fill:#dff0d8;}"
                          =".stroke-error{stroke:#eed3d7;}"
                          =".stroke-success{stroke:#d6e9c6;}"
                          =".txt-error{fill:#b94a48;}"
                          =".txt-success{fill:#468847;}"
                        %path(class="shape-error" style="stroke-miterlimit:10;stroke-width:0.5px" d="M71,437.3l1-332.1a5,5,0,0,1,5-5H609a5,5,0,0,0,5-5V5.3a5,5,0,0,0-5-5H49a5,5,0,0,0-5,5L43.5,127a5,5,0,0,1-5,5H23v-8.5l-23,23,23,23V161H38.5a5,5,0,0,1,5,5V465.8a5,5,0,0,1-5,5H23v-8.5l-23,23,23,23v-8.5H66a5,5,0,0,0,5-5Z")
                        %g(id="btn_plate_check")
                          %foreignobject(class="node" x="92" y="17" width="500" height="63")
                            %div
                            =t('Please, check if vehicle and license plate match over the section')
                            %div(style="margin-top:10px;text-align:center;")
                              %a.btn.btn-danger(href="#" onclick="DoubleCheckPlate(false,false);")
                                %span.icon-remove
                                No
                              %a.btn.btn-success(href="#" onclick="DoubleCheckPlate(true,false);")
                                %span.icon-ok
                                =t('Match')
                        %g
                          %foreignobject(class="node" x="92" y="120" width="505" height="380" style="border: 3px solid #a5a5a554;")
                            .plate-info-container(style="float:right;margin-right:40px;display:none;margin-top: 15px;")
                              -if($isWhitelist)
                                != $form->textFieldRow($event, 'Plate', array('class' => "touppercase {$platesClass} platefield plate-white-list {$ocrQualityClassHTML} span2", 'id'=>'Plate', 'data-title' => Yii::t('app', 'Accuracy: ') . $ocrQualityRate))
                              -else
                                != $form->textFieldRow($event, 'Plate', array('class' => "touppercase {$platesClass} platefield {$ocrQualityClassHTML} span2",'data-title' => Yii::t('app', 'Accuracy: ') . $ocrQualityRate))
                              -if(paramdeep('validation','plate','suggestions'))
                                -$this->addPlateSuggestionsJS($event)
                              -if($isWhitelist)
                                != $form->dropDownListRow($event, 'custom_nationality', array_merge(array('' => ''), CountryList::localized()), array('class' => 'chzn-select span2','data-placeholder' => Yii::t('app', 'Country...')))
                              -else
                                != $form->dropDownListRow($event, 'custom_nationality', array_merge(array('' => ''), CountryList::localized()), array('class' => 'chzn-select span2', 'data-placeholder' => Yii::t('app', 'Country...')))
                              -if($isWhitelist)
                                #whitelist-smart-tips
                              != $form->dropDownListRow($event, 'custom_vehicle_type', array_merge(array('' => ''), VehicleTypes::localizedForValidation()), array('class' => 'chzn-select span2','data-placeholder' => Yii::t('app', 'Class...')))
                              != $form->dropDownListRow($event, 'custom_plate_type',  array_merge(array('' => ''), CHtml::listData(CustomPlateType::model()->findAll(), 'type', 'label')), array('class' => 'chzn-select span2','data-placeholder' => Yii::t('app', 'Plate Type...')))
                              != $form->dropDownListRow($event, 'custom_property_type', array_merge(array('' => ''), CHtml::listData(CustomPropertyType::model()->findAll(), 'type', 'label')), array('class' => 'chzn-select span2','data-placeholder' => Yii::t('app', 'Custom Property...')))
                              .control-group.input-append(style="float:right;")
                                != $form->textField($event, 'Kemler', array('class'=>''))
                                .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')
                        %g
                          %foreignobject(class="node" x="92" y="437" width="500" height="28")
                            .plate-info-container(style="text-align:center;width:500px;display:none;margin-top: 15px;")
                              -if(Yii::app()->params['photoEditingMode']=="facecrop")
                                %a.btn.btn-success(href="#" onclick="DoubleCheckPlate(true,true)")
                                  %span.icon-ok
                                    =t('Done')
                              -else
                                %a.btn.btn-success(href="#" onclick="displayNextStep('final_check',true)")
                                  %span.icon-ok
                                    =t('Done')
                      #sp_details.alert-info(style="float: right;margin-right: 16px;border: 1px solid #bce8f1;padding-left: 25px;padding-right: 25px;padding-top: 10px;padding-bottom: 10px;")
                        
                    -else
                      ToDO
                  
                #transit.tab-pane
                  -if(Yii::app()->params['photoEditingMode']=="all")
                    To Do Select photoEditingMode All
                  -if(Yii::app()->params['photoEditingMode']=="none")
                    To Do Select photoEditingMode None
                  -if(Yii::app()->params['photoEditingMode']=="select")
                    To Do Select photoEditingMode Select
                  -if(Yii::app()->params['photoEditingMode']=="facecrop")  
                    -$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)
                    .span8
                      -$this->dragonImage($photosBWCOL, "99.5%", $DIMENSIONE_IMMAGINI."px", array(), array("style" => "border: 2px solid #000;border-radius: 5px;margin-bottom: 15px;"))
                    #thumb-selected.span2
                      %ul(class="thumbnails")
                    .span10(style="text-align: right;")
                      %a.btn.btn-danger(href="#" onclick="DoubleCheckPlate(false,false)" style="width: 200px;")
                        %span.icon-remove
                          Not All Faces Are Selectable
                  -if(Yii::app()->params['photoEditingMode']=="obscure")
                    To Do Select photoEditingMode Obscure

                #video.tab-pane
                  -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)
                      %div.span4
                        -$this->renderVideo($video->url, null, $DIMENSIONE_IMMAGINI)
                #final_check.tab-pane
                  - if (Yii::app()->user->checkAccess('edit_event_behaviors'))
                    %h5(style="padding-left:10px;padding-top:10px;")
                      = Yii::t('app', 'Violations')
                      -if(user()->checkAccess('event_behavior_create'))
                        %a.icon-plus(href="#{url('EventBehavior/create', array('id_event'=>$event->ID))}")
                    #sidebar2_violation.alert-error.error(style="height: 420px;border-radius:5px;")
                      %ul.zebra.unstyled
                        - foreach ($eventBehaviors as $index => $eventBehavior)
                          %li.zebra-item
                            - $this->renderPartial("_eventBehavior", array('eventBehavior' => $eventBehavior, 'event' => $event, 'form' => $form, 'index' => $index, 'suggestedCodes' => $suggestedCodes[$eventBehavior->behavior->tag]))
                        - if($hasSpeedBehaviour)
                          %div.span4(style="width: #{$mainMediaColumnSize}px;")
                            -$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\"/>")
  - $this->endWidget()
  .span11.alert-block.alert
    .span4
      =t('Date Time')
      %span.text-info
        =DateHelper::formatShort($event->StartTime)
    .span4
      =t('Gate')
      %span.text-info
        =$event->GateDescription
    .span2
      =t('Device ID')
      %span.text-info
        =$event->gate->Gate
  %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.hide(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.hide(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!

#modal-alert-photo-preview


#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
#youAreDeletingRoi(title="Delete Crop?" style="display:none;")
  %p
    This operation cannot be undone. Would you like to proceed?