$categories_result = $dbconn->Execute("SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.access, c.categories_status FROM {$categoriestable} c, {$categories_descriptiontable} cd WHERE c.categories_id = cd.categories_id and cd.categories_languages_id = '" . intval($_SESSION['language_id']) . "' and cd.categories_name like '%" . $_GET['search'] . "%' ORDER BY c.sort_order, cd.categories_name"); } else { $categoriestable = $oostable['categories']; $categories_descriptiontable = $oostable['categories_description']; $categories_result = $dbconn->Execute("SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.access, c.categories_status FROM {$categoriestable} c, {$categories_descriptiontable} cd WHERE c.parent_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.categories_languages_id = '" . intval($_SESSION['language_id']) . "' ORDER BY c.sort_order, cd.categories_name"); } while ($aCategories = $categories_result->fields) { $categories_count++; $rows++; // Get parent_id for subcategories if search if (isset($_GET['search'])) { $categories = $aCategories['parent_id']; } if ((!isset($_GET['cID']) && !isset($_GET['pID']) || isset($_GET['cID']) && $_GET['cID'] == $aCategories['categories_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') { $category_childs = array('childs_count' => oos_childs_in_category_count($aCategories['categories_id'])); $category_products = array('products_count' => oos_products_in_category_count($aCategories['categories_id'])); $cInfo_array = array_merge($aCategories, $category_childs, $category_products); $cInfo = new objectInfo($cInfo_array); } if (isset($cInfo) && is_object($cInfo) && $aCategories['categories_id'] == $cInfo->categories_id) { echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . oos_href_link_admin($aFilename['categories'], oos_get_path($aCategories['categories_id'])) . '\'">' . "\n"; } else { echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . oos_href_link_admin($aFilename['categories'], 'categories=' . $categories . '&cID=' . $aCategories['categories_id']) . '\'">' . "\n"; } ?> <td class="dataTableContent"><?php echo '<a href="' . oos_href_link_admin($aFilename['categories'], oos_get_path($aCategories['categories_id'])) . '">' . oos_image(OOS_IMAGES . 'icons/folder.gif', ICON_FOLDER) . '</a> <b>' . ' #' . $aCategories['categories_id'] . ' ' . $aCategories['categories_name'] . '</b>'; ?> </td> <td class="dataTableContent" align="center"> </td> <td class="dataTableContent" align="center"> <?php
function oos_products_in_category_count($categories_id, $include_deactivated = false) { $products_count = 0; // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $productstable = $oostable['products']; $products_to_categoriestable = $oostable['products_to_categories']; if ($include_deactivated) { $products_query = "SELECT COUNT(*) AS total\n FROM {$productstable} p,\n {$products_to_categoriestable} p2c\n WHERE p.products_id = p2c.products_id\n AND p2c.categories_id = '" . intval($categories_id) . "'"; $products_result =& $dbconn->Execute($products_query); } else { $products_query = "SELECT COUNT(*) AS total\n FROM {$productstable} p,\n {$products_to_categoriestable} p2c\n WHERE p.products_id = p2c.products_id\n AND p.products_status >= '1'\n AND p2c.categories_id = '" . intval($categories_id) . "'"; $products_result =& $dbconn->Execute($products_query); } $products = $products_result->fields; // Close result set $products_result->Close(); $products_count += $products['total']; $categoriestable = $oostable['categories']; $childs_query = "SELECT categories_id\n FROM {$categoriestable}\n WHERE parent_id = '" . intval($categories_id) . "'"; $childs_result =& $dbconn->Execute($childs_query); if ($childs_result->RecordCount()) { while ($childs = $childs_result->fields) { $products_count += oos_products_in_category_count($childs['categories_id'], $include_deactivated); // Move that ADOdb pointer! $childs_result->MoveNext(); } } // Close result set $childs_result->Close(); return $products_count; }