-
Notifications
You must be signed in to change notification settings - Fork 0
/
rend.js
138 lines (121 loc) · 4.82 KB
/
rend.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
const { ipcRenderer } = require('electron');
// const {remote} = require('electron');
const path = require("path");
// const { PosPrinter } = remote.require("electron-pos-printer");
// let printers = webContents.getPrinters(); //list the printers
// console.log(printers);
// pos-printer
$('#btn-print-pos').click(function () {
// array to keep table data from transaction
var myTableArray = [];
// looping to get data from transaction table to /* myTableArray */
$("table#invoicetrnxtable tr").each(function () {
var arrayOfThisRow = [];
var tableData = $(this).find('td');
if (tableData.length > 0) {
tableData.each(function () { arrayOfThisRow.push($(this).text()); });
myTableArray.push(arrayOfThisRow);
}
});
console.log(myTableArray);
// lllll
var getsumt = document.getElementById("sum-items").innerHTML;
var getsumq = document.getElementById("sum-price").innerHTML;
// ;llll
var poscompany = document.getElementById('cname').innerHTML;
var posloc = document.getElementById('loc').innerHTML;
var postel = document.getElementById('tel').innerHTML;
var posmail = document.getElementById('mail').innerHTML;
var pospost = document.getElementById('post').innerHTML;
var postax = document.getElementById('tax').innerHTML;
var totalp = getsumt;
var tqy = getsumq;
var rec = document.getElementById('in_no').innerHTML;
var dat = document.getElementById('in_date').innerHTML;
var tim = document.getElementById('in_time').innerHTML;
// NetSales
var posnet = parseFloat(totalp) - parseFloat(postax);
// var rec = document.getElementById('in_no').innerHTML;
let data = [
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: poscompany,
style: `text-align:center; font-size:16px; margin:0px 0px 0px 0px; width:100%;`,
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: posloc,
style: `text-align:center; font-size:16px; margin:0px 0px 0px 0px; width:100%;`,
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: postel,
style: `text-align:center; font-size:16px; margin:0px 0px 0px 0px; width:100%;`,
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: posmail,
style: `text-align:center; font-size:16px; margin:0px 0px 0px 0px; width:100%;`,
css: { "font-weight": "30" }
},
{
type: "text",
value: pospost,
style: "text-align:center; font-size:16px; margin:0px 0px 0px 0px; width:100%;",
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: dat,
style: `text-align:center; font-size:16px; margin:20px 0px 0px 0px; width:100%;`,
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: tim,
style: `text-align:center; font-size:16px; margin:0px 0px 0px 0px;`,
css: { "font-weight": "30" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: 'Reciept: ' + rec,
style: `text-align:center; font-weight:300; font-size:18px; width:100%; margin-top:10px;`
// css: {"font-weight": "300","font-size": "18px","border":"1px solid"}
},
{
type: 'table',
style: 'text-align: center; margin-top: 20px;',
tableHeader: ['Qty', 'Unit', 'Product', 'Payment', 'Total'],
tableBody: myTableArray,
tableFooter: ['T.Qty:', tqy, ' -', 'Total:', totalp],
// tableHeaderStyle: '',
// custom style for the table body
tableBodyStyle: 'margin: 10px;',
// custom style for the table footer
tableFooterStyle: 'margin-top:20px; background-color: #000; color: white;',
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
style: `text-align:center; font-weight:100; font-size:18px`,
value: ['3% Vat: ₵' + postax + ' ' + '</br> Netsales: ₵' + posnet],
style: `text-align:center; font-weight:100; font-size:18px; margin:20px 0 10px 0; width:100%;`,
css: { "font-weight": "100", "font-size": "18px", "text-align": "center", "border": "1px solid" }
},
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "Finacord(TM) © all rights reserved",
style: `text-align:center; width:100%; margin-left:0px;`,
css: { "font-weight": "30", "font-size": "12px", "margin-top": "10px" }
},
];
// printer data
var printerData = {
printerName: 'EPSON TM-T20III Receipt',
data: data
};
// sending data to ipcmain (index.js to render to pos-printer)
ipcRenderer.send('print', JSON.stringify(printerData));
});