<?php
// ##############################################################

if (!empty($TYPE) && !empty($ID_ITEM)) {
    if (empty($_SESSION['printCenter'][$SET]['start'])) {
        $_SESSION['printCenter'][$SET]['start'] = 1;
    }
    if (isset($_REQUEST['changeStart'])) {
        $_SESSION['printCenter'][$SET]['start'] = intval($_REQUEST['changeStart']);
    }

    $class_order = new Orders($ID_ITEM);
    $html = $class_order->getOrder(true, true);
    $order = $class_order->getOrderValues();

    // ------------------------------------------------------
    $cena = roundPrice($order['total_price']);
    $dobirka = '='.number_format($cena, 2, ',', '').'=';

    // PROVIDER
    $odesilatel_firma = $GLOBALS['dbcfg']['shop_firm_name'];
    $odesilatel = $GLOBALS['dbcfg']['shop_address'];

    // DORUCOVACI UDAJE
    $prijemce[0] = $order['delivery_name'].' '.$order['delivery_surname'];
    if (!empty($order['delivery_name'])) {
        $prijemce[] = "\t".$order['delivery_firm'];
    }
    if (!empty($order['delivery_street'])) {
        $prijemce[] = $order['delivery_street'];
    }
    if (!empty($order['delivery_city'])) {
        $prijemce[] = $order['delivery_city'];
    }
    if (!empty($order['delivery_zip'])) {
        $prijemce[] = $order['delivery_zip'];
    }
    // if(!empty($order['delivery_country']))
    // $prijemce[] = $order['delivery_country'];

    $cena = roundPrice($order['total_price']);
    $cena_format = showPrice($order['total_price'], 0, 0, true, true, true);
    $cena_slova = ucfirst($this->prepisSlovne(number_format($cena, 0, '', ''))); ?>

   <div class="printHidden">
      <form method="post" action="launch.php?s=printCenter.php&type=<?php echo $TYPE; ?>&ID=<?php echo $ID_ITEM; ?>&set=<?php echo $SET; ?>">
         <select name="changeStart">
             <?php
             for ($x = 1; $x <= 6; $x++) {
                 echo '<option value="'.$x.'"'.checkSelect($_SESSION['printCenter'][$SET]['start'] + 1, $x).'>'.htmlspecialchars($x).'</option>';
             } ?>
         </select>
         <input class="button" type="submit" value="Posunout tištěnou řádku"/>
      </form>
   </div>
    <?php
    $no = $_SESSION['printCenter'][$SET]['start'];
    $posTop = (($no - 1) * 16.6);
    // if($no > 1) $posTop += 1;
    $posTopMM = (($no - 1) * 47);
    unset($no); ?>

   <style type="text/css" media="all">

      BODY {
         margin: 0;
         padding: 0;
      }

      #Stitky_2x6 {
         width: 817px;
         height: 1175px;
         margin-top: 16px;
         position: relative;
         border: 1px solid #DDD;
      }

      #s2x6_1, #s2x6_2 {
         position: absolute;
         overflow: hidden;
         top: <?php echo $posTop; ?>%;
         width: 405px;
         height: 185px;
      }

      #s2x6_1 {
         left: 0px;
         border-right: 1px solid #DDD;
      }

      #s2x6_2 {
         left: 410px;
      }

      .kolonka {
         background-color: transparent;
         border: 0;
         text-align: left;
         margin: 0;
      }

      .odesilatel_1 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
         overflow: hidden;
         width: 365px;
         margin: 20 20px 0 20px;
      }

      .prijemce_1 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
         overflow: hidden;
         width: 365px;
         margin: 20 20px 0 20px;
      }

      .prijemce_2,
      .odesilatel_2 {
         font-family: Arial, Helvetica, sans-serif;
         font-weight: bold;
         overflow: hidden;
         width: 365px;
         height: 150px;
         margin: 5px 20px 20px 20px;
      }

      .vel_pismo1 {
         font-size: 14px
      }

      .vel_pismo2 {
         font-size: 20px
      }

      .vel_pismo3 {
         font-size: 17px
      }

      @media print {
         @page {
            margin: 0cm;
            padding: 0cm;
            page-break-after: avoid;
         }

         BODY {
            margin: 0;
            padding: 0;
            background-color: white;
         }

         #Stitky_2x6 {
            background: white;
            border: 0;
            width: auto;
            height: auto;
            page-break-inside: avoid;
            margin-top: 8mm;
         }

         #Stitky_2x6 DIV {
            border: 0;
            page-break-after: avoid;
         }

         #s2x6_1, #s2x6_2 {
            top: <?php echo $posTopMM; ?>mm;
            width: 105mm;
            height: 48mm;
         }

         #s2x6_1 {
            left: 0mm;
            border-right: 0;
         }

         #s2x6_2 {
            left: 105mm;
         }

         .odesilatel_1 {
            margin: 5mm 5mm 0 5mm;
            width: 95mm;
         }

         .prijemce_1 {
            margin: 8mm 5mm 0 5mm;
            width: 95mm;
         }

         .odesilatel_2, .prijemce_2 {
            margin: 1mm 5mm 5mm 5mm;
            width: 95mm;
            height: 43mm;
         }
      }

   </style>

   <div id="Stitky_2x6">

      <div id="s2x6_1">
         <input class="kolonka odesilatel_1 vel_pismo2" type="text" name="textfield" maxlength=""
                value="<?php echo htmlspecialchars($odesilatel_firma); ?>"/>
         <textarea class="kolonka odesilatel_2 vel_pismo1" wrap="hard"><?php
             echo htmlspecialchars($odesilatel);
    echo "\n";
    echo "\n";
    echo "Dobírka:\t".$cena_format;
    echo "\n";
    echo "Slovy:\t".wordwrap($cena_slova, 35, "\n\t", 1);
    echo "\n";
    echo "Cena:\t".$cena_format; ?></textarea>
      </div>

      <div id="s2x6_2">
         <input class="kolonka prijemce_1 vel_pismo2" type="text" name="textfield" maxlength=""
                value="<?php echo htmlspecialchars($prijemce[0]); ?>"/>
         <textarea class="kolonka prijemce_2 vel_pismo3" wrap="hard"><?php
             for ($x = 1; $x < count($prijemce); $x++) {
                 echo $prijemce[$x]."\n";
             } ?></textarea>
      </div>

   </div>

    <?php
}

// ################################################
?>
