$not_is_new = substr($action, 0, 4) != 'new_'; $cID = $_GET['cID']; $pID = $_GET['pID']; $categories_query = olc_db_query($categories_query); while ($categories = olc_db_fetch_array($categories_query)) { $categories_count++; $rows++; // Get parent_id for subcategories if search if ($search) { $cPath = $categories['parent_id']; } $categories_id = $categories['categories_id']; if (!$pID) { if ((!$cID || $cID == $categories_id) && !$cInfo && $not_is_new) { $category_childs = array('childs_count' => olc_childs_in_category_count($categories_id)); $category_products = array('products_count' => olc_products_in_category_count($categories_id)); $cInfo_array = olc_array_merge($categories, $category_childs, $category_products); $cInfo = new objectInfo($cInfo_array); $categories_name = stripslashes($cInfo->categories_name); $cInfo->categories_name = str_replace('\\', EMPTY_STRING, $categories_name); } } if (is_object($cInfo) && $categories_id == $cInfo->categories_id) { $selected = 'Selected'; echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="javascript:' . olc_onclick_link(FILENAME_CATEGORIES, olc_get_path($categories_id)) . '">' . NEW_LINE; } else { $selected = EMPTY_STRING; echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" ' . 'onmouseout="this.className=\'dataTableRow\'" onclick="javascript:' . olc_onclick_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id) . '">' . NEW_LINE; } $td_start = '<td class="dataTableContent' . $selected . '" '; $categories_name = stripslashes($categories['categories_name']);
function olc_products_in_category_count($categories_id, $include_deactivated = false) { $products_count = 0; if ($include_deactivated) { $products_query = olc_db_query(SELECT . "count(*) as total" . SQL_FROM . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . $categories_id . APOS); } else { $products_query = olc_db_query(SELECT . "count(*) as total" . SQL_FROM . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . $categories_id . APOS); } $products = olc_db_fetch_array($products_query); $products_count += $products['total']; $childs_query = olc_db_query(SELECT . "categories_id" . SQL_FROM . TABLE_CATEGORIES . SQL_WHERE . "parent_id = '" . $categories_id . APOS); if (olc_db_num_rows($childs_query)) { while ($childs = olc_db_fetch_array($childs_query)) { $products_count += olc_products_in_category_count($childs['categories_id'], $include_deactivated); } } return $products_count; }