Ejemplo n.º 1
0
function xos_get_category_tree_for_movings($parent_id = '0', $spacing = '', $category_tree_array = '', $move_product = false)
{
    if (!is_array($category_tree_array)) {
        $category_tree_array = array();
    }
    if (sizeof($category_tree_array) < 1) {
        $category_tree_array[] = $move_product ? array('id' => '0', 'text' => TEXT_TOP, 'params' => 'style="color: grey;" disabled="disabled"') : array('id' => '0', 'text' => TEXT_TOP);
    }
    $categories_query = xos_db_query("select c.categories_or_pages_id, cpd.categories_or_pages_name, c.parent_id, c.categories_or_pages_status from " . TABLE_CATEGORIES_OR_PAGES . " c, " . TABLE_CATEGORIES_OR_PAGES_DATA . " cpd where c.categories_or_pages_id = cpd.categories_or_pages_id and c.is_page = 'false' and cpd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and c.parent_id = '" . (int) $parent_id . "' order by c.sort_order, cpd.categories_or_pages_name");
    while ($categories = xos_db_fetch_array($categories_query)) {
        if (xos_children_in_category_count($categories['categories_or_pages_id']) > 0 && $move_product || xos_children_in_category_count($categories['categories_or_pages_id']) == 0 && xos_products_in_category_count($categories['categories_or_pages_id'], true) > 0 && !$move_product) {
            $category_tree_array[] = array('id' => $categories['categories_or_pages_id'], 'text' => $spacing . $categories['categories_or_pages_name'], 'params' => 'style="color: grey;" disabled="disabled"');
        } else {
            $category_tree_array[] = array('id' => $categories['categories_or_pages_id'], 'text' => $spacing . $categories['categories_or_pages_name'], 'params' => $categories['categories_or_pages_status'] == 0 ? 'style="color: red;"' : '');
        }
        $category_tree_array = xos_get_category_tree_for_movings($categories['categories_or_pages_id'], $spacing . '&nbsp;&nbsp;&nbsp;', $category_tree_array, $move_product);
    }
    return $category_tree_array;
}
Ejemplo n.º 2
0
function xos_products_in_category_count($categories_or_pages_id, $include_deactivated = false)
{
    $products_count = 0;
    if ($include_deactivated) {
        $products_query = xos_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_or_pages_id = '" . (int) $categories_or_pages_id . "'");
    } else {
        $products_query = xos_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_or_pages_id = '" . (int) $categories_or_pages_id . "'");
    }
    $products = xos_db_fetch_array($products_query);
    $products_count += $products['total'];
    $children_query = xos_db_query("select categories_or_pages_id from " . TABLE_CATEGORIES_OR_PAGES . " where parent_id = '" . (int) $categories_or_pages_id . "'");
    if (xos_db_num_rows($children_query)) {
        while ($children = xos_db_fetch_array($children_query)) {
            $products_count += xos_products_in_category_count($children['categories_or_pages_id'], $include_deactivated);
        }
    }
    return $products_count;
}
Ejemplo n.º 3
0
         if ($product_categories['total'] == '0') {
             xos_remove_product($product_id);
         }
         $smarty_cache_control->clearAllCache();
     }
     xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
     break;
 case 'move_category_confirm':
     if (isset($_POST['categories_or_pages_id']) && $_POST['categories_or_pages_id'] != $_POST['move_to_category_id']) {
         $categories_or_pages_id = xos_db_prepare_input($_POST['categories_or_pages_id']);
         $new_parent_id = xos_db_prepare_input($_POST['move_to_category_id']);
         $path = explode('_', xos_get_generated_category_path_ids($new_parent_id));
         if (in_array($categories_or_pages_id, $path)) {
             $messageStack->add_session('header', ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
             xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cpID=' . $categories_or_pages_id));
         } elseif (xos_children_in_category_count($new_parent_id) == 0 && xos_products_in_category_count($new_parent_id) > 0) {
             $messageStack->add_session('header', ERROR_CANNOT_MOVE_CATEGORY_TO_CATEGORY_CONTAINING_PRODUCTS, 'error');
             xos_redirect(xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cpID=' . $categories_or_pages_id));
         } else {
             xos_db_query("update " . TABLE_CATEGORIES_OR_PAGES . " set parent_id = '" . (int) $new_parent_id . "', last_modified = now() where categories_or_pages_id = '" . (int) $categories_or_pages_id . "'");
             if ($new_parent_id > '0') {
                 $categories_query = xos_db_query("select categories_or_pages_status from " . TABLE_CATEGORIES_OR_PAGES . " where categories_or_pages_id = '" . (int) $new_parent_id . "'");
                 $categories = xos_db_fetch_array($categories_query);
                 if ($categories['categories_or_pages_status'] == '0') {
                     $tree = xos_get_category_tree($new_parent_id);
                     for ($i = 1; $i < sizeof($tree); $i++) {
                         xos_db_query("update " . TABLE_CATEGORIES_OR_PAGES . " set categories_or_pages_status = '0', last_modified = now() where categories_or_pages_id = '" . $tree[$i]['id'] . "'");
                     }
                 }
             }
             $smarty_cache_control->clearAllCache();
//              filename: categories.php
//
//              Released under the GNU General Public License
////////////////////////////////////////////////////////////////////////////////
if (!(@(include DIR_FS_SMARTY . 'admin/templates/' . ADMIN_TPL . '/php/includes/modules/categories_and_products.php') == 'overwrite_all')) {
    $categories_count = 0;
    $rows = 0;
    if (!isset($_GET['search'])) {
        $categories_query = xos_db_query("select c.categories_or_pages_id, cpd.categories_or_pages_name, c.categories_image, c.parent_id, c.product_list_b, c.sort_order, c.date_added, c.last_modified, c.categories_or_pages_status  from " . TABLE_CATEGORIES_OR_PAGES . " c, " . TABLE_CATEGORIES_OR_PAGES_DATA . " cpd where c.parent_id = '" . (int) $current_category_id . "' and c.categories_or_pages_id = cpd.categories_or_pages_id and c.is_page = 'false' and cpd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' order by c.sort_order, cpd.categories_or_pages_name");
        $categories_array = array();
        while ($categories = xos_db_fetch_array($categories_query)) {
            $categories_count++;
            $rows++;
            if ((!isset($_GET['cpID']) && !isset($_GET['pID']) || isset($_GET['cpID']) && $_GET['cpID'] == $categories['categories_or_pages_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') {
                $category_children = array('children_count' => xos_children_in_category_count($categories['categories_or_pages_id']));
                $category_products = array('products_count' => xos_products_in_category_count($categories['categories_or_pages_id']));
                $cInfo_array = array_merge((array) $categories, (array) $category_children, (array) $category_products);
                $cInfo = new objectInfo($cInfo_array);
            }
            $categories_array[] = array('selected' => isset($cInfo) && is_object($cInfo) && $categories['categories_or_pages_id'] == $cInfo->categories_or_pages_id ? true : false, 'status' => $categories['categories_or_pages_status'] == '1' ? true : false, 'name' => htmlspecialchars($categories['categories_or_pages_name']), 'sort_order' => $categories['sort_order'], 'icon_status_green' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_green.gif', ICON_TITLE_STATUS_GREEN), 'icon_status_red' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_red.gif', ICON_TITLE_STATUS_RED), 'icon_status_green_light' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_green_light.gif', ICON_TITLE_STATUS_GREEN_LIGHT), 'icon_status_red_light' => xos_image(DIR_WS_ADMIN_IMAGES . ADMIN_TPL . '/icon_status_red_light.gif', ICON_TITLE_STATUS_RED_LIGHT), 'link_filename_categories_flag_0' => xos_href_link(FILENAME_CATEGORIES, 'action=setflag_cat&flag=0&cpID=' . $categories['categories_or_pages_id'] . '&cPath=' . $cPath), 'link_filename_categories_flag_1' => xos_href_link(FILENAME_CATEGORIES, 'action=setflag_cat&flag=1&cpID=' . $categories['categories_or_pages_id'] . '&cPath=' . $cPath), 'link_filename_categories_get_path' => xos_href_link(FILENAME_CATEGORIES, xos_get_path($categories['categories_or_pages_id'])), 'link_filename_categories_cpath_cpath_cid' => xos_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cpID=' . $categories['categories_or_pages_id']));
        }
    }
    $products_count = 0;
    if (isset($_GET['search'])) {
        $search = xos_db_prepare_input($_GET['search']);
        $products_query = xos_db_query("select distinct p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_sort_order, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_or_pages_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and p.products_id = p2c.products_id and pd.products_name like '%" . xos_db_input($search) . "%' group by p.products_id order by p.products_sort_order, pd.products_name LIMIT 20");
    } else {
        $products_query = xos_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_sort_order, 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 p.products_id = pd.products_id and pd.language_id = '" . (int) $_SESSION['used_lng_id'] . "' and p.products_id = p2c.products_id and p2c.categories_or_pages_id = '" . (int) $current_category_id . "' order by p.products_sort_order, pd.products_name");
    }
    $products_array = array();
    while ($products = xos_db_fetch_array($products_query)) {