<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php echo $this->partial('_admin_breadcrumb.tpl', 'core', array('parentMenu' => "core_admin_main_manage", 'childMenuItemName' => 'core_admin_main_managedashboards')); ?>

<script type="text/javascript">
  function multiDelete() {
    return confirm("<?php echo $this->translate("Are you sure you want to delete the selected dashboards ?") ?>");
  }
  function selectAll() {
    var i;
    var multidelete_form = document.getElementById('multidelete_form');
    var inputs = multidelete_form.elements;
    for (i = 1; i < inputs.length - 1; i++) {
      inputs[i].checked = inputs[0].checked;
    }
  }
</script>
<h2 class="page_heading"><?php echo $this->translate("Manage Dashboard") ?></h2>
<p>
  <?php echo $this->translate("This page lists all the Dashboard created by you. Here, you can also add and manage any number of dashboard  on your website. You can place these dashboards anywhere on your website including the Landing Page and any other widgetized page of your choice.") ?>
</p>
<div class="core_search_reasult mb-2">
  <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'create'), $this->translate("Create New Dashboard "), array('class' => 'smoothbox admin_link_btn')) ?>
</div>
<?php if (is_countable($this->paginator) && engine_count($this->paginator)): ?>
  <div class="core_search_reasult mb-3">
    <?php echo $this->translate(array('%s dashboard found.', '%s dashboards found', $this->paginator->getTotalItemCount()), $this->locale()->toNumber($this->paginator->getTotalItemCount())) ?>
  </div>
  <form id='multidelete_form' method="post" action="<?php echo $this->url(); ?>" onSubmit="return multiDelete()">
    <table class='admin_table'>
      <thead>
        <tr>
          <th class='admin_table_short'><input onclick='selectAll();' type='checkbox' class='checkbox' /></th>
          <th class='admin_table_short'><?php echo $this->translate("ID"); ?></th>
          <th><?php echo $this->translate("Title") ?></th>
          <th><?php echo $this->translate("Creation Date") ?></th>
          <th class="admin_table_centered"><?php echo $this->translate("Status"); ?></th>
          <th><?php echo $this->translate("Options") ?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($this->paginator as $item): ?>
          <tr>
            <td><input type='checkbox' class='checkbox' name='delete_<?php echo $item->dashboard_id; ?>'
                value='<?php echo $item->dashboard_id ?>' /></td>
            <td><?php echo $item->dashboard_id ?></td>
            <td><?php echo $item->dashboard_name; ?></td>
            <td><?php echo $item->creation_date; ?></td>
            <td class="admin_table_centered">
              <?php echo ($item->enabled ? $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'enabled', 'id' => $item->dashboard_id), $this->htmlImage($this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/check.png', '', array('title' => $this->translate('Disable'))), array()) : $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'enabled', 'id' => $item->dashboard_id), $this->htmlImage('application/modules/Core/externals/images/admin/uncheck.png', '', array('title' => $this->translate('Enable'))))) ?>
            </td>
            <td class="admin_table_options nowrap">
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'dashboard-links', 'id' => $item->dashboard_id), $this->translate("Manage Links"), array()) ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'create', 'id' => $item->dashboard_id), $this->translate("Edit"), array('class' => 'smoothbox')) ?>
              |
              <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'delete-dashboard', 'id' => $item->dashboard_id), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
            </td>
          </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
    <div class='buttons'>
      <button type='submit'><?php echo $this->translate("Delete Selected") ?></button>
    </div>
  </form>
  <div>
    <?php echo $this->paginationControl($this->paginator); ?>
  </div>
<?php else: ?>
  <div class="tip">
    <span>
      <?php echo $this->translate("There are no dashboards created by you yet.") ?>
    </span>
  </div>
<?php endif; ?>