| 1 |
- |
1 |
<?php
|
| 5 |
- |
2 |
include_once('php/exchangeRates.php');
|
|
|
3 |
include_once('php/countryCodes.php');
|
|
|
4 |
include_once('php/constants.php');
|
|
|
5 |
include_once('php/ebay.php');
|
| 1 |
- |
6 |
|
| 5 |
- |
7 |
// search
|
|
|
8 |
function performSearch() {
|
|
|
9 |
$_SESSION["currentView"] = 'All';
|
|
|
10 |
$_SESSION["barcode"]["Type"] = clsLibGTIN::GTINCheck($_SESSION["searchTerm"], false, 1);
|
|
|
11 |
$_SESSION["barcode"]["Value"] = clsLibGTIN::GTINCheck($_SESSION["searchTerm"]);
|
| 1 |
- |
12 |
|
| 5 |
- |
13 |
$_SESSION["resultArr"] = [];
|
|
|
14 |
$_SESSION["resultArr"] = searchAll($_SESSION["searchTerm"]);
|
|
|
15 |
|
|
|
16 |
$_SESSION["lowestPrice"]["Used"] = findLowest("Used");
|
|
|
17 |
$_SESSION["lowestPrice"]["New"] = findLowest("New");
|
|
|
18 |
$_SESSION["lowestPrice"]["Digital"] = findLowest("Digital");
|
|
|
19 |
$_SESSION["lowestPrice"]["All"] = 0.00;
|
|
|
20 |
if (array_sum($_SESSION["lowestPrice"]) > 0) {
|
|
|
21 |
$_SESSION["lowestPrice"]["All"] = minNotNull($_SESSION["lowestPrice"]);
|
|
|
22 |
}
|
| 8 |
- |
23 |
|
|
|
24 |
saveSearchResult();
|
| 5 |
- |
25 |
}
|
|
|
26 |
|
|
|
27 |
// search for items on all sites
|
|
|
28 |
function searchAll($searchKey)
|
|
|
29 |
{
|
|
|
30 |
$arr = [];
|
|
|
31 |
$newArr = [];
|
|
|
32 |
if ($_SESSION["filterCondition"]["New"]) {
|
|
|
33 |
$arr = get_ebay($searchKey, constant("NEW"));
|
|
|
34 |
}
|
|
|
35 |
if ($_SESSION["filterCondition"]["Used"]) {
|
|
|
36 |
$newArr = get_ebay($searchKey, constant("USED"));
|
|
|
37 |
}
|
|
|
38 |
$arr = array_merge($arr, $newArr);
|
|
|
39 |
|
|
|
40 |
$arr = applyExchangeRates($arr);
|
|
|
41 |
usort($arr, 'compare_price');
|
|
|
42 |
|
|
|
43 |
return $arr;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
// check search filters
|
|
|
47 |
function checkSearchFilters() {
|
|
|
48 |
$_SESSION["filterWarnings"] = "";
|
|
|
49 |
$filterOk = true;
|
|
|
50 |
|
|
|
51 |
if (!$_SESSION["filterCondition"]["New"] && !$_SESSION["filterCondition"]["Used"]) {
|
|
|
52 |
$_SESSION["filterWarnings"] .= '<div class="alert alert-danger"><i class="fas fa-filter mr-1"></i> Please select at least one Condition (New or Used)</div>';
|
|
|
53 |
$filterOk = false;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
if (!$_SESSION["filterMediaType"]["CD"] && !$_SESSION["filterMediaType"]["Record"] && !$_SESSION["filterMediaType"]["Digital"]) {
|
|
|
57 |
$_SESSION["filterWarnings"] .= '<div class="alert alert-danger"><i class="fas fa-filter mr-1"></i> Please select at least one Media Type (CD, Record or Digital)</div>';
|
|
|
58 |
$filterOk = false;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
return($filterOk);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
// filter results for types All, New, Used or Digital
|
|
|
65 |
function filterResults()
|
|
|
66 |
{
|
|
|
67 |
foreach ($_SESSION["resultArr"] as &$value) {
|
|
|
68 |
if ($_SESSION["currentView"] == 'All') {
|
|
|
69 |
$value["Show"] = true;
|
|
|
70 |
} else {
|
|
|
71 |
$value["Show"] = ($_SESSION["currentView"] == $value["Type"]);
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
}
|
| 1 |
- |
75 |
|
|
|
76 |
// build HTML table from array
|
| 5 |
- |
77 |
function buildTable()
|
|
|
78 |
{
|
|
|
79 |
$str = "<div>";
|
|
|
80 |
$str .= "<table class=\"table table-striped table-condensed small\">";
|
|
|
81 |
$str .= "<thead class=\"thead-dark sticky-top\"><tr><th>Image</th><th class=\"text-left\">Title / Merchant</th><th>Condition</th><th class=\"hide-small\">Price</th><th class=\"hide-small\">S/H</th><th>Total</th><th class=\"hide-extra-small\"></th></tr></thead>";
|
|
|
82 |
$str .= "<tbody>";
|
| 1 |
- |
83 |
|
| 5 |
- |
84 |
foreach ($_SESSION["resultArr"] as $value) {
|
|
|
85 |
if (!$value["Show"]) {
|
|
|
86 |
continue;
|
|
|
87 |
}
|
| 1 |
- |
88 |
|
| 5 |
- |
89 |
$url = base64_encode($value["URL"]);
|
|
|
90 |
|
|
|
91 |
$str .= "<tr>";
|
| 1 |
- |
92 |
|
|
|
93 |
// Image
|
| 5 |
- |
94 |
$str .= "<td><a href=\"/redirect.php?target=" . $url . "\" target=\"_blank\"><img class=\"img-fluid\" src=\"" . $value["Image"] . "\" alt=\"Item Image\"></a></td>";
|
| 1 |
- |
95 |
|
|
|
96 |
// Title / Merchant
|
| 5 |
- |
97 |
$str .= "<td class=\"text-left\"><span class=\"font-weight-bold\"><a href=\"/redirect.php?target=" . $url . "\" target=\"_blank\">" . $value["Title"] . "</a></span><br/><br/>";
|
|
|
98 |
$str .= "<span class=\"font-weight-bold\">" . $value["Merchant"] . "</span>";
|
|
|
99 |
$str .= "<span class=\"hide-extra-small\"><br/>" . $value["SellerName"] . " (" . number_format($value["FeedbackScore"], 0, "", ",") . " / " . $value["FeedbackPercent"] . "%)</span></td>";
|
| 1 |
- |
100 |
|
|
|
101 |
// Condition
|
| 5 |
- |
102 |
$str .= "<td>";
|
|
|
103 |
$categoryIcon = "";
|
|
|
104 |
$categoryStyle = "";
|
|
|
105 |
$tooltip = "";
|
|
|
106 |
switch ($value["Category"]) {
|
|
|
107 |
case "CD":
|
|
|
108 |
$categoryIcon = "fas fa-compact-disc";
|
|
|
109 |
$categoryStyle = "color:silver;";
|
|
|
110 |
$tooltip = "Compact Disc";
|
|
|
111 |
break;
|
| 1 |
- |
112 |
|
| 5 |
- |
113 |
case "Record":
|
|
|
114 |
$categoryIcon = "fas fa-dot-circle";
|
|
|
115 |
$tooltip = "Vinyl Record";
|
|
|
116 |
break;
|
|
|
117 |
|
|
|
118 |
case "Digital":
|
|
|
119 |
$categoryIcon = "digital";
|
|
|
120 |
$tooltip = "Digital Download";
|
|
|
121 |
break;
|
|
|
122 |
}
|
|
|
123 |
$str .= "<span class=\"font-weight-bold\">" . $value["Condition"] . "</span>";
|
|
|
124 |
$str .= "<br/><br/>";
|
|
|
125 |
$str .= "<i class=\"" . $categoryIcon . "\" style=\"font-size:32px;text-shadow:2px 2px 4px #000000;" . $categoryStyle . "\" title=\"" . $tooltip . "\" data-toggle=\"tooltip\" data-placement=\"right\" data-delay=\"200\"></i>";
|
|
|
126 |
$str .= "</td>";
|
|
|
127 |
|
| 1 |
- |
128 |
// Price
|
| 5 |
- |
129 |
$str .= "<td class=\"hide-small\">" . print_monetary($value["Price"], $value["Currency"]);
|
|
|
130 |
if ($value["Currency"] != $_SESSION["buyer"]["Currency"]) {
|
|
|
131 |
$str .= "<br/>≈ " . print_monetary($value["ConvertedPrice"], $_SESSION["buyer"]["Currency"]);
|
|
|
132 |
}
|
|
|
133 |
$str .= "</td>";
|
| 1 |
- |
134 |
|
|
|
135 |
// Shipping and Handling Cost
|
| 5 |
- |
136 |
$str .= "<td class=\"hide-small\">";
|
|
|
137 |
if ($value["ShippingCost"] == 0.00) {
|
|
|
138 |
$str .= "Free Shipping";
|
|
|
139 |
} else {
|
|
|
140 |
$str .= print_monetary($value["ShippingCost"], $value["ShippingCurrency"]);
|
|
|
141 |
}
|
|
|
142 |
if ($value["ShippingCost"] > 0.00 && $value["ShippingCurrency"] != $_SESSION["buyer"]["Currency"]) {
|
|
|
143 |
$str .= "<br/>≈ " . print_monetary($value["ConvertedShippingCost"], $_SESSION["buyer"]["Currency"]);
|
|
|
144 |
}
|
|
|
145 |
$str .= "<br/><img class=\"img-fluid\" title=\"Ships from " . getCountry($value["Country"]) . "\" data-toggle=\"tooltip\" data-placement=\"right\" data-delay=\"200\" src=\"/images/flags/" . $value["Country"] . ".png\" alt=\"" . getCountry($value["Country"]) . " Flag\"></td>";
|
| 1 |
- |
146 |
|
|
|
147 |
// Total Price
|
| 5 |
- |
148 |
$str .= "<td class=\"font-weight-bolder\">" . print_monetary($value["ConvertedTotalPrice"], $_SESSION["buyer"]["Currency"]) . "</td>";
|
| 1 |
- |
149 |
|
|
|
150 |
// Link
|
| 5 |
- |
151 |
$str .= "<td class=\"hide-extra-small\"><a class=\"btn btn-danger\" role=\"button\" href=\"/redirect.php?target=" . $url . "\" target=\"_blank\"><i class=\"fas fa-shopping-cart\" style=\"font-size:20px\"></i><span class=\"hide-small\"><br>Buy It Now</span></a></td>";
|
| 1 |
- |
152 |
|
| 5 |
- |
153 |
$str .= "</tr>";
|
|
|
154 |
}
|
| 1 |
- |
155 |
|
| 5 |
- |
156 |
$str .= "</tbody>";
|
|
|
157 |
$str .= "<tfoot class=\"text-right\"><tr><td colspan=\"7\">Prices retrieved on " . gmdate("Y-m-d H:i") . " UTC<br>Daily exchange rates update</td></tr></tfoot>";
|
|
|
158 |
$str .= "</table>";
|
|
|
159 |
$str .= "</div>";
|
| 1 |
- |
160 |
|
| 5 |
- |
161 |
return ($str);
|
|
|
162 |
}
|
|
|
163 |
|
| 1 |
- |
164 |
// print summary/header on top of listing table
|
| 5 |
- |
165 |
function printTableHeader()
|
|
|
166 |
{
|
| 7 |
- |
167 |
global $handler;
|
|
|
168 |
|
| 5 |
- |
169 |
$str = '<form method="post" action="/index.php">';
|
| 7 |
- |
170 |
$str .= '<input type="hidden" name="sessionTab" value="' . $handler->getSessionTab() . '">';
|
|
|
171 |
$str .= '<div class="d-flex flex-wrap justify-content-center p-2">';
|
| 5 |
- |
172 |
$str .= ' <button name="submit" value="All" type="' . getButtonType("All") . '" class="btn mx-2 ' . getBackgroundColor("All") . '"';
|
|
|
173 |
if ($_SESSION["lowestPrice"]["All"] <= 0) {
|
|
|
174 |
$str .= ' disabled';
|
|
|
175 |
}
|
| 6 |
- |
176 |
$str .= '><span class="display-5 font-weight-bolder">All</span><span class="display-7"> from</span><br><span class="display-6 font-weight-bolder">' . print_monetary($_SESSION["lowestPrice"]["All"], $_SESSION["buyer"]["Currency"]) . '</span>';
|
| 5 |
- |
177 |
$str .= ' </button>';
|
|
|
178 |
$str .= ' <button name="submit" value="New" type="' . getButtonType("New") . '" class="btn mx-2 ' . getBackgroundColor("New") . '"';
|
|
|
179 |
if ($_SESSION["lowestPrice"]["New"] <= 0) {
|
|
|
180 |
$str .= ' disabled';
|
|
|
181 |
}
|
| 6 |
- |
182 |
$str .= '><span class="display-5 font-weight-bolder">New</span><span class="display-7"> from</span><br><span class="display-6 font-weight-bolder">' . print_monetary($_SESSION["lowestPrice"]["New"], $_SESSION["buyer"]["Currency"]) . '</span>';
|
| 5 |
- |
183 |
$str .= ' </button>';
|
|
|
184 |
$str .= ' <button name="submit" value="Used" type="' . getButtonType("Used") . '" class="btn mx-2 ' . getBackgroundColor("Used") . '"';
|
|
|
185 |
if ($_SESSION["lowestPrice"]["Used"] <= 0) {
|
|
|
186 |
$str .= ' disabled';
|
|
|
187 |
}
|
| 6 |
- |
188 |
$str .= '><span class="display-5 font-weight-bolder">Used</span><span class="display-7"> from</span><br><span class="display-6 font-weight-bolder">' . print_monetary($_SESSION["lowestPrice"]["Used"], $_SESSION["buyer"]["Currency"]) . '</span>';
|
| 5 |
- |
189 |
$str .= ' </button>';
|
|
|
190 |
/*
|
|
|
191 |
$str .= ' <button name="submit" value="Digital" type="' . getButtonType("Digital") . '" class="btn mx-2 ' . getBackgroundColor("Digital"). '"';
|
|
|
192 |
if ($_SESSION["lowestPrice"]["Digital"] <= 0) {
|
|
|
193 |
$str .= ' disabled';
|
| 1 |
- |
194 |
}
|
| 6 |
- |
195 |
$str .= '><span class="display-5 font-weight-bolder">Digital</span><span class="display-7"> from</span><br><span class="display-6 font-weight-bolder">' . print_monetary($_SESSION["lowestPrice"]["Digital"], $_SESSION["buyer"]["Currency"]) . '</span>';
|
| 5 |
- |
196 |
$str .= ' </button>';
|
|
|
197 |
*/
|
|
|
198 |
$str .= '</div>';
|
|
|
199 |
$str .= '</form>';
|
| 1 |
- |
200 |
|
| 5 |
- |
201 |
return $str;
|
|
|
202 |
}
|
| 1 |
- |
203 |
|
| 5 |
- |
204 |
// get top button background color
|
|
|
205 |
function getBackgroundColor($sel)
|
|
|
206 |
{
|
|
|
207 |
if ($_SESSION["currentView"] == $sel) {
|
|
|
208 |
return ("btn-primary active");
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
return ("btn-primary text-dark");
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
// get top button type
|
|
|
215 |
function getButtonType($sel)
|
|
|
216 |
{
|
|
|
217 |
if ($_SESSION["currentView"] == $sel) {
|
|
|
218 |
return ("button");
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
return ("submit");
|
|
|
222 |
}
|
|
|
223 |
|
| 1 |
- |
224 |
// compare price for sort low to high
|
| 5 |
- |
225 |
function compare_price($a, $b)
|
|
|
226 |
{
|
|
|
227 |
return strnatcmp($a['ConvertedTotalPrice'], $b['ConvertedTotalPrice']);
|
|
|
228 |
}
|
| 1 |
- |
229 |
|
|
|
230 |
// print monetary values with correct symbol and thousands/decimal delimiters
|
| 5 |
- |
231 |
function print_monetary($num, $curr)
|
|
|
232 |
{
|
|
|
233 |
if ($curr == "USD") {
|
|
|
234 |
return ("$" . number_format($num, 2, '.', ','));
|
|
|
235 |
} else if ($curr == "CAD") {
|
|
|
236 |
return ("C $" . number_format($num, 2, '.', ','));
|
|
|
237 |
} else if ($curr == "EUR") {
|
|
|
238 |
return (number_format($num, 2, ',', '.') . "€");
|
|
|
239 |
} else if ($curr == "GBP") {
|
|
|
240 |
return ("£" . number_format($num, 2, '.', ','));
|
|
|
241 |
} else if ($curr == "AUD") {
|
|
|
242 |
return ("AU $" . number_format($num, 2, '.', ','));
|
|
|
243 |
}
|
| 1 |
- |
244 |
|
| 5 |
- |
245 |
return ($curr . " " . number_format($num, 2, '.', ','));
|
|
|
246 |
}
|
| 1 |
- |
247 |
|
|
|
248 |
// find lowest used / new prices and return their array index
|
| 5 |
- |
249 |
function findLowest($type)
|
|
|
250 |
{
|
|
|
251 |
foreach ($_SESSION["resultArr"] as $value) {
|
|
|
252 |
if (!$value["Show"]) {
|
|
|
253 |
continue;
|
|
|
254 |
}
|
| 1 |
- |
255 |
|
| 5 |
- |
256 |
if ($type == $value["Type"]) {
|
|
|
257 |
return ($value["ConvertedTotalPrice"]);
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
return (0);
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
// find lowest non-zero double value in array
|
|
|
265 |
function minNotNull(Array $values)
|
|
|
266 |
{
|
|
|
267 |
return min(array_diff(array_map('doubleval', $values), array(0)));
|
|
|
268 |
}
|
| 1 |
- |
269 |
// apply exchange rates
|
| 5 |
- |
270 |
function applyExchangeRates($arr)
|
|
|
271 |
{
|
|
|
272 |
foreach ($arr as &$value) {
|
|
|
273 |
$value["ConvertedPrice"] = $value["Price"];
|
|
|
274 |
$value["ConvertedShippingCost"] = $value["ShippingCost"];
|
| 1 |
- |
275 |
|
| 5 |
- |
276 |
if ($_SESSION["buyer"]["Currency"] != $value["Currency"]) {
|
|
|
277 |
$value["ConvertedPrice"] = number_format($value["Price"] / getExchangeRate($_SESSION["buyer"]["Currency"], $value["Currency"]), 2, '.', '');
|
|
|
278 |
}
|
| 1 |
- |
279 |
|
| 5 |
- |
280 |
if ($_SESSION["buyer"]["Currency"] != $value["ShippingCurrency"]) {
|
|
|
281 |
$value["ConvertedShippingCost"] = number_format($value["ShippingCost"] / getExchangeRate($_SESSION["buyer"]["Currency"], $value["ShippingCurrency"]), 2, '.', '');
|
|
|
282 |
}
|
| 1 |
- |
283 |
|
| 5 |
- |
284 |
$value["ConvertedTotalPrice"] = number_format($value["ConvertedPrice"] + $value["ConvertedShippingCost"], 2, '.', '');
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
return ($arr);
|
|
|
288 |
}
|
|
|
289 |
|
| 1 |
- |
290 |
// sanitize user input
|
| 5 |
- |
291 |
function sanitizeInput($data)
|
|
|
292 |
{
|
|
|
293 |
$data = trim($data);
|
|
|
294 |
$data = stripslashes($data);
|
|
|
295 |
$data = htmlspecialchars($data);
|
|
|
296 |
return $data;
|
|
|
297 |
}
|
| 1 |
- |
298 |
|
|
|
299 |
// get a SESSION value, return empty string if not set
|
| 5 |
- |
300 |
function getSV($var)
|
|
|
301 |
{
|
|
|
302 |
if (!isset($_SESSION[$var])) {
|
|
|
303 |
return ('');
|
|
|
304 |
}
|
| 1 |
- |
305 |
|
| 5 |
- |
306 |
return ($_SESSION[$var]);
|
|
|
307 |
}
|
|
|
308 |
|
| 1 |
- |
309 |
// initialize a SESSION value if not set
|
| 5 |
- |
310 |
function initSV($var, $value)
|
|
|
311 |
{
|
|
|
312 |
if (!isset($_SESSION[$var])) {
|
|
|
313 |
$_SESSION[$var] = $value;
|
|
|
314 |
}
|
|
|
315 |
}
|
| 1 |
- |
316 |
|
| 5 |
- |
317 |
// initialize sessions variables
|
|
|
318 |
function initSessionVariables()
|
|
|
319 |
{
|
|
|
320 |
initSV("resultArr", []);
|
|
|
321 |
initSV("barcode", array("Type" => "", "Value" => ""));
|
|
|
322 |
initSV("buyer", array("Country" => "United States", "Currency" => "USD", "Zip" => ""));
|
|
|
323 |
initSV("filterCondition", array("New" => true, "Used" => true));
|
|
|
324 |
initSV("filterMediaType", array("CD" => true, "Record" => false, "Digital" => false));
|
|
|
325 |
initSV("currentView", "All");
|
|
|
326 |
initSV("lowestPrice", array("Used" => 0.00, "New" => 0.00, "Digital" => 0.00, "All" => 0.00));
|
|
|
327 |
initSV("filterWarnings", "");
|
|
|
328 |
}
|
|
|
329 |
|
| 1 |
- |
330 |
// check POST value, return true if set and false if not
|
| 5 |
- |
331 |
function checkPV($var)
|
|
|
332 |
{
|
|
|
333 |
if (isset($_POST[$var])) {
|
|
|
334 |
return (true);
|
|
|
335 |
}
|
| 1 |
- |
336 |
|
| 5 |
- |
337 |
return (false);
|
|
|
338 |
}
|
|
|
339 |
|
| 1 |
- |
340 |
// print search filter modal with current selection
|
| 5 |
- |
341 |
function printSearchFilterModal()
|
|
|
342 |
{
|
| 7 |
- |
343 |
global $handler;
|
|
|
344 |
|
| 5 |
- |
345 |
$str = '';
|
|
|
346 |
$str .= '<div class="modal fade" id="filterModal">';
|
|
|
347 |
$str .= ' <div class="modal-dialog">';
|
|
|
348 |
$str .= ' <div class="modal-content">';
|
|
|
349 |
$str .= '';
|
|
|
350 |
$str .= ' <div class="modal-header bg-primary">';
|
|
|
351 |
$str .= ' <h4 class="modal-title">Search Filters</h4>';
|
|
|
352 |
$str .= ' </div>';
|
|
|
353 |
$str .= '';
|
|
|
354 |
$str .= ' <form method="post" action="/index.php">';
|
| 7 |
- |
355 |
$str .= ' <input type="hidden" name="sessionTab" value="' . $handler->getSessionTab() . '">';
|
| 5 |
- |
356 |
$str .= ' <div class="modal-body">';
|
|
|
357 |
$str .= ' <div class="card-group">';
|
|
|
358 |
$str .= '';
|
|
|
359 |
$str .= ' <div class="card m-2">';
|
|
|
360 |
$str .= ' <div class="card-header font-weight-bold">Condition</div>';
|
|
|
361 |
$str .= ' <div class="card-body">';
|
|
|
362 |
$str .= ' <div class="form-check">';
|
|
|
363 |
$str .= ' <label class="form-check-label">';
|
|
|
364 |
$str .= ' <input name="filterConditionNew" type="checkbox" class="form-check-input" value="New"' . ($_SESSION["filterCondition"]["New"] ? " checked" : "") . '>New';
|
|
|
365 |
$str .= ' </label>';
|
|
|
366 |
$str .= ' </div>';
|
|
|
367 |
$str .= ' <div class="form-check">';
|
|
|
368 |
$str .= ' <label class="form-check-label">';
|
|
|
369 |
$str .= ' <input name="filterConditionUsed" type="checkbox" class="form-check-input" value="Used"' . ($_SESSION["filterCondition"]["Used"] ? " checked" : "") . '>Used';
|
|
|
370 |
$str .= ' </label>';
|
|
|
371 |
$str .= ' </div>';
|
|
|
372 |
$str .= ' </div>';
|
|
|
373 |
$str .= ' </div>';
|
|
|
374 |
$str .= '';
|
|
|
375 |
$str .= ' <div class="card m-2">';
|
|
|
376 |
$str .= ' <div class="card-header font-weight-bold">Media Type</div>';
|
|
|
377 |
$str .= ' <div class="card-body">';
|
|
|
378 |
$str .= ' <div class="form-check">';
|
|
|
379 |
$str .= ' <label class="form-check-label">';
|
|
|
380 |
$str .= ' <input name="filterMediaTypeCD" type="checkbox" class="form-check-input" value="CD"' . ($_SESSION["filterMediaType"]["CD"] ? " checked" : "") . '><i class="fas fa-compact-disc" style="color:silver;"></i> Compact Disc';
|
|
|
381 |
$str .= ' </label>';
|
|
|
382 |
$str .= ' </div>';
|
|
|
383 |
$str .= ' <div class="form-check">';
|
|
|
384 |
$str .= ' <label class="form-check-label">';
|
|
|
385 |
$str .= ' <input name="filterMediaTypeRecord" type="checkbox" class="form-check-input" value="Record"' . ($_SESSION["filterMediaType"]["Record"] ? " checked" : "") . '><i class="fas fa-dot-circle"></i> Vinyl Record';
|
|
|
386 |
$str .= ' </label>';
|
|
|
387 |
$str .= ' </div>';
|
|
|
388 |
$str .= ' <div class="form-check">';
|
|
|
389 |
$str .= ' <label class="form-check-label">';
|
|
|
390 |
$str .= ' <input name="filterMediaTypeDigital" type="checkbox" class="form-check-input" value="Digital"' . ($_SESSION["filterMediaType"]["Digital"] ? " checked" : "") . '><i class="fas fa-download"></i> Digital';
|
|
|
391 |
$str .= ' </label>';
|
|
|
392 |
$str .= ' </div>';
|
|
|
393 |
$str .= ' </div>';
|
|
|
394 |
$str .= ' </div>';
|
|
|
395 |
$str .= ' </div>';
|
|
|
396 |
$str .= ' </div>';
|
|
|
397 |
$str .= '';
|
|
|
398 |
$str .= ' <div class="modal-footer bg-primary">';
|
|
|
399 |
$str .= ' <button id="save" type="submit" class="btn btn-success" name="submit" value="Save">Save</button>';
|
|
|
400 |
$str .= ' <button id="discard" type="button" class="btn btn-danger" data-dismiss="modal">Discard</button>';
|
|
|
401 |
$str .= ' </div>';
|
|
|
402 |
$str .= ' </form>';
|
|
|
403 |
$str .= ' </div>';
|
|
|
404 |
$str .= ' </div>';
|
|
|
405 |
$str .= '</div>';
|
| 1 |
- |
406 |
|
| 5 |
- |
407 |
return ($str);
|
| 1 |
- |
408 |
}
|
| 3 |
- |
409 |
|
|
|
410 |
// print search info modal
|
| 5 |
- |
411 |
function printSearchInfoModal()
|
|
|
412 |
{
|
|
|
413 |
$str = '';
|
|
|
414 |
$str .= '<div class="modal fade" id="searchInfoModal">';
|
|
|
415 |
$str .= ' <div class="modal-dialog">';
|
|
|
416 |
$str .= ' <div class="modal-content">';
|
|
|
417 |
$str .= '';
|
|
|
418 |
$str .= ' <div class="modal-header bg-primary">';
|
|
|
419 |
$str .= ' <h4 class="modal-title">Search Tips</h4>';
|
|
|
420 |
$str .= ' <button type="button" class="close" data-dismiss="modal"><i class="fas fa-window-close" style="font-size:24px"></i></button>';
|
|
|
421 |
$str .= ' </div>';
|
|
|
422 |
$str .= '';
|
|
|
423 |
$str .= ' <div class="modal-body">';
|
|
|
424 |
$str .= ' <h4>Search Keywords</h4>';
|
|
|
425 |
$str .= '';
|
|
|
426 |
$str .= ' <p><span class=font-weight-bold>Barcode:</span>';
|
|
|
427 |
$str .= ' <br>The 12 or 13 digit barcode, normally located on the back, offers the best chance to find a specific album.</p>';
|
|
|
428 |
$str .= '';
|
|
|
429 |
$str .= ' <p><span class=font-weight-bold>Artist and Title:</span>';
|
|
|
430 |
$str .= ' <br>The full name of the album, including artist and title, will usually lead to a specific album.</p>';
|
|
|
431 |
$str .= '';
|
|
|
432 |
$str .= ' <p><span class=font-weight-bold>Just Artist or Title:</span>';
|
|
|
433 |
$str .= ' <br>Searches for artist or title alone will bring up random albums.</p>';
|
|
|
434 |
$str .= ' </div>';
|
|
|
435 |
$str .= ' </div>';
|
|
|
436 |
$str .= ' </div>';
|
|
|
437 |
$str .= '</div>';
|
| 3 |
- |
438 |
|
| 5 |
- |
439 |
return ($str);
|
| 3 |
- |
440 |
}
|
| 8 |
- |
441 |
|
|
|
442 |
function saveSearchResult() {
|
|
|
443 |
global $handler;
|
|
|
444 |
$_sess_db = $handler->getDBSessionId();
|
|
|
445 |
|
|
|
446 |
$access = mysqli_real_escape_string($_sess_db, time());
|
|
|
447 |
// country
|
|
|
448 |
// currency
|
|
|
449 |
$zip = mysqli_real_escape_string($_sess_db, $_SESSION['buyer']['Zip']);
|
|
|
450 |
$condNew = $_SESSION['filterCondition']['New'] ? 'Y' : 'N';
|
|
|
451 |
$condUsed = $_SESSION['filterCondition']['Used'] ? 'Y' : 'N';
|
|
|
452 |
$mediaCD = $_SESSION['filterMediaType']['CD'] ? 'Y' : 'N';
|
|
|
453 |
$mediaRecord = $_SESSION['filterMediaType']['Record'] ? 'Y' : 'N';
|
|
|
454 |
$mediaDigital = $_SESSION['filterMediaType']['Digital'] ? 'Y' : 'N';
|
|
|
455 |
$data = mysqli_real_escape_string($_sess_db, $_SESSION['searchTerm']);
|
|
|
456 |
$lowNew = floatval($_SESSION['lowestPrice']['New']);
|
|
|
457 |
$lowUsed = floatval($_SESSION['lowestPrice']['Used']);
|
|
|
458 |
$lowDigital = floatval($_SESSION['lowestPrice']['Digital']);
|
|
|
459 |
$count = count($_SESSION['resultArr']);
|
|
|
460 |
|
|
|
461 |
$sql = "INSERT
|
|
|
462 |
INTO searches
|
|
|
463 |
(sessId, access, zip, condNew, condUsed, mediaCD, mediaRecord, mediaDigital, data, lowNew, lowUsed, lowDigital, count)
|
|
|
464 |
VALUES ('" . session_id() . "', '$access', '$zip', '$condNew', '$condUsed', '$mediaCD', '$mediaRecord', '$mediaDigital', '$data', $lowNew, $lowUsed, $lowDigital, $count)";
|
|
|
465 |
|
|
|
466 |
return mysqli_query($_sess_db, $sql);
|
|
|
467 |
|
|
|
468 |
}
|
| 5 |
- |
469 |
?>
|