$cPath = $categories['parent_id']; } if ((!isset($_GET['cID']) && !isset($_GET['pID']) || isset($_GET['cID']) && $_GET['cID'] == $categories['categories_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') { $category_childs = array('childs_count' => smn_childs_in_category_count($categories['categories_id'])); $category_products = array('products_count' => smn_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 id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . smn_href_link(FILENAME_CATEGORIES, smn_get_path($categories['categories_id'])) . '\'">' . "\n"; } else { echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . smn_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n"; } ?> <td class="dataTableContent"><?php echo '<a href="' . smn_href_link(FILENAME_CATEGORIES, smn_get_path($categories['categories_id'])) . '">' . smn_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a> <b>' . $categories['categories_name'] . '</b>'; ?> </td> <td class="dataTableContent" align="center"> </td> <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && $categories['categories_id'] == $cInfo->categories_id) { echo smn_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . smn_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '">' . smn_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> </tr> <?php } $products_count = 0;
if (isset($cPath) && $cPath != '') { if (strpos('_', $cPath)) { // check to see if there are deeper categories within the current category $category_links = array_reverse($cPath_array); for ($i = 0, $n = sizeof($category_links); $i < $n; $i++) { $categories_query = smn_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.store_id= '" . $store->get_store_id() . "' and c.parent_id = '" . (int) $category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) $languages_id . "'"); $categories = smn_db_fetch_array($categories_query); if ($categories['total'] < 1) { // do nothing, go through the loop } else { $categories_query = smn_db_query("select c.categories_id, cd.categories_description, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.store_id= '" . $store->get_store_id() . "' and c.parent_id = '" . (int) $category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) $languages_id . "' order by sort_order, cd.categories_name"); break; // we've found the deepest category the customer is in } } } } else { $categories_query = smn_db_query("select c.categories_id, cd.categories_description, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.store_id= '" . $store->get_store_id() . "' and c.parent_id = '" . (int) $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) $languages_id . "' order by sort_order, cd.categories_name"); } $number_of_categories = smn_db_num_rows($categories_query); $rows = 0; while ($categories = smn_db_fetch_array($categories_query)) { $rows++; $cPath_new = smn_get_path($categories['categories_id']); $width = (int) (100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . smn_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . smn_image(DIR_WS_IMAGES . $categories['categories_image'], '', SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT, 'onmouseover=\'toolTip("' . ($categories['categories_description'] == '' ? $categories['categories_name'] : $categories['categories_description']) . '",this)\'') . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ($rows / MAX_DISPLAY_CATEGORIES_PER_ROW == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) && $rows != $number_of_categories) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } }
$categories_query = smn_db_query("select cd.categories_description, c.category_head_title_tag, c.category_head_desc_tag, c.category_head_keywords_tag, c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.store_id = '". $store_id . "' and c.store_id = '". $store_id . "' and c.parent_id = '" . (int)$current_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 = smn_db_fetch_array($categories_query)) { $categories_count++; $rows++; // Get parent_id for subcategories if search if (isset($_POST['search'])) $cPath= $categories['parent_id']; if ((!isset($_GET['cID']) && !isset($_GET['pID']) || (isset($_GET['cID']) && ($_GET['cID'] == $categories['categories_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { $category_childs = array('childs_count' => smn_childs_in_category_count($categories['categories_id'])); $category_products = array('products_count' => smn_products_in_category_count($categories['categories_id'])); $cInfo = array_merge($categories, $category_childs, $category_products); } ?> <?php if(!$action) {?> <td class="dataTableContent"><?php echo '<a href="' . smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, smn_get_path($categories['categories_id']).'&ID='.$store_id) . '">' . smn_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a> <b>' . $categories['categories_name'] . '</b>'; ?></td> <td class="dataTableContent" align="center"> </td> <td class="dataTableContent" align="right"><?php echo '<a href="' . smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath . '&ID='.$store_id.'&cID=' . $categories[categories_id] . '&action=edit_category') . '">' . smn_image(DIR_WS_ICONS . 'edit.png', IMAGE_ICON_EDIT) . '</a> '; echo '<a href="' . smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath . '&ID='.$store_id.'&cID=' . $categories[categories_id] . '&action=delete_category') . '">' . smn_image(DIR_WS_ICONS . 'delete.png', IMAGE_ICON_DELETE) . '</a> ';echo '<a href="' . smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath . '&ID='.$store_id.'&cID=' . $categories[categories_id] . '&action=move_category') . '">' . smn_image(DIR_WS_ICONS . 'move.png', IMAGE_ICON_MOVE) . '</a>'; ?> </td> </tr> <? } ?> <?php } $products_count = 0; if (isset($_POST['search'])) { $products_query = smn_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p2c.store_id = '". $store_id . "' and p.store_id = '" . $store_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . smn_db_input($search) . "%' order by pd.products_name"); } else { $products_query = smn_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p2c.store_id = '". $store_id . "' and p.store_id = '" . $store_id . "' and 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)$current_category_id . "' order by pd.products_name"); } while ($products = smn_db_fetch_array($products_query)) { $products_count++; $rows++;