<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php if( !$this->travel): ?>
<?php echo $this->translate('The travel you are looking for does not exist or has been deleted.');?>
<?php return; // Do no render the rest of the script in this mode
endif; ?>

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

  var tagAction = function(tag_id){
    var url = "<?php echo $this->url(array('module' => 'travel','action'=>'index'), 'travel_general', true) ?>?tag_id="+tag_id;
    loadAjaxContentApp(url);
  }
</script>

<form id='filter_form' class='global_form_box' method='post' action='<?php echo $this->url(array('module' => 'travel', 'controller' => 'index', 'action' => 'index'), 'default', true) ?>' style='display:none;'>
<input type="hidden" id="tag" name="tag" value=""/>
</form>

<div class="travel_top">
  <?php if($this->travel->photo_id) { ?>
  <div class="travel_left">
    <div class="travels_thumbs_nav vertical slider">
      <?php $mainPhoto = 0; ?>
      <?php foreach( $this->paginator as $photo ): ?>
      <div>
        <div>
          <div class="travels_thumbs_description" style="display: none;">
            <?php if( '' != $photo->getDescription() ): ?>
            <?php echo Engine_Api::_()->core()->smileyToEmoticons($photo->getDescription()); ?>
            <?php endif; ?>
          </div>
          <?php echo $this->htmlImage($photo->getPhotoUrl(), $photo->getTitle(), array('id' => 'media_photo',"class"=>"travels_thumbs")); ?>
        </div>
      </div>
      <?php endforeach;?>
      </div>
      <div class="travels_thumbs_main_image">
          <div class="travels_thumbs_main">
          </div>
        <div class="travels_thumbs_description">
      </div>
    </div>
  </div>
            <?php } ?>
  <div class="travel_right">
    <h1>
      <?php echo $this->travel->getTitle(); ?>
      <?php if( $this->travel->closed == 1 ): ?>
        <i class="icon_closed" data-bs-toggle="tooltip" title="<?php echo $this->translate("Closed")?>"></i>
      <?php endif;?>
    </h1>
    <div class="travel_entrylist_entry_date  d-flex flex-wrap gap-2">
      <span>
        <?php echo $this->translate('Posted by');?>
        <?php echo $this->htmlLink($this->travel->getParent(), $this->travel->getParent()->getTitle(), array('class' => 'font_color')) ?>
      </span>
      <?php echo $this->timestamp($this->travel->creation_date) ?>
      <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('travel.enable.location', 0) && Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0) && !empty($this->travel->location)) { ?>
        <span class="d-flex flex-wrap gap-1">
          <i class="icon_map"></i>
          <span class="flex-fill"><a href="<?php echo 'http://maps.google.com/?q='.$this->travel->location; ?>" class="font_color" target="_blank"><?php echo $this->travel->location; ?></a></span>
        </span>
      <?php } ?>
    </div>
    <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('travel.enable.rating', 1)) { ?>
      <?php echo $this->partial('_rating.tpl', 'core', array('item' => $this->travel, 'module' => 'travel', 'param' => 'create', 'notificationType' => 'travel_rating')); ?>
    <?php } ?>
    <div class="travels_entrylist">
      <?php echo $this->fieldValueLoop($this->travel, $this->fieldStructure) ?>
    </div>
    <?php if ($this->travel->closed == 1):?>
      <div class="tip">
          <span>
            <?php echo $this->translate('This travel listing has been closed by the poster.');?>
          </span>
      </div>
      <?php endif; ?>
  </div>
</div>
<div class="travel_entrylist_entry_body">
  <h3><?php echo $this->translate('About'); ?></h3>
  <div class="rich_content_body">
    <?php echo Engine_Api::_()->core()->smileyToEmoticons(nl2br($this->travel->body)); ?>
  </div>
  <div class="travels_tags">
    <?php if (engine_count($this->travelTags )):?>
      <?php foreach ($this->travelTags as $tag): ?>
        <?php if (!empty($tag->getTag()->text)):?>
          <a href='javascript:void(0);' class="tag" onclick='javascript:tagAction(<?php echo $tag->getTag()->tag_id; ?>);'>#<?php echo $tag->getTag()->text?></a>&nbsp;
        <?php endif; ?>
      <?php endforeach; ?>
    <?php endif; ?>
  </div>
</div>

<div class="travel_stats font_color_light">
  <?php if( $this->canUpload ): ?>
  <?php echo $this->htmlLink(array(
  'route' => 'travel_extended',
  'controller' => 'photo',
  'action' => 'upload',
  'travel_id' => $this->travel->getIdentity(),
  ), $this->translate('Add Photos')) ?>
  &nbsp;|&nbsp;
  <?php endif; ?>
  <?php if( $this->canEdit ): ?>
  <?php echo $this->htmlLink(array(
  'route' => 'travel_specific',
  'action' => 'edit',
  'travel_id' => $this->travel->getIdentity(),
  //'format' => 'smoothbox'
  ), $this->translate("Edit")/*, array('class' => 'smoothbox')*/); ?>
  &nbsp;|&nbsp;
  <?php endif; ?>
  <?php if( $this->canDelete ): ?>
  <?php echo $this->htmlLink(array(
  'route' => 'travel_specific',
  'action' => 'delete',
  'travel_id' => $this->travel->getIdentity(),
  'format' => 'smoothbox'
  ), $this->translate("Delete"), array('class' => 'smoothbox')); ?>
  &nbsp;|&nbsp;
  <?php endif; ?>
  <?php if( $this->canEdit ): ?>
  <?php if( !$this->travel->closed ): ?>
  <?php echo $this->htmlLink(array(
  'route' => 'travel_specific',
  'action' => 'close',
  'travel_id' => $this->travel->getIdentity(),
  'closed' => 1,
  'QUERY' => array(
  'return_url' => $this->url(),
  ),
  ), $this->translate('Close')) ?>
  <?php else: ?>
  <?php echo $this->htmlLink(array(
  'route' => 'travel_specific',
  'action' => 'close',
  'travel_id' => $this->travel->getIdentity(),
  'closed' => 0,
  'QUERY' => array(
  'return_url' => $this->url(),
  ),
  ), $this->translate('Open')) ?>
  <?php endif; ?>
  &nbsp;|&nbsp;
  <?php endif; ?>
  <?php if( $this->viewer()->getIdentity() ): ?>
  <?php echo $this->htmlLink(array(
  'module' => 'activity',
  'controller' => 'index',
  'action' => 'share',
  'route' => 'default',
  'type' => 'travel',
  'id' => $this->travel->getIdentity(),
  'format' => 'smoothbox'
  ), $this->translate("Share"), array('class' => 'smoothbox')); ?>
  &nbsp;|&nbsp;
  <?php echo $this->htmlLink(array(
  'module' => 'core',
  'controller' => 'report',
  'action' => 'create',
  'route' => 'default',
  'subject' => $this->travel->getGuid(),
  'format' => 'smoothbox'
  ), $this->translate("Report"), array('class' => 'smoothbox')); ?>
  &nbsp;|&nbsp;
  <?php endif ?>
  <?php echo $this->translate(array('%s view', '%s views', $this->travel->view_count), $this->locale()->toNumber($this->travel->view_count)) ?>
</div>

<script type="text/javascript">
    scriptJquery('.core_main_travel').parent().addClass('active');
    AttachEventListerSE("click",".travels_thumbs",function(){
      var tab = scriptJquery(this).attr("tab-index");
      var elm = scriptJquery(".travels_mth[tab-index="+tab+"]");
      scriptJquery(".travels_thumbs_main").prepend(elm.clone());
      scriptJquery(".travels_thumbs_main").siblings(".travels_thumbs_description").html(elm.find(".description").html());
      elm.remove();
      scriptJquery(".travels_thumbs_main a").hide();
      scriptJquery(".travels_mth").eq(0).show();
      $items = scriptJquery('.travels_mth');

    });
    (function() {
      scriptJquery(".travels_thumbs").each(function(index){
        var src = scriptJquery(this).attr("src");
        scriptJquery(this).attr("tab-index",index);
        var description = scriptJquery(this).siblings(".travels_thumbs_description");

        scriptJquery(".travels_thumbs_main").append(`<a data-darkbox="${src}" data-darkbox-group="photos_<?php echo $this->travel->getIdentity();?>" data-darkbox-description="${description.html()}" href="javascipt:;" class="travels_mth ajaxPrevent" tab-index="${index}"><div class="description" style="display:none;">${description.html()}</div><img src="${src}" alt="" id="media_photo" class="travels_mthumb"></a>`);
      });
      scriptJquery(".travels_thumbs").eq(0).trigger("click");
    })();

    en4.core.runonce.add(function(){
      scriptJquery(".vertical").slick({
				vertical: true,
				infinite: false,
				draggable: false,
				arrows:true,
        slidesToShow: 4,
				slidesToScroll: 1,
				responsive: [
    {
      breakpoint: 1024,
      settings: {
        slidesToShow: 3,
        slidesToScroll: 3
      }
    },
    {
      breakpoint: 767,
      settings: {
        slidesToShow: 1,
        slidesToScroll: 1,
				vertical: false,
				arrows: false,
				dots: true
      }
    },
     ]
      });
   
    
  // Add parant element to table
  scriptJquery('.rich_content_body table').each(function() {                            
    scriptJquery(this).addClass('table');
    scriptJquery(this).wrap('<div class="table_wrap"></div>');
  });
});
</script>
