-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
227 lines (186 loc) · 7.74 KB
/
index.html
File metadata and controls
227 lines (186 loc) · 7.74 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<link rel="manifest" href="manifest.json" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Asset Tiger Bulk Printer</title>
<meta name="description" content="">
<meta name="author" content="Tiwonge Lwara" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- bootstrap core css -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<!-- fonts style -->
<link href="css/googlefont.css" rel="stylesheet" />
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet" />
<!-- responsive style -->
<link href="css/responsive.css" rel="stylesheet" />
<script src="js/PapaParse-5.0.2/papaparse.min.js"></script>
<script defer
type="text/javascript" src="js/BrowserPrint-Zebra-1.1.250.min.js"></script>
<script defer
type="text/javascript"
src="js/BrowserPrint-3.1.250.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<main>
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="/images/barcode.png" alt="" width="30" height="24" class="d-inline-block align-text-top">
Barcode Printer
</a>
</div>
</nav>
<div class="hero_area" >
<div class="container ">
<div class="row">
<div class="col-md-5">
<div class="detail-box">
<h1>
BAR CODE <br>
PRINTING SERVICE
</h1>
<p>
First, upload your csv file and then click print.
</p>
<div class="btn-box">
<a href="Tag Sample.csv" download>Download Sample CSV here </a>
<label for="csvFileInput">Choose CSV File</label>
<input type="file" accept=".csv" id="csvFileInput">
<button class = "btn btn-success", id="printButton" onClick="parse_uploaded_csv()">Print Tags</button>
</div>
<hr>
<h1>
OR
</h1>
<p>
Print one Tag at a time and then click print.
</p>
<div class="btn-box">
<form>
<label for="tagInput" class="form-label">Asset Tag ID :</label>
<input type="text" class = "textinput form-control" id="tagInput" required>
<br>
<button class = "btn btn-primary", id="printButton" onClick="printSingleTag()">Print Tags</button>
</form>
<br>
</div>
</div>
</div>
<div class="col-md-7">
<div class="img-box">
<img src="images/tag.jpg" alt="">
</div>
</div>
</div>
</div>
</div>
</main>
<!-- footer section -->
<footer class="footer_section">
<div class="container">
<p>
© <span id="displayYear"></span> All Rights Reserved By
<a href="#">DevOps-EGPAF</a>
</p>
</div>
</footer>
<!-- footer section -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('serviceWorker.js').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function(err) {
//registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}else {
console.log('No service-worker on this browser');
}
</script>
<script>
let parsedData; // This will keep parsed data from PapaParse
function printSingleTag()
{
console.log("now in printing function")
const tagInput = document.getElementById("tagInput");
const tag = tagInput.value;
printCSV(tag)
}
function parse_uploaded_csv()
{
const fileInput = document.getElementById('csvFileInput');
const file = fileInput.files[0];
if (file) {
// Handle the CSV file here (e.g., parse and format data).
parseCSV(file, function (csvData)
{
console.log("Let's see", parsedData);
// Initiate the print action here (Zebra printer integration would go here).
// loop through and then send tag to be printed
csvData.forEach(function(rowData, index) {
console.log("Item " + (index + 1) + ":");
console.log("Asset Tag ID: " + rowData.Asset_Tag_ID);
const tag = rowData.Asset_Tag_ID
printCSV(tag)
});});
}
else {alert('Please select a CSV file.');
}
}
function parseCSV(file, callback) {
console.log("Now Parsing the uploaded CSV");
// Using Papa framework
Papa.parse(file, {
header: true,
transformHeader: function (header) {
// Replace spaces with underscores
return header.replace(/ /g, '_');
},
dynamicTyping: true,
complete: function (results) {
parsedData = results.data;
callback(parsedData); // Call the callback function with the parsed data
}
});
}
function printCSV(tag) {
// This will print data received from ParsedData
// Loop through the parsed data
console.log("Now Printing !");
console.log("this is what we have received for printing :"+tag);
const zplBarCodeCommand = `^XA
^FO250,20^CF0,40^FD^FDEGPAF-MALAWI^FS
^FO80,120^BY2^BCN,100,Y,N,N
^FD${tag}^FS
^FO80,240^A0N,30,30^FH\^FD${tag}^FS
^XZ`;
// Structure of Code taken from ASSETBOX
BrowserPrint.getDefaultDevice("printer", function(device) {
// Success callback function
console.log("Attempting connection to printer");
console.log(device);
device.send(zplBarCodeCommand, function(success) {
// Inner success callback function
console.log("Successfully sent job to the printer");
}, function(error) {
// Inner error callback function
console.error("Error:" + error);
});
}, function(error) {
// Outer error callback function
console.log("Problems connecting to the printer");
});
}
</script>
</body>
</html>