<?php

class labelTemplate extends label{

	/**
	 * Template d'impression �tiquette
	 */
    
	function template($x, $y, $dataPrint){

           
            // define barcode style
$style = array(
    'position' => '',
    'align' => 'C',
    'stretch' => false,
    'fitwidth' => false,
    'cellfitalign' => '',
    'border' => false,
    'hpadding' => 'auto',
    'padding' => 'auto',
    'vpadding' => 'auto',
    'fgcolor' => array(0,0,0),
    'bgcolor' => false, //array(255,255,255),
    'text' => true,
    'font' => 'courier',
    'vertical space' => 0,
    'fontsize' =>8,
    'stretchtext' => false
);



            
	$x += $this->labelMargin;
	$y += $this->labelMargin;
	 
		// Etiquette
		$aff_border = 0;
		$ref_font = max($this->labelWidth, $this->labelHeight);
		$des_font = 0.5* min($this->labelWidth, $this->labelHeight);

                
                
                 $this->SetFillColor(255, 255, 255);
                  
                $m=0;
                
               foreach ($dataPrint as $key) {

                   
                   if (!array_key_exists('barcode', $key))
                   {
                       
                       
                    if(array_key_exists('fname', $key))
                    {$fname = strval($key['fname']);}
                    else { $fname="dejavusans"; }
                       
                       if(array_key_exists('fstyle', $key))
                    {$fstyle = strval($key['fstyle']);}
                    else { $fstyle=""; }
                    
                    
                    
                       $this->SetFont($fname, $fstyle, strval($key['size']) * $des_font);

                       $this->setXY($key['x']+$x,$key['y']+$y);
                       
                       $cellwidth = strval($this->labelWidth) - strval($this->labelMargin) - strval($key['x']);
                       $this->MultiCell($cellwidth, 5, $key['value'], 0, $key['align'], 1, 2, '' ,'', true);
                       
                       

                   }
                   else
                   {
                       if(isset($key['text']) && $key['text']=='false'){
                           $style["text"]=false;
                       }

                $bsize  = explode(".", $key['size']);
                $this->setXY($key['x']+$x,$key['y']+$y);
                
                
                
                $this->write1DBarcode($key['barcode'], $key['type'], '', '',$bsize[0], $bsize[1], 1, $style, 'N');

                   }
                       $m+=1;                   
                }
                
                
	}

}//End of class labels

?>