-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_label_2.php
173 lines (154 loc) · 3.87 KB
/
product_label_2.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
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
<?php
$sku = 'test';
$title = 'Carbon Fiber PETG Bear Wine Bottle Holder';
$filament_type = 'OV PLA+';
$filamnet_color = 'Orange';
require_once 'includes/site_params.php';
$sku = $_GET['sku'];
if (isset($_GET['qr_data'])) {
$qr_data = $_GET['qr_data'];
} else {
$qr_data = $sku;
}
$conn = mysqli_connect(
$_ENV['mysql_host'],
$_ENV['mysql_user'],
$_ENV['mysql_pass'],
'Web_3dprints'
) or die("Couldn't connect to server.");
if (strlen($sku) == 15 || (strlen($sku) == 3)) {
$get_color = true;
} else {
$get_color = false;
}
$base_sku = substr($sku, 0, 11);
$dyncolor_sku = $base_sku . '-000';
// Search Product by full SKU
$product_sql = "
SELECT
sku,
title
FROM
Web_3dprints.products
WHERE 1=1
AND sku = '$sku';
";
// Search Product by Dynamic Color
$product_dyncolor_sql = "
SELECT
sku,
title
FROM
Web_3dprints.products
WHERE 1=1
AND sku = '$dyncolor_sku';
";
$product_result = mysqli_query($conn, $product_sql);
$product_num_results = mysqli_num_rows($product_result);
$product_data = mysqli_fetch_assoc($product_result);
if ($product_num_results == 0) {
$dyncolor_product_result = mysqli_query($conn, $product_dyncolor_sql);
$product_data = mysqli_fetch_assoc($dyncolor_product_result);
}
if ($get_color) {
$color_id = substr($sku, -3);
$color_sql = "
SELECT
swatch_id,
`name`,
`type`,
color_name
FROM
Web_3dprints.filament
WHERE 1=1
AND (swatch_id = '$color_id' OR manufacture_barcode = '$sku');
";
$color_result = mysqli_query($conn, $color_sql);
$color_num_results = mysqli_num_rows($color_result);
$color_data = mysqli_fetch_assoc($color_result);
}
$title = $product_data['title'];
$filament_type = $color_data['type'];
$filament_color = $color_data['color_name'];
$qr_url = 'https://api.qrserver.com/v1/create-qr-code/?size=50x50&data=' . $qr_data;
?>
<html>
<head>
<style>
@page {
margin: 0;
}
body {
margin: 0in 0in 0in 0in;
width: 50mm;
height: 49.7mm;
}
.body {
width: 50mm;
height: 49.7mm;
}
.logo {
width: 33mm;
align-items: center;
padding-left: 0.02mm;
padding-top: 0.01mm;
}
.sku {
text-align: center;
text-wrap: wrap;
line-height: 15mm;
font-size: medium;
padding-left: 13.6mm;
}
.title {
text-align: center;
text-wrap: break-word;
padding-left: 0.1mm;
padding-right: 0.1mm;
padding-top: 1mm;
font-size: small;
height: 10mm;
max-width: 79.2mm;
/* padding-right: 12mm; */
}
.color-name {
text-align: center;
text-wrap: break-word;
padding-left: 0.1mm;
/* padding-right: 0.1mm; */
padding-bottom: 1mm;
font-size: small;
height: 2mm;
line-height: 1em;
max-height: 1em;
max-width: 49.2mm;
/* padding-right: 12mm; */
}
.qr {
width: 20mm;
float: right;
padding-top: 1mm;
padding-right: 1.5mm;
}
/* * {
font-family: arial;
font-size: 12px;
} */
.top-container {
width: 50mm;
height: 5mm;
}
</style>
</head>
<body>
<div class="top-container">
<img class="qr" src="<?php echo $qr_url; ?>">
</div>
<div class="title">
<img class="logo" src="images/logo_black_transparent.png"><br>
<b>
<?php echo $title; ?>
</b>
</div>
</body>
</html>