<?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')); ?>

<?php $this->headScript()->appendFile($this->layout()->staticBaseUrl . 'application/modules/Core/externals/scripts/admin/categories.js'); ?>
<script>
  ajaxurl = en4.core.baseUrl+"admin/core/manage/change-order";
</script>

<?php include APPLICATION_PATH .  '/application/modules/Core/views/scripts/dismiss_message.tpl';?>

<div class='settings'>
  <form class="global_form">
    <div>
      <h2 class="page_heading"><?php echo $this->translate("Manage Dashboard Links") ?> </h2>
      <p class="description">
        <?php echo $this->translate('Here, you can create categories and you can also manage links to be shown in the Dashboard widget of your website arranged under various categories. You can also edit / delete / enable / disable any category and links from here.') ?>
      </p>
      <div class="mb-2">
        <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'index'), $this->translate("Back to Manage Dashboards"), array('class'=>'admin_link_btn')); ?>
        <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'addheading', 'dashboard_id' => $this->dashboard_id), $this->translate('Add Category'), array('class' => 'smoothbox admin_link_btn')); ?>
      </div>
      <?php if(engine_count($this->paginator)>0):?>
      <table class='admin_table' style="width: 100%;">
        <thead>
          <tr>
            <th><?php echo $this->translate("Categories & Links") ?></th>
            <th><?php echo $this->translate("Icon") ?></th>
            <th class="admin_table_centered"><?php echo $this->translate("Enabled") ?></th>
            <th><?php echo $this->translate("Options") ?></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach ($this->paginator as $category): ?>
            <tr id="categoryorder-<?php echo $category->getIdentity(); ?>" data-id="<?php echo $category->getIdentity(); ?>">
              <td style="display:none;"><input type="checkbox" class="checkbox check-column" name="delete_tag[]" value="<?php echo $category->getIdentity(); ?>" /></td>
              <td><b class="bold"><?php echo $category->name ?></b></td>
              <td>
                <?php echo "---"; ?>
              </td>
              <td class="admin_table_centered">
                <?php echo ( $category->enabled ? $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'enabled-link', 'dashboardlink_id' => $category->dashboardlink_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-link', 'dashboardlink_id' => $category->dashboardlink_id), $this->htmlImage('application/modules/Core/externals/images/admin/uncheck.png', '', array('title' => $this->translate('Enable')))) ) ?>
              </td>
              <td>
                <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'editheading', 'dashboardlink_id' => $category->dashboardlink_id, 'dashboard_id' => $this->dashboard_id), $this->translate("Edit"), array('class' => 'smoothbox')) ?>
                <?php //if($category->dashboardlink_id != 1): ?> |
                <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'addsublink', 'dashboardlink_id' => $category->dashboardlink_id, 'dashboard_id' => $this->dashboard_id), $this->translate('Add New Sub Link'), array('class' => 'smoothbox')); ?><?php //endif; ?>
                |
                <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'delete', 'dashboardlink_id' => $category->dashboardlink_id), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
              </td>
            </tr>
            <?php $manageSubLinks = Engine_Api::_()->getDbTable('dashboardlinks', 'core')->getInfo(array('sublink' => $category->dashboardlink_id, 'admin' => 1)); ?>
            <?php foreach ($manageSubLinks as $sub_category):  ?>
              <tr id="categoryorder-<?php echo $category->getIdentity(); ?>" data-id="<?php echo $sub_category->getIdentity(); ?>">
                
                <td style="display:none;"><input type="checkbox" class="checkbox check-column" name="delete_tag[]" value="<?php echo $sub_category->getIdentity(); ?>" /></td>
                <td>&rarr; <?php echo $sub_category->name ?></td>
                <td>
                  <?php if(empty($sub_category->icon_type) && !empty($sub_category->file_id)): ?>
                    <?php $photo = $this->storage->get($sub_category->file_id, '');
                    if($photo) {
                    $photo = $photo->map(); ?>
                      <img class="expose_manangemenu_icon" alt="" src="<?php echo $photo ?>" height="24px" />
                    <?php } else { ?>
                      <?php echo "---"; ?>
                    <?php } ?>
                  <?php elseif(empty($sub_category->file_id) && !empty($sub_category->icon_type)): ?>
                    <i class="fa <?php echo $sub_category->font_icon; ?>" style="font-size:24px;"></i>
                  <?php endif;?>
                </td>
                <td class="admin_table_centered">
                  <?php echo ( $sub_category->enabled ? $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'enabled-link', 'dashboardlink_id' => $sub_category->dashboardlink_id, 'sublink' => $sub_category->sublink), $this->htmlImage($this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/check.png', '', array('title' => $this->translate('Disabled'))), array()) : $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'enabled-link', 'dashboardlink_id' => $sub_category->dashboardlink_id, 'sublink' => $sub_category->sublink), $this->htmlImage('application/modules/Core/externals/images/admin/uncheck.png', '', array('title' => $this->translate('Enabled')))) ) ?>
                </td>
                <td class="admin_table_options nowrap">
                  <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'editlink', 'dashboardlink_id' => $sub_category->dashboardlink_id, 'sublink' => $sub_category->sublink), $this->translate("Edit"), array('class' => 'smoothbox')) ?> |
                  <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'core', 'controller' => 'managedashboard', 'action' => 'deletesublink', 'dashboardlink_id' => $sub_category->dashboardlink_id), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
                </td>
              </tr>
            <?php endforeach; ?>
          <?php endforeach; ?>
        </tbody>
      </table>
      <?php else:?>
        <div class="tip">
          <span><?php echo $this->translate("There are currently no entry yet.") ?></span>
        </div>
      <?php endif;?>
    </div>
  </form>
</div>
<script type="application/javascript">
  scriptJquery('.core_admin_main_themebuilder').parent().addClass('active');
  scriptJquery('.core_admin_main_themebuilder_managedashboards').addClass('active');
</script>
