fiche-technique.php 12 KB
Newer Older
Nahla Shiri's avatar
Nahla Shiri committed
1 2 3 4 5 6
<?php

/**
 * Template Name: Fiche technique
 *
 */
7
$nfiles = glob("fiches-techniques/[!\\.]*");
Nahla Shiri's avatar
Nahla Shiri committed
8 9 10 11 12 13 14 15 16 17

if ($nfiles !== FALSE) {

    $nb_fiche = count($nfiles) + 1;
} else {

    $nb_fiche = 1;
}

$fiche_num = str_pad($nb_fiche, 6, "0", STR_PAD_LEFT);
18
$product_id = $_GET['product_id'];
Nahla Shiri's avatar
Nahla Shiri committed
19 20
$variation_id = $_GET['variation_id'];
$file_title = "";
imac's avatar
imac committed
21 22 23 24
$parent_cat = wp_get_post_terms($product_id, 'product_cat', array( 'parent' => 0,'fields' => 'ids' ));
$sub_cat = wp_get_post_terms($product_id, 'product_cat', array( 'parent' =>$parent_cat[0],'fields' => 'names' ));

$file_title.=$sub_cat[0];
25 26 27 28 29 30 31 32 33 34 35 36 37 38

//fiche variable
if($variation_id !='undefined'){
    $code_variation = nap_load_variation_settings_fields($variation_id);
    $fiche_id = $code_variation['var_fiche'];
    $sku = nap_variable_meta($variation_id, 'sku');
    $gencod = $code_variation['var_gencod'];
    $itf14 = $code_variation['var_itf14'] ;
    $variable_product = wc_get_product($variation_id);
    $thumb_image = get_the_post_thumbnail($variation_id, 'medium');
    
    $file_title.="<br/>" . $variable_product->get_attribute('format') . " " . get_the_title($product_id);
    $color="<span class='variation_color'><strong><em>Couleur </em>: " . $variable_product->get_attribute('couleur') . "</strong></span>";
}
Nahla Shiri's avatar
Nahla Shiri committed
39

40 41 42 43 44 45 46 47 48 49 50 51
//fiche simple
else {
    
 $fiche_id = get_post_meta($product_id, '_fiche_simple', true); 
 $sku = get_post_meta($product_id, '_sku',true);
 $gencod = get_post_meta($product_id, '_gencod_simple', true); 
 $itf14 = get_post_meta($product_id,'_itf14_simple', true);
 $thumb_image = get_the_post_thumbnail($product_id, 'medium');
 
 $file_title.="<br/>" . get_the_title($product_id);
 
}
Nahla Shiri's avatar
Nahla Shiri committed
52 53 54 55 56 57 58 59 60 61 62 63 64



$icones = "";

if (get_field('fiche_icones', $fiche_id)):

    while (has_sub_field('fiche_icones', $fiche_id)) :
        $img = get_sub_field('fiche_icone', $fiche_id);
        $icones.= wp_get_attachment_image($img, 'shop_thumbnail');

    endwhile;
endif;
65
$file_content = "<html>
Nahla Shiri's avatar
Nahla Shiri committed
66 67
<head><title>" . $file_title . "</title>
  <style>
imac's avatar
imac committed
68 69 70
    .html,body {
        margin:0;
        padding:0;
Nahla Shiri's avatar
Nahla Shiri committed
71
        background: #f5f6fa;
imac's avatar
imac committed
72
    }
Nahla Shiri's avatar
Nahla Shiri committed
73
    .file_content, table, th,td {
imac's avatar
imac committed
74 75
        color: #233266;
        font-family: sans-serif;
Nahla Shiri's avatar
Nahla Shiri committed
76 77 78
        
        
        
imac's avatar
imac committed
79 80
    }
    .file_content .half_width {
Nahla Shiri's avatar
Nahla Shiri committed
81
        float: left ;
imac's avatar
imac committed
82 83 84 85 86
        width: 50%;
    }

    .file_header {
        overflow: hidden;
Nahla Shiri's avatar
Nahla Shiri committed
87
        padding: 0 30px;
imac's avatar
imac committed
88 89 90
    }

    .ft-table, .ft_infos, .ft_tolerance {
Nahla Shiri's avatar
Nahla Shiri committed
91
        margin:30px;
imac's avatar
imac committed
92 93 94 95 96
    }

    .ft-table-content {
        margin-top: 30px;
    }
Nahla Shiri's avatar
Nahla Shiri committed
97
    .ft-table-content p{
imac's avatar
imac committed
98 99 100 101 102 103 104 105
        background: #adb4ce;
        width: 100%;
        display: block;
        text-align: center;
        height: 30px;
        line-height: 30px;
        font-weight: bold;
        font-size: 14px;
Nahla Shiri's avatar
Nahla Shiri committed
106
        margin-bottom:0
imac's avatar
imac committed
107 108 109 110 111 112 113 114 115
    }


    .ft-table-content table {
        width: 100%;
        text-align: center;
        border: 1px solid #ccc;
        color: #233266;
    }
Nahla Shiri's avatar
Nahla Shiri committed
116 117
    .ft-table-content thead th {
        background-color:#d6dae6 
imac's avatar
imac committed
118 119 120 121 122 123 124 125 126
    }

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


    .thumb_var img {
        padding-right: 100px;
127 128
        
        
imac's avatar
imac committed
129 130 131 132 133 134 135 136
    }

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

    }
    .gallery-item img{
Nahla Shiri's avatar
Nahla Shiri committed
137 138
        width: 55px !important;
        height: 55px !important;
imac's avatar
imac committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    }

    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;
    }
Nahla Shiri's avatar
Nahla Shiri committed
172
</style>  
imac's avatar
imac committed
173 174 175
</head>    
<body><div class='file_content'>
    <div class='file_header'>
176 177
        <div class='half_width thumb_var' style='text-align:center'>
        " . $thumb_image. "
imac's avatar
imac committed
178
         </div>
179
        <div class='half_width' style='margin-left:20px;'>
imac's avatar
imac committed
180
            <h1>" . $file_title . "</h1>
181
            ".$color."
imac's avatar
imac committed
182
            " . nap_get_content($fiche_id) . "
Nahla Shiri's avatar
Nahla Shiri committed
183
                <div>" . $icones . "</div>
imac's avatar
imac committed
184 185 186
        </div>
        </div>
        <div class='bleu_zone'>
Nahla Shiri's avatar
Nahla Shiri committed
187
            <div class='half_width' style='position:relative; padding-left:30px'>
188 189 190
                <p>Code article : " . $sku . "</p>
                <p>Gencod : " . $gencod. "</p>
                <p>ITF 14 : " . $itf14 . "</p>
imac's avatar
imac committed
191 192 193

            </div>

Nahla Shiri's avatar
Nahla Shiri committed
194
            <div class='half_width' style='width:40%'>
imac's avatar
imac committed
195 196 197 198 199 200 201 202 203 204
                <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'>
Nahla Shiri's avatar
Nahla Shiri committed
205
                <p>DIMENSIONS (1)</p>
imac's avatar
imac committed
206 207 208 209 210 211
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
212
                            <th>Ø (cm)</th>
imac's avatar
imac committed
213 214
                            <th>Épaisseur (cm)</th>
                            <th>Capacité (cm)</th>
215
                            <th>Taille</th>
imac's avatar
imac committed
216 217 218 219 220 221 222 223
                            <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>
224
                            <td>" . get_field('ft_unite_diametre', $fiche_id) . "</td>
imac's avatar
imac committed
225 226
                            <td>" . get_field('ft_unite_epaisseur', $fiche_id) . "</td>
                            <td>" . get_field('ft_unite_capacite', $fiche_id) . "</td>
227
                            <td>" . get_field('ft_unite_taille', $fiche_id) . "</td>
imac's avatar
imac committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
                            <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'>
Nahla Shiri's avatar
Nahla Shiri committed
246
               <p>DIMENSIONS (1)</p>
imac's avatar
imac committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
                <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'>
Nahla Shiri's avatar
Nahla Shiri committed
281
               <p>DIMENSIONS (1)</p>
imac's avatar
imac committed
282 283 284 285 286 287 288
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Volume (cm3)</th>
imac's avatar
imac committed
289 290
                            <th>Poids net (Kg)</th>
                            <th>Poids brut (Kg)</th> 
imac's avatar
imac committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
                        </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'>
Nahla Shiri's avatar
Nahla Shiri committed
316
                <p>DIMENSIONS (1)</p>
imac's avatar
imac committed
317 318 319 320 321 322 323
                <table>
                    <thead>
                        <tr>
                            <th>L (cm)</th>
                            <th>l (cm)</th>
                            <th>H (cm)</th>
                            <th>Volume (cm3)</th>
imac's avatar
imac committed
324
                            <th>Poids brut (Kg)</th> 
imac's avatar
imac committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
                        </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>";
Nahla Shiri's avatar
Nahla Shiri committed
361 362 363 364 365 366 367
include("mpdf/mpdf.php");

$mpdf=new mPDF('utf-8', 'Letter', 0, '', 0, 0, 20, 20, 0, 0); 

$mpdf->WriteHTML($file_content);

$mpdf->Output('fiches-techniques/fiche-'.$fiche_num.'.pdf');
imac's avatar
imac committed
368
$pdf ='/fiches-techniques/fiche-'.$fiche_num.'.pdf';
Nahla Shiri's avatar
Nahla Shiri committed
369 370
header('Location:'.$pdf );