- if(!is_bool($canEdit))
  - $canEdit = $this->canEdit()
  
- $eventsVoidCount = user()->checkAccess('can_see_void_events') ? $service->eventsVoidCount : 0

%tr(id="service-#{$service->ID}"  class=$service->isManageable()?"":"service-not-manageable" data-service-id="#{$service->ID}")
  %td
    %a.tooltipbox
      = "$service->ID"
      %span
        =$service->gateGroup->name
  %td= DateHelper::formatMedium($service->start_time)
  %td
    - if($service->isTerminated())
      = DateHelper::formatMedium($service->termination_time)
    - else
      = DateHelper::formatMedium($service->expected_end_time)
  %td= $service->eventsCount
  %td= $service->eventsExaminedCount
  %td
    - if (user()->checkAccess('verify_all_events') || user()->checkAccess('verify_all_events_view'))
      %span(title="#{Yii::t("app", "Total Validated")}")
        = $service->eventsValidatedCount
      %span(title="#{Yii::t("app", "Approved")}")
        = "["
        = $service->eventsApprovedCount
        = " / "
      %span(title="#{Yii::t("app", "Invalid")}")
        =$service->eventsInvalidCount
        = " / "
      %span(title="#{Yii::t("app", "Pending")}")
        =$service->eventsPendingCount
        = "]"
    - else
      = '-'

  %td
    - if (user()->checkAccess('verify_all_events') || user()->checkAccess('verify_all_events_view'))
      %span(title="#{Yii::t("app", "Reported")}")
        = $service->eventsQueuedForExportCount
        = " / "
      %span(title="#{Yii::t("app", "Queued for report")}")
        = $service->eventsApprovedCount
    - else
      = '-'  
  %td
    - if (user()->checkAccess('verify_all_events') || user()->checkAccess('verify_all_events_view'))
      %span(title="#{Yii::t("app", "Exported")}")
        = $service->eventsExportedCount
        = " / "
      %span(title="#{Yii::t("app", "Queued for export")}")
        = $service->eventsQueuedForExportCount
      - if($service->report_user > 0)
        %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->registerOperator->fullName}")
          %i.icon-user
    - else
      = '-'  
  %td
    - if($service->status == Service::STATUS_READY_TO_EVALUATE)
      - if($canEdit)
        - if (isset($service->assignedOperator))
          - if($service->isAssignedTo(user()->id))
            - if(paramdeep('report','byWorkPeriod') || ($service->id_user_validating <= 0))          
              %button.release-charge.btn.btn-small(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
                = Yii::t("app", "Release")
            - else
              - if(!paramdeep('report','byWorkPeriod') && ($service->id_user_validating > 0) && user()->checkAccess('reset-services-master'))  
                %button.reset-validation.btn.btn-small.btn-warning.pull-right(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
                  %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->validatingOperator->fullName}")
                    = Yii::t("app", "validating")    
                    %i.icon-user
                  = Yii::t("app", "Reset")
              - else
                %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->assignedOperator->fullName}")
                  = Yii::t("app", "me")
                  %i.icon-user
          - else
            - if(!paramdeep('report','byWorkPeriod') && ($service->id_user_validating > 0) && user()->checkAccess('reset-services-master'))  
              %button.reset-validation.btn.btn-small.btn-warning.pull-right(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
                %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->validatingOperator->fullName}")
                  = Yii::t("app", "validating")    
                  %i.icon-user
                = Yii::t("app", "Reset")          
            - else if(user()->checkAccess('release-services-master'))  
              %button.release-charge.btn.btn-small.btn-warning.pull-right(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
                %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->assignedOperator->fullName}")
                  = Yii::t("app", "Taken")    
                  %i.icon-user
                = Yii::t("app", "Release")
            - else   
              %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->assignedOperator->fullName}")
                - if($service->assignedOperator == user()->id)
                  = Yii::t("app", "By me")
                - else
                  = Yii::t("app", "Taken")  
                %i.icon-user
        - else
          - if(paramdeep('report','byWorkPeriod') || ($service->id_user_validating <= 0)  ||  $service->isValidatingBy(user()->id))
            %button.take-charge.btn.btn-small(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
              = Yii::t("app", "Take Charge")
          - else
            - if(!paramdeep('report','byWorkPeriod') && ($service->id_user_validating > 0) && user()->checkAccess('reset-services-master'))  
              %button.reset-validation.btn.btn-small.btn-warning.pull-right(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
                %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->validatingOperator->fullName}")
                  = Yii::t("app", "validation in progress")    
                  %i.icon-user
                = Yii::t("app", "Reset")
            - else  
              %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->validatingOperator->fullName}")
                = Yii::t("app", "validating")
                %i.icon-user 
      - else
        - if (isset($service->assignedOperator))
          %span.tooltip-placemark.assigned-operator(data-toggle="tooltip" title="#{$service->assignedOperator->fullName}")
            = Yii::t("app", "Taken")
            %i.icon-user
        
  %td
    -$this->renderPartial('_serviceButtons', get_defined_vars())