<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<div class="settings browserpush_schedule_popup">
    <?php echo $this->form->render($this); ?>
</div>
<script type="text/javascript">
function testuser(){
  if(!scriptJquery('#title').val())  {
    scriptJquery('#title').css('border','1px solid red');
    return false;  
  }
  scriptJquery('#title').css('border','');
  scriptJquery('.global_form').css('position','relative').append('<span class="browsepush_loading_cont_overlay" style="display:block"></span>');
  
  var formData = new FormData(scriptJquery('.global_form')[0]);
			formData.append('test_user', 'true');
			submitFormAjax = scriptJquery.ajax({
					type:'POST',
					url: en4.core.baseUrl+'admin/browserpush/settings/notification/',
					data:formData,
					cache:false,
					contentType: false,
					processData: false,
					success:function(data){
            scriptJquery('.browsepush_loading_cont_overlay').remove();  
          },
					error: function(data){
						//silence
					}
			});
  
}
 en4.core.runonce.add(function(e){
  criteriaOpen(scriptJquery('#criteria').val()); 
  <?php if($this->user_id){ ?> 
  scriptJquery('#toValues-wrapper').hide();
  scriptJquery('#criteria-wrapper').hide();
  <?php } ?>  
 })
 function criteriaOpen(value){
   if(value == 'all'){
    scriptJquery('#to-wrapper').hide();
    scriptJquery('#toValues-wrapper').hide();
    scriptJquery('#network-wrapper').hide();
    scriptJquery('#memberlevel-wrapper').hide();
   }else if(value == 'memberlevel'){
    scriptJquery('#to-wrapper').hide();
    scriptJquery('#toValues-wrapper').hide();
    scriptJquery('#network-wrapper').hide();
    scriptJquery('#memberlevel-wrapper').show();
   }else if(value == 'network'){
    scriptJquery('#to-wrapper').hide();
    scriptJquery('#toValues-wrapper').hide();
    scriptJquery('#network-wrapper').show();
    scriptJquery('#memberlevel-wrapper').hide();
   }else if(value == 'user'){
    scriptJquery('#to-wrapper').show();
    scriptJquery('#toValues-wrapper').show();
    scriptJquery('#network-wrapper').hide();
    scriptJquery('#memberlevel-wrapper').hide(); 
   }else{
    scriptJquery('#to-wrapper').hide();
    scriptJquery('#toValues-wrapper').hide();
    scriptJquery('#network-wrapper').hide();
    scriptJquery('#memberlevel-wrapper').hide();  
   }
 }
</script>
<?php
  $start = time();
  $oldTz = date_default_timezone_get();
  date_default_timezone_set($this->viewer()->timezone);
  $start_date = date('m/d/Y',$start);
  date_default_timezone_set($oldTz);
?>
<script type="text/javascript">
  var selectedDate = '<?php echo $start_date;  ?>'; 
  scriptJquery('#scheduled_time-date').attr("type","text").attr("autocomplete","off").attr("placeholder","<?php echo $this->translate('Select a Date'); ?>").datepicker({
    minDate: '<?php echo $start_date;  ?>',
   }).on('change', function(ev){
      selectedDate = scriptJquery('#scheduled_time-date').val();
  });

  en4.core.runonce.add(function(e) {
    hideShow('<?php echo !empty($this->schedule) ? $this->schedule : 0; ?>');
  });

  function hideShow(value) {
    if(value == 1) {
      scriptJquery("#scheduled_time-wrapper").show();
    } else {
      scriptJquery("#scheduled_time-wrapper").hide();
    }
  }
</script>
