Jump to content

Recommended Posts

Hello everyone!
I'm building a PHP manufacturing inventory system tied to ODBC.
The first two fields, two dropdowns, must be validated by scanning a QR code (QR#1:Material). And then, when the check with the first two fields will be true, with another QR scanning (QR#2:Machine) the operator will start a time tracking of his job.
The timestamp will be stored into database.

In your opinion, is it possible to create a similar application? And if so, what do you recommend?
Thanks for the help!!!

Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/
Share on other sites

It's not like the experience is entirely unusable...
Make the scanner so it gets the data from the QR code. Use Javascript to do whatever it takes to validate with the dropdowns - I have no idea what this part is since you didn't go into much detail about it. Then either you submit a form or you send an AJAX request to the server to store "the timestamp" (what timestamp?) in the database.

Break the whole thing down into discrete steps: scanning the QR code is one, validating with the dropdowns is another, scanning the second QR code is a third, and so on. Work on each step in turn.

  • Great Answer 1
Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/#findComment-1581028
Share on other sites

Again, you haven't gone into any sort of detail about anything regarding these dropdowns so I have no idea what it is you need to do.

Besides... use Javascript?

If you want more detailed advice then you'll have to start posting code and markup and whatever you have, along with a complete description of what sort of "data matching/comparison" you're talking about.

  • Like 1
Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/#findComment-1581032
Share on other sites

Dropdowns get data from sql. The first field populate a "product orders" and the second is for "material".

Then, the operator must scan a qr code from the material.

With the scan, the app have to do in first a data matching/controll of the previous data. 

When the controll will results ok, then everything is fine. If the product order field or the material field will be different from the scan result of the material a message will warn the operator. 

I don't know how many details I have to tell you.

However, thanks for your advices :)

Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/#findComment-1581033
Share on other sites

This could be a language barrier thing, but I'm a bit confused.It sounds like the user will select a material from the second drop-down then scan a QR code that identifies the material they're scanning and that scan should match the selection from the second drop-down? If so, why? What's the thought behind making the user select a material from the second drop-down and then match that to the QR scan?

Also, because the problem isn't clear at this point show the code you have, as well as any error messages or unexpected results you're getting. Assuming there's no error message and the results are unexpected, give us the results you were expecting.

Edited by maxxd
  • Like 1
Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/#findComment-1581034
Share on other sites

Good morning! Here's my code.
I've updated the project and I've cutted off the second dropdown for the material selection. Everything, now, is on the first dropdown.

-sel_op.php-

<?php

$conn = odbc_connect('', '', '');
    if(! $conn){
        print( "error..." );
        exit;
    }
    //definisco gli ordini di produzione
    $sql="SELECT * 
            FROM dbo.OP_Ordini 
            LEFT JOIN dbo.MG_AnaART
            ON dbo.OP_Ordini.OPOR_MGAA_Id = dbo.MG_AnaArt.MGAA_Id ";
    $rs=odbc_exec($conn,$sql);
        if (!$rs)
        {exit("Error!");}
    echo"<center>";
        echo"<br>";
        echo"<select>";
        echo"<option>--ORDERS--</option>";
            while(odbc_fetch_row($rs))
            {

    $ord_id=odbc_result($rs,"OPOR_Id");
    $ord_anno=odbc_result($rs,"OPOR_Anno");            
    $ord_ordine=odbc_result($rs,"OPOR_Ordine");
    $ord_lotto=odbc_result($rs,"OPOR_Lotto");
    $ord_desc=odbc_result($rs,"OPOR_Descr");  
    $mgaa_matr=odbc_result($rs,"MGAA_Matricola");                
                echo"<option>| $ord_id | $ord_anno | $ord_ordine | $ord_lotto | $ord_desc | $mgaa_matr</option>";
            }
    echo"</select>";
    echo"<br>";
    echo"<br>";
    echo"<br>";
    echo"<br>"; 

?>

In this part, I'm calling the order list (OPOR) with the material (MGAA).
The second step, is the comparison with the dropdown AFTER the scan submit.
QR Code have OPOR_Id information.

I'm stuck here, I'm strugglin with the data comparison : dropdown option (with OPOR_id data) must be === to scan result (OPOR_Id).

This is the qrcode-reader.js:

(function($,window,document,undefined){"use strict";if(!window.requestAnimationFrame){window.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback,element){window.setTimeout(callback,1e3/60)}}()}var qrr,QRCodeReader=function(){};$.qrCodeReader={jsQRpath:"../dist/js/jsQR/jsQR.min.js",beepPath:"../dist/audio/beep.mp3",instance:null,defaults:{multiple:false,qrcodeRegexp:/./,audioFeedback:true,repeatTimeout:1500,target:null,skipDuplicates:true,lineColor:"#FF3B58",callback:function(code){}}};QRCodeReader.prototype={constructor:QRCodeReader,init:function(){qrr.buildHTML();qrr.scriptLoaded=false;qrr.isOpen=false;$.getScript($.qrCodeReader.jsQRpath,function(data,textStatus,jqxhr){if(jqxhr.status==200){qrr.scriptLoaded=true}else{console.error("Errore leggendo lo script")}})},buildHTML:function(){qrr.bgOverlay=$('<div id="qrr-overlay"></div>');qrr.container=$('<div id="qrr-container"></div>');qrr.closeBtn=$('<span id="qrr-close">&times;</span>');qrr.closeBtn.appendTo(qrr.container);qrr.okBtn=$('<a id="qrr-ok">OK</a>');qrr.loadingMessage=$('<div id="qrr-loading-message"> Impossibile accedere allo stream video</div>');qrr.canvas=$('<canvas id="qrr-canvas" class="hidden"></canvas>');qrr.audio=$('<audio hidden id="qrr-beep" src="'+$.qrCodeReader.beepPath+'" type="audio/mp3"></audio>');qrr.outputDiv=$('<div id="qrr-output"></div>');qrr.outputNoData=$('<div id="qrr-nodata">Nessun QR rilevato.</div>');qrr.outputData=$('<div id="qrr-output-data"></div>');qrr.outputNoData.appendTo(qrr.outputDiv);qrr.outputData.appendTo(qrr.outputDiv);qrr.loadingMessage.appendTo(qrr.container);qrr.canvas.appendTo(qrr.container);qrr.outputDiv.appendTo(qrr.container);qrr.audio.appendTo(qrr.container);qrr.okBtn.appendTo(qrr.container);qrr.bgOverlay.appendTo(document.body);qrr.bgOverlay.on("click",qrr.close);qrr.closeBtn.on("click",qrr.close);qrr.container.appendTo(document.body);qrr.video=document.createElement("video")},drawLine:function(begin,end,color){var canvas=qrr.canvas[0].getContext("2d");canvas.beginPath();canvas.moveTo(begin.x,begin.y);canvas.lineTo(end.x,end.y);canvas.lineWidth=4;canvas.strokeStyle=color;canvas.stroke()},drawBox:function(location,color){qrr.drawLine(location.topLeftCorner,location.topRightCorner,color);qrr.drawLine(location.topRightCorner,location.bottomRightCorner,color);qrr.drawLine(location.bottomRightCorner,location.bottomLeftCorner,color);qrr.drawLine(location.bottomLeftCorner,location.topLeftCorner,color)},setOptions:function(element,options){var dataOptions={multiple:$(element).data("qrr-multiple"),qrcodeRegexp:new RegExp($(element).data("qrr-qrcode-regexp")),audioFeedback:$(element).data("qrr-audio-feedback"),repeatTimeout:$(element).data("qrr-repeat-timeout"),target:$(element).data("qrr-target"),skipDuplicates:$(element).data("qrr-skip-duplicates"),lineColor:$(element).data("qrr-line-color"),callback:$(element).data("qrr-callback")};options=$.extend({},dataOptions,options);var settings=$.extend({},$.qrCodeReader.defaults,options);$(element).data("qrr",settings)},getOptions:function(element){qrr.settings=$(element).data("qrr")},open:function(){if(qrr.isOpen)return;qrr.getOptions(this);qrr.bgOverlay.show();qrr.container.slideDown();qrr.codes=[];qrr.outputNoData.show();qrr.outputData.empty();qrr.outputData.hide();if(qrr.settings.multiple){qrr.okBtn.show();qrr.okBtn.off("click").on("click",qrr.doneReading)}else{qrr.okBtn.hide()}$(document).on("keyup.qrCodeReader",function(e){if(e.keyCode===27){qrr.close()}if(qrr.settings.multiple&&e.keyCode===13){qrr.doneReading()}});qrr.isOpen=true;if(qrr.scriptLoaded){qrr.start()}},start:function(){navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(function(stream){qrr.video.srcObject=stream;qrr.video.setAttribute("playsinline",true);qrr.video.play();qrr.startReading()})},startReading:function(){qrr.requestID=window.requestAnimationFrame(qrr.read)},doneReading:function(){var value=qrr.codes[0];if(qrr.settings.target){if(qrr.settings.multiple){var value=qrr.codes.join("\n")}$(qrr.settings.target).val(value)}if(qrr.settings.callback){try{if(qrr.settings.multiple){qrr.settings.callback(qrr.codes)}else{qrr.settings.callback(value)}}catch(err){console.error(err)}}qrr.close()},read:function(){var codeRead=false;var canvas=qrr.canvas[0].getContext("2d");qrr.loadingMessage.text("Caricamento video...");qrr.canvas.off("click.qrCodeReader",qrr.startReading);if(qrr.video.readyState===qrr.video.HAVE_ENOUGH_DATA){qrr.loadingMessage.hide();qrr.canvas.removeClass("hidden");qrr.canvas[0].height=qrr.video.videoHeight;qrr.canvas[0].width=qrr.video.videoWidth;canvas.drawImage(qrr.video,0,0,qrr.canvas[0].width,qrr.canvas[0].height);var imageData=canvas.getImageData(0,0,qrr.canvas[0].width,qrr.canvas[0].height);var code=jsQR(imageData.data,imageData.width,imageData.height,{inversionAttempts:"dontInvert"});if(code&&qrr.settings.qrcodeRegexp.test(code.data)){qrr.drawBox(code.location,qrr.settings.lineColor);codeRead=true;qrr.codes.push(code.data);qrr.outputNoData.hide();qrr.outputData.show();if(qrr.settings.audioFeedback){qrr.audio[0].play()}if(qrr.settings.multiple){if(qrr.settings.skipDuplicates){qrr.codes=$.unique(qrr.codes)}$('<div class="qrr-input"></div>').text(code.data).appendTo(qrr.outputData);qrr.outputDiv[0].scrollTop=qrr.outputDiv[0].scrollHeight;qrr.canvas.on("click.qrCodeReader",qrr.startReading);if(qrr.settings.repeatTimeout>0){setTimeout(qrr.startReading,qrr.settings.repeatTimeout)}else{qrr.loadingMessage.text("Clicca sull'immagine per leggere il QR Code");qrr.loadingMessage.show()}}else{qrr.doneReading()}}}if(!codeRead){qrr.startReading()}},close:function(){if(qrr.requestID){window.cancelAnimationFrame(qrr.requestID)}$(document).off("keyup.qrCodeReader");if(qrr.video.srcObject){qrr.video.srcObject.getTracks()[0].stop()}qrr.canvas.addClass("hidden");qrr.loadingMessage.show();qrr.bgOverlay.hide();qrr.container.hide();qrr.isOpen=false}};$.fn.qrCodeReader=function(options){if(!$.qrCodeReader.instance){qrr=new QRCodeReader;qrr.init();$.qrCodeReader.instance=qrr}return this.each(function(){qrr.setOptions(this,options);$(this).off("click.qrCodeReader").on("click.qrCodeReader",qrr.open)})}})(jQuery,window,document);

Edited by Bramhowl
Link to comment
https://forums.phpfreaks.com/topic/311402-inventory-system/#findComment-1581043
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.