<?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">
  en4.core.runonce.add(function(){
    <?php if( !$this->renderOne ): ?>
      var anchor = scriptJquery('#profile_groups_events').parent();
    scriptJquery('#profile_groups_events_previous').css("display",'<?php echo ( $this->paginator->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>');
    scriptJquery('#profile_groups_events_next').css("display",'<?php echo ( $this->paginator->count() == $this->paginator->getCurrentPageNumber() ? 'none' : '' ) ?>');
    scriptJquery('#profile_groups_events_previous').off('click').on('click', function(){
      en4.core.request.send(scriptJquery.ajax({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        method : 'post',
        dataType : 'html',
        data : {
        format : 'html',
        subject : en4.core.subject.guid,
        page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() - 1) ?>
      }
                                              }
                                             ), {
        'element' : anchor
      }
                           )
    }
                                                                   );
    scriptJquery('#profile_groups_events_next').off('click').on('click', function(){
      en4.core.request.send(scriptJquery.ajax({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        method : 'post',
        dataType : 'html',
        data : {
        format : 'html',
        subject : en4.core.subject.guid,
        page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() + 1) ?>
      }
                                              }
                                             ), {
        'element' : anchor
      }
                           )
    }
                                                               );
    <?php endif;
    ?>
  }
    );
</script>

<?php if( $this->canAdd ): ?>
  <div class="profile_tab_options">
    <div>
      <?php echo $this->htmlLink(array('route' => 'event_general', 'controller' => 'event', 'action' => 'create', 'parent_type'=> 'group', 'subject_id' => $this->subject()->getIdentity()), $this->translate('Add Events'), array('class' => 'btn btn-alt icon_add')) ?>
    </div>
  </div>
<?php endif; ?>

<?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
  <div class="container no-padding events_listing">
    <div class='grid_listing'>
      <?php foreach( $this->paginator as $event ): ?>
      <div class="grid_listing_item">
        <article>
          <div class='grid_listing_item_thumb'>
            <?php echo $this->htmlLink($event->getHref(), $this->itemBackgroundPhoto($event, 'thumb.profile')) ?>
          </div>
          <div class='grid_listing_item_info'>
            <div class="grid_listing_item_title">
              <?php echo $this->htmlLink($event->getHref(), $this->string()->chunk($event->getTitle(), 10)) ?>
            </div>
            <div class="grid_listing_item_owner">
              <span><?php echo $this->translate('led by') ?>
              <?php echo $this->htmlLink($event->getOwner()->getHref(), $event->getOwner()->getTitle()) ?></span>
              <span><?php echo $this->translate(array('%s guest', '%s guests', $event->membership()->getMemberCount()),$this->locale()->toNumber($event->membership()->getMemberCount())) ?></span>
            </div>
            <div class="grid_listing_item_stat">
              <i class="icon_calendar"></i>
              <span class="event_start_date"> 
                <?php echo $this->locale()->toDateTime($event->starttime) ?>
              </span>
            </div>

          </div>
        </article>
      </div>
      <?php endforeach;?>
    </div>
  </div>

  <div class="profile_paginator">
    <div id="profile_groups_events_previous" class="paginator_previous">
      <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Previous'), array(
  'onclick' => '',
  'class' => 'buttonlink icon_previous'
  )); ?>
    </div>
    <div id="profile_groups_events_next" class="paginator_next">
      <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Next'), array(
  'onclick' => '',
  'class' => 'buttonlink_right icon_next'
  )); ?>
    </div>
  </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('No events have been added to this group yet.');?></p>
  </div>
<?php endif; ?>
