<?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/Fbclone/views/scripts/_adminHeader.tpl';?>
<?php 
$this->headScript()->appendFile($this->layout()->staticBaseUrl . 'externals/jQuery/jquery-ui.js');
$this->headScript()->appendFile($this->layout()->staticBaseUrl . 'externals/jQuery/odering.js'); 
?>
<?php $fbclone_admin = Zend_Registry::isRegistered('fbclone_admin') ? Zend_Registry::get('fbclone_admin') : null; ?>
<script>
  ajaxurl = en4.core.baseUrl+"admin/fbclone/manage/change-order";
</script>
<div class='settings'>
  <form class="global_form">
    <div>
      <h3><?php echo $this->translate("Manage Dashboard Links") ?> </h3>
      <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>
      <p class="mb-3"> <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', 'action' => 'addheading'), $this->translate('Add Category'), array('class' => 'smoothbox admin_link_btn')); ?> </p>
      <?php if($fbclone_admin && engine_count($this->paginator)>0):?>
        <div class="fbclone_dashboard_links">
          <table class='admin_table admin_table_order' style="width: 100%;">
            <thead>
              <tr>
                <th><?php echo $this->translate("Categories & Links") ?></th>
                <th><?php echo $this->translate("Icon") ?></th>
                <th><?php echo $this->translate("Enabled") ?></th>
                <th><?php echo $this->translate("Options") ?></th>
              </tr>
            </thead>
            <tbody>
              <?php foreach ($this->paginator as $category): ?>
                <tr 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>
                    <?php echo ( $category->enabled ? $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', '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' => 'fbclone', 'controller' => 'manage', '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' => 'fbclone', 'controller' => 'manage', 'action' => 'editheading', 'dashboardlink_id' => $category->dashboardlink_id), $this->translate("Edit"), array('class' => 'smoothbox')) ?>
                    <?php //if($category->dashboardlink_id != 1): ?> |
                    <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', 'action' => 'addsublink', 'dashboardlink_id' => $category->dashboardlink_id), $this->translate('Add New Sub Link'), array('class' => 'smoothbox')); ?><?php //endif; ?>
                    |
                    <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', 'action' => 'delete', 'dashboardlink_id' => $category->dashboardlink_id), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
                  </td>
                </tr>
                <?php $manageSubLinks = Engine_Api::_()->getDbTable('dashboardlinks', 'fbclone')->getInfo(array('sublink' => $category->dashboardlink_id)); ?>
                <?php foreach ($manageSubLinks as $sub_category):  ?>
                  <tr 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->photo)): ?>
                        <?php $icon = Engine_Api::_()->core()->getFileUrl($sub_category->photo, true); ?>
                        <img class="fbclone_manangemenu_icon" src="<?php echo $icon['image'] ?>" alt="<?php echo $icon['alt_text'] ? $icon['alt_text'] : 'image' ?>" />
                      <?php elseif(empty($sub_category->photo) && !empty($sub_category->icon_type)): ?>
                        <i class="fa <?php echo $sub_category->font_icon; ?>" <?php if($sub_category->fonticoncolor) { ?> style="color:<?php echo $sub_category->fonticoncolor; ?>" <?php } ?>></i>
                      <?php endif;?>
                    </td>
                    <td>
                      <?php echo ( $sub_category->enabled ? $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', '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' => 'fbclone', 'controller' => 'manage', '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>
                      <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'fbclone', 'controller' => 'manage', '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' => 'fbclone', 'controller' => 'manage', 'action' => 'deletesublink', 'dashboardlink_id' => $sub_category->dashboardlink_id), $this->translate("Delete"), array('class' => 'smoothbox')) ?>
                    </td>
                  </tr>
                <?php endforeach; ?>
              <?php endforeach; ?>
            </tbody>
          </table>
        </div>
      <?php else:?>
      <div class="tip">
        <span><?php echo $this->translate("There are currently no categories added yet.") ?></span>
      </div>
      <?php endif;?>
    </div>
  </form>
</div>
