<?php if(!is_bool($canEdit)) { ?>
  <?php $canEdit = ServiceController::canEdit(); ?>
<?php } ?>
<?php if (Yii::app()->user->checkAccess('create_events_report') &&  ($service->areAllEventsValidatedAndNotSuspended() || !paramdeep('report','completeService')) && !$service->isRegistered()&& !paramdeep('report','byWorkPeriod') ) { ?>
  <?php $readyForReport = true  ; ?>
<?php } ?>
<?php if($canEdit) { ?>
  <?php if($service->status == Service::STATUS_READY_TO_EVALUATE) { ?>
    <?php if($service->isAssignedTo(user()->id)) { ?>
      <div class="btn-group">
        <?php if($readyForReport) { ?>
          <a class="btn btn-small btn-warning dropdown-toggle" data-toggle="dropdown" href="#">
            <?php echo htmlspecialchars(Yii::t("app", "Actions")     ,ENT_QUOTES,'UTF-8'); ?>
            <span class="caret"></span>
          </a>
        <?php } else { ?>
          <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
            <?php echo htmlspecialchars(Yii::t("app", "Actions")     ,ENT_QUOTES,'UTF-8'); ?>
            <span class="caret"></span>
          </a>
        <?php } ?>
        <ul class="dropdown-menu pull-right">
          <?php if (user()->checkAccess('check_events') && !user()->checkAccess('verify_all_events')) { ?>
            <li>
              <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'newEvents'))))), 'html5', 'UTF-8'); ?>>
                <?php echo htmlspecialchars(Yii::t("app", ("to be checked")),ENT_QUOTES,'UTF-8'); ?>
              </a>
            </li>
          <?php } ?>
          <?php if (user()->checkAccess('verify_all_events')) { ?>
            <?php if (user()->checkAccess('verify_suspended_events')) { ?>
              <li>
                <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'notClosedEvents'))))), 'html5', 'UTF-8'); ?>>
                  <?php echo htmlspecialchars(Yii::t("app", "all"),ENT_QUOTES,'UTF-8'); ?>
                </a>
              </li>
            <?php } else  { ?>
              <li>
                <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'notClosedNotPendingEvents'))))), 'html5', 'UTF-8'); ?>>
                  <?php echo htmlspecialchars(Yii::t("app", "all"),ENT_QUOTES,'UTF-8'); ?>
                </a>
              </li>
            <?php } ?>
          <?php } ?>
          <?php if (user()->checkAccess('verify_checked_events')) { ?>
            <?php if (user()->checkAccess('verify_suspended_events')) { ?>
              <li>
                <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'examinedNotClosedEvents'))))), 'html5', 'UTF-8'); ?>>
                  <?php echo htmlspecialchars(Yii::t("app", "checked"),ENT_QUOTES,'UTF-8'); ?>
                </a>
              </li>
            <?php } else { ?>
              <li>
                <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'examinedNotClosedNotPendingEvents'))))), 'html5', 'UTF-8'); ?>>
                  <?php echo htmlspecialchars(Yii::t("app", "checked"),ENT_QUOTES,'UTF-8'); ?>
                </a>
              </li>
            <?php } ?>
          <?php } ?>
          <?php if (user()->checkAccess('verify_suspended_events')) { ?>
            <li>
              <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('event/indexFilter', array('service' => $service->ID, 'scope' => 'pendingNotClosedEvents'))))), 'html5', 'UTF-8'); ?>>
                <?php echo htmlspecialchars(Yii::t("app", "suspended"),ENT_QUOTES,'UTF-8'); ?>
              </a>
            </li>
          <?php } ?>
          <?php if (user()->checkAccess('confirm_all_events')) { ?>
            <li>
              <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createUrl('service/confirmAllEvents', array('id' => $service->ID, 'url'=>$this->createUrl('service/index')))))), 'html5', 'UTF-8'); ?>>
                <?php echo htmlspecialchars(Yii::t("app", "confirm all"),ENT_QUOTES,'UTF-8'); ?>
              </a>
            </li>
          <?php } ?>
          <?php if (Yii::app()->user->checkAccess('create_events_report') && !paramdeep('report','byWorkPeriod'))       { ?>
            <?php if ( ($service->areAllEventsValidatedAndNotSuspended() || !paramdeep('report','completeService')) && !$service->isRegistered()) { ?>
              <?php if(paramdeep('report','showPreviewButton')) { ?>
                <li>
                  <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (Yii::app()->createAbsoluteUrl('report/previewByService', array('serviceID' => $service->ID))))), 'html5', 'UTF-8'); ?>>
                    <?php echo htmlspecialchars(t("Report"),ENT_QUOTES,'UTF-8'); ?>
                  </a>
                </li>
              <?php } ?>
            <?php } ?>
          <?php } ?>
        </ul>
      </div>
    <?php } ?>
  <?php } else if($service->status == Service::STATUS_TERMINATION_CONFIRMED) { ?>
    <?php if (user()->checkAccess('can_set_service_ready_to_evaluate')) { ?>
      <button <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('to-evaluate' . ' ' . 'btn' . ' ' . 'btn-small')), array('data-service-id', ($service->ID)), array('data-confirm-text', (Yii::t('app', 'Confirm?')))), 'html5', 'UTF-8'); ?>>
        <?php echo htmlspecialchars(Yii::t("app", "Evaluate"),ENT_QUOTES,'UTF-8'); ?>
      </button>
    <?php } ?>
  <?php } ?>
<?php } ?>
