- if(!is_bool($canEdit))
  - $canEdit = ServiceController::canEdit()
  
/*Modificato argomento if a seguito di rilevazione campo report islanda mancante-> modificato con nuova tabella delle verità che aggiunge il caso : Tutti gli eventi validi e parametro completeService(true) e confermati > 0 e task NON esportato/registrato, 03/01/2019 NGasbarro */ 
- /*if (Yii::app()->user->checkAccess('create_events_report') &&  ($service->areAllEventsValidatedAndNotSuspended() || (!paramdeep('report','completeService') && $service->toBeConfirmed > 0 )) && (!$service->isRegistered() && !paramdeep('report','completeService')) )*/
  - /*$readyForReport = true*/

- if (Yii::app()->user->checkAccess('create_events_report') &&  (!$service->isRegistered() && ($service->areAllEventsValidatedAndNotSuspended()&& ($service->toBeConfirmed > 0) || ($service->toBeConfirmed > 0) && (!paramdeep('report','completeService')) || $service->areAllEventsValidatedAndNotSuspended() && (!paramdeep('report','completeService')) )))
  - $readyForReport = true

-if($canEdit)
  - if($service->status == Service::STATUS_READY_TO_EVALUATE)
    - if($service->isAssignedTo(user()->id))
      .btn-group
        -if($readyForReport)
          %a.btn.btn-small.btn-primary.dropdown-toggle(data-toggle="dropdown" href="#")
            = Yii::t("app", "Actions")     
            %span.caret
        -else
          %a.btn.btn-small.dropdown-toggle(data-toggle="dropdown" href="#")
            = Yii::t("app", "Actions")     
            %span.caret     
        %ul.dropdown-menu.pull-right
          - if (user()->checkAccess('check_events') && !user()->checkAccess('verify_all_events'))
            %li
              %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'newEvents'))}")
                = Yii::t("app", ("to be checked"))
          - if (user()->checkAccess('verify_all_events'))
            - if (user()->checkAccess('verify_suspended_events'))
              %li
                %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'notClosedEvents', 'toValidateOnly' => true))}")
                  = Yii::t("app", "All")
            - else 
              %li
                %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'notClosedNotPendingEvents'))}")
                  = Yii::t("app", "All")
                  
          - if (user()->checkAccess('verify_checked_events'))
            - if (user()->checkAccess('verify_suspended_events'))
              %li 
                %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'examinedNotClosedEvents'))}")
                  = Yii::t("app", "Checked")
            - else
              %li 
                %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'examinedNotClosedNotPendingEvents'))}")
                  = Yii::t("app", "Checked")
                
          - if (user()->checkAccess('verify_suspended_events'))
            %li
              %a(href="#{Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'pendingNotClosedEvents'))}")
                = Yii::t("app", "Suspended")
          - if (user()->checkAccess('confirm_all_events'))
            %li
              %a(href="#{Yii::app()->createUrl('service/confirmAllEvents', array('id' => $service->ID, 'url'=>$this->createUrl('service/index')))}")
                = Yii::t("app", "Confirm all")
          - if (Yii::app()->user->checkAccess('create_events_report') && !paramdeep('report','byWorkPeriod') && $readyForReport )      
            - if (($service->areAllEventsValidatedAndNotSuspended() || (!$service->isRegistered() && !paramdeep('report','completeService'))))
              -if(paramdeep('report','showPreviewButton'))
                %li
                  -if(paramdeep('report','showReportPreviewPage'))
                    %a(href="#{Yii::app()->createAbsoluteUrl('report/previewByService', array('serviceID' => $service->ID))}")
                      =t("Report")
                  -else
                    %a(href="#{Yii::app()->createAbsoluteUrl('report/createByService', array('serviceID' => $service->ID))}")
                      =t("Report")

                
              
  - else if($service->status == Service::STATUS_TERMINATION_CONFIRMED)
    - if (user()->checkAccess('can_set_service_ready_to_evaluate'))
      %button.to-evaluate.btn.btn-small(data-service-id="#{$service->ID}" data-confirm-text="#{Yii::t('app', 'Confirm?')}")
        = Yii::t("app", "Evaluate")
