function zen_get_category_tree($parent_id = '3', $category_tree_array = '')
{
    global $db;
    if (!is_array($category_tree_array)) {
        $category_tree_array = array();
    }
    $categories = $db->Execute("select c.categories_id, cd.categories_name, c.parent_id\n                                from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd\n                                where c.categories_id = cd.categories_id\n                                and cd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                and c.parent_id = '" . (int) $parent_id . "'\n                                order by c.sort_order, cd.categories_name");
    while (!$categories->EOF) {
        if (zen_products_in_category_count($categories->fields['categories_id'], true, true) >= 1) {
            $category_tree_array[] = array('id' => $categories->fields['categories_id'], 'text' => $categories->fields['categories_name']);
        }
        $categories->MoveNext();
    }
    return $category_tree_array;
}
      </tr>
  <tr>
    <td class="smallText" width="100%" align="right">
<?php 
    // toggle switch for editor
    echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_CATEGORIES, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') . zen_hide_session_id() . zen_draw_hidden_field('cID', $cPath) . zen_draw_hidden_field('cPath', $cPath) . zen_draw_hidden_field('pID', $_GET['pID']) . zen_draw_hidden_field('page', $_GET['page']) . zen_draw_hidden_field('action', 'set_editor') . '</form>';
    ?>
    </td>
  </tr>

  <tr>
    <td class="smallText" width="100%" align="right">
      <?php 
    // check for which buttons to show for categories and products
    $check_categories = zen_has_category_subcategories($current_category_id);
    $check_products = zen_products_in_category_count($current_category_id, false, false, 1);
    $zc_skip_products = false;
    $zc_skip_categories = false;
    if ($check_products == 0) {
        $zc_skip_products = false;
        $zc_skip_categories = false;
    }
    if ($check_categories == true) {
        $zc_skip_products = true;
        $zc_skip_categories = false;
    }
    if ($check_products > 0) {
        $zc_skip_products = false;
        $zc_skip_categories = true;
    }
    if ($zc_skip_products == true) {
Example #3
0
function zen_products_in_category_count($categories_id, $include_deactivated = false, $include_child = true, $limit = false)
{
    global $db;
    $products_count = 0;
    if ($limit) {
        $limit_count = ' limit 1';
    } else {
        $limit_count = '';
    }
    if ($include_deactivated) {
        $products = $db->Execute("select count(*) as total\n                                from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n                                where p.products_id = p2c.products_id\n                                and p2c.categories_id = '" . (int) $categories_id . "'" . $limit_count);
    } else {
        $products = $db->Execute("select count(*) as total\n                                from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n                                where p.products_id = p2c.products_id\n                                and p.products_status = 1\n                                and p2c.categories_id = '" . (int) $categories_id . "'" . $limit_count);
    }
    $products_count += $products->fields['total'];
    if ($include_child) {
        $childs = $db->Execute("select categories_id from " . TABLE_CATEGORIES . "\n                              where parent_id = '" . (int) $categories_id . "'");
        if ($childs->RecordCount() > 0) {
            while (!$childs->EOF) {
                $products_count += zen_products_in_category_count($childs->fields['categories_id'], $include_deactivated);
                $childs->MoveNext();
            }
        }
    }
    return $products_count;
}
Example #4
0
function zen_products_in_category_count($categories_id, $include_deactivated = false, $include_child = true, $limit = false)
{
    global $gBitDb;
    $products_count = 0;
    if ($limit) {
        $limit_count = 1;
    } else {
        $limit_count = 100;
    }
    if ($include_deactivated) {
        $products = $gBitDb->Execute("SELECT count(*) as `total`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`products_id` = p2c.`products_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand p2c.`categories_id` = '" . (int) $categories_id . "'", NULL, $limit_count);
    } else {
        $products = $gBitDb->Execute("SELECT count(*) as `total`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`products_id` = p2c.`products_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand p.`products_status` = '1'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand p2c.`categories_id` = '" . (int) $categories_id . "'", NULL, $limit_count);
    }
    $products_count += $products->fields['total'];
    if ($include_child) {
        $childs = $gBitDb->Execute("SELECT `categories_id` FROM " . TABLE_CATEGORIES . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `parent_id` = '" . (int) $categories_id . "'");
        if ($childs->RecordCount() > 0) {
            while (!$childs->EOF) {
                $products_count += zen_products_in_category_count($childs->fields['categories_id'], $include_deactivated);
                $childs->MoveNext();
            }
        }
    }
    return $products_count;
}