<?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("Here, you can add the 3rd party services from other social networking websites like Facebook Linkedin, Youtube, etc which you use on your website for login, uploading video, sharing on them, importing photos, or any other purpose. You can also enable / disable and delete the services.<br>Users on your website will see an “Opt Out” option for the added and enabled service. They will be redirected to the configured link to adjust the settings of another 3rd party services on their respective sites."); ?></p>
<?php $gdpr_dpo = Zend_Registry::isRegistered('gdpr_dpo') ? Zend_Registry::get('gdpr_dpo') : null; ?>

<p>
  <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'add-service'), $this->translate("Create New Service"), array('class' => 'smoothbox admin_link_btn')); ?>
</p>
<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 $counter = $this->paginator->getTotalItemCount(); ?>
<?php if ($gdpr_dpo && 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'>
      <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("URL") ?></a></th>
          <th class="admin_table_centered"><a href="javascript:void(0);"><?php echo $this->translate("Status") ?></a></th>
          <th><a href="javascript:void(0);"><?php echo $this->translate("Creation 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="<?php echo $item->url; ?>" target="_blank"><?php echo $item->url; ?></a></td>
            <td class="admin_table_centered">
              <?php if ($item->enabled == 1): ?>
                <?php echo $this->htmlLink(array('route' => 'default', 'module' => 'gdpr', 'controller' => 'admin-settings', 'action' => 'service-approved', 'id' => $item->getIdentity()), $this->htmlImage($this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/check.png', '', array('title' => $this->translate('Disable')))) ?>
              <?php else: ?>
                <?php echo $this->htmlLink(array('route' => 'default', 'module' => 'gdpr', 'controller' => 'admin-settings', 'action' => 'service-approved', 'id' => $item->getIdentity()), $this->htmlImage($this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/uncheck.png', '', array('title' => $this->translate('Enable')))) ?>
              <?php endif; ?>

            </td>
            <td><?php echo $item->creation_date; ?></td>
            <td>
              <?php
              echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'add-service', 'id' => $item->getIdentity()), $this->translate("Edit"), array('class' => 'smoothbox'));
              ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'gdpr', 'controller' => 'settings', 'action' => 'delete-service', '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 no service created by you yet.") ?>
    </span>
  </div>
<?php endif; ?>
