[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> categories.php (source)

   1  <?php
   2  /*
   3  $Id: categories.php 16 2006-07-30 03:27:26Z user $
   4  
   5    osCMax Power E-Commerce
   6    http://oscdox.com
   7  
   8    Copyright 2006 osCMax
   9  
  10    Released under the GNU General Public License
  11  */
  12  
  13    require ('includes/application_top.php');
  14  // LINE ADDED: Categories Description 1.5
  15    require ('includes/functions/categories_description.php');
  16  
  17  // LINE ADDED: FCKEditor
  18    require (DIR_FCKEDITOR . 'fckeditor.php');
  19    require (DIR_WS_CLASSES . 'currencies.php');
  20    $currencies = new currencies();
  21  
  22    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  23  
  24  // Ultimate SEO URLs v2.1
  25  // If the action will affect the cache entries
  26      if ( eregi("(insert|update|setflag)", $action) ) include_once ('includes/reset_seo_cache.php');
  27  
  28  
  29    if (tep_not_null($action)) {
  30      switch ($action) {
  31        case 'setflag':
  32          if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
  33            if (isset($HTTP_GET_VARS['pID'])) {
  34              tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
  35            }
  36  
  37            if (USE_CACHE == 'true') {
  38              tep_reset_cache_block('categories');
  39              tep_reset_cache_block('also_purchased');
  40            }
  41          }
  42  
  43          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
  44          break;
  45  // BOF: MOD for Categories Description 1.5
  46        case 'new_category':
  47        case 'edit_category':
  48          if (ALLOW_CATEGORY_DESCRIPTIONS == 'true')
  49            $HTTP_GET_VARS['action']=$HTTP_GET_VARS['action'] . '_ACD';
  50          break;
  51  // EOF: MOD for Categories Description 1.5
  52        case 'insert_category':
  53        case 'update_category':
  54  // BOF: MOD for Categories Description 1.5
  55          if ( ($HTTP_POST_VARS['edit_x']) || ($HTTP_POST_VARS['edit_y']) ) {
  56            $HTTP_GET_VARS['action'] = 'edit_category_ACD';
  57          } else {
  58  // EOF: MOD for Categories Description 1.5
  59            if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
  60  // BOF: MOD for Categories Description 1.5
  61            if ($categories_id == '') {
  62               $categories_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  63             }
  64  // EOF: MOD for Categories Description 1.5
  65            $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
  66  
  67          $sql_data_array = array('sort_order' => (int)$sort_order);
  68  
  69            if ($action == 'insert_category') {
  70              $insert_sql_data = array('parent_id' => $current_category_id,
  71                                       'date_added' => 'now()');
  72  
  73              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  74  
  75              tep_db_perform(TABLE_CATEGORIES, $sql_data_array);
  76  
  77              $categories_id = tep_db_insert_id();
  78              } elseif ($action == 'update_category') {
  79                $update_sql_data = array('last_modified' => 'now()');
  80  
  81                $sql_data_array = array_merge($sql_data_array, $update_sql_data);
  82  
  83                tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
  84              }
  85  
  86              $languages = tep_get_languages();
  87              for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  88                $categories_name_array = $HTTP_POST_VARS['categories_name'];
  89  
  90                $language_id = $languages[$i]['id'];
  91  
  92                $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));
  93  
  94  // BOF: MOD for Categories Description 1.5
  95                if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {
  96                  $sql_data_array = array('categories_name' => tep_db_prepare_input($HTTP_POST_VARS['categories_name'][$language_id]),
  97                                          'categories_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['categories_heading_title'][$language_id]),
  98                                          'categories_description' => tep_db_prepare_input($HTTP_POST_VARS['categories_description'][$language_id]));
  99                }
 100  // EOF: MOD for Categories Description 1.5
 101                if ($action == 'insert_category') {
 102                  $insert_sql_data = array('categories_id' => $categories_id,
 103                                           'language_id' => $languages[$i]['id']);
 104  
 105                  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
 106  
 107                  tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
 108                } elseif ($action == 'update_category') {
 109                  tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
 110                }
 111              }
 112  
 113  // BOF: MOD for Categories Description 1.5
 114  //OLD-    if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
 115  //          tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . //tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
 116  //Added the following to replacce above code
 117            if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {
 118              tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $HTTP_POST_VARS['categories_image'] . "' where categories_id = '" .  tep_db_input($categories_id) . "'");
 119              $categories_image = '';
 120            } else {
 121          $categories_image = new upload('categories_image');
 122          $categories_image->set_destination(DIR_FS_CATALOG_IMAGES);
 123  
 124          if ($categories_image->parse() && $categories_image->save()) {
 125                tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
 126              }
 127  // EOF: MOD for Categories Description 1.5
 128            }
 129  
 130            if (USE_CACHE == 'true') {
 131              tep_reset_cache_block('categories');
 132              tep_reset_cache_block('also_purchased');
 133            }
 134  
 135            tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
 136  // BOF: MOD for Categories Description 1.5
 137          }
 138  // EOF: MOD for Categories Description 1.5
 139          break;
 140        case 'delete_category_confirm':
 141          if (isset($HTTP_POST_VARS['categories_id'])) {
 142            $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
 143  
 144            $categories = tep_get_category_tree($categories_id, '', '0', '', true);
 145            $products = array();
 146            $products_delete = array();
 147  
 148            for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
 149              $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");
 150  
 151              while ($product_ids = tep_db_fetch_array($product_ids_query)) {
 152                $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
 153              }
 154            }
 155  
 156            reset($products);
 157            while (list($key, $value) = each($products)) {
 158              $category_ids = '';
 159  
 160              for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
 161                $category_ids .= "'" . (int)$value['categories'][$i] . "', ";
 162              }
 163              $category_ids = substr($category_ids, 0, -2);
 164  
 165              $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")");
 166              $check = tep_db_fetch_array($check_query);
 167              if ($check['total'] < '1') {
 168                $products_delete[$key] = $key;
 169              }
 170            }
 171  
 172  // removing categories can be a lengthy process
 173            tep_set_time_limit(0);
 174            for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
 175              tep_remove_category($categories[$i]['id']);
 176            }
 177  
 178            reset($products_delete);
 179            while (list($key) = each($products_delete)) {
 180              tep_remove_product($key);
 181            }
 182          }
 183  
 184          if (USE_CACHE == 'true') {
 185            tep_reset_cache_block('categories');
 186            tep_reset_cache_block('also_purchased');
 187          }
 188  
 189          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
 190          break;
 191        case 'delete_product_confirm':
 192          if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
 193            $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
 194            $product_categories = $HTTP_POST_VARS['product_categories'];
 195  
 196            for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
 197              tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");
 198          
 199  // LINE ADDED: MOD - Separate Price per Customer
 200             tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . tep_db_input($product_id) . "' ");
 201            }
 202  
 203            $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
 204            $product_categories = tep_db_fetch_array($product_categories_query);
 205  
 206            if ($product_categories['total'] == '0') {
 207              tep_remove_product($product_id);
 208            }
 209          }
 210  
 211          if (USE_CACHE == 'true') {
 212            tep_reset_cache_block('categories');
 213            tep_reset_cache_block('also_purchased');
 214          }
 215  
 216          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
 217          break;
 218        case 'move_category_confirm':
 219          if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {
 220            $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
 221            $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
 222  
 223            $path = explode('_', tep_get_generated_category_path_ids($new_parent_id));
 224  
 225            if (in_array($categories_id, $path)) {
 226              $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
 227  
 228              tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
 229            } else {
 230              tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");
 231  
 232              if (USE_CACHE == 'true') {
 233                tep_reset_cache_block('categories');
 234                tep_reset_cache_block('also_purchased');
 235              }
 236  
 237              tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));
 238            }
 239          }
 240  
 241          break;
 242        case 'move_product_confirm':
 243          $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
 244          $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
 245  
 246          $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'");
 247          $duplicate_check = tep_db_fetch_array($duplicate_check_query);
 248          if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'");
 249  
 250          if (USE_CACHE == 'true') {
 251            tep_reset_cache_block('categories');
 252            tep_reset_cache_block('also_purchased');
 253          }
 254  
 255          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));
 256          break;
 257        case 'insert_product':
 258        case 'update_product':
 259          if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
 260            $action = 'new_product';
 261          } else {
 262            if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
 263            $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);
 264  
 265            $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
 266  
 267            $sql_data_array = array('products_quantity' => (int)tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
 268  //LINE ADDED: MOD - indvship
 269                                    'products_ship_price' => tep_db_prepare_input($HTTP_POST_VARS['products_ship_price']), //indvship
 270                                    'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
 271                                    'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
 272                                    'products_date_available' => $products_date_available,
 273                                    'products_weight' => (float)tep_db_prepare_input($HTTP_POST_VARS['products_weight']),
 274                                    'products_height' => tep_db_prepare_input($HTTP_POST_VARS['products_height']),
 275                                    'products_length' => tep_db_prepare_input($HTTP_POST_VARS['products_length']),
 276                                    'products_width' => tep_db_prepare_input($HTTP_POST_VARS['products_width']),
 277                                    'products_ready_to_ship' => tep_db_prepare_input($HTTP_POST_VARS['products_ready_to_ship']),
 278                                    'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
 279                                    'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
 280                                    'manufacturers_id' => (int)tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));
 281  
 282            if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
 283              $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
 284            }
 285  
 286            if ($action == 'insert_product') {
 287              $insert_sql_data = array('products_date_added' => 'now()');
 288  
 289              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
 290  
 291              tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
 292              $products_id = tep_db_insert_id();
 293  
 294              tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
 295            } elseif ($action == 'update_product') {
 296              $update_sql_data = array('products_last_modified' => 'now()');
 297  
 298              $sql_data_array = array_merge($sql_data_array, $update_sql_data);
 299  
 300              tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
 301            }
 302            
 303  //BOF: MOD - AJAX Attribute Manager 
 304            require_once ('attributeManager/includes/attributeManagerUpdateAtomic.inc.php'); 
 305  //EOF: MOD - AJAX Attribute Manager 
 306  
 307  
 308  // BOF: MOD - Separate Price per Customer
 309            $customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
 310            while ($customers_group = tep_db_fetch_array($customers_group_query))  { // Gets all of the customers groups
 311              $attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");
 312              $attributes = tep_db_fetch_array($attributes_query);
 313              if (tep_db_num_rows($attributes_query) > 0) {
 314                if ($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) {// this is checking if the check box is checked
 315                  if ( ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {
 316                  tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");
 317                    $attributes = tep_db_fetch_array($attributes_query);
 318                  }
 319                  elseif (($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {
 320                  $attributes = tep_db_fetch_array($attributes_query);
 321                  }
 322                }
 323                else {
 324                  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
 325                  $attributes = tep_db_fetch_array($attributes_query);
 326                }
 327              }
 328              elseif (($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) && ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] != '')) {
 329                tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "')");
 330                $attributes = tep_db_fetch_array($attributes_query);
 331              }
 332            }
 333  // EOF: MOD - Separate Price per Customer
 334  
 335            $languages = tep_get_languages();
 336            for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 337              $language_id = $languages[$i]['id'];
 338  
 339              $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
 340                                      'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
 341                                      'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));
 342  
 343              if ($action == 'insert_product') {
 344                $insert_sql_data = array('products_id' => $products_id,
 345                                         'language_id' => $language_id);
 346  
 347                $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
 348  
 349                tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
 350              } elseif ($action == 'update_product') {
 351                tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
 352              }
 353            }
 354  
 355            if (USE_CACHE == 'true') {
 356              tep_reset_cache_block('categories');
 357              tep_reset_cache_block('also_purchased');
 358            }
 359  
 360            tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
 361          }
 362          break;
 363        case 'copy_to_confirm':
 364          if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) {
 365            $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
 366            $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
 367  
 368            if ($HTTP_POST_VARS['copy_as'] == 'link') {
 369              if ($categories_id != $current_category_id) {
 370                $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'");
 371                $check = tep_db_fetch_array($check_query);
 372                if ($check['total'] < '1') {
 373                  tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");
 374                }
 375              } else {
 376                $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
 377              }
 378            } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
 379  // LINE MODED: Added "products_ship_price and dimensions for upsxml"
 380              $product_query = tep_db_query("select products_ship_price, products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_length, products_width, products_height, products_ready_to_ship, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
 381              $product = tep_db_fetch_array($product_query);
 382  
 383  // LINE CHANGED: MS2 update 501112 - Added :(empty($product['products_date_available']) ? "null" : ...{some code}... ") . "
 384  // LINE MODED: Added "products_ship_price and dimensions for upsxml"
 385              tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, products_ship_price, products_image, products_price, products_date_added, products_date_available, products_weight, products_length, products_width, products_height, products_ready_to_ship, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . $product['products_ship_price'] . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "',  now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '" . $product['products_length'] . "', '" . $product['products_width'] . "', '" . $product['products_height']. "', '" . $product['products_ready_to_ship'] . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");  
 386              $dup_products_id = tep_db_insert_id();
 387  
 388              $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
 389              while ($description = tep_db_fetch_array($description_query)) {
 390                tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
 391              }
 392  
 393              tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
 394              $products_id = $dup_products_id;
 395            }
 396  
 397            if (USE_CACHE == 'true') {
 398              tep_reset_cache_block('categories');
 399              tep_reset_cache_block('also_purchased');
 400            }
 401          }
 402  
 403          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));
 404          break;
 405        case 'new_product_preview':
 406  // copy image only if modified
 407          $products_image = new upload('products_image');
 408          $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
 409          if ($products_image->parse() && $products_image->save()) {
 410            $products_image_name = $products_image->filename;
 411          } else {
 412            $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
 413          }
 414          break;
 415      }
 416    }
 417  
 418  // check if the catalog image directory exists
 419    if (is_dir(DIR_FS_CATALOG_IMAGES)) {
 420      if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 421    } else {
 422      $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
 423    }
 424  ?>
 425  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 426  <html <?php echo HTML_PARAMS; ?>>
 427  <head>
 428  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 429  <title><?php echo TITLE; ?></title>
 430  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 431  <script language="javascript" src="includes/general.js"></script>
 432  <!-- AJAX Attribute Manager  -->
 433  <?php require_once( 'attributeManager/includes/attributeManagerHeader.inc.php' )?>
 434  <!-- AJAX Attribute Manager  end -->
 435  </head>
 436  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="goOnLoad();">
 437  <div id="spiffycalendar" class="text"></div>
 438  <!-- header //-->
 439  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 440  <!-- header_eof //-->
 441  
 442  <!-- body //-->
 443  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 444    <tr>
 445      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 446  <!-- left_navigation //-->
 447  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 448  <!-- left_navigation_eof //-->
 449      </table></td>
 450  <!-- body_text //-->
 451  <?php // BOF: MOD  new_category / edit_category (when ALLOW_CATEGORY_DESCRIPTIONS is 'true') 
 452  //    <td width="100%" valign="top">
 453  //  if ($action == 'new_product') {
 454  ?>
 455         <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 456    <?php   //----- new_category / edit_category (when ALLOW_CATEGORY_DESCRIPTIONS is 'true') -----
 457    if ($HTTP_GET_VARS['action'] == 'new_category_ACD' || $HTTP_GET_VARS['action'] == 'edit_category_ACD') {
 458      if ( ($HTTP_GET_VARS['cID']) && (!$HTTP_POST_VARS) ) {
 459        $categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $HTTP_GET_VARS['cID'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by c.sort_order, cd.categories_name");
 460        $category = tep_db_fetch_array($categories_query);
 461  
 462        $cInfo = new objectInfo($category);
 463      } elseif ($HTTP_POST_VARS) {
 464        $cInfo = new objectInfo($HTTP_POST_VARS);
 465        $categories_name = $HTTP_POST_VARS['categories_name'];
 466        $categories_heading_title = $HTTP_POST_VARS['categories_heading_title'];
 467        $categories_description = $HTTP_POST_VARS['categories_description'];
 468        $categories_url = $HTTP_POST_VARS['categories_url'];
 469      } else {
 470        $cInfo = new objectInfo(array());
 471      }
 472  
 473      $languages = tep_get_languages();
 474  
 475      $text_new_or_edit = ($HTTP_GET_VARS['action']=='new_category_ACD') ? TEXT_INFO_HEADING_NEW_CATEGORY : TEXT_INFO_HEADING_EDIT_CATEGORY;
 476  ?>
 477        <tr>
 478          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 479            <tr>
 480              <td class="pageHeading"><?php echo sprintf($text_new_or_edit, tep_output_generated_category_path($current_category_id)); ?></td>
 481              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 482            </tr>
 483          </table></td>
 484        </tr>
 485        <tr>
 486          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 487        </tr>
 488        <tr><?php echo tep_draw_form('new_category', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=new_category_preview', 'post', 'enctype="multipart/form-data"'); ?>
 489          <td><table border="0" cellspacing="0" cellpadding="2">
 490  <?php
 491      for ($i=0; $i<sizeof($languages); $i++) {
 492  ?>
 493            <tr>
 494              <td class="main"><?php if ($i == 0) echo TEXT_EDIT_CATEGORIES_NAME; ?></td>
 495              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', (($categories_name[$languages[$i]['id']]) ? stripslashes($categories_name[$languages[$i]['id']]) : tep_get_category_name($cInfo->categories_id, $languages[$i]['id']))); ?></td>
 496            </tr>
 497  <?php
 498      }
 499  ?>
 500            <tr>
 501              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 502            </tr>
 503  <?php
 504      for ($i=0; $i<sizeof($languages); $i++) {
 505  ?>
 506            <tr>
 507              <td class="main"><?php if ($i == 0) echo TEXT_EDIT_CATEGORIES_HEADING_TITLE; ?></td>
 508              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_heading_title[' . $languages[$i]['id'] . ']', (($categories_name[$languages[$i]['id']]) ? stripslashes($categories_name[$languages[$i]['id']]) : tep_get_category_heading_title($cInfo->categories_id, $languages[$i]['id']))); ?></td>
 509            </tr>
 510  <?php
 511      }
 512  ?>
 513            <tr>
 514              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 515            </tr>
 516  <?php
 517      for ($i=0; $i<sizeof($languages); $i++) {
 518  ?>
 519            <tr>
 520              <td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_CATEGORIES_DESCRIPTION; ?></td>
 521              <td><table border="0" cellspacing="0" cellpadding="0">
 522                <tr>
 523                  <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
 524                  <td class="main">
 525                  <?php if(HTML_AREA_WYSIWYG_DISABLE == 'Enable') {
 526  // Line Changed - MOD: Ajustable Editor Window
 527                    echo tep_draw_fckeditor ('categories_description[' . $languages[$i]['id'] . ']', HTML_AREA_WYSIWYG_EDITOR_WIDTH, HTML_AREA_WYSIWYG_EDITOR_HEIGHT, (isset($categories_description[$languages[$i]['id']]) ? stripslashes($categories_description[$languages[$i]['id']]) : tep_get_category_description($cInfo->categories_id, $languages[$i]['id']))) . '</td>';
 528                    } else { echo tep_draw_textarea_field('categories_description[' . $languages[$i]['id'].']','soft','70','15',(isset($categories_description[$languages[$i]['id']]) ? $categories_description[$languages[$i]['id']] : tep_get_category_description($cInfo->categories_id, $languages[$i]['id']))) . '</td>';
 529                  }
 530                  ?>
 531                </tr>
 532              </table></td>
 533            </tr>
 534  <?php
 535      }
 536  ?>
 537            <tr>
 538              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 539            </tr>
 540            <tr>
 541            <tr>
 542              <td class="main"><?php echo TEXT_EDIT_CATEGORIES_IMAGE; ?></td>
 543              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_file_field('categories_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $cInfo->categories_image . tep_draw_hidden_field('categories_previous_image', $cInfo->categories_image); ?></td>
 544            </tr>
 545            <tr>
 546              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 547            </tr>
 548            <tr>
 549              <td class="main"><?php echo TEXT_EDIT_SORT_ORDER; ?></td>
 550              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'); ?></td>
 551            </tr>
 552            <tr>
 553              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 554            </tr>
 555          </table></td>
 556        </tr>
 557        <tr>
 558          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 559        </tr>
 560        <tr>
 561          <td class="main" align="right"><?php echo tep_draw_hidden_field('categories_date_added', (($cInfo->date_added) ? $cInfo->date_added : date('Y-m-d'))) . tep_draw_hidden_field('parent_id', $cInfo->parent_id) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
 562        </form></tr>
 563  <?php
 564  
 565    //----- new_category_preview (active when ALLOW_CATEGORY_DESCRIPTIONS is 'true') -----
 566    } elseif ($HTTP_GET_VARS['action'] == 'new_category_preview') {
 567      if ($HTTP_POST_VARS) {
 568        $cInfo = new objectInfo($HTTP_POST_VARS);
 569        $categories_name = $HTTP_POST_VARS['categories_name'];
 570        $categories_heading_title = $HTTP_POST_VARS['categories_heading_title'];
 571        $categories_description = $HTTP_POST_VARS['categories_description'];
 572  
 573  // copy image only if modified
 574          $categories_image = new upload('categories_image');
 575          $categories_image->set_destination(DIR_FS_CATALOG_IMAGES);
 576          if ($categories_image->parse() && $categories_image->save()) {
 577            $categories_image_name = $categories_image->filename;
 578          } else {
 579          $categories_image_name = $HTTP_POST_VARS['categories_previous_image'];
 580        }
 581  #     if ( ($categories_image != 'none') && ($categories_image != '') ) {
 582  #       $image_location = DIR_FS_CATALOG_IMAGES . $categories_image_name;
 583  #       if (file_exists($image_location)) @unlink($image_location);
 584  #       copy($categories_image, $image_location);
 585  #     } else {
 586  #       $categories_image_name = $HTTP_POST_VARS['categories_previous_image'];
 587  #     }
 588      } else {
 589        $category_query = tep_db_query("select c.categories_id, cd.language_id, cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and c.categories_id = '" . $HTTP_GET_VARS['cID'] . "'");
 590        $category = tep_db_fetch_array($category_query);
 591  
 592        $cInfo = new objectInfo($category);
 593        $categories_image_name = $cInfo->categories_image;
 594      }
 595  
 596      $form_action = ($HTTP_GET_VARS['cID']) ? 'update_category' : 'insert_category';
 597  
 598      echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');
 599  
 600      $languages = tep_get_languages();
 601      for ($i=0; $i<sizeof($languages); $i++) {
 602        if ($HTTP_GET_VARS['read'] == 'only') {
 603          $cInfo->categories_name = tep_get_category_name($cInfo->categories_id, $languages[$i]['id']);
 604          $cInfo->categories_heading_title = tep_get_category_heading_title($cInfo->categories_id, $languages[$i]['id']);
 605          $cInfo->categories_description = tep_get_category_description($cInfo->categories_id, $languages[$i]['id']);
 606        } else {
 607          $cInfo->categories_name = tep_db_prepare_input($categories_name[$languages[$i]['id']]);
 608          $cInfo->categories_heading_title = tep_db_prepare_input($categories_heading_title[$languages[$i]['id']]);
 609          $cInfo->categories_description = tep_db_prepare_input($categories_description[$languages[$i]['id']]);
 610        }
 611  ?>
 612        <tr>
 613          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 614            <tr>
 615              <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $cInfo->categories_heading_title; ?></td>
 616            </tr>
 617          </table></td>
 618        </tr>
 619        <tr>
 620          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 621        </tr>
 622        <tr>
 623          <td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $categories_image_name, $cInfo->categories_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $cInfo->categories_description; ?></td>
 624        </tr>
 625  
 626  <?php
 627      }
 628      if ($HTTP_GET_VARS['read'] == 'only') {
 629        if ($HTTP_GET_VARS['origin']) {
 630          $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
 631          if ($pos_params != false) {
 632            $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
 633            $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
 634          } else {
 635            $back_url = $HTTP_GET_VARS['origin'];
 636            $back_url_params = '';
 637          }
 638        } else {
 639          $back_url = FILENAME_CATEGORIES;
 640          $back_url_params = 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id;
 641        }
 642  ?>
 643        <tr>
 644          <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
 645        </tr>
 646  <?php
 647      } else {
 648  ?>
 649        <tr>
 650          <td align="right" class="smallText">
 651  <?php
 652  /* Re-Post all POST'ed variables */
 653        reset($HTTP_POST_VARS);
 654        while (list($key, $value) = each($HTTP_POST_VARS)) {
 655          if (!is_array($HTTP_POST_VARS[$key])) {
 656            echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 657          }
 658        }
 659        $languages = tep_get_languages();
 660        for ($i=0; $i<sizeof($languages); $i++) {
 661          echo tep_draw_hidden_field('categories_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($categories_name[$languages[$i]['id']])));
 662          echo tep_draw_hidden_field('categories_heading_title[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($categories_heading_title[$languages[$i]['id']])));
 663          echo tep_draw_hidden_field('categories_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($categories_description[$languages[$i]['id']])));
 664        }
 665        echo tep_draw_hidden_field('X_categories_image', stripslashes($categories_image_name));
 666        echo tep_draw_hidden_field('categories_image', stripslashes($categories_image_name));
 667  
 668        echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '&nbsp;&nbsp;';
 669  
 670        if ($HTTP_GET_VARS['cID']) {
 671          echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
 672        } else {
 673          echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
 674        }
 675        echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
 676  ?></td>
 677        </form></tr>
 678  <?php
 679      }
 680  
 681    } elseif ($action == 'new_product') {
 682  // EOF: MOD  new_category / edit_category (when ALLOW_CATEGORY_DESCRIPTIONS is 'true') 
 683      $parameters = array('products_name' => '',
 684                         'products_description' => '',
 685                         'products_url' => '',
 686                         'products_id' => '',
 687                         'products_quantity' => '',
 688                         'products_model' => '',
 689                         'products_image' => '',
 690                         'products_price' => '',
 691                         'products_weight' => '',
 692                         'products_length' => '',
 693                         'products_width' => '',
 694                         'products_height' => '',
 695                         'products_ready_to_ship' => '',
 696                         'products_date_added' => '',
 697                         'products_last_modified' => '',
 698                         'products_date_available' => '',
 699                         'products_status' => '',
 700                             'products_tax_class_id' => '',
 701                         'manufacturers_id' => '');
 702  
 703      $pInfo = new objectInfo($parameters);
 704  
 705      if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
 706  //LINE MODED: Added "p.products_ship_price"
 707        $product_query = tep_db_query("select p.products_ship_price, pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, products_length, products_width, products_height, products_ready_to_ship, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
 708        $product = tep_db_fetch_array($product_query);
 709  
 710        $pInfo->objectInfo($product);
 711      } elseif (tep_not_null($HTTP_POST_VARS)) {
 712        $pInfo->objectInfo($HTTP_POST_VARS);
 713        $products_name = $HTTP_POST_VARS['products_name'];
 714        $products_description = $HTTP_POST_VARS['products_description'];
 715        $products_url = $HTTP_POST_VARS['products_url'];
 716      }
 717  
 718      $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
 719      $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
 720      while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
 721        $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
 722                                       'text' => $manufacturers['manufacturers_name']);
 723      }
 724  
 725      $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
 726      $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
 727      while ($tax_class = tep_db_fetch_array($tax_class_query)) {
 728        $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
 729                                   'text' => $tax_class['tax_class_title']);
 730      }
 731  
 732      $languages = tep_get_languages();
 733  
 734      if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
 735      switch ($pInfo->products_status) {
 736        case '0': $in_status = false; $out_status = true; break;
 737        case '1':
 738        default: $in_status = true; $out_status = false;
 739      }
 740  ?>
 741  <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
 742  <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
 743  <script language="javascript"><!--
 744    var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
 745  //--></script>
 746  <script language="javascript"><!--
 747  var tax_rates = new Array();
 748  <?php
 749      for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
 750        if ($tax_class_array[$i]['id'] > 0) {
 751          echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
 752        }
 753      }
 754  ?>
 755  
 756  function doRound(x, places) {
 757    return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
 758  }
 759  
 760  function getTaxRate() {
 761    var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
 762    var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;
 763  
 764    if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
 765      return tax_rates[parameterVal];
 766    } else {
 767      return 0;
 768    }
 769  }
 770  
 771  function updateGross() {
 772    var taxRate = getTaxRate();
 773    var grossValue = document.forms["new_product"].products_price.value;
 774  
 775    if (taxRate > 0) {
 776      grossValue = grossValue * ((taxRate / 100) + 1);
 777    }
 778  
 779    document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
 780  }
 781  
 782  function updateNet() {
 783    var taxRate = getTaxRate();
 784    var netValue = document.forms["new_product"].products_price_gross.value;
 785  
 786    if (taxRate > 0) {
 787      netValue = netValue / ((taxRate / 100) + 1);
 788    }
 789  
 790    document.forms["new_product"].products_price.value = doRound(netValue, 4);
 791  }
 792  //--></script>
 793      <?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?>
 794      <table border="0" width="100%" cellspacing="0" cellpadding="2">
 795        <tr>
 796          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 797            <tr>
 798              <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>
 799              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 800            </tr>
 801          </table></td>
 802        </tr>
 803        <tr>
 804          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 805        </tr>
 806        <tr>
 807          <td><table border="0" cellspacing="0" cellpadding="2">
 808            <tr>
 809              <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
 810              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_radio_field('products_status', '1', $in_status) . '&nbsp;' . TEXT_PRODUCT_AVAILABLE . '&nbsp;' . tep_draw_radio_field('products_status', '0', $out_status) . '&nbsp;' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
 811            </tr>
 812            <tr>
 813              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 814            </tr>
 815            <tr>
 816              <td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
 817              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;'; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>
 818            </tr>
 819            <tr>
 820              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 821            </tr>
 822            <tr>
 823              <td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
 824              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>
 825            </tr>
 826            <tr>
 827              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 828            </tr>
 829  <?php
 830      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 831  ?>
 832            <tr>
 833              <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
 834  <?php /* LINE CHANGED: MS2 update 501112 - Added: stripslashes(...) */ ?>
 835              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td>
 836            </tr>
 837  <?php
 838      }
 839  ?>
 840            <tr>
 841              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 842            </tr>
 843            <tr bgcolor="#ebebff">
 844              <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
 845              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id, 'onchange="updateGross()"'); ?></td>
 846            </tr>
 847            <tr bgcolor="#ebebff">
 848              <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
 849              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td>
 850            </tr>
 851            <tr bgcolor="#ebebff">
 852              <td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
 853              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'OnKeyUp="updateNet()"'); ?></td>
 854            </tr>
 855            <!-- AJAX Attribute Manager  -->
 856            <tr>
 857                <td colspan="2"><?php require_once ( 'attributeManager/includes/attributeManagerPlaceHolder.inc.php' )?></td>
 858            </tr>
 859            <!-- AJAX Attribute Manager end -->
 860  
 861  <?php // EOF: MOD - indvship ?>
 862            <tr>
 863              <td class="main"><?php echo 'Indv. Shipping Price:'; ?></td>
 864              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_ship_price', $pInfo->products_ship_price); ?></td>
 865            </tr>
 866  <?php // EOF: MOD - indvship ?>
 867            <tr>
 868              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 869            </tr>
 870  <script language="javascript"><!--
 871  updateGross();
 872  //--></script>
 873  <?php
 874  // BOF: MOD - Separate Pricing Per Customer
 875      $customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
 876      $header = false;
 877      while ($customers_group = tep_db_fetch_array($customers_group_query)) {
 878  
 879       if (tep_db_num_rows($customers_group_query) > 0) {
 880         $attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $pInfo->products_id . "' and customers_group_id = '" . $customers_group['customers_group_id'] . "' order by customers_group_id");
 881       } else {
 882           $attributes = array('customers_group_id' => 'new');
 883       }
 884   if (!$header) { ?>
 885  
 886      <tr bgcolor="#ebebff">
 887      <td class="main" colspan="2" style="font-style: italic">Note that if a field is left empty, no price for that customer group will be inserted in the database.<br />
 888  If a field is filled, but the checkbox is unchecked no price will be inserted either.<br />
 889  If a price is already inserted in the database, but the checkbox unchecked it will be removed from the database.
 890  <?php if (isset($pInfo->sppcoption[$customers_group['customers_group_id']])) { // when a preview was done and the back button used
 891  print ("<br />\n<strong>Make sure you uncheck the appropriate boxes again!</strong>\n");
 892  } ?>
 893  </td>
 894      </tr>
 895   <?php
 896   $header = true;
 897   } // end if (!header), makes sure this is only shown once
 898   ?>
 899        <tr bgcolor="#ebebff">
 900        <td class="main"><?php
 901        echo tep_draw_checkbox_field('sppcoption[' . $customers_group['customers_group_id'] . ']', 'sppcoption[' . $customers_group['customers_group_id'] . ']', true) . '&nbsp;' . $customers_group['customers_group_name'];
 902  ?>
 903   &nbsp;</td>
 904         <td class="main"><?php
 905         if ($attributes = tep_db_fetch_array($attributes_query)) {
 906         echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('sppcprice[' . $customers_group['customers_group_id'] . ']', $attributes['customers_group_price']);
 907         }  else {
 908           if (isset($pInfo->sppcprice[$customers_group['customers_group_id']])) { // when a preview was done and the back button used
 909             $sppc_cg_price = $pInfo->sppcprice[$customers_group['customers_group_id']];
 910           } else { // nothing in the db, nothing in the post variables
 911             $sppc_cg_price = '';
 912           }
 913       echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('sppcprice[' . $customers_group['customers_group_id'] . ']', $sppc_cg_price );
 914     }  ?></td>
 915      </tr>
 916  <?php
 917          } // end while ($customers_group = tep_db_fetch_array($customers_group_query))
 918  ?>
 919            <tr>
 920              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 921            </tr>
 922  <?php
 923  // EOF: MOD - Separate Pricing Per Customer
 924      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 925  ?>
 926            <tr>
 927              <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
 928              <td><table border="0" cellspacing="0" cellpadding="0">
 929                <tr>
 930                  <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
 931  <?php // BOF: MOD WYSIWYG Editor
 932  /*              <td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td> */?>
 933                  <td class="main"><?php if(HTML_AREA_WYSIWYG_DISABLE == 'Enable') {
 934        echo tep_draw_fckeditor ('products_description[' . $languages[$i]['id'] . ']', '550', '300', (isset($products_description[$languages[$i]['id']]) ? stripslashes($products_description[$languages[$i]['id']]) : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))) . '</td>';
 935  // LINE MODIFIED: BUGFIX 0000083 - Not using fck Editor in admin categ/products won't save description
 936      } else {
 937  // LINE CHANGED: MS2 update 501112 - Added: stripslashes(...)
 938        echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'].']','soft','70','15',(isset($products_description[$languages[$i]['id']]) ? stripslashes($products_description[$languages[$i]['id']]) : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))) . '</td>';
 939      }
 940  // EOF: MOD WYSIWYG Editor ?>
 941                </tr>
 942              </table></td>
 943            </tr>
 944  <?php
 945      }
 946  ?>
 947            <tr>
 948              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 949            </tr>
 950            <tr>
 951              <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
 952              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>
 953            </tr>
 954            <tr>
 955              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 956            </tr>
 957            <tr>
 958              <td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>
 959              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>
 960            </tr>
 961            <tr>
 962              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 963            </tr>
 964            <tr>
 965              <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
 966              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>
 967            </tr>
 968            <tr>
 969              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 970            </tr>
 971  <?php
 972      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 973  ?>
 974            <tr>
 975              <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<br><small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
 976  <?php /* LINE CHANGED: MS2 update 501112 - Added: stripslashes(...) */ ?>
 977              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? stripslashes($products_url[$languages[$i]['id']]) : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td>
 978            </tr>
 979  <?php
 980      }
 981  ?>
 982            <tr>
 983              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 984            </tr>
 985            <tr>
 986              <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
 987              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
 988            </tr>
 989            <tr>
 990              <td class="main"><?php echo TEXT_PRODUCTS_LENGTH; ?></td>
 991              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_length', $pInfo->products_length); ?></td>
 992            </tr>
 993            <tr>
 994              <td class="main"><?php echo TEXT_PRODUCTS_WIDTH; ?></td>
 995              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_width', $pInfo->products_width); ?></td>
 996            </tr>
 997            <tr>
 998              <td class="main"><?php echo TEXT_PRODUCTS_HEIGHT; ?></td>
 999              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_height', $pInfo->products_height); ?></td>
1000            </tr>
1001            <tr>
1002              <td class="main"><?php echo TEXT_PRODUCTS_READY_TO_SHIP; ?></td>
1003              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_checkbox_field('products_ready_to_ship', '1', (($product['products_ready_to_ship'] == '1') ? true : false)); ?></td>
1004            </tr>
1005          </table></td>
1006        </tr>
1007        <tr>
1008          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1009        </tr>
1010        <tr>
1011          <td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
1012        </tr>
1013      </table></form>
1014  <?php
1015    } elseif ($action == 'new_product_preview') {
1016      if (tep_not_null($HTTP_POST_VARS)) {
1017        $pInfo = new objectInfo($HTTP_POST_VARS);
1018        $products_name = $HTTP_POST_VARS['products_name'];
1019        $products_description = $HTTP_POST_VARS['products_description'];
1020        $products_url = $HTTP_POST_VARS['products_url'];
1021      } else {
1022  // LINE CHANGED: Added p.products_shipped_price and dimensions for upsxml
1023        $product_query = tep_db_query("select p.products_ship_price, p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_length, p.products_width, p.products_height, p.products_ready_to_ship, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
1024        $product = tep_db_fetch_array($product_query);
1025  
1026        $pInfo = new objectInfo($product);
1027        $products_image_name = $pInfo->products_image;
1028      }
1029  
1030      $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product';
1031  
1032      echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');
1033  
1034      $languages = tep_get_languages();
1035      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
1036        if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
1037          $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);
1038          $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);
1039          $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);
1040        } else {
1041          $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]);
1042          $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]);
1043          $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]);
1044        }
1045  ?>
1046      <table border="0" width="100%" cellspacing="0" cellpadding="2">
1047        <tr>
1048          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
1049            <tr>
1050              <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $pInfo->products_name; ?></td>
1051              <td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>
1052            </tr>
1053          </table></td>
1054        </tr>
1055        <tr>
1056          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1057        </tr>
1058        <tr>
1059          <td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td>
1060        </tr>
1061  <?php
1062        if ($pInfo->products_url) {
1063  ?>
1064        <tr>
1065          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1066        </tr>
1067        <tr>
1068          <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td>
1069        </tr>
1070  <?php
1071        }
1072  ?>
1073        <tr>
1074          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1075        </tr>
1076  <?php
1077        if ($pInfo->products_date_available > date('Y-m-d')) {
1078  ?>
1079        <tr>
1080          <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td>
1081        </tr>
1082  <?php
1083        } else {
1084  ?>
1085        <tr>
1086          <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td>
1087        </tr>
1088  <?php
1089        }
1090  ?>
1091        <tr>
1092          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
1093        </tr>
1094  <?php
1095      }
1096  
1097      if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
1098        if (isset($HTTP_GET_VARS['origin'])) {
1099          $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
1100          if ($pos_params != false) {
1101            $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
1102            $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
1103          } else {
1104            $back_url = $HTTP_GET_VARS['origin'];
1105            $back_url_params = '';
1106          }
1107        } else {
1108          $back_url = FILENAME_CATEGORIES;
1109          $back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id;
1110        }
1111  ?>
1112        <tr>
1113          <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
1114        </tr>
1115  <?php
1116      } else {
1117  ?>
1118        <tr>
1119          <td align="right" class="smallText">
1120  <?php
1121  /* Re-Post all POST'ed variables */
1122        reset($HTTP_POST_VARS);
1123        while (list($key, $value) = each($HTTP_POST_VARS)) {
1124  // BOF: MOD - Separate Pricing Per Customer
1125  //        if (!is_array($HTTP_POST_VARS[$key])) {
1126            if (is_array($value)) {
1127              while (list($k, $v) = each($value)) {
1128                echo tep_draw_hidden_field($key . '[' . $k . ']', htmlspecialchars(stripslashes($v)));
1129              }
1130            } else {
1131  // EOF: MOD - Separate Pricing Per Customer
1132  
1133            echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
1134          }
1135         }
1136        $languages = tep_get_languages();
1137        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
1138          echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']])));
1139          echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']])));
1140          echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']])));
1141        }
1142        echo tep_draw_hidden_field('products_image', stripslashes($products_image_name));
1143  
1144        echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '&nbsp;&nbsp;';
1145  
1146        if (isset($HTTP_GET_VARS['pID'])) {
1147          echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
1148        } else {
1149          echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
1150        }
1151        echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
1152  ?></td>
1153        </tr>
1154      </table></form>
1155  <?php
1156      }
1157    } else {
1158  ?>
1159      <table border="0" width="100%" cellspacing="0" cellpadding="2">
1160        <tr>
1161          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
1162            <tr>
1163              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
1164              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
1165              <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
1166                <tr>
1167                  <td class="smallText" align="right">
1168  <?php
1169      echo tep_draw_form('search', FILENAME_CATEGORIES, '', 'get');
1170      echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search');
1171      echo tep_hide_session_id() . '</form>';
1172  ?>
1173                  </td>
1174                </tr>
1175                <tr>
1176                  <td class="smallText" align="right">
1177  <?php
1178      echo tep_draw_form('goto', FILENAME_CATEGORIES, '', 'get');
1179      echo HEADING_TITLE_GOTO . ' ' . tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"');
1180      echo tep_hide_session_id() . '</form>';
1181  ?>
1182                  </td>
1183                </tr>
1184              </table></td>
1185            </tr>
1186          </table></td>
1187        </tr>
1188        <tr>
1189          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
1190            <tr>
1191              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
1192                <tr class="dataTableHeadingRow">
1193                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td>
1194                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
1195                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
1196                </tr>
1197  <?php
1198      $categories_count = 0;
1199      $rows = 0;
1200      if (isset($HTTP_GET_VARS['search'])) {
1201        $search = tep_db_prepare_input($HTTP_GET_VARS['search']);
1202  
1203        $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");
1204      } else {
1205        $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
1206      }
1207      while ($categories = tep_db_fetch_array($categories_query)) {
1208        $categories_count++;
1209        $rows++;
1210  
1211  // Get parent_id for subcategories if search
1212        if (isset($HTTP_GET_VARS['search'])) $cPath= $categories['parent_id'];
1213  
1214        if ((!isset($HTTP_GET_VARS['cID']) && !isset($HTTP_GET_VARS['pID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $categories['categories_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
1215          $category_childs = array('childs_count' => tep_childs_in_category_count($categories['categories_id']));
1216          $category_products = array('products_count' => tep_products_in_category_count($categories['categories_id']));
1217  
1218          $cInfo_array = array_merge($categories, $category_childs, $category_products);
1219          $cInfo = new objectInfo($cInfo_array);
1220        }
1221  
1222        if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) {
1223          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($categories['categories_id'])) . '\'">' . "\n";
1224        } else {
1225          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n";
1226        }
1227  ?>
1228                  <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, tep_get_path($categories['categories_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $categories['categories_name'] . '</b>'; ?></td>
1229                  <td class="dataTableContent" align="center">&nbsp;</td>
1230                  <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
1231                </tr>
1232  <?php
1233      }
1234  
1235      $products_count = 0;
1236      if (isset($HTTP_GET_VARS['search'])) {
1237  // LINE CHANGED: Added p.products_shipped_price
1238       $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_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)$languages_id . "' and p.products_id = p2c.products_id and (pd.products_name like '%" . tep_db_input($search) . "%' or p.products_model like '%" . tep_db_input($search) . "%') order by pd.products_name");
1239      } else {
1240  // LINE CHANGED: Added p.products_shipped_price   
1241       $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, 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)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
1242      }
1243      while ($products = tep_db_fetch_array($products_query)) {
1244        $products_count++;
1245        $rows++;
1246  
1247  // Get categories_id for product if search
1248        if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id'];
1249  
1250        if ( (!isset($HTTP_GET_VARS['pID']) && !isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['pID']) && ($HTTP_GET_VARS['pID'] == $products['products_id']))) && !isset($pInfo) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
1251  // find out the rating average from customer reviews
1252          $reviews_query = tep_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$products['products_id'] . "'");
1253          $reviews = tep_db_fetch_array($reviews_query);
1254          $pInfo_array = array_merge($products, $reviews);
1255          $pInfo = new objectInfo($pInfo_array);
1256        }
1257  
1258        if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id) ) {
1259          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '\'">' . "\n";
1260        } else {
1261          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '\'">' . "\n";
1262        }
1263  ?>
1264                  <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;' . $products['products_name']; ?></td>
1265                  <td class="dataTableContent" align="center">
1266  <?php
1267        if ($products['products_status'] == '1') {
1268          echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
1269        } else {
1270          echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
1271        }
1272  ?></td>
1273                  <td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($products['products_id'] == $pInfo->products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
1274                </tr>
1275  <?php
1276      }
1277  
1278      $cPath_back = '';
1279      if (sizeof($cPath_array) > 0) {
1280        for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) {
1281          if (empty($cPath_back)) {
1282            $cPath_back .= $cPath_array[$i];
1283          } else {
1284            $cPath_back .= '_' . $cPath_array[$i];
1285          }
1286        }
1287      }
1288  
1289      $cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
1290  ?>
1291                <tr>
1292                  <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
1293                    <tr>
1294                      <td class="smallText"><?php echo TEXT_CATEGORIES . '&nbsp;' . $categories_count . '<br>' . TEXT_PRODUCTS . '&nbsp;' . $products_count; ?></td>
1295                      <td align="right" class="smallText"><?php if (sizeof($cPath_array) > 0) echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, $cPath_back . 'cID=' . $current_category_id) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>&nbsp;'; if (!isset($HTTP_GET_VARS['search'])) echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=new_category') . '">' . tep_image_button('button_new_category.gif', IMAGE_NEW_CATEGORY) . '</a>&nbsp;<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&action=new_product') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?>&nbsp;</td>
1296                    </tr>
1297                  </table></td>
1298                </tr>
1299              </table></td>
1300  <?php
1301      $heading = array();
1302      $contents = array();
1303      switch ($action) {
1304        case 'new_category':
1305          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_CATEGORY . '</b>');
1306  
1307          $contents = array('form' => tep_draw_form('newcategory', FILENAME_CATEGORIES, 'action=insert_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"'));
1308          $contents[] = array('text' => TEXT_NEW_CATEGORY_INTRO);
1309  
1310          $category_inputs_string = '';
1311          $languages = tep_get_languages();
1312          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
1313            $category_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']');
1314          }
1315  
1316          $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_NAME . $category_inputs_string);
1317          $contents[] = array('text' => '<br>' . TEXT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image'));
1318          $contents[] = array('text' => '<br>' . TEXT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', '', 'size="2"'));
1319          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1320          break;
1321        case 'edit_category':
1322          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_CATEGORY . '</b>');
1323  
1324          $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"') . tep_draw_hidden_field('categories_id', $cInfo->categories_id));
1325          $contents[] = array('text' => TEXT_EDIT_INTRO);
1326  
1327          $category_inputs_string = '';
1328          $languages = tep_get_languages();
1329          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
1330            $category_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', tep_get_category_name($cInfo->categories_id, $languages[$i]['id']));
1331          }
1332  
1333          $contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_NAME . $category_inputs_string);
1334          $contents[] = array('text' => '<br>' . tep_image(DIR_WS_CATALOG_IMAGES . $cInfo->categories_image, $cInfo->categories_name) . '<br>' . DIR_WS_CATALOG_IMAGES . '<br><b>' . $cInfo->categories_image . '</b>');
1335          $contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image'));
1336          $contents[] = array('text' => '<br>' . TEXT_EDIT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'));
1337          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1338          break;
1339        case 'delete_category':
1340          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CATEGORY . '</b>');
1341  
1342          $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id));
1343          $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO);
1344          $contents[] = array('text' => '<br><b>' . $cInfo->categories_name . '</b>');
1345          if ($cInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count));
1346          if ($cInfo->products_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count));
1347          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1348          break;
1349        case 'move_category':
1350          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_CATEGORY . '</b>');
1351  
1352          $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=move_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id));
1353          $contents[] = array('text' => sprintf(TEXT_MOVE_CATEGORIES_INTRO, $cInfo->categories_name));
1354          $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br>' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id));
1355          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $cInfo->categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1356          break;
1357        case 'delete_product':
1358          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_PRODUCT . '</b>');
1359  
1360          $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=delete_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id));
1361          $contents[] = array('text' => TEXT_DELETE_PRODUCT_INTRO);
1362          $contents[] = array('text' => '<br><b>' . $pInfo->products_name . '</b>');
1363  
1364          $product_categories_string = '';
1365          $product_categories = tep_generate_category_path($pInfo->products_id, 'product');
1366          for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) {
1367            $category_path = '';
1368            for ($j = 0, $k = sizeof($product_categories[$i]); $j < $k; $j++) {
1369              $category_path .= $product_categories[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
1370            }
1371            $category_path = substr($category_path, 0, -16);
1372            $product_categories_string .= tep_draw_checkbox_field('product_categories[]', $product_categories[$i][sizeof($product_categories[$i])-1]['id'], true) . '&nbsp;' . $category_path . '<br>';
1373          }
1374          $product_categories_string = substr($product_categories_string, 0, -4);
1375  
1376          $contents[] = array('text' => '<br>' . $product_categories_string);
1377          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1378          break;
1379        case 'move_product':
1380          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_PRODUCT . '</b>');
1381  
1382          $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=move_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id));
1383          $contents[] = array('text' => sprintf(TEXT_MOVE_PRODUCTS_INTRO, $pInfo->products_name));
1384          $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . tep_output_generated_category_path($pInfo->products_id, 'product') . '</b>');
1385          $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $pInfo->products_name) . '<br>' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id));
1386          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1387          break;
1388        case 'copy_to':
1389          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TO . '</b>');
1390  
1391          $contents = array('form' => tep_draw_form('copy_to', FILENAME_CATEGORIES, 'action=copy_to_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id));
1392          $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO);
1393          $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . tep_output_generated_category_path($pInfo->products_id, 'product') . '</b>');
1394          $contents[] = array('text' => '<br>' . TEXT_CATEGORIES . '<br>' . tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $current_category_id));
1395          $contents[] = array('text' => '<br>' . TEXT_HOW_TO_COPY . '<br>' . tep_draw_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '<br>' . tep_draw_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE);
1396          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_copy.gif', IMAGE_COPY) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1397          break;
1398        default:
1399          if ($rows > 0) {
1400            if (isset($cInfo) && is_object($cInfo)) { // category info box contents
1401              $category_path_string = '';
1402              $category_path = tep_generate_category_path($cInfo->categories_id);
1403              for ($i=(sizeof($category_path[0])-1); $i>0; $i--) {
1404                $category_path_string .= $category_path[0][$i]['id'] . '_';
1405              }
1406              $category_path_string = substr($category_path_string, 0, -1);
1407              $heading[] = array('text' => '<b>' . $cInfo->categories_name . '</b>');
1408  
1409              $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $category_path_string . '&cID=' . $cInfo->categories_id . '&action=edit_category') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $category_path_string . '&cID=' . $cInfo->categories_id . '&action=delete_category') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $category_path_string . '&cID=' . $cInfo->categories_id . '&action=move_category') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a>');
1410              $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added));
1411              if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified));
1412              $contents[] = array('text' => '<br>' . tep_info_image($cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br>' . $cInfo->categories_image);
1413              $contents[] = array('text' => '<br>' . TEXT_SUBCATEGORIES . ' ' . $cInfo->childs_count . '<br>' . TEXT_PRODUCTS . ' ' . $cInfo->products_count);
1414            } elseif (isset($pInfo) && is_object($pInfo)) { // product info box contents
1415              $heading[] = array('text' => '<b>' . tep_get_products_name($pInfo->products_id, $languages_id) . '</b>');
1416  
1417  // LINE CHANGED: MOD - QT Pro
1418  //          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=delete_product') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=move_product') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=copy_to') . '">' . tep_image_button('button_copy_to.gif', IMAGE_COPY_TO) . '</a>');
1419              $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=delete_product') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=move_product') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a> <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=copy_to') . '">' . tep_image_button('button_copy_to.gif', IMAGE_COPY_TO) . '</a><a href="' . tep_href_link("stock.php", 'product_id=' . $pInfo->products_id) . '">' . tep_image_button('button_stock.gif', "Stock") . '</a>');
1420              $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($pInfo->products_date_added));
1421              if (tep_not_null($pInfo->products_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($pInfo->products_last_modified));
1422              if (date('Y-m-d') < $pInfo->products_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE . ' ' . tep_date_short($pInfo->products_date_available));
1423              $contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_image);
1424              $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br>' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity);
1425              $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%');
1426            }
1427          } else { // create category/product info
1428            $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>');
1429  
1430            $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS);
1431          }
1432          break;
1433      }
1434  
1435      if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
1436        echo '            <td width="25%" valign="top">' . "\n";
1437  
1438        $box = new box;
1439        echo $box->infoBox($heading, $contents);
1440  
1441        echo '            </td>' . "\n";
1442      }
1443  ?>
1444            </tr>
1445          </table></td>
1446        </tr>
1447      </table>
1448  <?php
1449    }
1450  ?>
1451      </td>
1452  <!-- body_text_eof //-->
1453    </tr>
1454  </table>
1455  <!-- body_eof //-->
1456  
1457  <!-- footer //-->
1458  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
1459  <!-- footer_eof //-->
1460  <br>
1461  </body>
1462  </html>
1463  <?php require (DIR_WS_INCLUDES . 'application_bottom.php');
1464  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7