<?php
defined('ABSPATH') or die("No script kiddies please!");
global $post;
$post_id = $post->ID;
$egpr_display_settings = get_post_meta($post_id, 'egpr_display_settings', true);
$show_reviews = (isset($egpr_display_settings['show_reviews']) && $egpr_display_settings['show_reviews'] == 'true') ? 'true' : 'false';
$choose_template = (isset($egpr_display_settings['choose_template']) && $egpr_display_settings['choose_template'] != '') ? $egpr_display_settings['choose_template'] : 'template1';
$layout_type = (isset($egpr_display_settings['layout_type']) && $egpr_display_settings['layout_type'] != '') ? $egpr_display_settings['layout_type'] : 'list';
$badge_position = (isset($egpr_display_settings['badge_position']) && $egpr_display_settings['badge_position'] != '') ? $egpr_display_settings['badge_position'] : 'horizontal';
$pager_show = (isset($egpr_display_settings['slider']['pager'])  && $egpr_display_settings['slider']['pager'] == "true")?"true":"false";
$pager_type = (isset($egpr_display_settings['slider']['pager_type'])  && $egpr_display_settings['slider']['pager_type'] != "")?$egpr_display_settings['slider']['pager_type']:"dot";
$mode = (isset($egpr_display_settings['slider']['mode'])  && $egpr_display_settings['slider']['mode'] != "")?$egpr_display_settings['slider']['mode']:"horizontal";
$autoplay = (isset($egpr_display_settings['slider']['autoplay'])  && $egpr_display_settings['slider']['autoplay'] == "true")?"true":"false";
$adaptive_height = (isset($egpr_display_settings['slider']['adaptive_height'])  && $egpr_display_settings['slider']['adaptive_height'] == "true")?"true":"false";
$controls = (isset($egpr_display_settings['slider']['controls'])  && $egpr_display_settings['slider']['controls'] == "true")?"true":"false";
$controls_type = (isset($egpr_display_settings['slider']['controls_type'])  && $egpr_display_settings['slider']['controls_type'] != "")?$egpr_display_settings['slider']['controls_type']:"arrow";
$enable_review_animation = (isset($egpr_display_settings['enable_review_animation']) && $egpr_display_settings['enable_review_animation'] == 'true') ? 'true' : 'false';
$disable_user_links = (isset($egpr_display_settings['disable_user_links']) && $egpr_display_settings['disable_user_links'] == 'true') ? 'true' : 'false';
$disable_date = (isset($egpr_display_settings['disable_date']) && $egpr_display_settings['disable_date'] == 'true') ? 'true' : 'false';
$review_animation_type = (isset($egpr_display_settings['review_animation_type']) && $egpr_display_settings['review_animation_type'] != '') ? $egpr_display_settings['review_animation_type'] : '';
?>
<div class="egpr_display_section-wrapper">
    <div class="egpr-type-field">
          <label for="egpr_meta_show_reviews">
              <h4><?php _e('Show User Reviews', 'everest-google-places-reviews'); ?></h4>
          </label>
        <label class="egpr-switch">
             <input type="checkbox" name="egpr_display_settings[show_reviews]" id="egpr_meta_show_reviews" 
                   value="true" <?php
                   if (isset($show_reviews)) {
                       checked($show_reviews, 'true');
                   }
                   ?>/>
              <div class="egpr-slider round"></div>
        </label>
        <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Show/hide reviews with user rating, user name, description, photo.', 'everest-google-places-reviews'); ?>
                </div>
       </div>
  </div>
   <div class="egpr-show-reviews-options" <?php if ($show_reviews != "true") echo 'style="display:none;"'; ?>>
    <div class="egpr-type-field">
        <label for="egpr_meta_choose_template">
            <h4><?php _e('Choose Template', 'everest-google-places-reviews'); ?></h4>
        </label>
        <label class="egpr-noswitch">
            <select name="egpr_display_settings[choose_template]" class="egpr-template-selection egpr-field-selection" id="egpr_meta_choose_template">
                <?php for ($i = 1; $i <= 10; $i++) { ?>  
                    <option value="template<?php echo $i; ?>" <?php selected($choose_template, 'template' . $i); ?>>Review Layout <?php echo $i; ?></option>
                <?php } ?>
            </select>
        </label>
    </div>
    <div class="egpr-template-demo" id="egpr-preview-image">
        <?php for ($cnt = 1; $cnt <= 10; $cnt++) {
            if($choose_template == "template".$cnt){
                $style = "";
            }else{
                $style = "style='display:none;'";
            }
            ?>
            <div class="egpr-temp-common" id="egpr-demo-template<?php echo $cnt; ?>" <?php echo $style;?>>
                 <h4><?php _e('Review Layout ', 'everest-google-places-reviews'); ?> <?php echo $cnt; ?> <?php _e('Preview', 'everest-google-places-reviews'); ?></h4>
                 <img src="<?php echo EGPR_BACKEND_IMG_DIR . 'templates/template' . $cnt . '.png' ?>" width="800" />
            </div>
        <?php } ?>
    </div>
       
   <div class="egpr-type-field">
        <label for="egpr_meta_badge_position"><h4><?php _e('Badge Position', 'everest-google-places-reviews'); ?></h4></label>
        <label class="egpr-noswitch">
            <select name="egpr_display_settings[badge_position]" class="egpr-badge-position egpr-field-selection" id="egpr_meta_badge_position">
                    <option value="horizontal" <?php selected($badge_position, 'horizontal'); ?>>Horizontal</option>
                    <option value="vertical" <?php selected($badge_position, 'vertical'); ?>>Vertical</option>
            </select>
        </label>
    </div>
    <div class="egpr-type-field">
          <label for="egpr_meta_disable_date"><h4><?php _e('Disable Date', 'everest-google-places-reviews'); ?></h4></label>
         <label class="egpr-switch">
            <input type="checkbox" name="egpr_display_settings[disable_date]" id="egpr_meta_disable_date" 
                   value="true" <?php
                    if ( isset($disable_date) ) {
                        checked($disable_date, 'true');
                    }
                ?>/>
             <div class="egpr-slider round"></div>
         </label>
          <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Check this button to order to disable user reviewed date.', 'everest-google-places-reviews'); ?>
                </div>
         </div>
    </div>

    <div class="egpr-type-field">
          <label for="egpr_meta_disable_user_links"><h4><?php _e('Disable User Profile Links', 'everest-google-places-reviews'); ?></h4></label>
         <label class="egpr-switch">
            <input type="checkbox" name="egpr_display_settings[disable_user_links]" id="egpr_meta_disable_user_links" 
                   value="true" <?php
                    if ( isset($disable_user_links) ) {
                        checked($disable_user_links, 'true');
                    }
                ?>/>
             <div class="egpr-slider round"></div>
         </label>
          <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Check this button to order to disable user profile links on their image and name.', 'everest-google-places-reviews'); ?>
                </div>
         </div>
    </div>

     <div class="egpr-type-field">
          <label for="egpr_meta_enable_ranimation"><h4><?php _e('Enable Review Animation', 'everest-google-places-reviews'); ?></h4></label>
         <label class="egpr-switch">
            <input type="checkbox" name="egpr_display_settings[enable_review_animation]" id="egpr_meta_enable_ranimation" 
                   value="true" <?php
                    if ( isset($enable_review_animation) ) {
                        checked($enable_review_animation, 'true');
                    }
                ?>/>
             <div class="egpr-slider round"></div>
         </label>
          <div class="egpr-tooltip-description">
                <div class="egpr-description">
                   <?php _e('Check this button to enable review animation.', '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-review-animation epgr-animation">
            <label><h4><?php _e('Choose Animation', 'everest-google-places-reviews'); ?></h4></label>
            <label class="egpr-noswitch">
                 <select name="egpr_display_settings[review_animation_type]" 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($review_animation_type, $v); ?>><?php echo esc_attr(ucwords($v));?></option>
                             <?php
                               }
                           } 
                          ?>
                        </optgroup>
                    <?php } } ?>
                    </select>
            </label>
     </div>
    
    <div class="egpr-type-field">

        <label for="egpr_meta_layouttype"><h4><?php _e('Layout Type', 'everest-google-places-reviews'); ?></h4></label>
        <label class="egpr-noswitch">
            <select name="egpr_display_settings[layout_type]" class="egpr-layout-type egpr-field-selection" id="egpr_meta_layouttype">
                    <option value="list" <?php selected($layout_type, 'list'); ?>>List</option>
                    <option value="slider" <?php selected($layout_type, 'slider'); ?>>Slider</option>
            </select>
        </label>
    </div>
    <!--Grid setting section-->
    <div class="egpr-layout-setting-wrap egpr-slider-setting-wrapper">
        <div class="egpr-slider-toogle-outer-wrap egpr-toogle-outer-wrap">
            <h3>
                <?php _e('Slider Settings', 'everest-google-places-reviews'); ?>
            </h3>
            <span class="dashicons dashicons-arrow-down"></span>
        </div>
        <div class="egpr-slider-setting-inner-wrap" style="display: none;">
              <div class="egpr-type-field">
                    <label for="egpr_meta_slider_mode"><h4><?php _e('Mode', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                        <select name="egpr_display_settings[slider][mode]" class="egpr-field-selection">
                            <option value="horizontal" <?php selected($mode, 'horizontal'); ?>>Horizontal</option>                           
                            <option value="vertical" <?php selected($mode, 'vertical'); ?>>Vertical</option>
                            <option value="fade" <?php selected($mode, 'fade'); ?>>Fade</option>
                        </select>
                    </label>

                </div>
               <div class="egpr-type-field">
                    <label for="egpr_meta_speed"><h4><?php _e('Speed', 'everest-google-places-reviews'); ?></h4></label>
                    <label class="egpr-noswitch">
                     <input type="number" class="egpr_meta_speed" name="egpr_display_settings[slider][speed]"  value="<?php
                        if (isset($egpr_display_settings['slider']['speed']) && $egpr_display_settings['slider']['speed'] != '') {
                            echo esc_attr($egpr_display_settings['slider']['speed']);
                        }
                        ?>"/> <em> ms</em>
                    </label>

                </div>
             <div class="egpr-type-field">
                    <label for="egpr_meta_pause"><h4><?php _e('Pause', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                     <input type="number" class="egpr_meta_pause" name="egpr_display_settings[slider][pause]"  value="<?php
                         if (isset($egpr_display_settings['slider']['pause']) && $egpr_display_settings['slider']['pause'] != '') {
                            echo esc_attr($egpr_display_settings['slider']['pause']);
                        }
                        ?>"/> <em> ms</em>
                    </label>

                </div>
             <div class="egpr-type-field">
                    <label for="egpr_meta_slider_pager"><h4><?php _e('Pager', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                          <select name="egpr_display_settings[slider][pager]" class="egpr_slider_pager_type egpr-field-selection">
                            <option value="true" <?php selected($pager_show, 'true'); ?>>True</option>                           
                            <option value="false" <?php selected($pager_show, 'false'); ?>>False</option>
                        </select>
                    </label>

              </div>
            <div class="pager_type_preview" <?php if($pager_show != "true") echo 'style="display:none;"';?>>
                <div class="egpr-type-field">
                    <label for="egpr_meta_slider_pager_type"><h4><?php _e('Pager Type', 'everest-google-places-reviews'); ?></h4></label>
                    <label class="egpr-noswitch">
                          <select name="egpr_display_settings[slider][pager_type]" class="egpr-field-selection">
                              <option value="pagination"<?php selected($pager_type, 'pagination'); ?>><?php _e('Pagination Type', 'everest-google-places-reviews'); ?></option>                           
                              <option value="dot" <?php selected($pager_type, 'dot'); ?>><?php _e('Dot Type', 'everest-google-places-reviews'); ?></option>
                        </select>
                    </label>
                 </div>
           
            </div>
            <div class="egpr-type-field">
                    <label for="egpr_meta_slider_autoplay"><h4><?php _e('Autoplay', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                         <select name="egpr_display_settings[slider][autoplay]" class="egpr-field-selection">
                            <option value="true" <?php selected($autoplay, 'true'); ?>>True</option>                           
                            <option value="false" <?php selected($autoplay, 'false'); ?>>False</option>
                        </select>
                    </label>

             </div>
               <div class="egpr-type-field">
                    <label for="egpr_meta_slider_adaptive_height"><h4><?php _e('Adjactive Height', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                         <select name="egpr_display_settings[slider][adaptive_height]" class="egpr-field-selection">
                            <option value="true" <?php selected($adaptive_height, 'true'); ?>>True</option>                           
                            <option value="false" <?php selected($adaptive_height, 'false'); ?>>False</option>
                        </select>
                    </label>

             </div>
             <div class="egpr-type-field">
                    <label for="egpr_meta_slider_controls"><h4><?php _e('Controls', 'everest-google-places-reviews'); ?></h4></label>
                     <label class="egpr-noswitch">
                        <select name="egpr_display_settings[slider][controls]" class="egpr-field-selection slider_controls_show">
                            <option value="false" <?php selected($controls, 'false'); ?>>False</option>
                            <option value="true" <?php selected($controls, 'true'); ?>>True</option>
                        </select>
                    </label>

                </div>
              <div class="controls_type_preview" <?php if($controls != "true") echo 'style="display:none;"';?>>
                <div class="egpr-type-field">
                    <label for="egpr_meta_slider_controls_type"><h4><?php _e('Controls Type', 'everest-google-places-reviews'); ?></h4></label>
                    <label class="egpr-noswitch">
                        <select name="egpr_display_settings[slider][controls_type]" class="slider_controls_type egpr-field-selection">
                              <option value="arrow" <?php selected($controls_type, 'arrow'); ?>><?php _e('Arrow Type', 'everest-google-places-reviews'); ?></option>                           
                            <option value="text" <?php selected($controls_type, 'text'); ?>><?php _e('Text Type', 'everest-google-places-reviews'); ?></option>
                        </select>
                    </label>
                 </div>
            </div>

           
        </div>
    </div>
   </div>
</div>