<?php 
   /*
      Type: post_archive_layout
   */
   use Elementor\Plugin;
   $type = 'post_archive_layout';
   $title = esc_html__('New Post Archive Template', 'sominx-themer');
?>
<div class="gva-template-layout">
   <h3><?php echo esc_html__('Post Archive Templates', 'sominx-themer') ?></h3>
   <div class="list-template-layout">
      <div class="item heading">
         <div class="state"><?php echo esc_html__('State', 'sominx-themer') ?></div>
         <div class="name"><?php echo esc_html__('Name', 'sominx-themer') ?></div>
         <div class="header"><?php echo esc_html__('Choose Header', 'sominx-themer') ?></div>
         <div class="footer"><?php echo esc_html__('Choose Footer', 'sominx-themer') ?></div>
         <div class="action" style="text-align: right;"><?php echo esc_html__('Actions', 'sominx-themer') ?></div>
      </div>
      <?php foreach ($this->get_templates($type) as $item) { ?>
         <?php
            $header_value = get_post_meta( $item['id'], 'header_layout', true );
            $footer_value = get_post_meta( $item['id'], 'footer_layout', true );
            $default = get_post_meta( $item['id'], '_gva_set_default', true );
            $state = ($default == 'enabled') ? 'active' : '';
         ?>
         <div class="item" data-type="<?php echo $type ?>">
            <div class="state">
              <a class="btn-set-config-state <?php echo esc_attr($state) ?>" title="<?php echo esc_attr('Active Default', 'sominx-theme') ?>" href="#" data-id="<?php echo $item['id'] ?>" data-type="<?php echo $type ?>"><i class="dashicons-before dashicons-marker"></i><span class="text">Active</span></a>
            </div>
            <div class="name"><?php echo $item['title'] ?></div>
            <div class="header checkboxs"><?php $this->get_checkboxs_header_footer('header_layout', $item['id'], $header_value) ?></div>
            <div class="footer checkboxs"><?php $this->get_checkboxs_header_footer('footer_layout', $item['id'], $footer_value) ?></div>
            <div class="action">
               <a target="_bank" href="<?php echo Plugin::$instance->documents->get( $item['id'] )->get_edit_url() ?>" title="<?php echo esc_attr__('Edit', 'sominx-themer') ?>">
                  <i class="dashicons-before dashicons-edit"></i>
               </a> 
               <a target="_bank" href="<?php the_permalink($item['id']) ?>" title="<?php echo esc_attr__('View', 'sominx-themer') ?>">
                  <i class="dashicons dashicons-welcome-view-site"></i>
               </a>

               <a class="template-layout-dulipcate" data-post_id="<?php echo $item['id'] ?>" data-language="" href="#" title="<?php echo esc_attr__('Duplicate', 'sominx-themer') ?>">
                  <i class="dashicons dashicons-admin-page"></i>
               </a>
               <?php $languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' ); ?>
               <?php if($languages && count($languages) > 1){ ?>
                  <?php 
                     foreach ($languages as $language){
                        if(!$language['active']){
                           echo '<a class="template-layout-dulipcate dulipcate-width-language" data-post_id="'.$item['id'].'" data-language="'.$language['code'].'" href="#" title="' . esc_attr('Duplicate to ', 'sominx-themer') . $language['code'] . '">';
                              echo '<i class="dashicons dashicons-admin-page"></i>' . $language['code'];
                           echo '</a>';
                        }
                     }
                  ?>
               <?php } ?>
               <a class="template-layout-delete" href="#" data-post_id="<?php echo $item['id'] ?>"><i class="dashicons dashicons-trash"></i></a>
            </div>
         </div> 
      <?php } ?>
   </div>
   <p><a class="button-primary template-layout-add-new" data-type="<?php echo $type ?>" data-title="<?php echo $title ?>" href="#">
      <?php echo esc_html__('+ Add New', 'sominx-themer') ?>
   </a></p>
</div>