<?php
/* 
* Theme: PREMIUMPRESS CORE FRAMEWORK FILE
* Url: www.premiumpress.com
* Author: Mark Fail
*
* THIS FILE WILL BE UPDATED WITH EVERY UPDATE
* IF YOU WANT TO MODIFY THIS FILE, CREATE A CHILD THEME
*
* http://codex.wordpress.org/Child_Themes
*/
if (!defined('THEME_VERSION')) {	header('HTTP/1.0 403 Forbidden'); exit; }

global $CORE, $CORE_DIRECTORY, $post, $settings, $userdata;
 
// ADMIN ON/OFF SETTING
if(_ppt('businesshours') != '1'){ return ""; }
 
 
$bh = get_post_meta($post->ID,'businesshours',true);

$days = array(
__('Monday',"premiumpress"),
__('Tuesday',"premiumpress"),
__('Wednesday',"premiumpress"),
__('Thursday',"premiumpress"),
__('Friday',"premiumpress"),
__('Saturday',"premiumpress"),
__('Sunday',"premiumpress"),
);


// DONT SHOW IF ADMIN TO SHOW FOR ELEMENTOR PLUGIN
if(is_admin()){

$bh = array(
    'start' => array
        (
            0 => '09:00',
            1 => '09:00',
            2 => '12:00',
            3 => '09:45',
            4 => '09:00',
            5 => '09:00',
            6 => '06:45',
        ),

    'end' => array
        (
            0 => '18:00',
            1 => '18:00',
            2 => '18:00',
            3 => '18:00',
            4 => '18:00',
            5 => '18:00',
            6 => '18:00',
        ),

    'active' => array
        (
            0 => '1',
            1 => '1',
            2 => '1',
            3 => '1',
            4 => '1',
            5 => '1',
            6 => '0',
        ),

);
}else{

	$i=0; $countClosed = 0; while($i < 7){  if(isset($bh['active'][$i]) && $bh['active'][$i] == 1){ }else{ $countClosed++; } $i++; }
	
	if($countClosed == 7 && !is_admin() ){ return; }
}

if(is_array($bh) && !empty($bh) ){ 
 
?> 


<div class="widget"  id="businesshoursbox" data-title="<?php echo __("Opening Hours","premiumpress") ?>">

   <?php 
   
   // WIDGET OPTION
   // SHOW TITLE
   if(!isset($settings['showtitle']) || ( isset($settings['showtitle']) && $settings['showtitle'] != 0) ){ ?><div class="widget-title">
<i class="fa fa-clock float-right mt-1"></i>
<?php if(defined('IS_MOBILEVIEW') && _ppt('mobileweb') == 1 ){   ?>
<h4 class="bold bottom-10 color-highlight"><?php echo __("Opening Hours","premiumpress") ?></h6> 
<?php }else{ ?>
<h6><?php echo __("Opening Hours","premiumpress") ?></h6> 	
<?php } ?>
</div><?php } ?>


<div class="h4 mt-2">
<?php
if($bh['active'][date('w')] == 1 ){
echo __("Open Today","premiumpress");
}else{
echo __("Closed Today","premiumpress");
}
?>!

</div>

<ul class="working-hour list-unstyled mt-4">

<?php $i=0; while($i < 7){ ?>
<li> 

<?php echo $days[$i]; ?>

	<?php if(isset($bh['active'][$i]) && $bh['active'][$i] == 1){ 
	
	
	?>
    <span><?php echo date('H:i A', strtotime($bh['start'][$i])); ?> - <?php echo date('H:i A', strtotime($bh['end'][$i])); ?></span>
    <?php }else{ ?>
    <span><?php echo __("Closed","premiumpress"); ?></span>
    <?php } ?>
    
</li>

<?php $i++; } ?>
 
</ul> 
</div> 
<script>

jQuery(document).ready(function() {
	
	if(jQuery('#videobox').height() < 500){ 
		jQuery('#videobox').html('');
	}	
});

</script>
<?php } ?>