This repository has been archived by the owner on May 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Home
Mian Saleem edited this page Dec 6, 2016
·
1 revision
Welcome to the PHP POS Print Server (ppp) wiki!
{
"id": "2", // just for reference
"title": "Order Printer", // just for reference
"type": "network", // windows (usb, serial, parallel), network or linux
"profile": "default", // default, simple or SP2000 (star branded)
"path": "", // see below
"ip_address": "192.168.1.200", // ip address of network printer
"port": "9100", // printing port usually 9100
"char_per_line": "48" // printer characters per line
}
Printer Path:
For Windows: (Local USB, Serial or Parallel Printer): Share the printer and enter the share name for your printer here or for Server Message Block (SMB): enter as a smb:// url format such as smb://computername/Receipt Printer
For Linux: Parallel as /dev/lp0
, USB as /dev/usb/lp1
, USB-Serial as /dev/ttyUSB0
, Serial as /dev/ttyS0
{
"store_name": "My Shop", // will be printed in double size
"header": "Some header line\nLibe2", // will be printed in center
"info": "I: Some info line/nD: with some data", // will be printed left
"items": "default", // receipt items
"totals": "", // receipt totals
"payments": "", // will be after totals
"footer": "Thank you", // will be printed in center
}
To open set cash_drawer
to true in data
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PHP POS Print Server</title>
<!-- Styles -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet">
<style type="text/css" media="screen">
html, body { background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0; }
.full-height { height: 100vh; }
.flex-center { align-items: center; display: flex; justify-content: center; }
.position-ref { position: relative; }
.top-right { position: absolute; right: 10px; top: 18px; }
.content { text-align: center; }
.title { font-size: 48px; line-height: 48px; margin-bottom: 15px; }
#message, .info { margin: 20px 0; line-height: 18px; }
#message > span { text-transform: none; color: blue; }
#message, .info, .links > a { color: #636b6f; padding: 0 25px; font-size: 12px; font-weight: 600; letter-spacing: .1rem; text-decoration: none; text-transform: uppercase; }
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title">
PHP POS Print Server
</div>
<div class="links">
<a href="#" id="curr" onclick="return checkStatus()">Checking...</a>
</div>
<div id="message"></div>
<div class="links info"><a href="https://github.com/Tecdiary/ppp">GitHub Repository</a></div>
</div>
</div>
<script type="text/javascript">
var socket = null;
try {
socket = new WebSocket('ws://127.0.0.1:6441');
socket.onopen = function () {
document.getElementById('curr').innerHTML = "<span style='color:green;'>UP & RUNNING</span>";
return;
};
socket.onclose = function () {
document.getElementById('curr').innerHTML = "<span style='color:red;'>NOT CONNECTED</span>";
return;
};
} catch (e) {
console.log(e);
}
function openDrawer() {
var data = {
'printer': {"id":"2","title":"Order Printer","type":"network","profile":"default","path":"","ip_address":"192.168.1.200","port":"9100","char_per_line":"48"}
};
if (socket.readyState == 1) {
socket.send(JSON.stringify({
type: 'open-cashdrawer',
data: data
}));
return false;
} else {
alert('Not connected to socket.');
return false;
}
}
function printData() {
var data = {
'printer': {"id":"2","title":"Order Printer","type":"network","profile":"default","path":"","ip_address":"192.168.1.200","port":"9100","char_per_line":"48"},
'text': {"store_name": "Store Name\n", "header": "This is header text\nJust sample data only\n", "info": "R:Reference\nU: User\nT: Time\nC: Customer\n", "items": "Product 1 100.00\nProduct 2 200.00\n", "totals": "Total: 188.20\nRounding: 0.00\nGrand Total: 188.20\n", "payments": "", "footer": "Thank you for using ppp.\n\n"},
'cash_drawer': false
};
if (socket.readyState == 1) {
socket.send(JSON.stringify({
type: 'print-receipt',
data: data
}));
return false;
} else {
alert('Not connected to socket.');
return false;
}
}
function checkStatus() {
if (socket.readyState == 1) {
socket.send(JSON.stringify({
type: 'check-status'
}));
return false;
} else {
document.getElementById('message').innerHTML = 'Unable to connect to server.';
return false;
}
}
</script>
</body>
</html>