-
Notifications
You must be signed in to change notification settings - Fork 0
/
barcode_label.php
146 lines (130 loc) · 3.32 KB
/
barcode_label.php
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
<?php
$sku = 'test';
$title = 'Carbon Fiber PETG Bear Wine Bottle Holder';
$filamnet_color = 'Orange';
require_once 'includes/site_params.php';
$sku = $_GET['sku'];
$conn = mysqli_connect(
"sql.kumpedns.us",
$_ENV['mysql_user'],
$_ENV['mysql_pass'],
'Web_3dprints'
) or die("Couldn't connect to server.");
if (isset($_GET['distributor'])) {
$distributor = $_GET['distributor'];
} else {
$distributor = 0;
}
// Search Product by full SKU
$product_sql = "
SELECT
upc.upc,
upc.ean,
upc.sku,
IFNULL(dist.dist_sku, upc.sku) AS dist_sku
FROM
Web_3dprints.upc_codes upc
LEFT JOIN
distributor_skus dist ON dist.sku = upc.sku
AND dist.iddistributors = $distributor
WHERE 1 = 1
AND (upc.sku = '$sku' OR upc.upc = '$sku');
";
$product_result = mysqli_query($conn, $product_sql);
$product_num_results = mysqli_num_rows($product_result);
$product_data = mysqli_fetch_assoc($product_result);
if (true) {
$color_id = substr($product_data['sku'], -3);
$color_sql = "
SELECT
swatch_id,
`name`,
`type`,
color_name
FROM
Web_3dprints.filament
WHERE 1=1
AND (swatch_id = '$color_id');
";
$color_result = mysqli_query($conn, $color_sql);
$color_num_results = mysqli_num_rows($color_result);
$color_data = mysqli_fetch_assoc($color_result);
}
$filament_color = $color_data['color_name'];
$upc = $product_data['upc'];
$barcode = "https://barcodeapi.org/api/$upc";
?>
<html>
<head>
<style>
@page {
margin: 0;
}
body {
margin: 0in 0in 0in 0in;
width: 40mm;
height: 28mm;
}
.body {
width: 40mm;
height: 28mm;
}
.sku {
text-align: center;
text-wrap: break-word;
font-size: smaller;
max-width: 39.7mm;
/* padding-right: 12mm; */
line-height: 1em;
/* a */
max-height: 1em;
/* a x number of line to show (ex : 2 line) */
}
.color-name {
text-align: center;
text-wrap: break-word;
font-size: xx-small;
max-width: 39.7mm;
/* padding-right: 12mm; */
line-height: 1em;
/* a */
max-height: 1em;
/* a x number of line to show (ex : 2 line) */
}
.barcode-block {
text-align: center;
text-wrap: break-word;
font-size: x-small;
padding-top: 1mm;
max-width: 39.7mm;
/* padding-right: 12mm; */
line-height: 1em;
/* a */
max-height: 1em;
/* a x number of line to show (ex : 2 line) */
}
.qr {
height: 17mm;
}
/* * {
font-family: arial;
font-size: 12px;
} */
</style>
</head>
<body>
<div class="sku">
<b>
<?php echo $product_data['dist_sku']; ?>
</b>
</div>
<div class="color-name">
<b>
<?php echo $filament_color; ?>
</b>
</div>
<div class="barcode-block">
<img class="qr" src="<?php echo $barcode; ?>">
</div>
</body>
</html>