xos_redirect(xos_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'options_page=1&' . $parameter_string)); break; case 'delete_value': $value_id = xos_db_prepare_input($_GET['value_id']); xos_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int) $value_id . "'"); xos_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int) $value_id . "'"); xos_redirect(xos_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'options_page=1&' . $parameter_string)); break; case 'delete_attribute': $attribute_id = xos_db_prepare_input($_GET['attribute_id']); $products_id = xos_db_prepare_input($_GET['products_id']); $combinations_query = xos_db_query("select p.products_quantity, p.attributes_quantity, p.attributes_combinations, p.attributes_not_updated, pa.options_id, pa.options_values_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where p.products_id = '" . (int) $products_id . "' and pa.products_attributes_id = '" . (int) $attribute_id . "'"); $combinations = xos_db_fetch_array($combinations_query); $qty = 0; if (xos_not_null($combinations['attributes_combinations'])) { $attributes_not_updated = xos_get_attributes_not_updated($combinations['attributes_not_updated']); foreach ($attributes_not_updated as $key_not_updated => $val_not_updated) { if ($val_not_updated == $combinations['options_id'] . ',' . $combinations['options_values_id']) { unset($attributes_not_updated[$key_not_updated]); } } ksort($attributes_not_updated); if (empty($attributes_not_updated)) { $not_updated = "attributes_not_updated = null"; } else { $not_updated = "attributes_not_updated = '" . xos_db_input(serialize($attributes_not_updated)) . "'"; } $qty = $combinations['products_quantity']; $attributes_quantity = xos_get_attributes_quantity($combinations['attributes_quantity']); $combinations['attributes_combinations'] = trim($combinations['attributes_combinations'], '|'); $elements_comb = explode('|', $combinations['attributes_combinations']);
$product_query = xos_db_query("select p.products_status, p.attributes_quantity, p.attributes_combinations, p.attributes_not_updated, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int) $_GET['products_id'] . "' and pd.language_id = '" . (int) $_SESSION['used_lng_id'] . "'"); $product = xos_db_fetch_array($product_query); switch ($_GET['action']) { case 'combinations': switch ($product['products_status']) { case '0': $in_status = false; $out_status = true; break; case '1': default: $in_status = true; $out_status = false; } $attributes_quantity = xos_get_attributes_quantity($product['attributes_quantity']); $attributes_not_updated = xos_get_attributes_not_updated($product['attributes_not_updated']); xos_not_null($product['attributes_combinations']) ? $combinations_string = $product['attributes_combinations'] : ($combinations_string = ''); $opt_query = xos_db_query("select pa.options_id, po.products_options_name from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po where pa.products_id = '" . (int) $_GET['products_id'] . "' and pa.options_id = po.products_options_id and po.language_id = '" . (int) $_SESSION['used_lng_id'] . "' order by pa.options_sort_order asc, pa.options_id asc"); $opt_array = array(); $opt_values_array = array(); $opt_result_array = array(); $opt_rows_array = array(); $opt_out_array = array(); $i = 0; $ii = 1; $option_id = ''; while ($opt = xos_db_fetch_array($opt_query)) { if ($option_id == $opt['options_id']) { $i--; } $opt_array[$i] = array('options_id' => $opt['options_id'], 'options_name' => $opt['products_options_name'], 'options_values_qty' => $option_id == $opt['options_id'] || $option_id == '' ? $ii : ($ii = 1));