Website to POS printer - php

I'm looking for a solution with POS printing.
The scenario is:
A restaurant currently has a POS system up and running, they take orders from iPads in store and have a network setup that processes the orders and automatically prints them out on the thermal printer in the kitchen (pretty cool, huh?). Anyway, this restaurant also has a website for online ordering (written in PHP) which have to be checked via email manually. The restaurant wants their online system to send each order to the printer, automatically.
I must add that I haven't been involved with the development of their site or their in-house ordering system. I haven't worked with PHP to POS systems before - is it even possible? What are the alternative solutions for sending data from website forms to a POS printer automatically?

Webservice on the php website with a status flag for processed or not.
Query the webservice from the internal application/an internal application every x minutes (1 is probably sufficient) lists all unprocessed orders and flags them as processed when its retrieved (hack but will suffice)
c#/java/c++ etc will be best to avoid the issue of web based not able to access local printer interface/queue app simply takes result set back from web service and formats/prints it.
Fairly simple about 20 lines of php perhaps and probably less than 100k of c# would do it nicely.

I would be thinking less about the printer, and more about how to interface with the POS software that they use. Find out the manufacturer, product name, and version number (if you can). Then check with that manufacturer to see if they have an SDK or API that you can hook into.
When it comes to actually hooking it into the web site, I wouldn't make the call directly from your PHP page into their POS system. Even if possible, this sort of tight coupling would mean that if the POS system was offline or inaccessible, that the web site would be broken.
Instead, use a database or queuing system to store the orders from the web site. Write a small bit of middleware (such as a daemon or service) that will read from the database or queue, and feed orders to the POS system using their SDK or API.
Keeping these systems decoupled will save you much time and money in the long run. Without it, you are certain to have scalability issues.
Think about this for a second - if you did write directly to the printer, what would happen if two orders came in simultaneously? Would the ticket get garbled with data from both orders? Would one order fail while the other went through? This is more likely than you think, since restaurants tend to be busy during peak times. Go ask anyone that's worked in a pizza delivery restaurant on Superbowl Sunday.

If the Tablet application is really connecting via WIFI to a configured network printer, and the printer is only Network connected, and there is no other PC, then it means you have a bit more work cut out for you. There are a couple of approaches you can take. Either way you are going to have to have a PC on site. If you can print to the network printer on the local network, from a web browser, you have a shot with an easy approach. If you set up a PC with Web Application access, you can configure the same network printer on the local network, and then just create an html page with a stylesheet media=print that formats the order appropriately, then a javascript print call on button click should do it. This requires a PC logged in to the web site, and a person managing the orders and clicking print in order to get the order data to the printer using standard methods. The second approach is to identify the printer manufacturer, download the POS drivers for the printer model and get a class written up to handle acquiring, queuing, and releasing invoices to the printer, and then create a scheduled job that writes orders to the printer similar to a service. This would require a PC on-site as well, but would not require a person monitoring the orders and printing the queue. The second approach is going to cost the client significantly more money to develop.

Related

How to print from the web to a local thermal printer connected by usb?

First of all, sorry for my English, I have been with this problem for quite a few days. I will comment on my situation: I am doing an online ordering system, where once an order is created the ticket printing is triggered. I have tried using Google Cloud Print, it prints but it takes a long time and it does not work as it should, I tried a library called mike42, it prints perfect but not from a website.
The system is in a hosting and I am using PHP together with slim 3, if any of you know how to solve this I would really appreciate it.
The result I want (to be more specific) is the following: The employed user logs on the web (system hosted in the hosting), goes to the orders menu, when he clicks on create the order, this function is executed and prints the ticket directly on the thermal printer connected to the local machine. The same works only if the web is on the local server, which is not what I want.
The title is clear and complete. Printing must take place in client side browser. Client may be connected to a cloud based accounting or purchase system and POS termal printer is connected through a USB port. Computer mat be a zero client with just a browser.
Well, PHP is a server side language, that means it has no communication with the hardware of the local machine.
I've already had to do similar work, and there are two possible solutions:
1- Install PHP on a machine connected to the printer directly, and then print, which is a little impracticable since the server would have to be physically on site.
2 - Generate an output in text formatted for the width of the print and use the window.print () javascript function to call up the print screen, and the user would just click on print.
When I needed it I ended up opting for the second alternative, and it worked well, it is a bit boring to get the print size right, but it worked well.

PHP Image Generation

So, for a simple test game, I'm working on generating user images based on their current in-game avatar. I got this idea from Club Penguin and GTA V. They both generate images of the current in-game avatar.
I created a script to simply put a few images together and print out the final image to the client. It's similar to how Club Penguin does it, I believe: http://cdn.avatar.clubpenguin.com/%7B13bcb2a5-2e21-442c-b8e4-10516be6abc6%7D/cp?size=300
As you can see, the penguin is wearing multiple clothing items. The items are each different images located at http://mobcdn.clubpenguin.com/game/items/images/paper/image/300/ (ex: http://mobcdn.clubpenguin.com/game/items/images/paper/image/300/210.png)
Anyway, I've already made the script and all, but I have a few questions.
When going to Club Penguin's or Grand Theft Auto's avatar generator, you'll notice it finishes the request so fast. Even when it's a new user, (so before it has a chance to cache the image since it hasn't been generated yet), it finishes in under a second.
How could I possibly speed up the image generation process? Right now I'm just using PHP, but I could definitely switch over to another language. I know a few others too and I'm willing to learn. Which language can provide the fastest web-image generator (it has to connect to a database first to grab the user avatar info)?
For server specs, how much RAM and all that fun stuff would be an okay amount? Right now I'm using an OVH cloud server (VPS Cloud 2) to test it and it's fine and all. But, if someone with experience with this could help, what might happen if I started getting a lot more traffic and there were people with 100+ image requests being made per client when they first log in (relationship system that shows their friend's avatar). I'll probably use Cloudflare and other caching tools to help so that most of them get cached for a maximum of 24 hours, but I can't completely rely on that.
tl;dr:
Two main questions:
What's the fastest way to generate avatars on the web (right now I'm using PHP)?
What are some good server specs for around 100+ daily unique clients (at minimum) using this server for generating these avatars?
Edit: Another question, which webserver could process more requests for this? Right now I'm using Apache for this server, but my other servers are using nginx for other API things (like logging users in, getting info, etc).
IMHO, language is not the bottleneck. PHP is fast enough for real-time small images processing. You just need right algorithm. Also, check out bytecode caching engines such as APC, or XCache, or even HHVM. They can significantly improve PHP performance.
I think, any VPS can do the job until you have >20 concurrent requests. The more clients use service at the same time the more RAM you need. You can easily determine your script memory needs and other performance info by using profiler, such as XHProf.
Nginx or Lighttpd in FastCGI mode use less RAM than Apache http server and they can handle more concurrent connections. But is's not important until you have many concurrent connections.
Yes, PHP is can do this job fast and flexible(example generate.php?size=32)
I know only German webspaces, but they have also an English interface. www.nitrado.net

PHP Socket Server/Client

I have read a few good articles about coding a socket server but thought I would ask here to see if there is any further knowledge/ideas about what I actually need.
I run multiple websites for clients all running off the same server, connecting to the same DB etc. Each client website has a form where users can submit their details for services we offer. These users are spread out across the world but what I am wanting to build is a monitoring system where my interface displays the users IP address, client website they are on, the page they are on etc. From the IP I will do a country/state look up (I know its not 100% accurate but close enough is good).
I would like the visiting site to send a packet to the socket server which in turns sends the output information to my screen in real time (after I perform some actions). I guess you could say I am building a mini NOC to monitor website activity. I would also like the output information to be most recent activity at top of screen but also show a scroll bar to view all activity.
Are sockets the best mechanism for this system? Any other suggestions or tutorials on how to achieve the outcome?
Many thanks.
Before you begin down this road, have you checked out the realtime part of Google Analytics? It does most of what you are looking for.
When someone is visiting your site, you aren't typically going to have a persistent connection. I'd suggest that rather than creating one, parse your server logs or store user information in a database, and query for the last x minutes of visitors.
For updating the viewing page that you are on in realtime, Web Sockets are best for this if you need very fast response time, but are currently quite the hassle to do in PHP. In addition, browser support isn't very wide. If you insist on using PHP, I'd recommend polling over AJAX. Otherwise, look into using Node.JS with Socket.IO. Socket.IO wraps up a lot of similar methods to web sockets to get the same effect with little effort. Still use PHP for your application... just use the Node.JS/Socket.IO part for your monitor interface.
Finally, I'd suggest questioning again why you might want this. You can spend a lot of time on a project like this, and the truth is that your analytics data over time is far more valuable than a snapshot when you are looking at it.

php handling POS printer and cashdrawer

i have been googling around wether PHP can handle to print a receipt and kick the cash drawer through a web server?
i read about PHP-GTK2, but it seems cant handle trhough a web server, only for desktop use or standalong apps. is there anyway or sample code or links would be appriciated, please!
You will have to have software running on the client machine the drawer is hooked up to if not running a cash drawer receipt printer. You are not able to directly access the client machine for security reasons. Most cashdrawers connect via a printer that also sends the signal to pop the drawer on receipt printing. You would be able to pop the drawer in this method because the browser can be set up to print to that receipt printer just like any other normal printer.
If you are not using a receipt printer you can look into a fairly new drawer made by APG that is networked but last I knew it was not available yet.
Ethernet cash drawer
You're talking about a browser-based POS? The question should be more along the lines of "can I control the drawer/printer from a browser". PHP's involvement with this process would be to generate the page attempting to control either device. PHP will never execute on the client-side, so can't do anything about the hardware. You'd need Javascript or some other API in the browser to talk to the hardware.
It's not beyond the realm of possibility to have a Java applet or Flash object kick the drawer open. A good number of them, as grantk noted, connect with a receipt printer and open on print -- or in some cases, when a certain character string is present. (I think.)
Now, since you can have JavaScript initiate a print, you could conceivably kick the drawer from any webpage. But, for the duration of the POS project I was working on, we never got the drawer auto-pop to work.) In the worst case, you can write a plugin to do the work. I'd try an applet first, of course.
However, if your PHP application runs on the same network as your POS stations, you can actually just add each printer to the server and print directly from the PHP app. And presumably, you can trigger the drawer similarly.
With WiFi enabled cash draws and printers I think you could be able to trigger a cash draw (located on a network) to open from anything that will kick off a web or socket request.
I have to build an EPOS system for work - as the old one is 20 years old and is crap! - plus building it yourself you have total control to design the stock and reporting exactly how you fancy.
Once I have played with the hardware I will report back :)
I know this is an old question, but the most simple solution is from within the printer/device configuration itself. Most POS printers have an option to trigger a drawer open, both on print or after printing. This goes for ALL Star, Citizen POS printers (or any POS printer for that matter). To access these settings, go into the device configuration options (in Windows based OS' - under Control Panel/Devices) and set it there.

Establish & Receive Calls via a GSM modem in PHP

I am having a CRM (Customer Relationship Management Software) built on php and running it on localhost (windows XP system). This contains the list of my clients. I want to be able to call these clients directly from my CRM and keep a log of the same. (Call time, call duration and record the calls). For incoming calls, I should be able to link it to my CRM, display the client details and log the data.
I have a voice enabled 3G GSM Modem (with USB connector) which can be used for this purpose. From my search, I understand I would need to send AT commands from PHP to interact with the modem. But I am not able to move ahead as I am completely new to this. I have never done any device interfacing before this.
Can you help me to understand how can I go about solving the above issue? Any leads, resources in this direction will be of great help.
I wouldn't try to do this with pure PHP since then you would have to have PHP interface with the hardware through the webserver, which can be a pain, if it is manageable at all. There are (edit) three options in my view:
1: AKA the hard way:
Write a PHP extension in C that does what you want, but this would mean a lot of programming for a relative small task.
2: The eas[y/ier] way:
Find a program (Maybe Skype?) that can do voice communication with your modem and has an API or a CLI so you can make PHP run:
voiceprogram.exe --call=555-000-5555 --saveTo=client1_20113103_1200.mp3
This allows the application to do what it's good as and only use PHP as the controller. The resulting MP3 (or Wav, OGG, etc) can be saved back to the CRM.
3: Other options
If you are able to program in a different language that does communicate easily with your modem you can write some custom code that can be triggered by PHP (sockets/SOAP/CLI) and handles the call. When finished it can 'POST' the call information back to your PHP script.
The first 2 solutions only work when the CRM runs on localhost, if you plan on using this in a shared network environment complexity will go up. The last option, if done correctly, can be used in a shared environment.

Categories