<?php
defined('ABSPATH') or die("No script kiddies please!");
global $post;
$post_id = $post->ID;
$egpr_badge_settings = get_post_meta($post_id, 'egpr_badge_settings', true);
$show_badge = (isset($egpr_badge_settings['show_badge']) && $egpr_badge_settings['show_badge'] == 'true') ? 'true' : 'false';
$show_header = (isset($egpr_badge_settings['show_header']) && $egpr_badge_settings['show_header'] == 'true') ? 'true' : 'false';
$choose_badge_template = (isset($egpr_badge_settings['choose_badge_template']) && $egpr_badge_settings['choose_badge_template'] != '') ? $egpr_badge_settings['choose_badge_template'] : 'template1';
$choose_header_template = (isset($egpr_badge_settings['choose_header_template']) && $egpr_badge_settings['choose_header_template'] != '') ? $egpr_badge_settings['choose_header_template'] : 'template1';
$enable_banimation = (isset($egpr_badge_settings['enable_banimation']) && $egpr_badge_settings['enable_banimation'] == 'true') ? 'true' : 'false';
$badge_animation_name = (isset($egpr_badge_settings['animation_name']) && $egpr_badge_settings['animation_name'] != '') ? $egpr_badge_settings['animation_name'] : '';
?>
<div class="egpr_customoptions_section-wrapper">

    <div class="egpr-type-field">
        <label for="egpr_meta_show_badge">
            <h4><?php _e('Show Badge', 'everest-google-places-reviews'); ?></h4>
        </label>
        <label class="egpr-switch">
            <input type="checkbox" name="egpr_badge_settings[show_badge]" id="egpr_meta_show_badge" 
                   value="true" <?php
                   if (isset($show_badge)) {
                       checked($show_badge, 'true');
                   }
                   ?>/>
             <div class="egpr-slider round"></div>
        </label>
         <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Show/hide badge to display business information with different pre available templates.', 'everest-google-places-reviews'); ?>
                </div>
       </div>
    </div>
    <div class="egpr-show-badge-options" <?php if ($show_badge != "true") echo 'style="display:none;"'; ?>>
      <div class="egpr-wrap"> 
        <div class="egpr-type-field">
        <label for="egpr_meta_choose_btemplate">
            <h4><?php _e('Choose Badge Template', 'everest-google-places-reviews'); ?></h4>
        </label>
        <label class="egpr-noswitch">
            <select name="egpr_badge_settings[choose_badge_template]" class="egpr-badge-selection egpr-field-selection" id="egpr_meta_choose_btemplate">
                <?php for ($i = 1; $i <= 10; $i++) { ?>  
                    <option value="template<?php echo $i; ?>" <?php selected($choose_badge_template, 'template' . $i); ?>>Badge Template <?php echo $i; ?></option>
                <?php } ?>
            </select>
        </label>

          </div>
            <div class="egpr-btemplate-demo egpr-preview-image">
                <?php for ($cnt = 1; $cnt <= 10; $cnt++) {
                    if($choose_badge_template == "template".$cnt){
                        $style = "";
                    }else{
                        $style = "style='display:none;'";
                    }
                    ?>
                    <div class="egpr-temp-common-badge" id="egpr-demobadge-template<?php echo $cnt; ?>" <?php echo $style;?>>
                         <h4><?php _e('Template', 'everest-google-places-reviews'); ?> <?php echo $cnt; ?> <?php _e('Preview', 'everest-google-places-reviews'); ?></h4>
                        <img src="<?php echo EGPR_BACKEND_IMG_DIR . 'badges/badge' . $cnt . '.jpg' ?>"/>
                    </div>
                <?php } ?>
            </div>
        </div>    
     <div class="clear"></div>
     <div class="egpr-type-field">
        <label for="egpr_meta_show_header">
            <h4><?php _e('Show Header Ribbon', 'everest-google-places-reviews'); ?></h4>
        </label>
         <label class="egpr-switch">
            <input type="checkbox" name="egpr_badge_settings[show_header]" id="egpr_meta_show_header" 
                   value="true" <?php
                   if (isset($show_header)) {
                       checked($show_header, 'true');
                   }
                   ?>/>
             <div class="egpr-slider round"></div>
        </label>
          <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Show/hide header to ribbon type header on badge.', 'everest-google-places-reviews'); ?>
                </div>
       </div>
    </div>
    <div class="egpr-show-header-options" <?php if ($show_header != "true") echo 'style="display:none;"'; ?>>
        <div class="egpr-type-field">

        <label for="egpr_meta_choose_htemplate">
            <h4><?php _e('Choose Header Template', 'everest-google-places-reviews'); ?></h4>
        </label>
        <label class="egpr-noswitch">
            <select name="egpr_badge_settings[choose_header_template]" class="egpr-header-selection egpr-field-selection" id="egpr_meta_choose_htemplate">
                <?php for ($i = 1; $i <= 10; $i++) { ?>  
                    <option value="template<?php echo $i; ?>" <?php selected($choose_header_template, 'template' . $i); ?>>Header Template <?php echo $i; ?></option>
                <?php } ?>
            </select>
        </label>

    </div>
    <div class="egpr-htemplate-demo egpr-preview-image">
        <?php for ($cnt = 1; $cnt <= 10; $cnt++) {
            if($choose_header_template == "template".$cnt){
                $style = "";
            }else{
                $style = "style='display:none;'";
            }
            ?>
            <div class="egpr-temp-common-header" id="egpr-headerdemo-template<?php echo $cnt; ?>" <?php echo $style;?>>
                 <h4><?php _e('Template', 'everest-google-places-reviews'); ?> <?php echo $cnt; ?> <?php _e('Preview', 'everest-google-places-reviews'); ?></h4>
                <img src="<?php echo EGPR_BACKEND_IMG_DIR . 'headers/header' . $cnt . '.png' ?>"/>
            </div>
        <?php } ?>
    </div>
    </div>
        
    </div>


   <div class="egpr-type-field">
          <label for="egpr_meta_enable_banimation"><h4><?php _e('Enable Badge Animation', 'everest-google-places-reviews'); ?></h4></label>
         <label class="egpr-switch">
            <input type="checkbox" name="egpr_badge_settings[enable_banimation]" id="egpr_meta_enable_banimation" 
                   value="true" <?php
                    if ( isset($enable_banimation) ) {
                        checked($enable_banimation, 'true');
                    }
                ?>/>
             <div class="egpr-slider round"></div>
         </label>
          <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Check this button to enable badge animation on this reviews.', 'everest-google-places-reviews'); ?>
                </div>
         </div>
    </div>

    <?php $egpr_tab_animation_data = get_option('egpr_tab_animation_data');
    if(empty($egpr_tab_animation_data )){
      $activate_egpr_obj  = new EGPR_Activation();
      $egpr_tab_animation_data = $activate_egpr_obj->egpr_tab_animation_data();
    }?>
     <div class="egpr-type-field epgr-badge-animation epgr-animation">
            <label><h4><?php _e('Choose Animation', 'everest-google-places-reviews'); ?></h4></label>
            <label class="egpr-noswitch">
                 <select name="egpr_badge_settings[animation_name]" class="egpr-field-selection">
                        <?php 
                        if(isset($egpr_tab_animation_data) && !empty($egpr_tab_animation_data)){
                        foreach ($egpr_tab_animation_data as $key => $kvalue){
                           ?>
                        <optgroup label="<?php echo ucwords(str_replace("_", " ", $key));?>">
                         <?php 
                           if(is_array($kvalue)){
                               foreach ($kvalue as $k => $v){ ?>
                               <option value="<?php echo esc_attr($v);?>" <?php selected($badge_animation_name, $v); ?>><?php echo esc_attr(ucwords($v));?></option>
                             <?php
                               }
                           } 
                          ?>
                        </optgroup>
                    <?php } } ?>
                    </select>
            </label>
     </div>
    
</div>