<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>

        <style type="text/css" >

            body {
                margin-left: 0px;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
            }
            .mainbarcode {
                height: 90px;
                width: 136px;
                margin: 0px;
                padding: 0px;
                margin-top: 8px;
                margin-bottom: 27px;
            }
            .price {
                width: 100px;
                float: left;

                margin-top:35px;
                margin-left:10px;

                font-size: 40px;
                font-weight:bold;
                text-align:center;
            }
            .price5 {
                /*width: 36px; */
                float: left;
                margin-top: 1px;
                margin-left: 5px;
                font-size: 13px;
                font-weight: bold;
                text-align: center;
            }
            .parcodeimage {
                float: right;
                margin-right: 0px;
                margin-top: 23px;
            }
            .barcodnum {
                float: right;
                text-align: center;
                margin-right: 8px;
                margin-left: 0px;
                margin-bottom: 10px;
                font-size: 29px;
                font-weight: bold;
                margin-top: -10px;
                font-weight: bold;
            }
            .barcodnum2 {
                float: right;
                text-align: center;
                margin-right: 8px;
                margin-left: 0px;
                margin-bottom: 10px;
                font-size: 29px;
                font-weight: bold;
                margin-top: -25px;
                font-weight: bold;
            }
            .single {
                height: 90px;
                float: right;

                width: 300px;
                border-bottom-width: medium;
                border-bottom-style: dotted;
                border-bottom-color: #000;
                margin-bottom: 5px;
                margin-top: 5px;
            }
            .single2 {
                height: 42px;
                /* float: right; */
                width: 136px;
                border-bottom-width: medium;
                border-bottom-style: dotted;
                border-bottom-color: #000;
                margin-bottom: 0px;
                margin-top: 9px;
                display: block;
                padding-right: 10px;
                position: relative;
            }
            .companyname {
                font-weight: bold;
                float: left;
                position: relative;
                font-size: 20px;
                left: -90px;
                font-family: Verdana,Geneva,sans-serif;

            }
            .single2 .companyname {
                font-weight: bold;
                float: left;
                position: absolute;
                font-size: 11px;
                bottom: 3px;
                color: #444!important;
                left: 1px;
                font-family: Verdana,Geneva,sans-serif;
            }
            .single2 .barcodnum {
                /*float: right;*/
                /*text-align: center;*/
                /*margin-right: 2px;*/
                /*margin-left: 0px;*/
                /*margin-bottom: -6px;*/
                /*font-size: 12px;*/
                /*font-weight: bold;*/
                /*margin-top: 0;*/
                /*font-weight: bold;*/
                /*position: relative;*/
                float: right!important;
                text-align: center!important;
                margin-right: 2px!important;
                margin-left: 0px!important;
                margin-bottom: -6px!important;
                font-size: 12px!important;
                font-weight: bold!important;
                margin-top: 0!important;
                font-weight: bold!important;
                position: relative!important;
            }
            .single2 .parcodeimage {
                float: right!important;
                margin-right: 0px!important;
                margin-top: 0px!important;
            }
            .single2 img{
                height: 23px!important;
                margin-top: -2px!important;
                width: 87px!important;
                float: right!important;
            }
            .single2 span{
                font-size: 9px!important;
                float: left!important;
                margin-left: 9px!important;
                font-weight: bold!important;
                margin-top: -16px!important;
                width: 67px!important;
            }
            .productname{
                /*background-color: #FFF;*/
                /*margin: 60px -14px 0px 140px;*/
                /*font-size: */<?php //echo (int) $_POST['size'];                                                                               ?>/*px;*/
                /*font-weight: bold;*/
                /*width: 200px;*/
                /*height: 20px;*/
                /*text-align: left;*/
                /*background-color: #FFF; */
                margin: 25px 0 -7px 0!important;
                font-size: 12px!important;
                font-weight: bold!important;
                /* width: 200px; */
                /* height: 20px; */
                float: right!important;
                position: absolute!important;
                display: block!important;
                text-align: right!important;
                right: 10px!important;
            }
            .productSize{
                font-size: <?php echo (int) $_POST['size']; ?>px;
            }
            .barcodnum1 {
                position: relative;
                background-color: #FFF;

                font-size: 16px;
                font-weight: bold;
                width: 100%;
                margin-top:-25px;
                left:0px;
                text-align: center;
            }
            .barcodnum11 {
                position: relative;
                background-color: #FFF;
                font-size: 16px;
                font-weight: bold;
                width: 48%;
                margin-top: -3px;
                left: -14px;
                text-align: center;
                float: right;
            }
        </style>

        <style>
            @media all {
                .page-break {
                    display: none;
                    margin:0;
                    padding:0;
                }
            }
            @media print {
                .page-break {
                    display: block;
                    page-break-before: always;
                }
            }
        </style>
        <style type="text/css" media="print">
            a{
                visibility:hidden;
                display:none;
            }
        </style>
        <style type="text/css">
            body {
                margin-left: 0px;
                margin-top: 0px;
                margin-right: 0px;
                margin-bottom: 0px;
            }
        </style>
    </head>
    <script src="../views/default/assets/js/jquery.js"></script>
    <body>
        <script>
            $(window).load(function (e) {
                //$(document).ready(function (e) {
                window.print();
                setTimeout(function () {
                    window.close();
                }, 0);
            });
        </script>
        <?php
        //define (__TRACE_ENABLED__, false);
        //define (__DEBUG_ENABLED__, false);

        require("../library/barcode/barcode.php");
        require("../library/barcode/i25object.php");
        require("../library/barcode/c39object.php");
        require("../library/barcode/c128aobject.php");
        require("../library/barcode/c128bobject.php");
        require("../library/barcode/c128cobject.php");

        //include all DAO files
        require_once('../models/sql/Connection.class.php');
        require_once('../models/sql/ConnectionFactory.class.php');
        require_once('../models/sql/ConnectionProperty.class.php');
        require_once('../models/sql/QueryExecutor.class.php');
        require_once('../models/sql/Transaction.class.php');
        require_once('../models/sql/SqlQuery.class.php');
        require_once('../models/core/ArrayList.class.php');
        require_once('../models/dao/DAOFactory.class.php');
        //Programsetting
        require_once('../models/dao/ProgramsettingsDAO.class.php');
        require_once('../models/dto/Programsetting.class.php');
        require_once('../models/mysql/ProgramsettingsMySqlDAO.class.php');
        require_once('../models/mysql/ext/ProgramsettingsMySqlExtDAO.class.php');
        $ProgramsettingDAO = new ProgramsettingsMySqlDAO();
        $programsettingsdata = $ProgramsettingDAO->load(1);

        $itr = $_POST["itr"];

        //echo $checkbx ;
        for ($i = 1; $i <= $itr; $i++) {
            //'parcode'.$i.''
            if (isset($_POST['productbarcode' . $i . '']) && !empty($_POST['productbarcode' . $i . ''])) {
                $Qty = $_POST['productnum' . $i . ''];
                $barcode = $_POST['productbarcode' . $i . ''];
                $name = $_POST['productname' . $i . ''];
                //print_r($name."<br>");
                $price = $_POST['price' . $i . ''];
                //print_r($price."<br>");
            }
        }
        $name22 = $_POST['name'];
        $userFontSize = (int) $_POST['size'];
        $xxx = $userCurrency = $_POST['currency'];
        if (empty($_POST["pricOption"])) {
            $xxx = $userCurrency = '';
        }
        // echo $name22 ;
        /* $barcode=$_GET["parcode"];
          $name=$_GET["name"];
          $price=$_GET["price"]; */
        $drawtext = "off";
        //$type = "C128B";//supports numbers, upper- and lower-case letters and some additional characters.
        // $type = "C128A"; //supports numbers, upper-case letters, and control characters, such as tab and new-line.
        $type = $settingType = $programsettingsdata->parcodeprinttype;  //"I25";
        $oddType = "C128A";
        $width = $programsettingsdata->parcodeprintwidth; //"150";
        $height = "70";
        $xres = "1";
        $font = 1; //"4";
        $output = "png";

        //$today=date("dm");
        //$barcode=$barcode.$today;
        //print($today);
        if (isset($barcode) && strlen($barcode) > 0) {
            $barcode = '22'; //just odd number .any number is ok
            $style = BCS_ALIGN_CENTER;
            $style |= ($output == "png" ) ? BCS_IMAGE_PNG : 0;
            $style |= ($output == "jpeg") ? BCS_IMAGE_JPEG : 0;
            $style |= ($border == "on" ) ? BCS_BORDER : 10;
            $style |= ($drawtext == "on" ) ? BCS_DRAW_TEXT : 0;
            $style |= ($stretchtext == "on" ) ? BCS_STRETCH_TEXT : 0;
            $style |= ($negative == "on" ) ? BCS_REVERSE_COLOR : 0;

            switch ($type) {
                case "I25":
                    $obj = new I25Object(250, 120, $style, $barcode);
                    break;
                case "C39":
                    $obj = new C39Object(250, 120, $style, $barcode);
                    break;
                case "C128A":
                    $obj = new C128AObject(250, 120, $style, $barcode);
                    break;
                case "C128B":
                    $obj = new C128BObject(250, 120, $style, $barcode);
                    break;
                case "C128C":
                    $obj = new C128CObject(250, 120, $style, $barcode);
                    break;
                default:
                    $obj = false;
            }
            //$style = 37; //this style is with border
            if ($obj) {
                if ($obj->DrawObject($xres)) {
                    $checkbx = $_POST['speparcode']; //طابعة باركود متخصصه
                    $double = $_POST['double']; //طباعة زوجية
                    $cat = $_POST['cat']; // طباعة التصنيف
                    $priceoption = $_POST["pricOption"]; //0 no price , 1 total , 2 half , 3 piece price
                    $showComp = $_POST['showComp'];
                    if ($checkbx == "1") {

                        //طباعه زوجيه + متخصصه
                        if ($double == "1") {

                            //echo '<div class="mainbarcode">	 ';
                            for ($i = 1; $i <= $itr; $i++) {

                                for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {
                                    if (($x % 2 == 0)) {

                                        echo '  <div class="mainbarcode">';
                                    }

                                    echo '
                      <div class="single2">
                            <div class="price5">';
                                    switch ($priceoption) {
                                        case 1://total
                                            echo (float) $_POST['pricenen' . $i . ''];
                                            break;
                                        case 2://half
                                            echo (float) $_POST['pricen' . $i . ''];
                                            break;
                                        case 3://piece price
                                            echo (float) $_POST['price' . $i . ''];
                                            break;
                                    }

                                    echo '</div>';
                                    if ($showComp != 1) {
                                        echo '<div class="companyname" style="color:white;"></div>'; //$name22
                                    } else {
                                        echo '<div class="companyname">' . $name22 . '</div>';
                                    }


                                    $type = $settingType;
                                    if (strlen($_POST['productbarcode' . $i . '']) % 2 == 1) {
                                        $type = $oddType;
                                    }
                                    echo '<div class="barcodnum">' . $_POST['productbarcode' . $i . ''] . '</div>
                            <div class="parcodeimage"><img style="margin-left: -116px;z-index: -1;position: absolute;" src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=' . $xres . '&font=' . $font . '">

                             </div>

                            <div class="productname">';
                                    if ($cat == "1") {
                                        echo $_POST['catname' . $i . ''] . '/';
                                    }

                                    echo $_POST['productname' . $i . ''] . '</div>

                            <span style="font-size:13px;float:left;;margin-left:0px !important;font-weight: bold;margin-top:-5px !important;z-index:9999">' . $xxx . '</span>


                    </div>
                      ';
                                    if ($x % 2 == 1) {

                                        echo '</div>';
                                    }
                                }
                            }
                        }
                        //طباعه  متخصصه
                        else {





                            //$width = 180;
                            $drawtext = "on";
                            $height = 50;

                            for ($i = 1; $i <= $itr; $i++) {
                                $comment = $_POST['commentpro' . $i];
                                $paddingTop = '25px';
                                if (isset($comment) && !empty($comment)) {
                                    $paddingTop = '5px';
                                }
                                for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {

//hazem
                                    echo '<div style="width:152px; margin-top:0px;padding-top:' . $paddingTop . ';">
             <div style="PADDING-BOTTOM: 30PX;">
<span style="width:135px;margin-left:5px;font-weight: bold;float: left;text-align: center;PADDING-BOTTOM: 44PX;" class="productSize"
>';
                                    if ($cat == "1") {
                                        echo $_POST['catname' . $i . ''] . '/';
                                    }

                                    //echo $_POST['productname' . $i . ''] . '</span></div>
                                    //<span style="font-size:20px;float:left;margin-left:2px;margin-bottom:10px;margin-top:20px;font-weight: bold;">' . $_POST['price' . $i . ''] . ' </span>
                                    //<div align="center" ><img style="" src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=1&font=2"/><div class="barcodnum11">' . $_POST['productbarcode' . $i . ''] . '</div></div>
                                    //<span style="padding-right: 28px;font-size:18px;float:left;margin-left:10px;font-weight: bold;margin-top:-55px;">' . $xxx . ' </span>';

                                    $type = $settingType;
                                    if (strlen($_POST['productbarcode' . $i . '']) % 2 == 1) {
                                        $type = $oddType;
                                    }

                                    echo $_POST['productname' . $i . ''] . '</span>

             <div align="center" ><div><img style="margin-left: -134px;position: absolute;z-index: -1;margin-top: 20px;" src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=1&font=1"/><div class="barcodnum11">' . $_POST['productbarcode' . $i . ''] . '</div>
            ';


                                    switch ($priceoption) {
                                        case 1://total
                                            echo '<span style="padding-right: 28px;font-size:18px;float:left;font-weight: bold;margin-top:-30px">' . (float) $_POST['pricenen' . $i . ''] . '</span>';
                                            break;
                                        case 2://half
                                            echo '<span style="padding-right: 28px;font-size:18px;float:left;font-weight: bold;margin-top:-30px">' . (float) $_POST['pricen' . $i . ''] . '</span>';
                                            break;
                                        case 3://piece price
                                            echo '<span style="padding-right: 28px;font-size:18px;float:left;font-weight: bold;margin-top:-30px">' . (float) $_POST['price' . $i . ''] . '</span>';
                                            break;
                                    }


                                    echo '</div>';

                                    if ($showComp != 1) {
                                        echo '<div class="companyname" style="left: 0; font-size: 15px; margin-top: -3px; color:white"></div>'; //$name22
                                    } else {
                                        echo '<div class="companyname" style="left: 0; font-size: 15px; margin-top: -3px;">' . $name22 . '</div>';
                                    }


                                    echo '<span style="padding-right: 29px;font-size:15px;float:left;font-weight: bold;margin-top:-47px;margin-left: -28px;z-index:9999">' . $xxx . ' </span>'
                                    . '</div></div><div style="visibility:hidden">/n</div>';
                                    if (isset($comment) && !empty($comment)) {
                                        echo '<div style="text-align: center;"> ' . $comment . '</div>';
                                    }
                                }
                            }
                        }
                    } else {
                        ?>
                        <link href="../views/default/assets/css/print.css" rel="stylesheet">
                            <div style="width:760px; padding-left:28px; padding-right:28px; padding-top:30px;  margin:auto; " align="center">
                                <?php
                                $xres = 1;
                                //$width = 180; //128
                                $drawtext = "on";
                                $height = 50; //75

                                for ($i = 1; $i <= $itr; $i++) {
                                    for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {
                                        echo '<div style="width:152px;float:right">
              <span style="font-size:11px;float:left;margin-left:10px;">';
                                        switch ($priceoption) {
                                            case 1://total
                                                echo (float) $_POST['pricenen' . $i . ''];
                                                break;
                                            case 2://half
                                                echo (float) $_POST['pricen' . $i . ''];
                                                break;
                                            case 3://piece price
                                                echo (float) $_POST['price' . $i . ''];
                                                break;
                                        }
                                        if ($showComp != 1) {
                                            echo '<div class="companyname" style="color:white;"></div>'; //$name22
                                        } else {
                                            echo '<div class="companyname">' . $name22 . '</div>';
                                        }
                                        echo $xxx . '
             <span style="font-size:11px;float:right;margin-right:15px;">';
                                        if ($cat == "1") {
                                            echo $_POST['catname' . $i . ''] . '/';
                                        }


                                        $type = $settingType;
                                        if (strlen($_POST['productbarcode' . $i . '']) % 2 == 1) {
                                            $type = $oddType;
                                        }
                                        echo $_POST['productname' . $i . ''] . '</span>

             <img src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=' . $xres . '&font=' . $font . '">

             <div style="float:right; margin-right:11px;margin-left:12px;padding:0px">
             </span>

    </div></div>';
                                    }
                                }
                                //print_r('pricOption'.$pricOption);
                                /* if ($priceoption != '1' && $priceoption1 != '1') {
                                  for ($i = 1; $i <= $itr; $i++) {

                                  for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {

                                  echo '<div style="width:152px;float:right"><span style="font-size:11px;float:right;margin-right:15px;">';
                                  if ($cat == "1") {
                                  echo $_POST['catname' . $i . ''] . '/';
                                  }

                                  echo $_POST['productname' . $i . ''] . '</span>

                                  <img src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=' . $xres . '&font=' . $font . '">

                                  <div style="float:right; margin-right:11px;margin-left:12px;padding:0px">

                                  </div></div>';
                                  if ($checkbx == "1") {
                                  echo'<span style="visibility:hidden">f</span><div class="page-break"></div>';
                                  }
                                  }
                                  }
                                  } elseif ($priceoption1 == "1" && $priceoption != "1") {


                                  $drawtext = "on";

                                  for ($i = 1; $i <= $itr; $i++) {
                                  for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {
                                  echo '<div style="width:152px;float:right">
                                  <span style="font-size:11px;float:left;margin-left:10px;">' . ($_POST['pricen' . $i] + 10) . '.LE
                                  <span style="font-size:11px;float:right;margin-right:15px;">';
                                  if ($cat == "1") {
                                  echo $_POST['catname' . $i . ''] . '/';
                                  }

                                  echo $_POST['productname' . $i . ''] . '</span>

                                  <img src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=' . $xres . '&font=' . $font . '">

                                  <div style="float:right; margin-right:11px;margin-left:12px;padding:0px">
                                  </span>

                                  </div></div>';
                                  }
                                  }
                                  } else {

                                  $drawtext = "on";
                                  //$type = "C128B";//supports numbers, upper- and lower-case letters and some additional characters.
                                  $type = "C128A"; //supports numbers, upper-case letters, and control characters, such as tab and new-line.
                                  $width = "190";
                                  $height = "50";
                                  $xres = "1";
                                  $font = "10";
                                  $output = "png";


                                  for ($i = 1; $i <= $itr; $i++) {
                                  for ($x = 0; $x < $_POST['productnum' . $i . '']; $x++) {
                                  echo '<div style="width:152px;float:right;padding-top:10px;">
                                  <span style="font-size:11px;float:left;margin-left:15px;">' . $_POST['price' . $i . ''] . '.LE
                                  <span style="font-size:11px;float:right;margin-right:15px;">';
                                  if ($cat == "1") {
                                  echo $_POST['catname' . $i . ''] . '/';
                                  }

                                  echo $_POST['productname' . $i . ''] . '


                                  </span>


                                  <img src="../library/barcode/image.php?code=' . $_POST['productbarcode' . $i . ''] . '&style=' . $style . '&type=' . $type . '&width=' . $width . "&height=" . $height . '&xres=' . $xres . '&font=' . $font . '">

                                  <span style="font-size:18px;float:left;margin-left:50px;position:relative;margin-top:-5px;background-color: #FFF;">' . $_POST['productbarcode' . $i . ''] . '</<span>

                                  ';
                                  if ($priceoption1 == "1") {
                                  echo '
                                  <span style="font-size:11px;float:left;margin-left:10px;position:absolute;padding-top:53px;margin-left:-120px;">
                                  ' . ($_POST['pricen' . $i] + 10) . '';
                                  }
                                  echo '
                                  <div style="float:right; margin-right:11px;margin-left:12px;padding:0px">
                                  </span>


                                  </div></div>';
                                  }
                                  }
                                  } */

                                // <span style="font-size:11px;float:left;margin-left:10px;">'.$_GET['price'].' L.E</span>
                            }
                        }
                    }
                }
                ?>
                <div style="clear:both;">
                    <a href="productController.php?do=showbarcode">
                        <input name="" value="رجوع"  type="button"  class="noprint"/>
                    </a>
                </div>
                </body>
                </html>
