forked from frankludriks/ocPOS25-Responsive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallprods.php
439 lines (363 loc) · 16.4 KB
/
allprods.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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<?php
include("includes/db.php");
include("includes/functions.php");
include("includes/session.php");
LoadLangFiles($lang);
/* // Determine if user is logged in
$session->logged_in = $session->checkLogin();
// If nobody is logged in, require login
if(!$session->logged_in) {
header('Location: login.php');
} */
$languages_id = get_default_lang();
if (isset($_GET['cPath'])) $current_category_id = $_GET['cPath'];
// clas and function info from osCommerce
class objectInfo {
// class constructor
function objectInfo($object_array) {
reset($object_array);
while (list($key, $value) = each($object_array)) {
$this->$key = tep_db_prepare_input($value);
}
}
}
function tep_db_prepare_input($string) {
if (is_string($string)) {
return trim(stripslashes($string));
} elseif (is_array($string)) {
reset($string);
while (list($key, $value) = each($string)) {
$string[$key] = tep_db_prepare_input($value);
}
return $string;
} else {
return $string;
}
}
function tep_get_category_name($category_id, $language_id=1, $fakename=0) {
$category_query = mysql_query("select categories_name from " . CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
$category = mysql_fetch_array($category_query);
if ($fakename == 1) {
if (substr_count($category['categories_name'], '_bundle') > 0 ) {
$inventory_name = substr_replace($category['categories_name'], ' Inventory ', -8, -1);
} else {
$inventory_name = $category['categories_name'];
}
return $inventory_name;
}
return $category['categories_name'];
}
////
// Count how many subcategories exist in a category
// TABLES: categories
function tep_childs_in_category_count($categories_id) {
$categories_count = 0;
$categories_query = mysql_query("select categories_id from " . CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
while ($categories = mysql_fetch_array($categories_query)) {
$categories_count++;
$categories_count += tep_childs_in_category_count($categories['categories_id']);
}
return $categories_count;
}
////
// Count how many products exist in a category
// TABLES: products, products_to_categories, categories
function tep_products_in_category_count($categories_id, $include_deactivated = false) {
$products_count = 0;
if ($include_deactivated) {
$products_query = mysql_query("select count(*) as total from " . PRODUCTS . " p, " . PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'");
} else {
$products_query = mysql_query("select count(*) as total from " . PRODUCTS . " p, " . PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'");
}
$products = mysql_fetch_array($products_query);
$products_count += $products['total'];
$childs_query = mysql_query("select categories_id from " . CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
if (mysql_num_rows($childs_query)) {
while ($childs = mysql_fetch_array($childs_query)) {
$products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);
}
}
return $products_count;
}
////
// The HTML href link wrapper function
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
if ($page == '') {
die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
}
// if ($connection == 'NONSSL') {
// $link = HTTP_SERVER . DIR_WS_ADMIN;
// } elseif ($connection == 'SSL') {
// if (ENABLE_SSL == 'true') {
// $link = HTTPS_SERVER . DIR_WS_ADMIN;
// } else {
// $link = HTTP_SERVER . DIR_WS_ADMIN;
// }
// } else {
// die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>');
// }
$link = '';
if ($parameters == '') {
$link = $link . $page . '?';
} else {
$link = $link . $page . '?' . $parameters;
}
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
return $link;
}
function tep_get_path($current_category_id = '') {
global $cPath_array;
if ($current_category_id == '') {
$cPath_new = implode('_', $cPath_array);
} else {
if (sizeof($cPath_array) == 0) {
$cPath_new = $current_category_id;
} else {
$cPath_new = '';
$last_category_query = mysql_query("select parent_id from " . CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
$last_category = mysql_fetch_array($last_category_query);
$current_category_query = mysql_query("select parent_id from " . CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$current_category = mysql_fetch_array($current_category_query);
if ($last_category['parent_id'] == $current_category['parent_id']) {
for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
} else {
for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
$cPath_new .= '_' . $cPath_array[$i];
}
}
$cPath_new .= '_' . $current_category_id;
if (substr($cPath_new, 0, 1) == '_') {
$cPath_new = substr($cPath_new, 1);
}
}
}
return 'cPath=' . $cPath_new;
}
////
// The HTML image wrapper function
function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
if (tep_not_null($alt)) {
$image .= ' title=" ' . tep_output_string($alt) . ' "';
}
if (tep_not_null($width) && tep_not_null($height)) {
$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
}
if (tep_not_null($parameters)) $image .= ' ' . $parameters;
$image .= '>';
return $image;
}
function tep_not_null($value) {
if (is_array($value)) {
if (sizeof($value) > 0) {
return true;
} else {
return false;
}
} else {
if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
return true;
} else {
return false;
}
}
}
function tep_info_image($image, $alt, $width = '', $height = '') {
if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
$image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
} else {
$image = TEXT_IMAGE_NONEXISTENT;
}
return $image;
}
////
// Output a function button in the selected language
function tep_image_button($image, $alt = '', $params = '') {
global $language;
return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params);
}
////
// Parse the data used in the html tags to ensure the tags will not break
function tep_parse_input_field_data($data, $parse) {
return strtr(trim($data), $parse);
}
function tep_output_string($string, $translate = false, $protected = false) {
if ($protected == true) {
return htmlspecialchars($string);
} else {
if ($translate == false) {
return tep_parse_input_field_data($string, array('"' => '"'));
} else {
return tep_parse_input_field_data($string, $translate);
}
}
}
// determine whether or not to include disabled products in search results
// if (ALLOW_DISABLED_PRODUCTS == '0') {
// $products_status_filter = " and p.products_status = '1' ";
// } else {
// $products_status_filter = '';
// }
// need to show all products, active or not. Otherwise there is potential confusion with Tranfer Orders
$products_status_filter = '';
$categories_count = 0;
$rows = 0;
if (isset($_GET['cPath'])) {
$parent_category_id = $_GET['cPath'];
} else {
if ($_SESSION['username'] == 'admin') {
$parent_category_id = 0;
} else {
$sql = "SELECT categories_id FROM " . CATEGORIES_DESCRIPTION . " WHERE categories_name = '" . $_SESSION['username'] . "'";
$query_result = oc_query($sql, 'Category ID Lookup');
$result_array = mysql_fetch_array($query_result);
$parent_category_id = $result_array['categories_id'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<link rel="icon" href="favicon.ico">
<title><?php echo($POSName) . ': ' . TITLE; ?></title>
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link href="user.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="jumbotron-narrow.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script language="JavaScript" src="javascript.js" type="text/javascript"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div class="container">
<?php include("includes/header.php"); ?>
<div id="spiffycalendar" class="text"></div>
<table class="table table-striped table-condensed table-hover" align="center">
<tr>
<thead>
<th align="left"><b><?php echo tep_get_category_name($parent_category_id, 1, 1); ?></b></td>
<th align="center"><b>Model Number</b></td>
<!--<td align="center" width="70"><b>Size</b></td>-->
<th align="center"><b>Quantity in Stock</b></td>
</thead>
</tr>
<?php
// $products_stock_table = GetProductStockTableName();
$categories_query = mysql_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . CATEGORIES . " c, " . CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$parent_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
while ($categories = mysql_fetch_array($categories_query)) {
$categories_count++;
$rows++;
$category_childs = array('childs_count' => tep_childs_in_category_count($categories['categories_id']));
$category_products = array('products_count' => tep_products_in_category_count($categories['categories_id']));
$cInfo_array = array_merge($categories, $category_childs, $category_products);
$cInfo = new objectInfo($cInfo_array);
if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) {
echo ' <tr onclick="document.location.href=\'' . tep_href_link('allprods.php', tep_get_path($categories['categories_id'])) . '\'">' . "\n";
} else {
echo ' <tr onclick="document.location.href=\'' . tep_href_link('allprods.php', 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n";
}
if (substr_count($categories['categories_name'], '_bundle') > 0) {
$catname = substr_replace($categories['categories_name'], ' Inventory ', -8, -1);
} else {
$catname = $categories['categories_name'];
}
?>
<td><?php echo '<a href="' . tep_href_link('allprods.php', tep_get_path($categories['categories_id'])) . '"><span class="glyphicon glyphicon-folder-close"</span></a> <b>' . $catname . '</b>'; ?></td>
<td align="center"> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<?php
}
$products_count = 0;
$products_by_size_count = 0;
$in_stock_count = 0;
$products_query = mysql_query("select p.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_ordered from " . PRODUCTS . " p, " . PRODUCTS_DESCRIPTION . " pd, " . PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$parent_category_id . "' $products_status_filter order by pd.products_name");
while ($products = mysql_fetch_array($products_query)) {
$products_count++;
$rows++;
?>
<tr>
<td class="dataTableContent"><a href="product.php?ProductID=<?php echo $products['products_id']; ?>"><?php echo $products['products_name']; ?></a></td>
<!-- show model number -->
<td align="center"><?php echo $products['products_model']; ?></td>
<!-- <td align="right"> </td>-->
<td align="center"><?php echo $products['products_quantity']; ?></td>
</tr>
<!-- show products in stock -->
<?php
/* $products_stock_query = mysql_query("SELECT ps.products_stock_attributes, ps.products_stock_quantity, pov.products_options_values_name FROM " . PRODUCTS_STOCK . " ps, " . PRODUCTS_OPTIONS_VALUES . " pov WHERE pov.products_options_values_id = substring(ps.products_stock_attributes,3) AND ps.products_id = '" . $products['products_id'] . "'");
while ($products_stock_results = mysql_fetch_array($products_stock_query)) {
$products_by_size_count++;
$in_stock_count += $products_stock_results['products_stock_quantity'];
echo ' <tr>' . "\n";
echo ' <td colspan="2"> </td>'. "\n";
echo ' <td align="center">' . $products_stock_results['products_options_values_name'] . '55</td>'. "\n";
echo ' <td align="center">' . $products_stock_results['products_stock_quantity'] . '</td>'. "\n";
echo ' </tr>';
} */
?>
<?php
}
$cPath_back = '';
if (sizeof($cPath_array) > 0) {
for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) {
if (empty($cPath_back)) {
$cPath_back .= $cPath_array[$i];
} else {
$cPath_back .= '_' . $cPath_array[$i];
}
}
}
$cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
?>
<tr>
<td colspan="4" align="right"> </td>
</tr>
<tr>
<td colspan="2" align="right">Products by Size</td>
<td align="center"><b><?php echo $products_by_size_count; ?></b></td>
<td align="right"> </td>
</tr>
<tr>
<td colspan="2" align="right">Total Units In Stock</td>
<td align="right"> </td>
<td align="center"><b><?php echo $in_stock_count; ?></b></td>
</tr>
<tr>
<td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText"><br><br><?php echo 'Categories ' . $categories_count . '<br>' . 'Products ' . $products_count; ?></td>
<td align="right" class="smallText"><?php if (sizeof($cPath_array) > 0) {
echo '<a href="' . tep_href_link('allprods.php', $cPath_back . 'cID=' . $current_category_id) . '">button</a> ';
} else {
echo '<button onclick="goBack()">Go Back</button>';
}
?>
</td>
</tr>
</table></td>
</tr>
</table>
<script>
function goBack() {
window.history.back();
}
</script>
<footer class="footer">
<?php include("includes/footer.php"); ?>
</footer>
</div> <!-- /container -->
</body>
</html>