function barcode_encode($code, $encoding)
{
    global $genbarcode_loc;
    if (preg_match("@^ean\$@i", $encoding) && (strlen($code) == 12 || strlen($code) == 13) || $encoding && preg_match("@^isbn\$@i", $encoding) && (strlen($code) == 9 || strlen($code) == 10 || (preg_match("@^978@i", $code) && strlen($code) == 12 || strlen($code) == 13)) || (!isset($encoding) || !$encoding || preg_match("@^ANY\$@i", $encoding)) && preg_match("@^[0-9]{12,13}\$@i", $code)) {
        /* use built-in EAN-Encoder */
        $bars = barcode_encode_ean($code, $encoding);
    } else {
        if (file_exists($genbarcode_loc)) {
            /* use genbarcode */
            $bars = barcode_encode_genbarcode($code, $encoding);
        } else {
            return ENCODING_UNHANDLED;
        }
    }
    return $bars;
}
Beispiel #2
0
function barcode_encode($code, $encoding)
{
    global $genbarcode_loc;
    if (preg_match("#^ean\$#i", $encoding) && (strlen($code) == 12 || strlen($code) == 13) || $encoding && preg_match("#^isbn\$#i", $encoding) && (strlen($code) == 9 || strlen($code) == 10 || (preg_match("#^978#", $code) && strlen($code) == 12 || strlen($code) == 13)) || (!isset($encoding) || !$encoding || preg_match("#^ANY\$#i", $encoding)) && preg_match("#^[0-9]{12,13}\$#", $code)) {
        /* use built-in EAN-Encoder */
        $bars = barcode_encode_ean($code, $encoding);
    } else {
        if (file_exists($genbarcode_loc)) {
            /* use genbarcode */
            $bars = barcode_encode_genbarcode($code, $encoding);
        } else {
            print "php-barcode needs an external programm for encodings other then EAN/ISBN<BR>\n";
            print "<ul>\n";
            print "<li>download gnu-barcode from <a href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</a></li>\n";
            print "<li>compile and install them</li>\n";
            print "<li>download genbarcode from <a href=\"http://www.ashberg.de/php-barcode/\">www.ashberg.de/php-barcode/</a></li>\n";
            print "<li>compile and install them</li>\n";
            print "<li>specify path to genbarcode in php-barcode.php</li>\n";
            print "</ul>\n";
            print "<br />\n";
            print "<a href=\"http://www.ashberg.de/php-barcode/\">Folke Ashberg's OpenSource PHP-Barcode</a><br />\n";
            return false;
        }
    }
    return $bars;
}
function barcode_encode($code, $encoding)
{
    global $genbarcode_loc;
    if (eregi("^ean\$", $encoding) && (strlen($code) == 12 || strlen($code) == 13) || $encoding && eregi("^isbn\$", $encoding) && (strlen($code) == 9 || strlen($code) == 10 || (ereg("^978", $code) && strlen($code) == 12 || strlen($code) == 13)) || (!isset($encoding) || !$encoding || eregi("^ANY\$", $encoding)) && ereg("^[0-9]{12,13}\$", $code)) {
        /* use built-in EAN-Encoder */
        $bars = barcode_encode_ean($code, $encoding);
    } else {
        if (file_exists($genbarcode_loc)) {
            /* use genbarcode */
            $bars = barcode_encode_genbarcode($code, $encoding);
        } else {
            print "php-barcode needs an external programm for encodings other then EAN/ISBN<BR>\n";
            print "<UL>\n";
            print "<LI>download gnu-barcode from <A href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
            print "<LI>compile and install them\n";
            print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
            print "<LI>compile and install them\n";
            print "<LI>specify path the genbarcode in php-barcode.php\n";
            print "</UL>\n";
            print "<BR>\n";
            print "<A HREF=\"http://www.ashberg.de/bar/\">Folke Ashberg's OpenSource PHP-Barcode</A><BR>\n";
            return false;
        }
    }
    return $bars;
}
Beispiel #4
0
/**
 * Encodes $code with $encoding using genbarcode OR built-in encoder if you don't have genbarcode only EAN-13/ISBN is possible
 *
 * You can use the following encodings (when you have genbarcode):
 *   ANY    choose best-fit (default)
 *   EAN    8 or 13 EAN-Code
 *   UPC    12-digit EAN
 *   ISBN   isbn numbers (still EAN-13)
 *   39     code 39
 *   128    code 128 (a,b,c: autoselection)
 *   128C   code 128 (compact form for digits)
 *   128B   code 128, full printable ascii
 *   I25    interleaved 2 of 5 (only digits)
 *   128RAW Raw code 128 (by Leonid A. Broukhis)
 *   CBR    Codabar (by Leonid A. Broukhis)
 *   MSI    MSI (by Leonid A. Broukhis)
 *   PLS    Plessey (by Leonid A. Broukhis)
 *
 * @param	string	$code		Code
 * @param	string	$encoding	Encoding
 * @return	array				array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
 */
function barcode_encode($code, $encoding)
{
    global $genbarcode_loc;
    if (preg_match("/^ean\$/i", $encoding) && (strlen($code) == 12 || strlen($code) == 13) || $encoding && preg_match("/^isbn\$/i", $encoding) && (strlen($code) == 9 || strlen($code) == 10 || (preg_match("/^978/", $code) && strlen($code) == 12 || strlen($code) == 13)) || (!isset($encoding) || !$encoding || preg_match("/^ANY\$/i", $encoding)) && preg_match("/^[0-9]{12,13}\$/", $code)) {
        /* use built-in EAN-Encoder */
        dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean");
        $bars = barcode_encode_ean($code, $encoding);
    } else {
        if (file_exists($genbarcode_loc)) {
            /* use genbarcode */
            dol_syslog("barcode.lib.php::barcode_encode Use genbarcode " . $genbarcode_loc . " code=" . $code . " encoding=" . $encoding);
            $bars = barcode_encode_genbarcode($code, $encoding);
        } else {
            print "barcode_encode needs an external programm for encodings other then EAN/ISBN<BR>\n";
            print "<UL>\n";
            print "<LI>download gnu-barcode from <A href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
            print "<LI>compile and install them\n";
            print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
            print "<LI>compile and install them\n";
            print "<LI>specify path the genbarcode in barcode module setup\n";
            print "</UL>\n";
            print "<BR>\n";
            return false;
        }
    }
    return $bars;
}