forked from MoussaKassim/MO-DJIB-consulting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLMCODEBARRE.html
278 lines (229 loc) · 8.75 KB
/
LMCODEBARRE.html
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Générateur d'Étiquettes de Codes-Barres</title>
<style>
@font-face {
font-family: 'IDAutomationHC39M';
src: url('https://example.com/path/to/IDAutomationHC39M.ttf') format('truetype'); /* Remplace par le chemin réel vers la police */
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
color: #333;
text-align: center;
}
.container {
width: 100%;
padding: 20px;
box-sizing: border-box;
}
h1 {
font-size: 2em;
color: #2c3e50;
margin-bottom: 20px;
}
input[type="text"],
input[type="number"] {
padding: 10px;
margin: 5px;
border: 2px solid #ccc;
border-radius: 4px;
width: calc(100% - 24px);
max-width: 300px;
box-sizing: border-box;
transition: border-color 0.3s;
}
input[type="text"]:focus,
input[type="number"]:focus {
border-color: #3498db;
outline: none;
}
button {
background-color: #3498db;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s, transform 0.2s;
}
button:hover {
background-color: #2980b9;
transform: scale(1.05);
}
button:active {
transform: scale(0.98);
}
.label {
border: 2px solid #2c3e50;
border-radius: 8px;
padding: 20px;
margin: 10px;
width: 100mm; /* Ajuste la largeur selon la taille de ton étiquette */
height: 80mm; /* Ajuste la hauteur selon la taille de ton étiquette */
box-sizing: border-box;
background-color: #fff;
display: inline-block;
text-align: center;
position: relative;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transition: transform 0.2s, box-shadow 0.2s;
}
.label:hover {
transform: scale(1.02);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.barcode {
display: block;
text-align: center;
margin: 10px 0;
padding: 10px;
background-color: #f9f9f9;
border: 1px dashed #3498db;
border-radius: 4px;
}
.label-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px;
}
.print-button {
background-color: #2ecc71;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
margin-top: 20px;
transition: background-color 0.3s, transform 0.2s;
}
.print-button:hover {
background-color: #27ae60;
transform: scale(1.05);
}
.print-button:active {
transform: scale(0.98);
}
@media print {
body {
background-color: #fff;
color: #000;
margin: 0;
padding: 0;
}
.container {
width: 100%;
padding: 0;
}
.label {
page-break-inside: avoid;
float: none;
display: inline-block;
box-shadow: none;
}
.label-list {
column-count: 3; /* Ajuste le nombre de colonnes pour s'adapter à la taille de la feuille */
column-gap: 10mm; /* Espace entre les étiquettes */
margin: 0;
}
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/JsBarcode.all.min.js"></script>
</head>
<body>
<div class="container">
<h1>CABINET MO-DJB CONSULTING</h1>
<label for="clientName">Nom du client :</label>
<input type="text" id="clientName" value="ClientX">
<br><br>
<label for="numBarcodes">Nombre de codes-barres à générer :</label>
<input type="number" id="numBarcodes" value="100">
<br><br>
<label for="countryPrefix">Préfixe du pays :</label>
<input type="text" id="countryPrefix" value="253">
<br><br>
<label for="companyCode">Code de l'entreprise :</label>
<input type="text" id="companyCode" value="LM">
<br><br>
<label for="productCategory">Code de la catégorie de produit :</label>
<input type="text" id="productCategory" value="01">
<br><br>
<label for="date">Date (AAAAMMJJ) :</label>
<input type="text" id="date" value="XXXX-XX-XX">
<br><br>
<label for="time">Heure (HHMMSS) :</label>
<input type="text" id="time" value="00h00">
<br><br>
<label for="checkDigit">Chiffre de contrôle (optionnel) :</label>
<input type="text" id="checkDigit" placeholder="Calculé automatiquement si vide">
<br><br>
<label for="startNumber">Numéro de départ :</label>
<input type="number" id="startNumber" value="1">
<br><br>
<label for="includeLabelNumber">Inclure numéro d'étiquette :</label>
<input type="checkbox" id="includeLabelNumber" checked>
<br><br>
<button onclick="generateLabels()">Générer les Étiquettes</button>
<h2>Étiquettes Générées :</h2>
<div id="labelList" class="label-list"></div>
<button class="print-button" onclick="window.print()">Imprimer les Étiquettes</button>
</div>
<script>
function generateCheckDigit(barcode) {
let sum = 0;
for (let i = 0; i < barcode.length; i++) {
let num = parseInt(barcode[i], 10);
if (i % 2 === 0) {
sum += num;
} else {
sum += num * 3;
}
}
let checkDigit = (10 - (sum % 10)) % 10;
return checkDigit;
}
function generateLabels() {
const clientName = document.getElementById('clientName').value;
const numBarcodes = parseInt(document.getElementById('numBarcodes').value, 10);
const countryPrefix = document.getElementById('countryPrefix').value;
const companyCode = document.getElementById('companyCode').value;
const productCategory = document.getElementById('productCategory').value;
const date = document.getElementById('date').value;
const time = document.getElementById('time').value;
const userCheckDigit = document.getElementById('checkDigit').value;
const startNumber = parseInt(document.getElementById('startNumber').value, 10);
const includeLabelNumber = document.getElementById('includeLabelNumber').checked;
const labelList = document.getElementById('labelList');
labelList.innerHTML = ''; // Clear the list
for (let i = 0; i < numBarcodes; i++) {
const productCode = String(startNumber + i).padStart(3, '0'); // Pad product code with leading zeros if necessary
const barcode = `${countryPrefix}${productCategory}${productCode}`;
const checkDigit = userCheckDigit !== "" ? userCheckDigit : generateCheckDigit(barcode);
const fullBarcode = `${barcode}${checkDigit}`;
const label = document.createElement('div');
label.className = 'label';
if (includeLabelNumber) {
label.innerHTML = `<strong>${clientName}</strong><br><svg class="barcode"></svg><br>Date: ${date}<br>Heure: ${time}<br>Code de l'entreprise: ${companyCode}<br>Numéro d'étiquette: ${startNumber + i}`;
} else {
label.innerHTML = `<strong>${clientName}</strong><br><svg class="barcode"></svg><br>Date: ${date}<br>Heure: ${time}<br>Code de l'entreprise: ${companyCode}`;
}
labelList.appendChild(label);
JsBarcode(label.querySelector('.barcode'), fullBarcode, {
format: "CODE128",
width: 2,
height: 50,
displayValue: false
});
}
}
</script>
</body>
</html>