<?php  $labelWidth = "370px"; ?>
<?php  $labelHeight = "148px"; ?>
<?php  $breakLineNumber = 6; ?>
<?php  $breakColumnNumber = 2; ?>
<?php  $pageOrientation = ""; ?>
<?php  $fontSize = "30px"; ?>
<?php  $fontWeight = "normal"; ?>
<?php  $cssPrint = "margin:10mm 4mm 10mm 4mm;"; ?>

<?php if($labelType == '1perPage'): ?>
    <?php  $labelWidth = "960px"; ?>
    <?php  $labelHeight = "600px"; ?>
    <?php  $breakLineNumber = 1; ?>
    <?php  $breakColumnNumber = 1; ?>
    <?php  $fontSize = "70px"; ?>
    <?php  $fontWeight = "bold"; ?>
    <?php  $cssPrint = $cssPrint . "margin:15mm 15mm 15mm 15mm; size: landscape;"; ?>
    
<?php elseif($labelType == '2perPage'): ?>
    <?php  $labelWidth = "640px"; ?>
    <?php  $labelHeight = "455px"; ?>
    <?php  $breakLineNumber = 2;; ?>
    <?php  $breakColumnNumber = 1; ?>
    <?php  $fontSize = "45px"; ?>
    <?php  $fontWeight = "bold"; ?>
    <?php  $cssPrint = $cssPrint . "margin:15mm 15mm 15mm 15mm;"; ?>
    
<?php endif; ?>
<style type='text/css' media='print'>@page  { <?php echo $cssPrint; ?> }</style>
<html>
<head>
    <title>Etiquetas</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
</head>
<?php echo $pageOrientation; ?>

<style>
    td {
        width: <?php echo $labelWidth; ?>; 
        height: <?php echo $labelHeight; ?>; 
        font-size: <?php echo $fontSize; ?>;
        font-family: "Bookman Old Style";
        border: thin dashed;
        font-weight: <?php echo $fontWeight; ?>;
        padding: 5px;
    }
    table {		
        border-collapse: collapse;		
    }
</style>

<body onload="window.print()">					
    <?php  $breakLineCounter= 0;; ?>
    <?php for($j = 0; $j < count($list); $j++): ?>
        <?php if($j == 0 || $breakLineCounter % $breakLineNumber == 0): ?> 
            <table align="center">
        <?php endif; ?>
                <tr>
                    <?php  $breakLineCounter = $breakLineCounter+ 1;; ?>
                    <?php for($k = 0; $k < $breakColumnNumber; $k++): ?>
                        <?php if($k > 0 ): ?>
                            <?php  $j = $j + 1; ?>
                        <?php endif; ?>
                        <?php if($j < count($list)): ?>
                            <td align="center">
                                <?php echo $list[$j]->product->name; ?><br>
                                <?php  $code = $list[$j]->product->code; ?>
                                <?php if($list[$j]->product->price > 10): ?>
                                    <?php  $code = $code . "-"; ?>
                                <?php endif; ?>
                                <?php  $code = $code . str_replace(array(',','.'),array('',''),$list[$j]->product->price); ?>
                                <?php echo $code; ?>

                            </td>
                        <?php else: ?>
                            <td>
                                <br>
                            </td>
                        <?php endif; ?>
                    <?php endfor; ?>
                </tr>
        <?php if($breakLineCounter % $breakLineNumber == 0 && $j+1 < count($list)): ?>
            </table> 
            <div style="page-break-before: always"></div>
	<?php endif; ?>
    <?php endfor; ?> 
</table>
</body>
<script type="text/javascript">
    alert('As etiquetas dos produtos selecionados foram geradas. Foi registrado a data/hora da geração e usuário que realizou a operação. É necessário filtrar novamente a listagem de produtos se desejar visualizar essas informações atualizadas.');
    //opener.location.reload();
</script>
</html>
