<style>
    .html,body {
        margin:0;
        padding:0;
    }
    .file_content {
        color: #233266;
        font-family: sans-serif;
        padding:100px 0 30px;
        background: #f5f6fa;
    }
    .file_content .half_width {
        float: left;
        width: 50%;
    }

    .file_header {
        overflow: hidden;
    }

    .ft-table, .ft_infos, .ft_tolerance {
        margin:50px;
    }

    .ft-table-content {
        margin-top: 30px;
    }
    .ft-table-content span{
        background: #adb4ce;
        width: 100%;
        display: block;
        text-align: center;
        height: 30px;
        line-height: 30px;
        font-weight: bold;
        font-size: 14px;
    }


    .ft-table-content table {
        width: 100%;
        text-align: center;
        border: 1px solid #ccc;
        color: #233266;
    }
    .ft-table-content thead {
        background:#d6dae6 
    }

    .ft-table-content th, .ft-table-content td{
        height: 30px;
    }


    .thumb_var img {
        max-width: 400px;
        max-height: 400px;
        padding-right: 100px;
        float: right;
    }

    .gallery-item {
        float: left;
        margin:5px;

    }
    .gallery-item img{
        width: 55px;
        height: 55px;
    }

    figcaption {
        display: none;
    }

    .bleu_zone {
        clear: both;
        background: #304682;
        color: #fff;
        overflow: hidden;
        margin: 50px 0;
    }

    .bleu_zone .half_width:first-child {
        position: relative;
        left: 100px
    }

    .ft-title {
        font-size: 20px;
        font-style: italic;
        height: 40px;
        border-bottom: 2px solid #ccc;
        font-weight: bold;
        color: #233266;
    }

    .ft_footer {
        border-top: 2px solid #ccc;
        padding-top: 30px;
        padding-left: 50px;
    }
</style>
<?php
/**
 * Template Name: Fiche technique
 *
 */
$variation_id = $_GET['variation_id'];
$code_variation = nap_load_variation_settings_fields($variation_id);
$fiche_id = $code_variation['var_fiche'];

$variable_product = wc_get_product($variation_id);
$product_title = $variable_product->get_title();
$product_infos = get_page_by_title($product_title, OBJECT, 'product');

// titre = Catégorie + sous catégorie + format + tag 
$file_title = "";
$product_cats = array_reverse(wp_get_post_terms($product_infos->ID, 'product_cat'));
foreach ($product_cats as $key => $value) {
    $file_title.=" " . $value->name;
}

$product = wc_get_product($product_infos->ID);
$tags = $product->get_tag_ids();

$file_title.="<br/>" . $variable_product->get_attribute('format') . " " . get_tag($tags[0])->name;





echo $file_content = "<html>
<head><title>" . $file_title . "</title>
    
</head>    
<body><div class='file_content'>
    <div class='file_header'>
        <div class='half_width thumb_var'>
        " . $thumb_image = get_the_post_thumbnail($variation_id, 'large') . "
         </div>
        <div class='half_width'>
            <h1>" . $file_title . "</h1>
            <span class='variation_color'><strong><em>Couleur </em>: " . $variable_product->get_attribute('couleur') . "</strong></span>
            " . nap_get_content($fiche_id) . "
        </div>
        </div>
        <div class='bleu_zone'>
            <div class='half_width'>
                <p>Code article : " . $code_variation['var_code'] . "</p>
                <p>Gencod : " . $code_variation['var_gencod'] . "</p>
                <p>ITF 14 : " . $code_variation['var_itf14'] . "</p>

            </div>

            <div class='half_width'>
                <p>Nomenclature douanière : " . get_field('ft_nomenclature_douaniere', $fiche_id) . "</p>
                <p>Pays origine : " . get_field('ft_pays_dorigine', $fiche_id) . "</p>
                <p>Labélisation : " . get_field('ft_labelisation', $fiche_id) . "</p>
            </div>
        </div>
        <div class='ft-table'>
            <div class='ft-title'>
                <span>Unité :</span>
            </div>
            <div class='ft-table-content'>
                <span>DIMENSIONS (1)</span>
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Épaisseur (cm)</th>
                            <th>Capacité (cm)</th>
                            <th>Poids (g)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>" . get_field('ft_unite_L1', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_l2', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_H', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_epaisseur', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_capacite', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_poids', $fiche_id) . "</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class='ft-table-footer'>
                <p><strong>Matière :</strong>" . get_field('ft_matiere_du_produit', $fiche_id) . "</p>
                <p><strong>Nombre de pli :</strong>" . get_field('ft_nb_de_plis', $fiche_id) . "</p>
                <p><strong>Grammage :</strong>" . get_field('ft_grammage', $fiche_id) . "</p>
            </div>
       
     </div>
     
    <div class='ft-table'>
            <div class='ft-title'>
                <span>UVC :</span>
            </div>
            <div class='ft-table-content'>
                <span>DIMENSIONS (1)</span>
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Poids net (g)</th>
                            <th>Poids brut (g)</th> 
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>" . get_field('ft_uvc_L1', $fiche_id) . "</td>
                            <td>" . get_field('ft_uvc_l2', $fiche_id) . "</td>
                            <td>" . get_field('ft_uvc_H', $fiche_id) . "</td>
                            <td>" . get_field('ft_uvc_poids_net', $fiche_id) . "</td>
                            <td>" . get_field('ft_uvc_poids_brut', $fiche_id) . "</td>
                           
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class='ft-table-footer'>
                <p><strong>Nombre d'unité/UVC :</strong>" . get_field('ft_nombre_dunite_uvc', $fiche_id) . "</p>
               
            </div>
       
     </div>
     
     <div class='ft-table'>
            <div class='ft-title'>
                <span>Colis :</span>
            </div>
            <div class='ft-table-content'>
                <span>DIMENSIONS (1)</span>
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Volume (cm3)</th>
                            <th>Poids net (g)</th>
                            <th>Poids brut (g)</th> 
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>" . get_field('ft_colis_L1', $fiche_id) . "</td>
                            <td>" . get_field('ft_colis_l2', $fiche_id) . "</td>
                            <td>" . get_field('ft_colis_H', $fiche_id) . "</td>
                            <td>" . get_field('ft_colis_volume', $fiche_id) . "</td>
                            <td>" . get_field('ft_colis_poids_net', $fiche_id) . "</td>
                            <td>" . get_field('ft_colis_poids_brut', $fiche_id) . "</td> 
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class='ft-table-footer'>
                <p><strong>Nombre d’UVC / colis :</strong>" . get_field('ft_nombre_duvc_colis', $fiche_id) . "</p>
               
            </div>
       
     </div>
     <div class='ft-table'>
            <div class='ft-title'>
                <span>Palette :</span>
            </div>
            <div class='ft-table-content'>
                <span>DIMENSIONS (1)</span>
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Volume (cm3)</th>
                            <th>Poids brut (g)</th> 
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>" . get_field('ft_palette_L1', $fiche_id) . "</td>
                            <td>" . get_field('ft_palette_l2', $fiche_id) . "</td>
                            <td>" . get_field('ft_palette_H', $fiche_id) . "</td>
                            <td>" . get_field('ft_palette_volume', $fiche_id) . "</td>
                            <td>" . get_field('ft_palette_poids_brut', $fiche_id) . "</td>
                             
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class='ft-table-footer'>
                <p><strong>Nombre de colis à la couche :</strong>" . get_field('ft_nombre_de_colis_a_la_couche', $fiche_id) . "</p>
                <p><strong>Nombre de couches :</strong>" . get_field('ft_nombre_de_couche', $fiche_id) . "</p>    
                <p><strong>Nombre de colis / palette :</strong>" . get_field('ft_nombre_de_colis_palette', $fiche_id) . "</p>
                <p><strong>Type de palette :</strong>" . get_field('ft_type_de_palette', $fiche_id) . "</p>
            </div>
      
     </div>
     <div class='ft_infos'> 
         <div class='ft-title'>
                <span>Plus d’informations :</span>
         </div>
     " . get_field('ft_plus_dinformations', $fiche_id) . " 
         </div>
     <div class='ft_tolerance'> " . get_field('ft_tolerance', $fiche_id) . "</div>
     <div class='ft_footer'>
        <span class=ft_date>Mise à jour le " . date('d/m/Y', time()) . "</span>
     " . get_field('ft_footer', $fiche_id) . "
     </div>
   
</div>
<body></html>";