<?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('modulename' => 'event')); ?>

<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>

<div class="global_form_wrap">
  <?php echo $this->form->render() ?>
</div>
<?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 sesselectedDate  = '<?php echo $dateFormat; ?>';
	scriptJquery('#starttime-date').attr("type","text").attr("autocomplete","off").attr("placeholder","<?php echo $this->translate('Select a Date'); ?>").datepicker({
		dateFormat: sesselectedDate ,
		minDate: new Date(<?php echo $year; ?>, <?php echo $month; ?>, <?php echo $day; ?>),
		changeMonth: true,
		changeYear: true,
		yearRange: "+0:+100"
	}).on('change', function(){
		var selectedDate = scriptJquery(this).datepicker('getDate');
		scriptJquery('#endtime-date').datepicker('option', 'minDate', selectedDate);
	});

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

  en4.core.runonce.add(function() {
    <?php if(Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0)) { ?>
      isOnline(0);
    <?php } else { ?>
      isOnline(1);
    <?php } ?>
  });

  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('');
    }
  }

  scriptJquery('.core_main_event').parent().addClass('active');
</script>