<?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('_location.tpl', 'core', array('item' => $this->event, 'modulename' => 'event')); ?>

<?php
  $start = time();
  $end = time();
  $oldTz = date_default_timezone_get();
  date_default_timezone_set($this->viewer()->timezone);
  $year  = date('Y', $start);
	$month = date('n', $start) - 1;
	$day   = date('j', $start);
	$dateFormat = Engine_Api::_()->core()->dateFormatCalendar();
  date_default_timezone_set($oldTz);
?>
<script type="text/javascript">
  var modulename = 'event';
  var category_id = '<?php echo $this->category_id; ?>';
  var subcat_id = '<?php echo $this->subcat_id; ?>';
  var subsubcat_id = '<?php echo $this->subsubcat_id; ?>';

  en4.core.runonce.add(function() {
    if(category_id && category_id != 0) {
      showSubCategory(category_id, subcat_id);
    } else {
      if(scriptJquery('#category_id').val()) {
        showSubCategory(scriptJquery('#category_id').val());
      } else {
        if(document.getElementById('subcat_id-wrapper'))
          document.getElementById('subcat_id-wrapper').style.display = "none";
      }
    }

    if(subsubcat_id) {
      if(subcat_id && subcat_id != 0) {
        showSubSubCategory(subcat_id, subsubcat_id);
      } else {
        if(document.getElementById('subsubcat_id-wrapper'))
          document.getElementById('subsubcat_id-wrapper').style.display = "none";
      }
    } else if(subcat_id) {
      showSubSubCategory(subcat_id);
    }
    else {
      if(document.getElementById('subsubcat_id-wrapper'))
        document.getElementById('subsubcat_id-wrapper').style.display = "none";
    }
  });
</script>
<?php echo $this->partial('_approved_tip.tpl', 'core', array('item' => $this->subject())); ?>
<div class="layout_middle">
  <div class="generic_layout_container layout_core_content">
    <div class="global_form_wrap">
      <?php echo $this->form->render($this) ?>
    </div>
  </div>
</div>

<script type="text/javascript">
  var sesselectedDate = '<?php echo $start_date;  ?>';
	var calendarFormat = '<?php echo $dateFormat; ?>';
  scriptJquery('#starttime-date').attr("type","text").attr("placeholder","<?php echo $this->translate('Select a Date'); ?>").datepicker({
    dateFormat: calendarFormat,
		minDate: new Date(<?php echo $year; ?>, <?php echo $month; ?>, <?php echo $day; ?>),
    changeMonth: true,
    changeYear: true,
    yearRange: "+0:+100",
   }).on('change', function(ev){
    sesselectedDate = scriptJquery('#starttime-date').val();
    scriptJquery('#endtime-date').datepicker('option', 'minDate', scriptJquery('#starttime-date').val());
  });

  scriptJquery('#endtime-date').attr("type","text").attr("placeholder","<?php echo $this->translate('Select a Date'); ?>").datepicker({
    dateFormat: calendarFormat,
		minDate: new Date(<?php echo $year; ?>, <?php echo $month; ?>, <?php echo $day; ?>),
    changeMonth: true,
    changeYear: true,
    yearRange: "+0:+100",
  });

  en4.core.runonce.add(function() {
    isOnline('<?php echo $this->event->is_online; ?>');
  });

  function isOnline(value) {
    if(value == 1) {
      scriptJquery('#website-wrapper').show();
      scriptJquery('#location-wrapper').hide();
      scriptJquery('#location').val('');
    } else {
      scriptJquery('#website-wrapper').hide();
      scriptJquery('#location-wrapper').show();
      scriptJquery('#website').val('');
    }
  }
</script>