<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>

<script type="text/javascript">
  var pageAction =function(page){
    scriptJquery('#page').val(page);
    scriptJquery('#filter_form').trigger("submit");
  }

  var searchBizlists = function() {
    scriptJquery('#filter_form').trigger("submit");
  }

  en4.core.runonce.add(function(){
    scriptJquery('#filter_form input[type=text]').each(function(f) {
        if (f.value == '' && f.id.match(/\min$/)) {
            //new OverText(f, {'textOverride':'min','element':'span'});
            //f.set('class', 'integer_field_unselected');
        }
        if (f.value == '' && f.id.match(/\max$/)) {
            //new OverText(f, {'textOverride':'max','element':'span'});
            //f.set('class', 'integer_field_unselected');
        }
    });
  });

  // scriptJquery(window).on('onChangeFields', function() {
  //   var firstSep = scriptJquery('li.browse-separator-wrapper').eq(0);
  //   var lastSep;
  //   var nextEl = firstSep;
  //   var allHidden = true;
  //   do {
  //     nextEl = nextEl.next();
  //     if( nextEl.hasClass('browse-separator-wrapper')) {
  //       lastSep = nextEl;
  //       nextEl = false;
  //     } else {
  //       allHidden = allHidden && ( nextEl.css('display') == 'none' );
  //     }
  //   } while(nextEl);
  //     if(lastSep) {
  //       lastSep.css('display', (allHidden ? 'none' : ''));
  //     }
  // });
</script>

<script type="text/javascript">
  en4.core.runonce.add(function() {
    // Enable links
    scriptJquery('.bizlists_browse_info_blurb').enableLinks();
  });
</script>

<?php
  /* Include the common user-end field switching javascript */
  echo $this->partial('_jsSwitch.tpl', 'fields', array(
    //'topLevelId' => (int) @$this->topLevelId,
    //'topLevelValue' => (int) @$this->topLevelValue
  ))
?>
<?php if (($this->current_count >= $this->quota) && !empty($this->quota)):?>
  <div class="tip">
    <span>
      <?php echo $this->translate('You have already created the maximum number of listings allowed. If you would like to create a new listing, please delete an old one first.');?>
    </span>
  </div>
<?php endif; ?>
<?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
  <ul class="manage_listing bizlists_manage">
    <?php foreach( $this->paginator as $item ): ?>
      <li class="manage_listing_item">
        <article>
          <div class='manage_listing_thumb'>
            <?php echo $this->htmlLink($item->getHref(), $this->itemBackgroundPhoto($item, 'thumb.normal')) ?>
          </div>
          <div class='manage_listing_info'>
            <div class='manage_listing_header'>
              <div class="manage_listing_title">
                <?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?>
                <?php if( $item->closed ): ?>
                  <i class="icon_closed" data-bs-toggle="tooltip" title="<?php echo $this->translate("Closed")?>"></i>
                <?php endif;?>
              </div>
              <div class="dropdown options_menu">
                <button class="btn btn-alt" type="button" id="manageoption" data-bs-toggle="dropdown" aria-expanded="false">
                  <i class="icon_option_menu"></i>
                </button>
                <ul class="dropdown-menu dropdown-option-menu dropdown-menu-end" aria-labelledby="manageoption">
                  <li><?php echo $this->htmlLink(array('route' => 'bizlist_specific', 'action' => 'edit', 'bizlist_id' => $item->getIdentity()), $this->translate('Edit Listing'), array('class' => 'dropdown-item icon_edit')) ?></li>
                  <?php if( $this->allowed_upload ): ?>
                    <?php echo $this->htmlLink(array('route' => 'bizlist_extended', 'controller' => 'photo', 'action' => 'upload', 'bizlist_id' => $item->getIdentity()), $this->translate('Add Photos'), array('class' => 'dropdown-item icon_photos')) ?>
                  <?php endif; ?>
                  <?php if( !$item->closed ): ?>
                    <li><?php echo $this->htmlLink(array('route' => 'bizlist_specific', 'action' => 'close', 'bizlist_id' => $item->getIdentity(), 'closed' => 1), $this->translate('Close Listing'), array('class' => 'dropdown-item icon_close')) ?></li>
                  <?php else: ?>
                    <li><?php echo $this->htmlLink(array('route' => 'bizlist_specific', 'action' => 'close', 'bizlist_id' => $item->getIdentity(), 'closed' => 0), $this->translate('Open Listing'), array('class' => 'dropdown-item icon_open')) ?></li>
                  <?php endif; ?>
                  <li><?php echo $this->htmlLink(array('route' => 'bizlist_specific', 'action' => 'delete', 'bizlist_id' => $item->getIdentity(), 'format' => 'smoothbox'), $this->translate('Delete Listing'), array('class' => 'dropdown-item smoothbox icon_delete')) ?></li>
                </ul>
              </div>
            </div>
            <div class='manage_listing_owner'>
              <span><?php echo $this->timestamp(strtotime($item->creation_date)) ?></span>
              <span><?php echo $this->translate('posted by');?> <?php echo $this->htmlLink($item->getOwner()->getHref(), $item->getOwner()->getTitle()) ?></span>
            </div>
            <div class='manage_listing_desc'>
              <?php echo $this->string()->truncate($this->string()->stripTags($item->body), 92) ?>
            </div>
            <?php echo $this->partial('_approved_tip.tpl', 'core', array('item' => $item)); ?>
          </div>
        </article>
      </li>
    <?php endforeach; ?>
  </ul>
<?php elseif($this->search): ?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="<?php echo $this->translate("No Result")?>"></i>
    <p><?php echo $this->translate('You do not have any business listing that match your search criteria.');?></p>
  </div>
<?php else:?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="<?php echo $this->translate("No Result")?>"></i>
    <p><?php echo $this->translate('You do not have any business listings.');?></p>
    <?php if ($this->can_create): ?>
      <p><?php echo $this->translate('Get started by <a href=\'%1$s\'>posting</a> a new listing.', $this->url(array('action' => 'create'), 'bizlist_general'));?></p>
    <?php endif; ?>
  </div>
<?php endif; ?>
<?php echo $this->paginationControl($this->paginator, null, null); ?>

<script type="text/javascript">
  scriptJquery('.core_main_bizlist').parent().addClass('active');
</script>
