<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php include APPLICATION_PATH . '/application/modules/Gdpr/views/scripts/_adminHeader.tpl'; ?>

<p><?php echo $this->translate('This page lists all the subject access requests made by the users of your website concerning their personal data you possess. You can take action on their requests from below.'); ?></p>

<div class='admin_search '>
  <?php echo $this->formFilter->render($this) ?>
</div>

<script type="text/javascript">

  function selectAll(obj) {
    scriptJquery('.checkbox').each(function(){
      scriptJquery(this).prop("checked",scriptJquery(obj).prop("checked"))
    });
  }

  scriptJquery(document).ready(function(){
    scriptJquery("input[name='delete']").on('click', function( event ) {
      event.preventDefault();
      var selectedItems = scriptJquery("input[name='selectedItems[]']");
      var name = scriptJquery(this).attr('name');
      if (selectedItems.filter(':checked').length == 0) {
        alert('<?php echo $this->string()->escapeJavascript($this->translate("Please select items for any mass action.")) ?>');
      } else {
        if (confirm('<?php echo $this->string()->escapeJavascript($this->translate("Are you sure you want to perform this action on selected entries?")) ?>')) {
          scriptJquery('#multimodify_form').append("<input type='hidden' value='"+name+"' name='"+name+"'>");
          scriptJquery('#multimodify_form').trigger("submit");
        }
      }
    });
  });
</script>
<?php if (is_countable($this->paginator) && engine_count($this->paginator)): ?>
  <form id='multimodify_form' method="post" action="<?php echo $this->url(); ?>">
    <div class="admin_manage_action d-flex flex-wrap">
      <div class="_count">
        <?php echo $this->translate(array('%s entry found.', '%s entries found.', $this->paginator->getTotalItemCount()), $this->locale()->toNumber($this->paginator->getTotalItemCount())) ?>
      </div>
      <div class="admin_manage_action_option">
        <span><?php echo $this->translate('With Selected:'); ?></span>
        <input type='submit' value="Delete" name="delete" class="btn btn-danger">
      </div>
      <div class="admin_manage_action_right d-flex flex-wrap align-items-center">
        <?php echo $this->paginationControl($this->paginator, null, null, array('pageAsQuery' => true)); ?>
      </div>
    </div>
    <table class='admin_table admin_responsive_table'>
      <thead>
        <tr>
          <th class='admin_table_short'><input onclick="selectAll(this)" type='checkbox' class='checkbox'></th>
          <th class='admin_table_short'><a href="javascript:void(0);"><?php echo $this->translate("ID") ?></a></th>
          <th><a href="javascript:void(0);"><?php echo $this->translate("Name") ?></a></th>
          <th><a href="javascript:void(0);"><?php echo $this->translate("Email") ?></a></th>
          <th><a href="javascript:void(0);"><?php echo $this->translate("Date") ?></a></th>
          <th><?php echo $this->translate("Options") ?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($this->paginator as $item): ?>
          <tr>
            <td><input name='selectedItems[]' value='<?php echo $item->getIdentity();?>' type='checkbox' class='checkbox'></td>
            <td><?php echo $item->getIdentity() ?></td>
            <td><?php echo $item->name; ?></td>
            <td><a href="mailto:<?php echo $item->email; ?>" target="_blank"><?php echo $item->email; ?></a></td>
            <td><?php echo $item->creation_date; ?></td>
            <td>
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'view', 'id' => $item->getIdentity()), $this->translate("View"), array('class' => 'ajaxsmoothbox')) ?>
              |
              <?php
              if (!$item->replied) {
                echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'reply', 'id' => $item->getIdentity()), $this->translate("Reply"), array('class' => 'smoothbox'));
              } else {
                echo $this->htmlLink('javascript:;', $this->translate("Replied"), array('class' => ''));
              }
              ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'note', 'id' => $item->getIdentity()), $this->translate("Note"), array('class' => 'smoothbox')); ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'delete', 'id' => $item->getIdentity()), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
            </td>
          </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
  </form>
<?php else: ?>
  <div class="tip">
    <span>
      <?php echo $this->translate("There are not any subject access requests made by your members yet.") ?>
    </span>
  </div>
<?php endif; ?>
