<?php $u = $workPeriod->user; ?>
<?php $itsMe = $u->id == user()->id; ?>
<tr>
  <td>
    <?php if(!$workPeriod->closed) { ?>
      <span <?php echo MtHaml\Runtime::renderAttributes(array(array('title', (t('Current active session')))), 'html5', 'UTF-8'); ?>><?php echo htmlspecialchars('*',ENT_QUOTES,'UTF-8'); ?></span>
    <?php } ?>
  </td>
  <td>
    <?php if (Yii::app()->user->checkAccess('edit_event_behaviors'))             { ?>
      <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', '#'), array('data-behavior', 'AjaxModal'), array('data-ajax-modal-target', '#modal-report-detail'), array('data-ajax-modal-url', (Yii::app()->createAbsoluteUrl('report/viewSummary', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
        <i class="icon-zoom-in"></i>
        <?php echo htmlspecialchars($workPeriod->id,ENT_QUOTES,'UTF-8'); ?>
      </a>
    <?php } else             { ?>
      <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', '#'), array('data-behavior', 'AjaxModal'), array('data-ajax-modal-target', '#modal-report-detail'), array('data-ajax-modal-url', (Yii::app()->createAbsoluteUrl('paySlip/viewSummary', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
        <i class="icon-zoom-in"></i>
        <?php echo htmlspecialchars($workPeriod->id,ENT_QUOTES,'UTF-8'); ?>
      </a>
    <?php } ?>
  </td>
  <?php if($all) { ?>
    <td>
      <?php if(user()->checkAccess('user_view')) { ?>
        <a <?php echo MtHaml\Runtime::renderAttributes(array(array('href', (url('user/view',array('id'=>$u->id)))), array('target', '_blank')), 'html5', 'UTF-8'); ?>><?php echo htmlspecialchars($u->getFullName(),ENT_QUOTES,'UTF-8'); ?></a>
      <?php } else { ?>
        <?php echo htmlspecialchars($u->getFullName(),ENT_QUOTES,'UTF-8'); ?>
      <?php } ?>
    </td>
  <?php } ?>
  <td><?php echo htmlspecialchars(new DateTimeEx($workPeriod->login_at),ENT_QUOTES,'UTF-8'); ?></td>
  <td><?php echo htmlspecialchars($workPeriod->last_action_at == null ? "-" : new DateTimeEx($workPeriod->last_action_at),ENT_QUOTES,'UTF-8'); ?></td>
  <td><?php echo htmlspecialchars($workPeriod->duration->format(t("%h hour %i min")),ENT_QUOTES,'UTF-8'); ?></td>
  <?php if(paramdeep('payslip','showButton')) { ?>
    <td>
      <?php if ($workPeriod->eventsManaged > 0 && $itsMe) { ?>
        <a <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small')), array('href', '#'), array('data-behavior', 'AjaxModal'), array('data-ajax-modal-target', '#modal-payslip-confirm'), array('data-ajax-modal-url', (Yii::app()->createAbsoluteUrl('paySlip/confirm', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
          <?php echo htmlspecialchars(t("Generate"),ENT_QUOTES,'UTF-8'); ?>
        </a>
      <?php } else    { ?>
        <div <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small' . ' ' . 'disable')), array('disabled', ('disabled'))), 'html5', 'UTF-8'); ?>>
          <?php echo htmlspecialchars(t("Generate"),ENT_QUOTES,'UTF-8'); ?>
        </div>
      <?php } ?>
    </td>
  <?php } ?>
  <?php if (Yii::app()->user->checkAccess('create_events_report') && paramdeep('report','byWorkPeriod')) { ?>
    <td>
      <?php if(paramdeep('report','showPreviewButton')) { ?>
        <?php if ( ($workPeriod->eventsApproved > 0 || $workPeriod->eventsInvalid > 0) ) { ?>
          <a <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small')), array('href', (Yii::app()->createAbsoluteUrl('report/preview', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
            <?php echo htmlspecialchars(t("Preview"),ENT_QUOTES,'UTF-8'); ?>
          </a>
        <?php } else { ?>
          <div <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small' . ' ' . 'disable')), array('disabled', ('disabled'))), 'html5', 'UTF-8'); ?>>
            <?php echo htmlspecialchars(t("Preview"),ENT_QUOTES,'UTF-8'); ?>
          </div>
        <?php } ?>
      <?php } ?>
      <?php if ($workPeriod->eventsReadyToTagCount > 0 && ($workPeriod->generatedReportsCount == 0) && ($workPeriod->generatedReportsCount == 0) && $itsMe) { ?>
        <a <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small' . ' ' . 'btn-warning')), array('data-behavior', 'AjaxModal'), array('data-ajax-modal-target', '#modal-report-confirm'), array('data-ajax-modal-url', (Yii::app()->createAbsoluteUrl('report/confirm', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
          <?php echo htmlspecialchars(t("Generate"),ENT_QUOTES,'UTF-8'); ?>
        </a>
      <?php } else if ( ($workPeriod->eventsApproved > 0 || $workPeriod->eventsInvalid > 0) && ($workPeriod->generatedReportsCount == 0) && $itsMe) { ?>
        <a <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small')), array('href', (Yii::app()->createAbsoluteUrl('report/create', array('workPeriodID' => $workPeriod->id))))), 'html5', 'UTF-8'); ?>>
          <?php echo htmlspecialchars(t("Generate"),ENT_QUOTES,'UTF-8'); ?>
        </a>
      <?php } else { ?>
        <div <?php echo MtHaml\Runtime::renderAttributes(array(array('class', ('btn' . ' ' . 'btn-small' . ' ' . 'disable')), array('disabled', ('disabled'))), 'html5', 'UTF-8'); ?>>
          <?php echo htmlspecialchars(t("Generate"),ENT_QUOTES,'UTF-8'); ?>
        </div>
      <?php } ?>
    </td>
  <?php } ?>
</tr>
