<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$formname = 'Label Print';
$font_size = "2px";
$barcode_width = "155px";
$barcode_height = "20px";

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$zroot = $_SESSION["zdbroot"];

$descrip = $_POST["descrip"];
$noline = $_POST["noline"];

?>

<html>

<head>
    <title><?= $formname ?></title>
    <style type="text/css">
        table {
            page-break-inside: auto
        }

        tr {
            page-break-inside: avoid;
            page-break-after: auto
        }

        thead {
            display: table-header-group
        }

        tfoot {
            display: table-footer-group
        }

        table {
            table-layout: fixed;
            width: 100%;
            margin-left: 1px;
            margin-bottom: 1px;
        }

        td.one {
            width: 20%;
            border: 0px solid black;
        }

        @media print {

            /* Remove margins and padding from the body */
            body {
                margin: 0 !important;
                padding: 0 !important;
                margin-top: 0px !important;
                margin-left: 7px !important;
                /* height: 310mm; */
            }

            /* Target specific elements if needed */
            * {
                margin: 0 !important;
                padding: 0 !important;
                box-sizing: border-box;
                /* Ensures consistent box sizing */
            }


            td {
                margin: 0 !important;
                padding: 0 !important;
                border-spacing: 0 !important;
                border-collapse: collapse !important;
                /* padding-left: 7mm !important; */
                /* Ensures no extra space due to borders */
            }


            table {
                margin: 0 !important;
                padding: 0 !important;
                border-spacing: 0 !important;
                /* Removes spacing between cells */
                border-collapse: collapse !important;
                /* Merges borders and removes gaps */

            }
        }
    </style>

</head>

<body>
    <?php
    $ctr = 0;
    $breaker = 1;
    $line = 1;
    $location = '';

    echo "<table border='0' align='left' style ='' class='sktable'>";
    
    for ($i = 1; $i <= $noline; $i++) {

        $ctr++;
        $line++;
        echo "<tr>";
        echo "<td style='width: 39mm;height:13.1mm; padding-left:7mm !important;'><span style='font-size:14px'>$descrip</span></td>";
        echo "<td style='width: 39mm;height:13.1mm;'><span style='font-size:14px'>$descrip</span></td>";
        echo "<td style='width: 39mm;height:13.1mm;'><span style='font-size:14px'>$descrip</span></td>";
        echo "<td style='width: 39mm;height:13.1mm;'><span style='font-size:14px'>$descrip</span></td>";
        echo "<td style='width: 39mm;height:13.1mm;'><span style='font-size:14px'>$descrip</span></td>";
        echo "</tr>";
    }

    echo "</table>";

    ?>
</body>

</html>