diff --git a/application/controllers/barcode.php b/application/controllers/barcode.php index 8d85ab974..037167398 100644 --- a/application/controllers/barcode.php +++ b/application/controllers/barcode.php @@ -11,5 +11,10 @@ class Barcode extends Secure_area { $this->load->view('barcode'); } + + function receipt() + { + $this->load->view('receipt_barcode'); + } } ?> \ No newline at end of file diff --git a/application/views/receipt_barcode.php b/application/views/receipt_barcode.php new file mode 100644 index 000000000..b80af25b9 --- /dev/null +++ b/application/views/receipt_barcode.php @@ -0,0 +1,362 @@ +=1 to enable + + + NOTE: You must have GD-1.8 or higher compiled into PHP + in order to use PNG and JPEG. GIF images only work with + GD-1.5 and lower. (http://www.boutell.com) + + + ANOTHER NOTE: If you actually intend to print the barcodes + and scan them with a scanner, I highly recommend choosing + JPEG with a quality of 100. Most browsers can't seem to print + a PNG without mangling it beyond recognition. + + + USAGE EXAMPLES FOR ANY PLAIN OLD HTML DOCUMENT: + ----------------------------------------------- + + + + + + + + +*/ +/*=============================================================================*/ + + +//----------------------------------------------------------------------------- +// Startup code +//----------------------------------------------------------------------------- + + +if(isset($_GET["text"])) $text=$_GET["text"]; +if(isset($_GET["format"])) $format=$_GET["format"]; +if(isset($_GET["quality"])) $quality=$_GET["quality"]; +if(isset($_GET["width"])) $width=$_GET["width"]; +if(isset($_GET["height"])) $height=$_GET["height"]; +if(isset($_GET["type"])) $type=$_GET["type"]; +if(isset($_GET["barcode"])) $barcode=$_GET["barcode"]; + + +if(isset($_POST["text"])) $text=$_POST["text"]; +if(isset($_POST["format"])) $format=$_POST["format"]; +if(isset($_POST["quality"])) $quality=$_POST["quality"]; +if(isset($_POST["width"])) $width=$_POST["width"]; +if(isset($_POST["height"])) $height=$_POST["height"]; +if(isset($_POST["type"])) $type=$_POST["type"]; +if(isset($_POST["barcode"])) $barcode=$_POST["barcode"]; + + +if (!isset ($text)) $text = 1; +if (!isset ($type)) $type = 1; +if (empty ($quality)) $quality = 100; +if (empty ($width)) $width = 160; +if (empty ($height)) $height = 80; +if (!empty ($format)) $format = strtoupper ($format); + else $format="PNG"; + + +switch ($type) +{ + default: + $type = 1; + case 1: + Barcode39 ($barcode, $width, $height, $quality, $format, $text); + break; +} + + +//----------------------------------------------------------------------------- +// Generate a Code 3 of 9 barcode +//----------------------------------------------------------------------------- +function Barcode39 ($barcode, $width, $height, $quality, $format, $text) +{ + switch ($format) + { + default: + $format = "JPEG"; + case "JPEG": + header ("Content-type: image/jpeg"); + break; + case "PNG": + header ("Content-type: image/png"); + break; + case "GIF": + header ("Content-type: image/gif"); + break; + } + + + $im = ImageCreate ($width, $height) + or die ("Cannot Initialize new GD image stream"); + $White = ImageColorAllocate ($im, 255, 255, 255); + $Black = ImageColorAllocate ($im, 0, 0, 0); + //ImageColorTransparent ($im, $White); + ImageInterLace ($im, 1); + + + + $NarrowRatio = 20; + $WideRatio = 55; + $QuietRatio = 35; + + + $nChars = (strlen($barcode)+2) * ((6 * $NarrowRatio) + (3 * $WideRatio) + ($QuietRatio)); + $Pixels = $width / $nChars; + $NarrowBar = (int)(20 * $Pixels); + $WideBar = (int)(55 * $Pixels); + $QuietBar = (int)(35 * $Pixels); + + + $ActualWidth = (($NarrowBar * 6) + ($WideBar*3) + $QuietBar) * (strlen ($barcode)+2); + + if (($NarrowBar == 0) || ($NarrowBar == $WideBar) || ($NarrowBar == $QuietBar) || ($WideBar == 0) || ($WideBar == $QuietBar) || ($QuietBar == 0)) + { + ImageString ($im, 1, 0, 0, "Image is too small!", $Black); + OutputImage ($im, $format, $quality); + exit; + } + + $CurrentBarX = (int)(($width - $ActualWidth) / 2); + $Color = $White; + $BarcodeFull = "*".strtoupper ($barcode)."*"; + settype ($BarcodeFull, "string"); + + $FontNum = 3; + $FontHeight = ImageFontHeight ($FontNum); + $FontWidth = ImageFontWidth ($FontNum); + if (!empty($text)) + { + $CenterLoc = (int)(($width) / 2) - (int)(($FontWidth * strlen($text)) / 2); + ImageString ($im, $FontNum, $CenterLoc, $height-$FontHeight, "$text", $Black); + } + else + { + $FontHeight=-2; + } + + + for ($i=0; $i diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index b5ae89423..a036405c1 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -103,7 +103,7 @@ if (isset($error_message)) config->item('return_policy')); ?>
- "; ?> + "; ?>
load->view("partial/footer"); ?> diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php index d66b13875..629f33170 100644 --- a/application/views/sales/receipt.php +++ b/application/views/sales/receipt.php @@ -110,7 +110,7 @@ if (isset($error_message)) config->item('return_policy')); ?>
- "; ?> + "; ?>
load->view("partial/footer"); ?>