Equipment QR Code Generator with PHP
I went to school at the Art Institute. While I was a student there, I worked as a student worker in the IT Department. As part of this job, we checked out high end photography equipment to students that needed it for their classes.
That process was pretty straight forward. We scanned the equipment the student wanted, scanned the student ID, put it into our booking software, and then told the student it was due back in X amount of days.
However, we ended up switching our booking software. This ended up creating a headache: we had to redo our entire inventory, import it into the new system, and create new tags with new numbers for every single piece of equipment we had.
At the time, a tag on each piece of our equipment contained the following information:
- Equipment Name (Alphabetic)
- Corporate ID (Numeric)
- Equipment ID (Numeric)
- Serial Number (Varies)
This was information that had to be manually curated into every single Photoshop document, and placed accordingly so it could print out. For over 100 items, this process could take a significant amount of time.
A Better Way
Instead of using Photoshop, why not have a script automate the process? I began work on a web-based tag generator. Eventually, I roughly hacked up the below.
The idea was that instead of relying on a student worker opening up Photoshop and manually creating each tag, they could go in and just enter a tag and the computer would auto generate it. It would event auto-generate the next set of tags by adding one number, if the user desired.
I revisited this project after I graduated, and cleaned it up a bit.
<?php
include "vendor/qrlib.php";
include "class.inc.php";
FS_Operation::clear_tmp();
?>
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/style.css">
<title>
<?php
echo 'Tag Generator- ' . $_POST['package_name'] . '';
?>
</title>
</head>
<body>
<?php
foreach($_POST['items'] as $key => $value) {
$filename = 'img/tmp/'.md5('test'.rand());
if($value !== '') {
QRcode::png($_POST['items_number'][$key], $filename,'L', min(max((int)4, 1), 10),2);
$items[$key]['qr'] = $filename;
}
$items[$key]['name'] = $value;
$items[$key]['number'] = $_POST['items_number'][$key];
}
?>
<?php
new Tag(
$_POST['package_name'][0],
$_POST['package_name_number'][0],
$_POST['serial_number'][0],
$_POST['edmc_number'][0],
$items
);
?>