26

I've built an e-shopping website for a big company which has country offices.

What i want to do is the following

  1. Generate barcode via PHP before sending package to country offices of company
  2. When the item will be arrived to country office, workers will login to their account, scan this barcode via barcode reader (which located on package) and website will automatically "approve" that item received.

Is it possible only with web interface? I mean without any local application. How to do that? PLease explain.

dnagirl
  • 20,196
  • 13
  • 80
  • 123
heron
  • 3,611
  • 25
  • 80
  • 148
  • 1
    google for "php barcode generator", and use an appropriate bar code reader that connects as HID (so you only need a text-input field on your website) see http://stackoverflow.com/questions/3262126/barcode-scanner-in-javascript-or-plugin-extension – sled Oct 25 '11 at 18:45
  • 1
    Most barcode-readers have a keyboard emulation setting, where the barcode reader fakes someone typing in the numbers. You need to set a prefix on the barcode reader (a magic string that is sent before the barcode is 'typed in') that will select your input field, after that the barcode will automatically be entered into your barcode field. – Johan Oct 25 '11 at 18:48
  • Looks very possible with an image processing library such as GD or something. – Madara's Ghost Oct 25 '11 at 18:51
  • how to read barcode from reader device and send the data to webform automatically? How can i access to HID device? – heron Oct 25 '11 at 18:56
  • If you're able to go with QR codes, Google has an API for that: http://code.google.com/apis/chart/infographics/docs/qr_codes.html – James Oct 25 '11 at 19:00

8 Answers8

27

so here is an approach that could work for you:

You need to put a record in a database like:

package_id |    name      |   status

  1234        My Package      shipped

Generate a barcode which contains the package_id, you have to decide what kind of barcode you want to use. You could also use a data matrix. Then you create the bar code as image so that you can print it. Data Matrix is very good for large custom data.

Print the bar code, put it on your package

The package arrives at the office, the user logs on to your website, clicks on "Confirm Package Received" or whatever. Then there is a text-field, he focuses the text-field, scans the barcode/data matrix and your package ID "1234" will appear in the text-field

Submit the form, lookup the entry in the database, change it to:

 package_id |     name      |   status
  1234         My Package      delivered

A Tip If you use a QR Code it can be read by many mobile phones, so you don't need a real bar code scanner. You could write an app that reads the bar code and sends the package_id to your server.

sled
  • 14,525
  • 3
  • 42
  • 70
  • 1
    You got it! I ordered a barcode scanner from ebay for $20 that works ok, so not really that expensive. And what other people said about 'keyboard emulation' is correct. When the scanner scans the barcode, say 1234, it is exactly the same as if you sat there and typed 1-2-3-4. And most have a setting that lets you pick whether or not it automatically presses 'enter' for you after too. So put mouse in yout text box, scan the code, and it will be entered into the box, and the form can be submitted automatically. – Sherwin Flight Nov 03 '11 at 03:07
  • For example, I have a screen where I can check the info on certain items, all the details and info about it. To use it I used to have to type the number in a box at the top of the page, and press enter, and the details would be shown. Now I can click the box, scan the code, and the info is just there. it works anywhere you can use a keyboard, so you can do all sorts of stuff with it (unnecessarily, haha) like encode web addresses, e-mail address, anything you want really. – Sherwin Flight Nov 03 '11 at 03:10
  • nice :) $20 is really cheap - maybe I'm gonna use barcodes for our quality management too! – sled Nov 03 '11 at 11:18
  • You will likely pay a little more, but they are still relatively cheap. It would be a lot more accurate than manually entering information though, so would be worth it. Things to keep an eye out for if buying a scanner: - Input type: Some are USB, some are PS/2 (like a mouse), and some use ports that I've never used before (serial/parallel?) - Keyboard emulation: This means it works the same as entering the text with the keyboard, so doesn't require any special software. – Sherwin Flight Nov 03 '11 at 14:47
  • - barcode format: I didn't realize there were so many. If you are using existing barcodes your scanner needs to be able to read them, most scanners support many types. If you don't yet use barcodes this isn't a problem, because you can make whatever codes work with your scanner. - Type of scan: Do you just pass the code under the scanner to read it, or pull the trigger to scan? Each has pros and cons. - Is it hand-held, or does it use a stand/holder? - length of the cable: needs to reach where you need it to reach. Just some helpful tips. – Sherwin Flight Nov 03 '11 at 14:50
6

Tcpdf has a few classes for generating barcodes:

http://www.tcpdf.org/doc/code/classTCPDFBarcode.html

With good examples:

http://www.tcpdf.org/examples.php

For example the first:

// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');

// output the barcode as HTML object
echo $barcodeobj->getBarcodeHTML(2, 30, 'black');
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
2

Check larsjung.de/qrcode/

It's JQuery Pluggin, but works well with PHP.

As I see your scenario, you need more than just 1D Barcode. You need QR Code.

Hope this helps.

V A S
  • 3,338
  • 4
  • 33
  • 39
JMS786
  • 66
  • 1
1

First, you need to chose which barcode type you want to generate. There are multiple to consider, 1D or 2D. 1D barcodes are simple encode only a small amount of data. 2D barcodes are bigger and can encode more data, they are also a little more aesthetic :) If you go for a 2D barcodes, I would recommend QRCode, or DataMatrix. The PDF417 is a viable option if you need to lay your data more horizontally instead of squared. You can find more information here: http://www.barcodebakery.com/en/resources/guide/php/choosing-barcodes

Once you found your code to write, you consider which reader to get. I currently own a Metrologic Focus FirstFlash MS1690. It reads all the barcodes mentioned above. They are multiple options here again, the easiest is to get a USB barcode reader: when you scan a barcode, it would simply write it to the screen as someone were typing it on the keyboard.

jsgoupil
  • 3,788
  • 3
  • 38
  • 53
0

This is possible to make using php only. For this you need to take any ready php class to generate qr-code or barcode. Generating barcode may be performed with means of just selecting appropriate bacode font, so, instead of writting numbers php will be writing by barcoded digits. Reading of barcode was described above.

0

Important note about TCPDF library:

A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.

For generating linear and bidimensional barcodes there is separate library: https://github.com/tecnickcom/tc-lib-barcode

To generate barcode using the tc-lib-barcode library:

$bobj = $barcode->getBarcodeObj('CODABAR', '123456', -3, -30, 'black', array(0, 0, 0, 0));

// output the barcode as HTML div (see other output formats in the documentation and examples)
echo $bobj->getHtmlDiv();
echo "</br>";

//Output as png image
echo "<p><img alt=\"Embedded Image\" src=\"data:image/png;base64,".base64_encode($bobj->getPngData())."\" /></p>";

//Save image to folder
$destination_folder = "uploads/barcode.png";
file_put_contents($destination_folder, $bobj->getPngData());

Note:- I have used 'CODABAR' as barcode type. You can change the type of barcode/QR-code according to your needs.

Manish Pareek
  • 409
  • 5
  • 12
0

I'm not sure if I completely understand your question, but if you are looking make a file that can be printed as a barcode, you'll need to know what kind of files your barcode printer can print.

And if you are looking to read a barcode with a scanner into a webform, the scanner needs to recognize the barcode type. The scanner inputs the barcode value into the webform (or any other program that accepts text). The webform has nothing to do with recognizing a barcode.

dnagirl
  • 20,196
  • 13
  • 80
  • 123
  • how to read barcode from reader device and send the data to webform automatically? How can i access to HID device? – heron Oct 25 '11 at 18:59
  • The barcode is on the package. The barcode scanner knows how to parse the barcode. Depending on the info you store in the barcode, there will be one or more fields. I'd suggest you scan one of your barcodes into a text editor. Then you can see its structure and determine how to best parse it. – dnagirl Oct 25 '11 at 19:01
  • please tell me exact solution which really works.. I mean which barcode reader i need o buy? which type of barcode i need to generate via php ? – heron Oct 25 '11 at 19:02
  • @DEVastator: read the documentation for your scanner. Depending on the brand there will be different ways of routing a scan. You should be able to generate a POST or GET request from your scanner. – dnagirl Oct 25 '11 at 19:06
  • @DEVastator: I don't make purchase recommendations. Contact your local scanner representatives and ask them how they implement this. It's a common problem. – dnagirl Oct 25 '11 at 19:07
0

I'm looking at Zend barcode to do something similar, but admittedly I'm only getting started. I'm eager to know how others handle this.

dkinzer
  • 32,179
  • 12
  • 66
  • 85