Created
October 17, 2012 17:00
-
-
Save johnvilsack/3906719 to your computer and use it in GitHub Desktop.
Simple UPC/EAN Capture Tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// UPC Capture Tool for Linea Pro / Simple Web Portal App | |
//Includes for Flourish and Connect Lib exist in Router | |
if(isset($_POST['formItemID']) || $_POST['formItemID'] != '') | |
{ | |
$connect = new ConnectDB; | |
$db = $connect->TempScan(); | |
$statement = $db->prepare("INSERT INTO captures (item_id, upc, ean) VALUES (%s, %s, %s)"); | |
$db->query($statement, $_POST['formItemID'], $_POST['formUPC'], $_POST['formEAN']); | |
$message = fHTML::encode($_POST['formItemID']) . 'Updated!<br>'; | |
$_POST['formItemID'] = ''; | |
$_POST['formUPC'] = ''; | |
$_POST['formEAN'] = ''; | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Temporary UPC Capture Tool</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="http://assets.app/css/bootstrap.css" rel="stylesheet"> | |
<link href="http://assets.app/css/bootstrap-responsive.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row-fluid"> | |
<div class="span12"> | |
<div id="message" class="alert alert-success"><?php echo $message; ?></div><br> | |
<form id="formInsert" action="http://epoch.app/upccap/" method="post"><br> | |
<center><button type="submit" id="SaveIt" style="display:none; width:100%;" class="btn btn-success btn-large btn-primary">Save Capture</button></center> | |
<input style="width:100%" type="hidden" name="formItemID" id="formItemID"><h3 id="ItemID">Scan Item ID</h3><br> | |
<input style="width:100%" type="hidden" name="formUPC" id="formUPC"><h3 id="UPC">Scan UPC</h3><br> | |
<input style="width:100%" type="hidden" name="formEAN" id="formEAN"><h3 id="EAN">Scan EAN</h3><br> | |
<a href="javascript:resetFields();"><button style="width:100%" class="btn btn-large btn-primary" type="button">Reset Form</button></a> | |
</form> | |
</div> | |
</div> | |
</div> | |
<script src="http://assets.app/js/jquery-1.7.2.min.js"></script> | |
<script src="http://assets.app/js/bootstrap.min.js"></script> | |
<script type="text/javascript"> | |
if ($('#message').html == '') | |
{ | |
$('#message').hide(); | |
} else | |
{ | |
setTimeout(function() { | |
$('#message').fadeOut('slow'); | |
}, 2000); | |
} | |
window.onLineaBrowserLoad = function (){ | |
LineaBrowser.setScanButtonMode(LineaBrowser.BUTTON_ENABLED); | |
LineaBrowser.enableBarcode(LineaBrowser.BAR_TYPES.BAR_ALL, true); | |
LineaBrowser.setScanMode(LineaBrowser.MODE_SINGLE_SCAN); | |
LineaBrowser.setBarcodeTypeMode(LineaBrowser.BARCODE_TYPE_DEFAULT); | |
LineaBrowser.hideConfigBar(); | |
LineaBrowser.on('barcodeData', function (data, type){ | |
if(type === 86 || type === 5) { | |
// Scan is Code39 aka ItemID | |
$('#ItemID').html('ItemID: ' + data); | |
$('input#formItemID').val(data); | |
} | |
if(type === 67 || type === 1) { | |
// Scan is UPC | |
$('#UPC').html('UPC: ' + data); | |
$('input#formUPC').val(data); | |
} | |
if(type === 66 || type === 14) { | |
// Scan is EAN | |
$('#EAN').html('EAN: ' + data); | |
$('input#formEAN').val(data); | |
} | |
ready(); | |
}); | |
}; | |
function ready() { | |
if ($('input#formItemID').val() != "") { | |
if ($('input#formUPC').val() != "" || $('input#formEAN').val() != "") | |
{ | |
$('#SaveIt').show(); | |
} | |
} | |
} | |
function resetFields() { | |
$('#ItemID').html('Scan Item ID'); | |
$('input#formItemID').val(''); | |
$('#UPC').html('Scan UPC'); | |
$('input#formUPC').val(''); | |
$('#EAN').html('Scan EAN'); | |
$('input#formEAN').val(''); | |
$('#SaveIt').hide(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment