Execute("DELETE FROM " . $oostable['products_to_master'] . " WHERE slave_id = " . intval($_GET['slave_id']) . " AND master_id = " . intval($_GET['master_id']) . " LIMIT 1"); $check_product_result = $dbconn->Execute("SELECT slave_id, master_id FROM " . $oostable['products_to_master'] . " WHERE slave_id = " . intval($_GET['slave_id'])); if ($check_product_result->RecordCount() == 0) { $dbconn->Execute("UPDATE " . $oostable['products'] . " SET products_slave_visible = '1' WHERE products_id = " . intval($_GET['slave_id'])); } $messageStack->add_session('Slave Deleted', 'success'); oos_redirect_admin(oos_href_link_admin($aContents['wastebasket'], 'cPath=' . $cPath . '&pID=' . $_GET['master_id'] . '&action=slave_products')); break; case 'untrash': if ( isset($_GET['flag']) && ($_GET['flag'] == '1') || ($_GET['flag'] == '2') ) { if (isset($_GET['pID']) && is_numeric($_GET['pID'])) { oos_set_product_status($_GET['pID'], $_GET['flag']); } elseif (isset($_GET['cID']) && is_numeric($_GET['cID'])) { oos_set_categories_status($_GET['cID'], $_GET['flag']); } } oos_redirect_admin(oos_href_link_admin($aContents['wastebasket'], '&cPath=' . $cPath . '&page=' . $nPage)); break; case 'delete_category_confirm': if (isset($_POST['categories_id']) && is_numeric($_POST['categories_id'])) { $categories_id = oos_db_prepare_input($_POST['categories_id']); $categories = oos_get_category_tree($categories_id, '', '0', '', TRUE); $products = array(); $products_delete = array(); for ($i = 0, $n = count($categories); $i < $n; $i++) { $product_ids_result = $dbconn->Execute("SELECT products_id FROM " . $oostable['products_to_categories'] . " WHERE categories_id = '" . intval($categories[$i]['id']) . "'"); while ($product_ids = $product_ids_result->fields) { $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; // Move that ADOdb pointer! $product_ids_result->MoveNext(); } } reset($products); foreach ($products as $key => $value) { $category_ids = ''; for ($i = 0, $n = count($value['categories']); $i < $n; $i++) { $category_ids .= '\'' . $value['categories'][$i] . '\', '; } $category_ids = substr($category_ids, 0, -2); $check_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($key) . "' and categories_id not in (" . $category_ids . ")"); $check = $check_result->fields; if ($check['total'] < '1') { $products_delete[$key] = $key; } } for ($i = 0, $n = count($categories); $i < $n; $i++) { oos_remove_category($categories[$i]['id']); } foreach($products_delete as $key) { oos_remove_product($key); } } oos_redirect_admin(oos_href_link_admin($aContents['wastebasket'], 'cPath=' . $cPath)); break; case 'delete_product_confirm': if (isset($_POST['products_id']) && isset($_POST['product_categories']) && is_array($_POST['product_categories'])) { $product_id = oos_db_prepare_input($_POST['products_id']); $product_categories = oos_db_prepare_input($_POST['product_categories']); for ($i = 0, $n = count($product_categories); $i < $n; $i++) { $dbconn->Execute("DELETE FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($product_id) . "' AND categories_id = '" . intval($product_categories[$i]) . "'"); } $product_categories_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($product_id) . "'"); $product_categories = $product_categories_result->fields; if ($product_categories['total'] == '0') { oos_remove_product($product_id); } } oos_redirect_admin(oos_href_link_admin($aContents['wastebasket'], 'cPath=' . $cPath)); break; } } // check if the catalog image directory exists require 'includes/header.php'; ?>

'' . TEXT_INFO_HEADING_DELETE_CATEGORY . ''); $contents = array('form' => oos_draw_form('id', 'categories', $aContents['wastebasket'], 'action=delete_category_confirm&cPath=' . $cPath, 'post', FALSE) . oos_draw_hidden_field('categories_id', $cInfo->categories_id)); $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO); $contents[] = array('text' => '
' . $cInfo->categories_name . ''); if ($cInfo->childs_count > 0) $contents[] = array('text' => '
' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count)); if ($cInfo->products_count > 0) $contents[] = array('text' => '
' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count)); $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(BUTTON_DELETE_PERMANENTLY) . ' ' . BUTTON_CANCEL . ''); break; case 'delete_product': $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_PRODUCT . ''); $contents = array('form' => oos_draw_form('id', 'products', $aContents['wastebasket'], 'action=delete_product_confirm&cPath=' . $cPath, 'post', FALSE) . oos_draw_hidden_field('products_id', $pInfo->products_id)); $contents[] = array('text' => TEXT_DELETE_PRODUCT_INTRO); $contents[] = array('text' => '
' . $pInfo->products_name . ''); $product_categories_string = ''; $product_categories = oos_generate_category_path($pInfo->products_id, 'product'); for ($i = 0, $n = count($product_categories); $i < $n; $i++) { $category_path = ''; for ($j = 0, $k = count($product_categories[$i]); $j < $k; $j++) { $category_path .= $product_categories[$i][$j]['text'] . ' > '; } $category_path = substr($category_path, 0, -16); $product_categories_string .= oos_draw_checkbox_field('product_categories[]', $product_categories[$i][count($product_categories[$i])-1]['id'], true) . ' ' . $category_path . '
'; } $product_categories_string = substr($product_categories_string, 0, -6); $contents[] = array('text' => '
' . $product_categories_string); $contents[] = array('align' => 'center', 'text' => '
' . oos_submit_button(BUTTON_DELETE_PERMANENTLY) . ' ' . BUTTON_CANCEL . ''); break; default: if ($rows > 0) { if (isset($cInfo) && is_object($cInfo)) { // category info box contents $heading[] = array('text' => '' . $cInfo->categories_name . ''); $contents[] = array('align' => 'center', 'text' => '' . oos_button(BUTTON_EDIT) . '' . oos_button(BUTTON_DELETE) . '' . oos_button(BUTTON_UNTRASH) . ''); $contents[] = array('text' => TEXT_CATEGORIES . ' ' . oos_get_categories_name($cPath) . ' ' . oos_get_categories_name($cID) . '
' . TEXT_DATE_ADDED . ' ' . oos_date_short($cInfo->date_added)); $contents[] = array('text' => '
' . oos_info_image('category/medium/' . $cInfo->categories_image, $cInfo->categories_name) . '
' . $cInfo->categories_image); $contents[] = array('text' => '
' . TEXT_SUBCATEGORIES . ' ' . $cInfo->childs_count . '
' . TEXT_PRODUCTS . ' ' . $cInfo->products_count); } elseif (isset($pInfo) && is_object($pInfo)) { // product info box contents $heading[] = array('text' => '' . $pInfo->products_name . ''); $contents[] = array('align' => 'center', 'text' => '' . oos_button(BUTTON_EDIT) . '' . oos_button(BUTTON_DELETE) . '' . oos_button(BUTTON_UNTRASH) . ''); $contents[] = array('text' => '#' . $pInfo->products_id . ' ' . TEXT_CATEGORIES . ' ' . oos_get_categories_name($current_category_id) . '
' . TEXT_DATE_ADDED . ' ' . oos_date_short($pInfo->products_date_added)); if (oos_is_not_null($pInfo->products_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . oos_date_short($pInfo->products_last_modified)); if (date('Y-m-d') < $pInfo->products_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE . ' ' . oos_date_short($pInfo->products_date_available)); $contents[] = array('text' => '
' . product_info_image($pInfo->products_image, $pInfo->products_name) . '
' . $pInfo->products_image); $contents[] = array('text' => '
' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%'); } } else { // create category/product info $parent_categories_name = oos_output_generated_category_path($current_category_id); $heading[] = array('text' => '' . EMPTY_CATEGORY . ''); $contents[] = array('text' => sprintf(TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS, $parent_categories_name)); } break; } if ( (oos_is_not_null($heading)) && (oos_is_not_null($contents)) ) { ?>
Execute("SELECT c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified, c.categories_status FROM " . $oostable['categories'] . " c, " . $oostable['categories_description'] . " cd WHERE c.categories_id = cd.categories_id AND c.categories_status = 0 AND cd.categories_languages_id = '" . intval($_SESSION['language_id']) . "' AND cd.categories_name like '%" . oos_db_input($_GET['search']) . "%' ORDER BY c.sort_order, cd.categories_name"); } else { $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.categories_status FROM " . $oostable['categories'] . " c, " . $oostable['categories_description'] . " cd WHERE c.parent_id = '" . intval($current_category_id) . "' AND c.categories_status = 0 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 ($categories = $categories_result->fields) { $categories_count++; $rows++; // Get parent_id for subcategories if search if (isset($_GET['search'])) $cPath = intval($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' => oos_childs_in_category_count($categories['categories_id'])); $category_products = array('products_count' => oos_products_in_category_count($categories['categories_id'])); $cInfo_array = array_merge($categories, $category_childs, $category_products); $cInfo = new objectInfo($cInfo_array); } ?> MoveNext(); } $products_count = 0; if (isset($_GET['search'])) { $products_result = $dbconn->Execute("SELECT p.products_id, pd.products_name, p.products_quantity, p.products_reorder_level, p.products_image, p.products_price, p.products_base_price, p.products_base_unit, p.products_tax_class_id, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_setting, p2c.categories_id, p.products_price_list, p.products_quantity_order_min, p.products_quantity_order_max, p.products_quantity_order_units, p.products_discount1, p.products_discount2, p.products_discount3, p.products_discount4, p.products_discount1_qty, p.products_discount2_qty, p.products_discount3_qty, p.products_discount4_qty, p.products_sort_order FROM " . $oostable['products'] . " p, " . $oostable['products_description'] . " pd WHERE p.products_setting = '0' AND p.products_id = pd.products_id AND pd.products_languages_id = '" . intval($_SESSION['language_id']) . "' AND pd.products_name like '%" . oos_db_input($_GET['search']) . "%' OR p.products_model like '%" . oos_db_input($_GET['search']) . "%' ORDER BY pd.products_name"); } else { $products_result = $dbconn->Execute("SELECT p.products_id, pd.products_name, p.products_quantity, p.products_reorder_level, p.products_image, p.products_price, p.products_base_price, p.products_base_unit, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_tax_class_id, p.products_setting, p.products_price_list, p.products_quantity_order_min, p.products_quantity_order_max, p.products_quantity_order_units, p.products_discount1, p.products_discount2, p.products_discount3, p.products_discount4, p.products_discount1_qty, p.products_discount2_qty, p.products_discount3_qty, p.products_discount4_qty, p.products_sort_order FROM " . $oostable['products'] . " p, " . $oostable['products_description'] . " pd WHERE p.products_setting = '0' AND p.products_id = pd.products_id AND pd.products_languages_id = '" . intval($_SESSION['language_id']) . "' ORDER BY pd.products_name"); } while ($products = $products_result->fields) { $products_count++; $rows++; // Get categories_id for product if search if (isset($_GET['search'])) $cPath = intval($products['categories_id']); if ((!isset($_GET['pID']) && !isset($_GET['cID']) || (isset($_GET['pID']) && ($_GET['pID'] == $products['products_id']))) && !isset($pInfo) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { // find out the rating average from customer reviews $reviews_result = $dbconn->Execute("SELECT (avg(reviews_rating) / 5 * 100) as average_rating FROM " . $oostable['reviews'] . " WHERE products_id = '" . intval($products['products_id']) . "'"); $reviews = $reviews_result->fields; $pInfo_array = array_merge($products, $reviews); $pInfo = new objectInfo($pInfo_array); } if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id) ) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
  ' . ' #' . $categories['categories_id'] . ' ' . $categories['categories_name'] . ''; ?>   categories_id . '&action=edit_category') . '"> '; ?> 
'; ?> 
infoBox($heading, $contents); ?>