[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 attributes_controller.php

Zen Cart 源代码 attributes_controller.php




下载文件

文件名: attributes_controller.php
文件类型: PHP文件
文件大小: 133.39 KiB
MD5: 4cc34f48f00e071fbe7bea6d9b41ba6f

attributes_controller.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version $Id: attributes_controller.php 17888 2010-10-08 21:06:31Z wilt $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.   // troubleshooting/debug of option name/value IDs:
  12.   $show_name_numbers = true;
  13.   $show_value_numbers = true;
  14.  
  15.   // verify option names, values, products
  16.   $chk_option_names = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id='" . $_SESSION['languages_id'] . "' limit 1");
  17.   if ($chk_option_names->RecordCount() < 1) {
  18.     $messageStack->add_session(ERROR_DEFINE_OPTION_NAMES, 'caution');
  19.     zen_redirect(zen_href_link(FILENAME_OPTIONS_NAME_MANAGER));
  20.   }
  21.   $chk_option_values = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id='" . $_SESSION['languages_id'] . "' limit 1");
  22.   if ($chk_option_values->RecordCount() < 1) {
  23.     $messageStack->add_session(ERROR_DEFINE_OPTION_VALUES, 'caution');
  24.     zen_redirect(zen_href_link(FILENAME_OPTIONS_VALUES_MANAGER));
  25.   }
  26.   $chk_products = $db->Execute("select * from " . TABLE_PRODUCTS . " limit 1");
  27.   if ($chk_products->RecordCount() < 1) {
  28.     $messageStack->add_session(ERROR_DEFINE_PRODUCTS, 'caution');
  29.     zen_redirect(zen_href_link(FILENAME_CATEGORIES));
  30.   }
  31.  
  32.   require(DIR_WS_CLASSES . 'currencies.php');
  33.   $currencies = new currencies();
  34.  
  35.   $languages = zen_get_languages();
  36.  
  37.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  38.  
  39.   $products_filter = (isset($_GET['products_filter']) ? $_GET['products_filter'] : $products_filter);
  40.  
  41.   $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  42.  
  43.   if ($action == 'new_cat') {
  44.     $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  45.     $sql =     "select ptc.*
  46.    from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
  47.    left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
  48.    on ptc.products_id = pd.products_id
  49.    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  50.    where ptc.categories_id='" . $current_category_id . "'
  51.    order by pd.products_name";
  52.     $new_product_query = $db->Execute($sql);
  53.     $products_filter = $new_product_query->fields['products_id'];
  54.     zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  55.   }
  56.  
  57. // set categories and products if not set
  58.   if ($products_filter == '' and $current_category_id != '') {
  59.     $sql =     "select ptc.*
  60.    from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
  61.    left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
  62.    on ptc.products_id = pd.products_id
  63.    and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  64.    where ptc.categories_id='" . $current_category_id . "'
  65.    order by pd.products_name";
  66.     $new_product_query = $db->Execute($sql);
  67.     $products_filter = $new_product_query->fields['products_id'];
  68.     if ($products_filter != '') {
  69.       zen_redirect(zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id));
  70.     }
  71.   } else {
  72.     if ($products_filter == '' and $current_category_id == '') {
  73.       $reset_categories_id = zen_get_category_tree('', '', '0', '', '', true);
  74.       $current_category_id = $reset_categories_id[0]['id'];
  75.       $sql = "select ptc.*
  76.      from " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc
  77.      left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
  78.      on ptc.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  79.      where ptc.categories_id='" . $current_category_id . "'
  80.      order by pd.products_name";
  81.       $new_product_query = $db->Execute($sql);
  82.       $products_filter = $new_product_query->fields['products_id'];
  83.       $_GET['products_filter'] = $products_filter;
  84.     }
  85.   }
  86.  
  87.   require(DIR_WS_MODULES . FILENAME_PREV_NEXT);
  88.  
  89.   if (zen_not_null($action)) {
  90.     $_SESSION['page_info'] = '';
  91.     if (isset($_GET['option_page'])) $_SESSION['page_info'] .= 'option_page=' . $_GET['option_page'] . '&';
  92.     if (isset($_GET['value_page'])) $_SESSION['page_info'] .= 'value_page=' . $_GET['value_page'] . '&';
  93.     if (isset($_GET['attribute_page'])) $_SESSION['page_info'] .= 'attribute_page=' . $_GET['attribute_page'] . '&';
  94.     if (isset($_GET['products_filter'])) $_SESSION['page_info'] .= 'products_filter=' . $_GET['products_filter'] . '&';
  95.     if (isset($_GET['current_category_id'])) $_SESSION['page_info'] .= 'current_category_id=' . $_GET['current_category_id'] . '&';
  96.  
  97.     if (zen_not_null($_SESSION['page_info'])) {
  98.       $_SESSION['page_info'] = substr($_SESSION['page_info'], 0, -1);
  99.     }
  100.  
  101.     switch ($action) {
  102. /////////////////////////////////////////
  103. //// BOF OF FLAGS
  104.       case 'set_flag_attributes_display_only':
  105.         $action='';
  106.         $new_flag= $db->Execute("select products_attributes_id, products_id, attributes_display_only from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  107.         if ($new_flag->fields['attributes_display_only'] == '0') {
  108.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_display_only='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  109.         } else {
  110.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_display_only='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  111.         }
  112.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  113.         break;
  114.  
  115.       case 'set_flag_product_attribute_is_free':
  116.         $action='';
  117.         $new_flag= $db->Execute("select products_attributes_id, products_id, product_attribute_is_free from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  118.         if ($new_flag->fields['product_attribute_is_free'] == '0') {
  119.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set product_attribute_is_free='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  120.         } else {
  121.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set product_attribute_is_free='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  122.         }
  123.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  124.         break;
  125.  
  126.       case 'set_flag_attributes_default':
  127.         $action='';
  128.         $new_flag= $db->Execute("select products_attributes_id, products_id, attributes_default from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  129.         if ($new_flag->fields['attributes_default'] == '0') {
  130.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_default='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  131.         } else {
  132.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_default='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  133.         }
  134.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  135.         break;
  136.  
  137.       case 'set_flag_attributes_discounted':
  138.         $action='';
  139.         $new_flag= $db->Execute("select products_attributes_id, products_id, attributes_discounted from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  140.         if ($new_flag->fields['attributes_discounted'] == '0') {
  141.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_discounted='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  142.         } else {
  143.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_discounted='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  144.         }
  145.  
  146.         // reset products_price_sorter for searches etc.
  147.         zen_update_products_price_sorter($_GET['products_filter']);
  148.  
  149.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  150.         break;
  151.  
  152.       case 'set_flag_attributes_price_base_included':
  153.         $action='';
  154.         $new_flag= $db->Execute("select products_attributes_id, products_id, attributes_price_base_included from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  155.         if ($new_flag->fields['attributes_price_base_included'] == '0') {
  156.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_price_base_included='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  157.         } else {
  158.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_price_base_included='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  159.         }
  160.  
  161.         // reset products_price_sorter for searches etc.
  162.         zen_update_products_price_sorter($_GET['products_filter']);
  163.  
  164.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  165.         break;
  166.  
  167.       case 'set_flag_attributes_required':
  168.         $action='';
  169.         $new_flag= $db->Execute("select products_attributes_id, products_id, attributes_required from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  170.         if ($new_flag->fields['attributes_required'] == '0') {
  171.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_required='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  172.         } else {
  173.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_required='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
  174.         }
  175.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  176.         break;
  177.  
  178. //// EOF OF FLAGS
  179. /////////////////////////////////////////
  180.  
  181.       case 'set_products_filter':
  182.         $_GET['products_filter'] = $_POST['products_filter'];
  183.         $_GET['current_category_id'] = $_POST['current_category_id'];
  184.         $action='';
  185.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
  186.         break;
  187. // update by product
  188.       case ('update_product'):
  189.         if (!zen_has_product_attributes($products_filter, 'false')) {
  190.           $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_SORT_NONE . $products_filter . ' ' . zen_get_products_name($products_filter, $_SESSION['languages_id']), 'error');
  191.         } else {
  192.           $messageStack->add_session(SUCCESS_PRODUCT_UPDATE_SORT . $products_filter . ' ' . zen_get_products_name($products_filter, $_SESSION['languages_id']), 'success');
  193.           zen_update_attributes_products_option_values_sort_order($products_filter);
  194.         }
  195.         $action='';
  196.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_GET['current_category_id']));
  197.         break;
  198.       case 'add_product_attributes':
  199.         $current_image_name = '';
  200.         for ($i=0; $i<sizeof($_POST['values_id']); $i++) {
  201. // check for duplicate and block them
  202.           $check_duplicate = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . "
  203.                                           where products_id ='" . $_POST['products_id'] . "'
  204.                                           and options_id = '" . $_POST['options_id'] . "'
  205.                                           and options_values_id = '" . $_POST['values_id'][$i] . "'");
  206.           if ($check_duplicate->RecordCount() > 0) {
  207.             // do not add duplicates -- give a warning
  208.             $messageStack->add_session(ATTRIBUTE_WARNING_DUPLICATE . ' - ' . zen_options_name($_POST['options_id']) . ' : ' . zen_values_name($_POST['values_id'][$i]), 'error');
  209.           } else {
  210. // For TEXT and FILE option types, ignore option value entered by administrator and use PRODUCTS_OPTIONS_VALUES_TEXT instead.
  211.             $products_options_array = $db->Execute("select products_options_type from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");
  212.             $values_id = zen_db_prepare_input((($products_options_array->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT) or ($products_options_array->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE)) ? PRODUCTS_OPTIONS_VALUES_TEXT_ID : $_POST['values_id'][$i]);
  213.  
  214.             $products_id = zen_db_prepare_input($_POST['products_id']);
  215.             $options_id = zen_db_prepare_input($_POST['options_id']);
  216. //            $values_id = zen_db_prepare_input($_POST['values_id'][$i]);
  217.             $value_price = zen_db_prepare_input($_POST['value_price']);
  218.             $price_prefix = zen_db_prepare_input($_POST['price_prefix']);
  219.  
  220.             $products_options_sort_order = zen_db_prepare_input($_POST['products_options_sort_order']);
  221.  
  222. // modified options sort order to use default if not otherwise set
  223.             if (zen_not_null($_POST['products_options_sort_order'])) {
  224.               $products_options_sort_order = zen_db_prepare_input($_POST['products_options_sort_order']);
  225.             } else {
  226.               $sort_order_query = $db->Execute("select products_options_values_sort_order from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . $_POST['values_id'][$i] . "'");
  227.               $products_options_sort_order = $sort_order_query->fields['products_options_values_sort_order'];
  228.             } // end if (zen_not_null($_POST['products_options_sort_order'])
  229.  
  230. // end modification for sort order
  231.  
  232.             $product_attribute_is_free = zen_db_prepare_input($_POST['product_attribute_is_free']);
  233.             $products_attributes_weight = zen_db_prepare_input($_POST['products_attributes_weight']);
  234.             $products_attributes_weight_prefix = zen_db_prepare_input($_POST['products_attributes_weight_prefix']);
  235.             $attributes_display_only = zen_db_prepare_input($_POST['attributes_display_only']);
  236.             $attributes_default = zen_db_prepare_input($_POST['attributes_default']);
  237.             $attributes_discounted = zen_db_prepare_input($_POST['attributes_discounted']);
  238.             $attributes_price_base_included = zen_db_prepare_input($_POST['attributes_price_base_included']);
  239.  
  240.             $attributes_price_onetime = zen_db_prepare_input($_POST['attributes_price_onetime']);
  241.             $attributes_price_factor = zen_db_prepare_input($_POST['attributes_price_factor']);
  242.             $attributes_price_factor_offset = zen_db_prepare_input($_POST['attributes_price_factor_offset']);
  243.             $attributes_price_factor_onetime = zen_db_prepare_input($_POST['attributes_price_factor_onetime']);
  244.             $attributes_price_factor_onetime_offset = zen_db_prepare_input($_POST['attributes_price_factor_onetime_offset']);
  245.             $attributes_qty_prices = zen_db_prepare_input($_POST['attributes_qty_prices']);
  246.             $attributes_qty_prices_onetime = zen_db_prepare_input($_POST['attributes_qty_prices_onetime']);
  247.  
  248.             $attributes_price_words = zen_db_prepare_input($_POST['attributes_price_words']);
  249.             $attributes_price_words_free = zen_db_prepare_input($_POST['attributes_price_words_free']);
  250.             $attributes_price_letters = zen_db_prepare_input($_POST['attributes_price_letters']);
  251.             $attributes_price_letters_free = zen_db_prepare_input($_POST['attributes_price_letters_free']);
  252.             $attributes_required = zen_db_prepare_input($_POST['attributes_required']);
  253.  
  254. // add - update as record exists
  255. // attributes images
  256. // when set to none remove from database
  257. // only processes image once for multiple selection of options_values_id
  258.             if ($i == 0) {
  259.               if (isset($_POST['attributes_image']) && zen_not_null($_POST['attributes_image']) && ($_POST['attributes_image'] != 'none')) {
  260.                 $attributes_image = zen_db_prepare_input($_POST['attributes_image']);
  261.               } else {
  262.                 $attributes_image = '';
  263.               }
  264.  
  265.               $attributes_image = new upload('attributes_image');
  266.               $attributes_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
  267.               if ($attributes_image->parse() && $attributes_image->save($_POST['overwrite'])) {
  268.                 $attributes_image_name = $_POST['img_dir'] . $attributes_image->filename;
  269.               } else {
  270.                 $attributes_image_name = (isset($_POST['attributes_previous_image']) ? $_POST['attributes_previous_image'] : '');
  271.               }
  272.               $current_image_name = $attributes_image_name;
  273.             } else {
  274.               $attributes_image_name = $current_image_name;
  275.             }
  276.  
  277.             $db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, product_attribute_is_free, products_attributes_weight, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted, attributes_image, attributes_price_base_included, attributes_price_onetime, attributes_price_factor, attributes_price_factor_offset, attributes_price_factor_onetime, attributes_price_factor_onetime_offset, attributes_qty_prices, attributes_qty_prices_onetime, attributes_price_words, attributes_price_words_free, attributes_price_letters, attributes_price_letters_free, attributes_required)
  278.                          values (0,
  279.                                  '" . (int)$products_id . "',
  280.                                  '" . (int)$options_id . "',
  281.                                  '" . (int)$values_id . "',
  282.                                  '" . (float)zen_db_input($value_price) . "',
  283.                                  '" . zen_db_input($price_prefix) . "',
  284.                                  '" . (int)zen_db_input($products_options_sort_order) . "',
  285.                                  '" . (int)zen_db_input($product_attribute_is_free) . "',
  286.                                  '" . (float)zen_db_input($products_attributes_weight) . "',
  287.                                  '" . zen_db_input($products_attributes_weight_prefix) . "',
  288.                                  '" . (int)zen_db_input($attributes_display_only) . "',
  289.                                  '" . (int)zen_db_input($attributes_default) . "',
  290.                                  '" . (int)zen_db_input($attributes_discounted) . "',
  291.                                  '" . zen_db_input($attributes_image_name) . "',
  292.                                  '" . (int)zen_db_input($attributes_price_base_included) . "',
  293.                                  '" . (float)zen_db_input($attributes_price_onetime) . "',
  294.                                  '" . (float)zen_db_input($attributes_price_factor) . "',
  295.                                  '" . (float)zen_db_input($attributes_price_factor_offset) . "',
  296.                                  '" . (float)zen_db_input($attributes_price_factor_onetime) . "',
  297.                                  '" . (float)zen_db_input($attributes_price_factor_onetime_offset) . "',
  298.                                  '" . zen_db_input($attributes_qty_prices) . "',
  299.                                  '" . zen_db_input($attributes_qty_prices_onetime) . "',
  300.                                  '" . (float)zen_db_input($attributes_price_words) . "',
  301.                                  '" . (int)zen_db_input($attributes_price_words_free) . "',
  302.                                  '" . (float)zen_db_input($attributes_price_letters) . "',
  303.                                  '" . (int)zen_db_input($attributes_price_letters_free) . "',
  304.                                  '" . (int)zen_db_input($attributes_required) . "')");
  305.  
  306.             if (DOWNLOAD_ENABLED == 'true') {
  307.               $products_attributes_id = $db->Insert_ID();
  308.  
  309.               $products_attributes_filename = zen_db_prepare_input($_POST['products_attributes_filename']);
  310.               $products_attributes_maxdays = (int)zen_db_prepare_input($_POST['products_attributes_maxdays']);
  311.               $products_attributes_maxcount = (int)zen_db_prepare_input($_POST['products_attributes_maxcount']);
  312.  
  313. //die( 'I am adding ' . strlen($_POST['products_attributes_filename']) . ' vs ' . strlen(trim($_POST['products_attributes_filename'])) . ' vs ' . strlen(zen_db_prepare_input($_POST['products_attributes_filename'])) . ' vs ' . strlen(zen_db_input($products_attributes_filename)) );
  314.               if (zen_not_null($products_attributes_filename)) {
  315.                 $db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
  316.                              (products_attributes_id, products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount)
  317.                              values (" . (int)$products_attributes_id . ",
  318.                                      '" . zen_db_input($products_attributes_filename) . "',
  319.                                      '" . zen_db_input($products_attributes_maxdays) . "',
  320.                                      '" . zen_db_input($products_attributes_maxcount) . "')");
  321.               }
  322.             }
  323.           }
  324.         }
  325.  
  326.         // reset products_price_sorter for searches etc.
  327.         zen_update_products_price_sorter($_POST['products_id']);
  328.  
  329.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_POST['products_id'] . '&current_category_id=' . $_POST['current_category_id']));
  330.         break;
  331.       case 'update_product_attribute':
  332.         $check_duplicate = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . "
  333.                                         where products_id ='" . $_POST['products_id'] . "'
  334.                                         and options_id = '" . $_POST['options_id'] . "'
  335.                                         and options_values_id = '" . $_POST['values_id'] . "'
  336.                                         and products_attributes_id != '" . $_POST['attribute_id'] . "'");
  337.  
  338.         if ($check_duplicate->RecordCount() > 0) {
  339.           // do not add duplicates give a warning
  340.           $messageStack->add_session(ATTRIBUTE_WARNING_DUPLICATE_UPDATE . ' - ' . zen_options_name($_POST['options_id']) . ' : ' . zen_values_name($_POST['values_id']), 'error');
  341.         } else {
  342.           // Validate options_id and options_value_id
  343.           if (!zen_validate_options_to_options_value($_POST['options_id'], $_POST['values_id'])) {
  344.             // do not add invalid match
  345.             $messageStack->add_session(ATTRIBUTE_WARNING_INVALID_MATCH_UPDATE . ' - ' . zen_options_name($_POST['options_id']) . ' : ' . zen_values_name($_POST['values_id']), 'error');
  346.           } else {
  347.             // add the new attribute
  348. // iii 030811 added:  Enforce rule that TEXT and FILE Options use value PRODUCTS_OPTIONS_VALUES_TEXT_ID
  349.         $products_options_query = $db->Execute("select products_options_type from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");
  350.         switch ($products_options_array->fields['products_options_type']) {
  351.           case PRODUCTS_OPTIONS_TYPE_TEXT:
  352.           case PRODUCTS_OPTIONS_TYPE_FILE:
  353.             $values_id = PRODUCTS_OPTIONS_VALUES_TEXT_ID;
  354.             break;
  355.           default:
  356.           $values_id = zen_db_prepare_input($_POST['values_id']);
  357.         }
  358. // iii 030811 added END
  359.  
  360.             $products_id = zen_db_prepare_input($_POST['products_id']);
  361.             $options_id = zen_db_prepare_input($_POST['options_id']);
  362. //            $values_id = zen_db_prepare_input($_POST['values_id']);
  363.             $value_price = zen_db_prepare_input($_POST['value_price']);
  364.             $price_prefix = zen_db_prepare_input($_POST['price_prefix']);
  365.  
  366.             $products_options_sort_order = zen_db_prepare_input($_POST['products_options_sort_order']);
  367.             $product_attribute_is_free = zen_db_prepare_input($_POST['product_attribute_is_free']);
  368.             $products_attributes_weight = zen_db_prepare_input($_POST['products_attributes_weight']);
  369.             $products_attributes_weight_prefix = zen_db_prepare_input($_POST['products_attributes_weight_prefix']);
  370.             $attributes_display_only = zen_db_prepare_input($_POST['attributes_display_only']);
  371.             $attributes_default = zen_db_prepare_input($_POST['attributes_default']);
  372.             $attributes_discounted = zen_db_prepare_input($_POST['attributes_discounted']);
  373.             $attributes_price_base_included = zen_db_prepare_input($_POST['attributes_price_base_included']);
  374.  
  375.             $attributes_price_onetime = zen_db_prepare_input($_POST['attributes_price_onetime']);
  376.             $attributes_price_factor = zen_db_prepare_input($_POST['attributes_price_factor']);
  377.             $attributes_price_factor_offset = zen_db_prepare_input($_POST['attributes_price_factor_offset']);
  378.             $attributes_price_factor_onetime = zen_db_prepare_input($_POST['attributes_price_factor_onetime']);
  379.             $attributes_price_factor_onetime_offset = zen_db_prepare_input($_POST['attributes_price_factor_onetime_offset']);
  380.             $attributes_qty_prices = zen_db_prepare_input($_POST['attributes_qty_prices']);
  381.             $attributes_qty_prices_onetime = zen_db_prepare_input($_POST['attributes_qty_prices_onetime']);
  382.  
  383.             $attributes_price_words = zen_db_prepare_input($_POST['attributes_price_words']);
  384.             $attributes_price_words_free = zen_db_prepare_input($_POST['attributes_price_words_free']);
  385.             $attributes_price_letters = zen_db_prepare_input($_POST['attributes_price_letters']);
  386.             $attributes_price_letters_free = zen_db_prepare_input($_POST['attributes_price_letters_free']);
  387.             $attributes_required = zen_db_prepare_input($_POST['attributes_required']);
  388.  
  389.             $attribute_id = zen_db_prepare_input($_POST['attribute_id']);
  390.  
  391. // edit
  392. // attributes images
  393. // when set to none remove from database
  394.           if (isset($_POST['attributes_image']) && zen_not_null($_POST['attributes_image']) && ($_POST['attributes_image'] != 'none')) {
  395.             $attributes_image = zen_db_prepare_input($_POST['attributes_image']);
  396.             $attributes_image_none = false;
  397.           } else {
  398.             $attributes_image = '';
  399.             $attributes_image_none = true;
  400.           }
  401.  
  402.           $attributes_image = new upload('attributes_image');
  403.           $attributes_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
  404.           if ($attributes_image->parse() && $attributes_image->save($_POST['overwrite'])) {
  405.             $attributes_image_name = ($attributes_image->filename != 'none' ? ($_POST['img_dir'] . $attributes_image->filename) : '');
  406.           } else {
  407.             $attributes_image_name = ((isset($_POST['attributes_previous_image']) and $_POST['attributes_image'] != 'none') ? $_POST['attributes_previous_image'] : '');
  408.           }
  409.  
  410. if ($_POST['image_delete'] == 1) {
  411.   $attributes_image_name = '';
  412. }
  413. // turned off until working
  414.           $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . "
  415.                        set attributes_image = '" .  $attributes_image_name . "'
  416.                        where products_attributes_id = '" . (int)$attribute_id . "'");
  417.  
  418.             $db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . "
  419.                          set products_id = '" . (int)$products_id . "',
  420.                              options_id = '" . (int)$options_id . "',
  421.                              options_values_id = '" . (int)$values_id . "',
  422.                              options_values_price = '" . zen_db_input($value_price) . "',
  423.                              price_prefix = '" . zen_db_input($price_prefix) . "',
  424.                              products_options_sort_order = '" . zen_db_input($products_options_sort_order) . "',
  425.                              product_attribute_is_free = '" . zen_db_input($product_attribute_is_free) . "',
  426.                              products_attributes_weight = '" . zen_db_input($products_attributes_weight) . "',
  427.                              products_attributes_weight_prefix = '" . zen_db_input($products_attributes_weight_prefix) . "',
  428.                              attributes_display_only = '" . zen_db_input($attributes_display_only) . "',
  429.                              attributes_default = '" . zen_db_input($attributes_default) . "',
  430.                              attributes_discounted = '" . zen_db_input($attributes_discounted) . "',
  431.                              attributes_price_base_included = '" . zen_db_input($attributes_price_base_included) . "',
  432.                              attributes_price_onetime = '" . zen_db_input($attributes_price_onetime) . "',
  433.                              attributes_price_factor = '" . zen_db_input($attributes_price_factor) . "',
  434.                              attributes_price_factor_offset = '" . zen_db_input($attributes_price_factor_offset) . "',
  435.                              attributes_price_factor_onetime = '" . zen_db_input($attributes_price_factor_onetime) . "',
  436.                              attributes_price_factor_onetime_offset = '" . zen_db_input($attributes_price_factor_onetime_offset) . "',
  437.                              attributes_qty_prices = '" . zen_db_input($attributes_qty_prices) . "',
  438.                              attributes_qty_prices_onetime = '" . zen_db_input($attributes_qty_prices_onetime) . "',
  439.                              attributes_price_words = '" . zen_db_input($attributes_price_words) . "',
  440.                              attributes_price_words_free = '" . zen_db_input($attributes_price_words_free) . "',
  441.                              attributes_price_letters = '" . zen_db_input($attributes_price_letters) . "',
  442.                              attributes_price_letters_free = '" . zen_db_input($attributes_price_letters_free) . "',
  443.                              attributes_required = '" . zen_db_input($attributes_required) . "'
  444.                          where products_attributes_id = '" . (int)$attribute_id . "'");
  445.  
  446.             if (DOWNLOAD_ENABLED == 'true') {
  447.               $products_attributes_filename = zen_db_prepare_input($_POST['products_attributes_filename']);
  448.               $products_attributes_maxdays = zen_db_prepare_input($_POST['products_attributes_maxdays']);
  449.               $products_attributes_maxcount = zen_db_prepare_input($_POST['products_attributes_maxcount']);
  450.  
  451.               if (zen_not_null($products_attributes_filename)) {
  452.                 $db->Execute("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
  453.                              set products_attributes_id = '" . (int)$attribute_id . "',
  454.                                  products_attributes_filename = '" . zen_db_input($products_attributes_filename) . "',
  455.                                  products_attributes_maxdays = '" . zen_db_input($products_attributes_maxdays) . "',
  456.                                  products_attributes_maxcount = '" . zen_db_input($products_attributes_maxcount) . "'");
  457.               }
  458.             }
  459.           }
  460.         }
  461.  
  462.         // reset products_price_sorter for searches etc.
  463.         zen_update_products_price_sorter($_POST['products_id']);
  464.  
  465.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&current_category_id=' . $_POST['current_category_id']));
  466.         break;
  467.       case 'delete_attribute':
  468.         // demo active test
  469.         if (zen_admin_demo()) {
  470.           $_GET['action']= '';
  471.           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  472.           zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&current_category_id=' . $_POST['current_category_id']));
  473.         }
  474.         $attribute_id = zen_db_prepare_input($_GET['attribute_id']);
  475.  
  476.         $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . "
  477.                      where products_attributes_id = '" . (int)$attribute_id . "'");
  478.  
  479. // added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled
  480.         $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
  481.                      where products_attributes_id = '" . (int)$attribute_id . "'");
  482.  
  483.         // reset products_price_sorter for searches etc.
  484.         zen_update_products_price_sorter($products_filter);
  485.  
  486. //        zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info']));
  487.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&current_category_id=' . $current_category_id));
  488.         break;
  489. // delete all attributes
  490.       case 'delete_all_attributes':
  491.         zen_delete_products_attributes($_POST['products_filter']);
  492.         $messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED . ' ID#' . $products_filter, 'success');
  493.         $action='';
  494.         $products_filter = $_POST['products_filter'];
  495.  
  496.         // reset products_price_sorter for searches etc.
  497.         zen_update_products_price_sorter($products_filter);
  498.  
  499.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_POST['current_category_id']));
  500.         break;
  501.  
  502.       case 'delete_option_name_values':
  503.         $delete_attributes_options_id = $db->Execute("select * from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_POST['products_filter'] . "' and options_id='" . $_POST['products_options_id_all'] . "'");
  504.         while (!$delete_attributes_options_id->EOF) {
  505. // remove any attached downloads
  506.           $remove_downloads = $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id= '" . $delete_attributes_options_id->fields['products_attributes_id'] . "'");
  507. // remove all option values
  508.           $delete_attributes_options_id_values = $db->Execute("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_POST['products_filter'] . "' and options_id='" . $_POST['products_options_id_all'] . "'");
  509.           $delete_attributes_options_id->MoveNext();
  510.         }
  511.  
  512.         $action='';
  513.         $products_filter = $_POST['products_filter'];
  514.         $messageStack->add_session(SUCCESS_ATTRIBUTES_DELETED_OPTION_NAME_VALUES. ' ID#' . zen_options_name($_POST['products_options_id_all']), 'success');
  515.  
  516.         // reset products_price_sorter for searches etc.
  517.         zen_update_products_price_sorter($products_filter);
  518.  
  519.         zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_POST['current_category_id']));
  520.         break;
  521.  
  522.  
  523. // attributes copy to product
  524.     case 'update_attributes_copy_to_product':
  525.       $copy_attributes_delete_first = ($_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0');
  526.       $copy_attributes_duplicates_skipped = ($_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0');
  527.       $copy_attributes_duplicates_overwrite = ($_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0');
  528.       zen_copy_products_attributes($_POST['products_filter'], $_POST['products_update_id']);
  529.       $_GET['action']= '';
  530.       $products_filter = $_POST['products_update_id'];
  531.       zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_POST['current_category_id']));
  532.       break;
  533.  
  534. // attributes copy to category
  535.     case 'update_attributes_copy_to_category':
  536.       $copy_attributes_delete_first = ($_POST['copy_attributes'] == 'copy_attributes_delete' ? '1' : '0');
  537.       $copy_attributes_duplicates_skipped = ($_POST['copy_attributes'] == 'copy_attributes_ignore' ? '1' : '0');
  538.       $copy_attributes_duplicates_overwrite = ($_POST['copy_attributes'] == 'copy_attributes_update' ? '1' : '0');
  539.       if ($_POST['categories_update_id'] == '') {
  540.         $messageStack->add_session(WARNING_PRODUCT_COPY_TO_CATEGORY_NONE . ' ID#' . $_POST['products_filter'], 'warning');
  541.       } else {
  542.         $copy_to_category = $db->Execute("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id='" . $_POST['categories_update_id'] . "'");
  543.         while (!$copy_to_category->EOF) {
  544.           zen_copy_products_attributes($_POST['products_filter'], $copy_to_category->fields['products_id']);
  545.           $copy_to_category->MoveNext();
  546.         }
  547.       }
  548.       $_GET['action']= '';
  549.       $products_filter = $_POST['products_filter'];
  550.       zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $_POST['current_category_id']));
  551.       break;
  552.  
  553.     }
  554.   }
  555.  
  556. //iii 031103 added to get results from database option type query
  557.   $products_options_types_list = array();
  558. //  $products_options_type_array = $db->Execute("select products_options_types_id, products_options_types_name from " . TABLE_PRODUCTS_OPTIONS_TYPES . " where language_id='" . $_SESSION['languages_id'] . "' order by products_options_types_id");
  559.   $products_options_type_array = $db->Execute("select products_options_types_id, products_options_types_name from " . TABLE_PRODUCTS_OPTIONS_TYPES . " order by products_options_types_id");
  560.   while (!$products_options_type_array->EOF) {
  561.     $products_options_types_list[$products_options_type_array->fields['products_options_types_id']] = $products_options_type_array->fields['products_options_types_name'];
  562.     $products_options_type_array->MoveNext();
  563.   }
  564.  
  565. //CLR 030312 add function to draw pulldown list of option types
  566. // Draw a pulldown for Option Types
  567. //iii 031103 modified to use results of database option type query from above
  568. function draw_optiontype_pulldown($name, $default = '') {
  569.   global $products_options_types_list;
  570.   $values = array();
  571.   foreach ($products_options_types_list as $id => $text) {
  572.     $values[] = array('id' => $id, 'text' => $text);
  573.   }
  574.   return zen_draw_pull_down_menu($name, $values, $default);
  575. }
  576.  
  577. //CLR 030312 add function to translate type_id to name
  578. // Translate option_type_values to english string
  579. //iii 031103 modified to use results of database option type query from above
  580. function translate_type_to_name($opt_type) {
  581.   global $products_options_types_list;
  582.   return $products_options_types_list[$opt_type];
  583. }
  584.  
  585.   function zen_js_option_values_list($selectedName, $fieldName) {
  586.     global $db, $show_value_numbers;
  587.     $attributes_sql = "SELECT povpo.products_options_id, povpo.products_options_values_id, po.products_options_name, po.products_options_sort_order,
  588.                       pov.products_options_values_name, pov.products_options_values_sort_order
  589.                       FROM " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " povpo, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
  590.                       WHERE povpo.products_options_id = po.products_options_id
  591.                       AND povpo.products_options_values_id = pov.products_options_values_id
  592.                       AND pov.language_id = po.language_id
  593.                       AND po.language_id = " . $_SESSION['languages_id'] . "
  594.                       ORDER BY po.products_options_id, po.products_options_name, pov.products_options_values_name";
  595.  
  596. //           "
  597. //           ORDER BY po.products_options_name, pov.products_options_values_sort_order";
  598.  
  599.     $attributes = $db->Execute($attributes_sql);
  600.  
  601.     $counter = 1;
  602.     $val_count = 0;
  603.     $value_string = '  // Build conditional Option Values Lists' . "\n";
  604.     $last_option_processed = null;
  605.     while (!$attributes->EOF) {
  606.       $products_options_values_name = str_replace('-', '\-', $attributes->fields['products_options_values_name']);
  607.       $products_options_values_name = str_replace('(', '\(', $products_options_values_name);
  608.       $products_options_values_name = str_replace(')', '\)', $products_options_values_name);
  609.       $products_options_values_name = str_replace('"', '\"', $products_options_values_name);
  610.       $products_options_values_name = str_replace('&quot;', '\"', $products_options_values_name);
  611.       $products_options_values_name = str_replace('&frac12;', '1/2', $products_options_values_name);
  612.  
  613.       if ($counter == 1) {
  614.         $value_string .= '  if (' . $selectedName . ' == "' . $attributes->fields['products_options_id'] . '") {' . "\n";
  615.       } elseif ($last_option_processed != $attributes->fields['products_options_id']) {
  616.         $value_string .= '  } else if (' . $selectedName . ' == "' . $attributes->fields['products_options_id'] . '") {' . "\n";
  617.         $val_count = 0;
  618.       }
  619.  
  620.       $value_string .= '    ' . $fieldName . '.options[' . $val_count . '] = new Option("' . $products_options_values_name . ($attributes->fields['products_options_values_id'] == 0 ? '/UPLOAD FILE' : '') . ($show_value_numbers ? ' [ #' . $attributes->fields['products_options_values_id'] . ' ] ' : '') . '", "' . $attributes->fields['products_options_values_id'] . '");' . "\n";
  621.  
  622.       $last_option_processed = $attributes->fields['products_options_id'];;
  623.       $val_count++;
  624.       $counter++;
  625.       $attributes->MoveNext();
  626.     }
  627.     if ($counter > 1) {
  628.       $value_string .= '  }' . "\n";
  629.     }
  630.     return $value_string;
  631.   }
  632.  
  633. ?>
  634. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  635. <html <?php echo HTML_PARAMS; ?>>
  636. <head>
  637. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  638. <title><?php echo TITLE; ?></title>
  639. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  640. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  641. <script language="javascript" src="includes/menu.js"></script>
  642. <script language="javascript" src="includes/general.js"></script>
  643. <script language="javascript"><!--
  644. function go_option() {
  645.   if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {
  646.     location = "<?php echo zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'option_page=' . ($_GET['option_page'] ? $_GET['option_page'] : 1)); ?>&option_order_by="+document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value;
  647.   }
  648. }
  649. function popupWindow(url) {
  650.   window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=460,screenX=150,screenY=150,top=150,left=150')
  651. }
  652. //--></script>
  653. <script type="text/javascript">
  654.   <!--
  655.   function init()
  656.   {
  657.     cssjsmenu('navbar');
  658.     if (document.getElementById)
  659.     {
  660.       var kill = document.getElementById('hoverJS');
  661.       kill.disabled = true;
  662.     }
  663.   }
  664.   // -->
  665. </script>
  666. </head>
  667. <!-- <body onload="init()"> -->
  668. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="init()">
  669. <!-- header //-->
  670. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  671. <!-- header_eof //-->
  672.  
  673. <!-- body //-->
  674. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  675.   <tr>
  676. <!-- body_text //-->
  677.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  678.               <tr>
  679.                 <td class="smallText" align="right">
  680. <?php
  681.     echo zen_draw_form('search', FILENAME_CATEGORIES, '', 'get');
  682. // show reset search
  683.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  684.       echo '<a href="' . zen_href_link(FILENAME_CATEGORIES) . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
  685.     }
  686.     echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
  687.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  688.       $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  689.       echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
  690.     }
  691.     echo '</form>';
  692. ?>
  693.                 </td>
  694.               </tr>
  695.  
  696.       <tr>
  697.         <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  698. <!-- products_attributes //-->
  699.       <tr>
  700.         <td width="100%"><table border="0" cellspacing="2" cellpadding="2">
  701.           <tr>
  702.             <td height="40" valign="bottom"><a href="<?php echo  zen_href_link(FILENAME_OPTIONS_NAME_MANAGER, '', 'NONSSL') ?>"><?php echo zen_image_button('button_option_names.gif', IMAGE_OPTION_NAMES); ?></a></td>
  703.             <td height="40" valign="bottom"><a href="<?php echo  zen_href_link(FILENAME_OPTIONS_VALUES_MANAGER, '', 'NONSSL') ?>"><?php echo zen_image_button('button_option_values.gif', IMAGE_OPTION_VALUES); ?></a></td>
  704.           </tr>
  705.         </table></td>
  706.       </tr>
  707.       <tr>
  708.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  709.           <tr>
  710.             <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE_ATRIB; ?>&nbsp;</td>
  711.           </tr>
  712.         </table></td>
  713.       </tr>
  714.  
  715. <?php
  716. if ($action == 'attributes_preview') {
  717.   // don't show anything from here down
  718. ?>
  719.  
  720. <tr><td><table align="center"><tr>
  721.             <td class="pageHeading" align="center"><?php echo TEXT_ATTRIBUTES_PREVIEW_DISPLAY . $products_filter . '<br />' . zen_get_products_name($products_filter); ?></td>
  722. </tr></table></td></tr>
  723.  
  724. <?php
  725. } else {
  726.   // show the attributes
  727. ?>
  728. <?php
  729.   if ($products_filter != '' and $action != 'attribute_features_copy_to_product' and $action != 'attribute_features_copy_to_category' and $action != 'delete_all_attributes_confirm') {
  730. ?>
  731.       <tr>
  732.         <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  733.       </tr>
  734.  
  735.       <tr>
  736.         <td colspan="2"><table border="1" cellspacing="2" cellpadding="4" align="left">
  737.           <tr>
  738.             <td colspan="7" class="main" align="center">
  739.               <?php echo TEXT_PRODUCTS_LISTING . TEXT_PRODUCTS_ID . $products_filter .  TEXT_PRODUCT_IN_CATEGORY_NAME . zen_get_category_name(zen_get_products_category_id($products_filter), (int)$_SESSION['languages_id']) . '<br />' . zen_get_products_name($products_filter); ?>
  740.             </td>
  741.           </tr>
  742.           <tr>
  743.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=new_product' . '&cPath=' . zen_get_product_path($products_filter) . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '<br />' . TEXT_PRODUCT_EDIT . '</a>'; ?></td>
  744.             <td class="smallText" align="center">
  745.               <?php
  746.                 if ($zc_products->get_allow_add_to_cart($products_filter) == "Y") {
  747.                   echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_products_price_manager.gif', IMAGE_PRODUCTS_PRICE_MANAGER) . '<br />' . TEXT_PRODUCTS_PRICE_MANAGER . '</a>';
  748.                 } else {
  749.                   echo TEXT_INFO_ALLOW_ADD_TO_CART_NO;
  750.                 }
  751.               ?>
  752.             </td>
  753. <?php
  754.   if (zen_has_product_attributes($products_filter, 'false')) {
  755. ?>
  756.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=update_product' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_update_sort.gif', IMAGE_UPDATE_SORT) . '<br />' . TEXT_ATTRIBUTES_UPDATE_SORT_ORDER . '</a>'; ?></td>
  757.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=attributes_preview' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '<br />' . TEXT_ATTRIBUTES_PREVIEW . '</a>'; ?></td>
  758.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=delete_all_attributes_confirm' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '<br />' . TEXT_ATTRIBUTES_DELETE . '</a>'; ?></td>
  759.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=attribute_features_copy_to_product' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_copy_to.gif', IMAGE_COPY) . '<br />' . TEXT_ATTRIBUTES_COPY_TO_PRODUCTS . '</a>'; ?></td>
  760.             <td class="smallText" align="center"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=attribute_features_copy_to_category' . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image_button('button_copy_to.gif', IMAGE_COPY) . '<br />' . TEXT_ATTRIBUTES_COPY_TO_CATEGORY . '</a>'; ?></td>
  761. <?php
  762. } else {
  763. ?>
  764.             <td class="main" align="center" width="200"><?php echo TEXT_NO_ATTRIBUTES_DEFINED . $products_filter; ?></td>
  765. <?php
  766. }
  767. ?>
  768.           </tr>
  769.           <tr>
  770.             <td class="smallText" align="center" colspan="7"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_TO_CATEGORIES, '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . IMAGE_PRODUCTS_TO_CATEGORIES . '</a>'; ?></td>
  771.           </tr>
  772.         </table></td>
  773.       </form></tr>
  774.       <tr>
  775.         <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  776.       </tr>
  777. <?php
  778. }
  779. ?>
  780. <?php
  781. } // eof: attributes_preview
  782. ?>
  783.  
  784. <?php
  785. // remove all attributes from the product
  786.   if ($action == 'delete_all_attributes_confirm') {
  787. ?>
  788.       <tr><form name="delete_all"<?php echo 'action="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=delete_all_attributes') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?><?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  789.         <td colspan="2"><table border="2" cellspacing="2" cellpadding="4">
  790.           <tr>
  791.             <td><table border="0" cellspacing="2" cellpadding="2">
  792.               <tr>
  793.                 <td class="alert" align="center"><?php echo TEXT_DELETE_ALL_ATTRIBUTES . $products_filter . '<br />' . zen_get_products_name($products_filter); ?></td>
  794.                 <td class="main" align="center"><?php echo zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  795.               </tr>
  796.             </table></td>
  797.           </table></td>
  798.         </tr>
  799.       </form></tr>
  800. <?php
  801. }
  802. ?>
  803.  
  804. <?php
  805. // remove option name and all values from the product
  806.   if ($action == 'delete_option_name_values_confirm') {
  807. ?>
  808.       <tr><form name="delete_all"<?php echo 'action="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=delete_option_name_values') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  809.         <?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?>
  810.         <?php echo zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?>
  811.         <?php echo zen_draw_hidden_field('products_options_id_all', $_GET['products_options_id_all']); ?>
  812.         <td colspan="2"><table border="2" cellspacing="2" cellpadding="4">
  813.           <tr>
  814.             <td><table border="0" cellspacing="2" cellpadding="2">
  815.               <tr class="pageHeading">
  816.                 <td class="alert" align="center" colspan="2"><?php echo TEXT_DELETE_ATTRIBUTES_OPTION_NAME_VALUES; ?></td>
  817.               </tr>
  818.               <tr>
  819.                 <td class="main" align="left"><?php echo TEXT_INFO_PRODUCT_NAME . zen_get_products_name($products_filter) . '<br />' . TEXT_INFO_PRODUCTS_OPTION_ID . $_GET['products_options_id_all'] . '&nbsp;' . TEXT_INFO_PRODUCTS_OPTION_NAME . '&nbsp;' . zen_options_name($_GET['products_options_id_all']); ?></td>
  820.                 <td class="main" align="left"><?php echo zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  821.               </tr>
  822.             </table></td>
  823.           </table></td>
  824.         </tr>
  825.       </form></tr>
  826. <?php
  827. }
  828. ?>
  829.  
  830. <?php
  831.   if ($action == 'attribute_features_copy_to_product') {
  832.     $_GET['products_update_id'] = '';
  833.     // excluded current product from the pull down menu of products
  834.     $products_exclude_array = array();
  835.     $products_exclude_array[] = $products_filter;
  836. ?>
  837.       <tr><form name="product_copy_to_product"<?php echo 'action="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=update_attributes_copy_to_product') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']) . zen_draw_hidden_field('products_id', $_GET['products_filter']) . zen_draw_hidden_field('products_update_id', $_GET['products_update_id']) . zen_draw_hidden_field('copy_attributes', $_GET['copy_attributes']); ?><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  838.         <td colspan="2"><table border="2" cellspacing="0" cellpadding="2">
  839.           <tr>
  840.             <td><table border="0" cellspacing="2" cellpadding="4">
  841.               <tr>
  842.                 <td class="main" align="center"><?php echo TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_PRODUCT . $products_filter . '<br />' . zen_get_products_name($products_filter); ?></td>
  843.                 <td class="main" align="left"><?php echo TEXT_COPY_ATTRIBUTES_CONDITIONS . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_delete', true) . ' ' . TEXT_COPY_ATTRIBUTES_DELETE . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_update') . ' ' . TEXT_COPY_ATTRIBUTES_UPDATE . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_ignore') . ' ' . TEXT_COPY_ATTRIBUTES_IGNORE; ?></td>
  844.               </tr>
  845.               <tr>
  846.                 <td class="alert" align="center"><?php echo TEXT_INFO_ATTRIBUTES_FEATURE_COPY_TO . '<br />' . zen_draw_products_pull_down('products_update_id', 'size="15"', $products_exclude_array, true, '', true); ?></td>
  847.                 <td class="main" align="center"><?php echo zen_image_submit('button_copy.gif', IMAGE_COPY) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  848.               </tr>
  849.             </table></td>
  850.           </table></td>
  851.         </tr>
  852.       </form></tr>
  853. <?php
  854. }
  855. ?>
  856.  
  857. <?php
  858.   if ($action == 'attribute_features_copy_to_category') {
  859. ?>
  860.       <tr><form name="product_copy_to_category"<?php echo 'action="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=update_attributes_copy_to_category') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']) . zen_draw_hidden_field('products_id', $_GET['products_filter']) . zen_draw_hidden_field('products_update_id', $_GET['products_update_id']) . zen_draw_hidden_field('copy_attributes', $_GET['copy_attributes']) . zen_draw_hidden_field('current_category_id', $_GET['current_category_id']); ?><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?>
  861.         <td colspan="2"><table border="2" cellspacing="0" cellpadding="2">
  862.           <tr>
  863.             <td><table border="0" cellspacing="2" cellpadding="4">
  864.               <tr>
  865.                 <td class="main" align="center"><?php echo TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_CATEGORY . $products_filter . '<br />' . zen_get_products_name($products_filter); ?></td>
  866.                 <td class="main" align="left"><?php echo TEXT_COPY_ATTRIBUTES_CONDITIONS . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_delete', true) . ' ' . TEXT_COPY_ATTRIBUTES_DELETE . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_update') . ' ' . TEXT_COPY_ATTRIBUTES_UPDATE . '<br />' . zen_draw_radio_field('copy_attributes', 'copy_attributes_ignore') . ' ' . TEXT_COPY_ATTRIBUTES_IGNORE; ?></td>
  867.               </tr>
  868.               <tr>
  869.                 <td class="alert" align="center"><?php echo TEXT_INFO_ATTRIBUTES_FEATURE_CATEGORIES_COPY_TO . '<br />' . zen_draw_products_pull_down_categories('categories_update_id', 'size="5"', '', true, true); ?></td>
  870.                 <td class="main" align="center"><?php echo zen_image_submit('button_copy.gif', IMAGE_COPY) . '&nbsp;&nbsp;' . '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  871.               </tr>
  872.             </table></td>
  873.           </table></td>
  874.         </tr>
  875.       </form></tr>
  876.  
  877. <?php
  878. }
  879. ?>
  880.  
  881. <?php
  882. // fix here
  883. // preview shot of attributes
  884. if ($action == 'attributes_preview') {
  885.   $_GET['products_id'] = $products_filter;
  886.   $pInfo->products_id = $products_filter;
  887.  
  888.   include(DIR_WS_INCLUDES . 'attributes_preview.php');
  889. ?>
  890.       <tr>
  891.         <td colspan="2" class="main" align="center" height= "40" valign="middle"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  892.       </tr>
  893.       <tr>
  894.         <td colspan="2"><table border="1" cellspacing="0" cellpadding="2" align="center" class="main_page">
  895.           <tr>
  896.             <td class="main">
  897. <?php
  898. //            where    patrib.products_id='" . $pInfo->products_id . "'
  899. //            where    patrib.products_id='" . (int)$_GET['products_id'] . "'
  900.   $check_template = $db->Execute("select template_dir from " . TABLE_TEMPLATE_SELECT);
  901.   echo '<link rel="stylesheet" type="text/css" href="' . DIR_WS_CATALOG_TEMPLATE . $check_template->fields['template_dir'] . '/css/stylesheet.css' . '" />';
  902. ?>
  903.  
  904.   <tr>
  905.     <td colspan="2" class="main" align="center">
  906. <?php
  907.   if ($pr_attr->fields['total'] > 0) {
  908. ?>
  909.       <table border="0" width="90%" cellspacing="0" cellpadding="2">
  910.         <tr>
  911.           <td colspan="2" class="main" align="left"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
  912.         </tr>
  913. <?php
  914.     for($i=0;$i<sizeof($options_name);$i++) {
  915. ?>
  916. <?php
  917.   if ($options_comment[$i] != '' and $options_comment_position[$i] == '0') {
  918. ?>
  919.         <tr>
  920.           <td colspan="2" class="ProductInfoComments" align="left" valign="bottom"><?php echo $options_comment[$i]; ?></td>
  921.         </tr>
  922. <?php
  923.   }
  924. ?>
  925.         <tr>
  926.           <td class="main" align="left" valign="top"><?php echo $options_name[$i] . ':'; ?></td>
  927.           <td class="main" align="left" valign="top" width="75%"><?php echo $options_menu[$i]; ?></td>
  928.         </tr>
  929. <?php if ($options_comment[$i] != '' and $options_comment_position[$i] == '1') { ?>
  930.         <tr>
  931.           <td colspan="2" class="ProductInfoComments" align="left" valign="top"><?php echo $options_comment[$i]; ?></td>
  932.         </tr>
  933. <?php } ?>
  934.  
  935. <?php
  936. if ($options_attributes_image[$i] != '') {
  937. ?>
  938.         <tr><td colspan="2"><table border= "0" align="center" valign="top" cellpadding="2" cellspacing="2"><tr>
  939.           <?php echo $options_attributes_image[$i]; ?>
  940.         </tr></table></td></tr>
  941. <?php
  942. }
  943. ?>
  944. <?php
  945.     }
  946. ?>
  947.       </table>
  948. <?php
  949.   }
  950. ?>
  951.     </td>
  952.   </tr>
  953.             </td>
  954.           </tr>
  955.         </table></td>
  956.       </tr>
  957.  
  958.       <tr>
  959.         <td colspan="2" class="main" align="center" height= "40" valign="middle"><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  960.       </tr>
  961. <?php
  962. } // eof: attributes preview
  963. ?>
  964.  
  965.       <tr>
  966.         <td colspan="3" class="main" height="20" align="center"><?php echo zen_draw_separator('pixel_black.gif', '90%', '2'); ?></td>
  967.       </tr>
  968.  
  969. <?php
  970. if ($action == 'attributes_preview') {
  971.   // don't show anything from here down
  972. } else {
  973.   // show the attributes
  974. ?>
  975. <?php
  976.   if ($action == '') {
  977. ?>
  978.       <tr>
  979.         <td colspan="2"><table>
  980.           <?php require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY); ?>
  981.         </table></td>
  982.       </tr>
  983.  
  984.       <tr><form name="set_products_filter_id" <?php echo 'action="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_products_filter') . '"'; ?> method="post"><?php echo zen_draw_hidden_field('products_filter', $products_filter); ?><?php echo zen_draw_hidden_field('current_category_id', $current_category_id); ?>
  985.         <td colspan="2"><table border="0" cellspacing="0" cellpadding="2">
  986.  
  987. <?php
  988.     if ($_GET['products_filter'] != '') {
  989. ?>
  990.           <tr>
  991.             <td class="main" width="200" align="left" valign="top">&nbsp;</td>
  992.             <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
  993.           </tr>
  994.           <tr>
  995.             <td class="main" width="200" align="center" valign="top">
  996. <?php
  997.   $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
  998.   echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
  999.   echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
  1000.   echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
  1001. ?>
  1002.             </td>
  1003.             <td class="attributes-even" align="center"><?php echo zen_draw_products_pull_down('products_filter', 'size="10"', '', true, $_GET['products_filter'], true, true); ?></td>
  1004.             <td class="main" align="right" valign="top"><?php echo zen_image_submit('button_display.gif', IMAGE_DISPLAY); ?></td>
  1005.           </tr>
  1006.         </table></td>
  1007.       </form></tr>
  1008.  
  1009. <?php
  1010.     } // product dropdown
  1011. ?>
  1012. <?php
  1013.   } // $action == ''
  1014. ?>
  1015. <?php
  1016. // start of attributes display
  1017. if ($_GET['products_filter'] == '') {
  1018. ?>
  1019.       <tr>
  1020.         <td colspan="2" class="pageHeading" align="center" valign="middle" height="200"><?php echo HEADING_TITLE_ATRIB_SELECT; ?></td>
  1021.       </tr>
  1022. <?php
  1023. } else {
  1024. ////
  1025. // attribute listings and add
  1026.  
  1027.   if ($action == 'update_attribute') {
  1028.     $form_action = 'update_product_attribute';
  1029.   } else {
  1030.     $form_action = 'add_product_attributes';
  1031.   }
  1032.  
  1033.   if (!isset($_GET['attribute_page'])) {
  1034.     $_GET['attribute_page'] = 1;
  1035.   }
  1036.   $prev_attribute_page = $_GET['attribute_page'] - 1;
  1037.   $next_attribute_page = $_GET['attribute_page'] + 1;
  1038. ?>
  1039.  
  1040. <?php
  1041. if ($action == '') {
  1042. ?>
  1043. <tr>
  1044.   <td>
  1045.     <table border="2" align="left" cellpadding="2" cellspacing="2">
  1046.       <tr>
  1047.         <td class="smallText" align="right"><?php echo LEGEND_BOX; ?></td>
  1048.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_DISPLAY_ONLY; ?></td>
  1049.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_IS_FREE; ?></td>
  1050.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_DEFAULT; ?></td>
  1051.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTE_IS_DISCOUNTED; ?></td>
  1052.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTE_PRICE_BASE_INCLUDED; ?></td>
  1053.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_REQUIRED; ?></td>
  1054.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_IMAGES ?></td>
  1055.         <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_DOWNLOAD ?></td>
  1056.       </tr>
  1057.       <tr>
  1058.         <td class="smallText" align="right"><?php echo LEGEND_KEYS; ?></td>
  1059.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_yellow_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif'); ?></td>
  1060.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_blue_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_blue_on.gif'); ?></td>
  1061.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_orange_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_orange_on.gif'); ?></td>
  1062.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_pink_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_pink_on.gif'); ?></td>
  1063.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_purple_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_purple_on.gif'); ?></td>
  1064.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_red_off.gif') . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif'); ?></td>
  1065.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif'); ?></td>
  1066.         <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'); ?></td>
  1067.       </tr>
  1068.     </table>
  1069.   </td>
  1070. <?php } ?>
  1071. <?php
  1072. // fix here border width
  1073. ?>
  1074.       <tr>
  1075.         <td><form name="attributes" action="<?php echo zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=' . $form_action . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter ); ?>" method="post", enctype="multipart/form-data"><?php echo zen_draw_hidden_field('securityToken', $_SESSION['securityToken']); ?><table border="0" cellspacing="0" cellpadding="2">
  1076.           <tr>
  1077.             <td colspan="10" class="smallText">
  1078. <?php
  1079.   $per_page = (defined('MAX_ROW_LISTS_ATTRIBUTES_CONTROLLER') && (int)MAX_ROW_LISTS_ATTRIBUTES_CONTROLLER > 3) ? (int)MAX_ROW_LISTS_ATTRIBUTES_CONTROLLER : 40;
  1080.   $attributes = "select pa.*
  1081.  from (" . TABLE_PRODUCTS_ATTRIBUTES . " pa
  1082.  left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
  1083.  on pa.products_id = pd.products_id
  1084.  and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  1085.  left join " . TABLE_PRODUCTS_OPTIONS . " po
  1086.  on pa.options_id = po.products_options_id
  1087.  and po.language_id = '" . (int)$_SESSION['languages_id'] . "'" . ")
  1088.  where pa.products_id ='" . $products_filter . "'
  1089.  order by pd.products_name, LPAD(po.products_options_sort_order,11,'0'), LPAD(pa.options_id,11,'0'), LPAD(pa.products_options_sort_order,11,'0')";
  1090.   $attribute_query = $db->Execute($attributes);
  1091.  
  1092.   $attribute_page_start = ($per_page * $_GET['attribute_page']) - $per_page;
  1093.   $num_rows = $attribute_query->RecordCount();
  1094.  
  1095.   if ($num_rows <= $per_page) {
  1096.      $num_pages = 1;
  1097.   } else if (($num_rows % $per_page) == 0) {
  1098.      $num_pages = ($num_rows / $per_page);
  1099.   } else {
  1100.      $num_pages = ($num_rows / $per_page) + 1;
  1101.   }
  1102.   $num_pages = (int) $num_pages;
  1103.  
  1104. // fix limit error on some versions
  1105.     if ($attribute_page_start < 0) { $attribute_page_start = 0; }
  1106.  
  1107.   $attributes = $attributes . " LIMIT $attribute_page_start, $per_page";
  1108.  
  1109.   // Previous
  1110.   if ($prev_attribute_page) {
  1111.     echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'attribute_page=' . $prev_attribute_page . '&products_filter=' . $products_filter) . '"> &lt;&lt; </a> | ';
  1112.   }
  1113.  
  1114.   for ($i = 1; $i <= $num_pages; $i++) {
  1115.     if ($i != $_GET['attribute_page']) {
  1116.       echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'attribute_page=' . $i  . '&products_filter=' . $products_filter) . '">' . $i . '</a> | ';
  1117.     } else {
  1118.       echo '<b><font color="red">' . $i . '</font></b> | ';
  1119.     }
  1120.   }
  1121.  
  1122.   // Next
  1123.   if ($_GET['attribute_page'] != $num_pages) {
  1124.     echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'attribute_page=' . $next_attribute_page . '&products_filter=' . $products_filter) . '"> &gt;&gt; </a>';
  1125.   }
  1126. ?>
  1127.             </td>
  1128.           </tr>
  1129.           <tr>
  1130.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1131.           </tr>
  1132.           <tr class="dataTableHeadingRow">
  1133.             <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
  1134.             <td class="dataTableHeadingContent">&nbsp;<?php // echo TABLE_HEADING_PRODUCT; ?>&nbsp;</td>
  1135.             <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</td>
  1136.             <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE; ?>&nbsp;</td>
  1137.             <td class="dataTableHeadingContent" align="right">&nbsp;<?php echo TABLE_HEADING_OPT_PRICE_PREFIX; ?>&nbsp;<?php echo TABLE_HEADING_OPT_PRICE; ?>&nbsp;</td>
  1138.             <td class="dataTableHeadingContent" align="right">&nbsp;<?php echo TABLE_HEADING_OPT_WEIGHT_PREFIX; ?>&nbsp;<?php echo TABLE_HEADING_OPT_WEIGHT; ?>&nbsp;</td>
  1139.             <td class="dataTableHeadingContent" align="right">&nbsp;<?php echo TABLE_HEADING_OPT_SORT_ORDER; ?>&nbsp;</td>
  1140.             <td class="dataTableHeadingContent" align="center"><?php echo LEGEND_BOX; ?></td>
  1141.             <td class="dataTableHeadingContent" align="right">&nbsp;<?php echo TABLE_HEADING_PRICE_TOTAL; ?>&nbsp;</td>
  1142.             <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  1143.           </tr>
  1144.           <tr>
  1145.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1146.           </tr>
  1147.  
  1148. <?php
  1149.   $next_id = 1;
  1150.   $attributes_values = $db->Execute($attributes);
  1151.  
  1152.   if ($attributes_values->RecordCount() == 0) {
  1153. ?>
  1154.           <tr class="attributeBoxContent">
  1155.             <td colspan="10" class="dataTableHeadingContent">&nbsp;</td>
  1156.           </tr>
  1157.           <tr class="attributes-even">
  1158.             <td colspan="10" class="pageHeading" align="center">
  1159.               <?php echo ($products_filter == '' ? TEXT_NO_PRODUCTS_SELECTED : TEXT_NO_ATTRIBUTES_DEFINED . $products_filter . ' ' . zen_get_products_model($products_filter) . ' - ' . zen_get_products_name($products_filter)); ?>
  1160.             </td>
  1161.           </tr>
  1162.           <tr class="dataTableHeadingRow">
  1163.             <td colspan="10" class="dataTableHeadingContent">&nbsp;</td>
  1164.           </tr>
  1165.  
  1166. <?php
  1167. } else {
  1168. ?>
  1169.           <tr class="attributeBoxContent">
  1170.             <td colspan="10" class="dataTableHeadingContent">&nbsp;</td>
  1171.           </tr>
  1172.           <tr class="attributes-even">
  1173.             <td colspan="10" class="pageHeading" align="center">
  1174.               <?php echo TEXT_INFO_ID . $products_filter . ' ' . zen_get_products_model($products_filter) . ' - ' . zen_get_products_name($products_filter); ?>
  1175.             </td>
  1176.           </tr>
  1177.           <tr class="attributeBoxContent">
  1178.             <td colspan="10" class="dataTableHeadingContent">&nbsp;</td>
  1179.           </tr>
  1180. <?php } ?>
  1181. <?php
  1182.   $current_options_name = '';
  1183.   while (!$attributes_values->EOF) {
  1184.     $current_attributes_products_id = $attributes_values->fields['products_id'];
  1185.     $current_attributes_options_id = $attributes_values->fields['options_id'];
  1186.  
  1187.     $products_name_only = zen_get_products_name($attributes_values->fields['products_id']);
  1188.     $options_name = zen_options_name($attributes_values->fields['options_id']);
  1189.     $values_name = zen_values_name($attributes_values->fields['options_values_id']);
  1190.     $rows++;
  1191.  
  1192. // delete all option name values
  1193.     if ($current_options_name != $options_name) {
  1194.       $current_options_name = $options_name;
  1195. ?>
  1196.           <tr>
  1197.             <td>
  1198.               <?php
  1199.               if ($action == '') {
  1200.                 echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=delete_option_name_values_confirm&products_options_id_all=' . $current_attributes_options_id . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id ) , '">' .
  1201.                 zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>';
  1202.               }
  1203.               ?>
  1204.               </td>
  1205.             <td class="pageHeading"><?php echo $current_options_name; ?></td>
  1206.           </tr>
  1207. <?php } // option name delete ?>
  1208.           <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
  1209. <?php
  1210.     if (($action == 'update_attribute') && ($_GET['attribute_id'] == $attributes_values->fields['products_attributes_id'])) {
  1211. ?>
  1212.           <tr>
  1213.             <td colspan="10"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  1214.           </tr>
  1215.           <tr>
  1216.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1217.           </tr>
  1218.  
  1219. <tr><td colspan="10" class="attributeBoxContent"><table border="0" width="100%">
  1220.  
  1221. <tr><td class="pageHeading"><?php echo PRODUCTS_ATTRIBUTES_EDITING; ?>
  1222.  
  1223. <?php // fix here edit ?>
  1224. <tr><td class="attributeBoxContent">
  1225. <table border="0" cellpadding="4" cellspacing="2">
  1226.  
  1227. <tr>
  1228.             <td class="smallText" valign="top" width="40">&nbsp;<?php echo $attributes_values->fields['products_attributes_id']; ?><input type="hidden" name="attribute_id" value="<?php echo $attributes_values->fields['products_attributes_id']; ?>">&nbsp;</td>
  1229.             <td class="smallText" valign="top">
  1230.             <td class="pageHeading" valign="top">&nbsp;
  1231.               <input type="hidden" name="products_id" value="<?php echo $products_filter; ?>">
  1232.               <input type="hidden" name="current_category_id" value="<?php echo $current_category_id; ?>">
  1233.               <?php
  1234.                 $show_model = zen_get_products_model($products_filter);
  1235.                 if(!empty($show_model)) {
  1236.                   $show_model = " - (" . $show_model . ")";
  1237.                 }
  1238.                 echo zen_clean_html(zen_get_products_name($products_filter)) . $show_model;
  1239.               ?>
  1240.             </td>
  1241.  
  1242.           </tr></table></td></tr>
  1243.           <tr class="attributeBoxContent"><td><table><tr>
  1244.             <td class="smallText" valign="top" width="40">&nbsp;</td>
  1245.             <td class="pageHeading">&nbsp;
  1246.               <input type="hidden" name="options_id" value="<?php echo $attributes_values->fields['options_id']; ?>">
  1247.               <?php echo zen_get_option_name_language($attributes_values->fields['options_id'], $_SESSION['languages_id']); ?>:
  1248.             </td>
  1249.             <td class="smallText">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE . '<br />'; ?><select name="values_id" size="10">
  1250. <?php
  1251. // FIX HERE 2 - editing
  1252.       $values_values = $db->Execute("select pov.* from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov left join " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " povtpo on pov.products_options_values_id = povtpo.products_options_values_id
  1253.                                     where pov.language_id ='" . $_SESSION['languages_id'] . "'
  1254.                                     and povtpo.products_options_id='" . $attributes_values->fields['options_id'] . "'
  1255.                                     order by pov.products_options_values_name");
  1256.  
  1257.       while(!$values_values->EOF) {
  1258.         // BOM by zen-cart.cn
  1259.         if ($show_value_numbers == false) {
  1260.           $show_option_name= '&nbsp;&nbsp;&nbsp;[' . GBcase(zen_get_products_options_name_from_value($values_values->fields['products_options_values_id']),"upper") . ' ]';
  1261.         } else {
  1262.           $show_option_name= ' [ #' . $values_values->fields['products_options_values_id'] . ' ] ' . '&nbsp;&nbsp;&nbsp;[' . GBcase(zen_get_products_options_name_from_value($values_values->fields['products_options_values_id']),"upper") . ' ]';
  1263.         }
  1264.         // EOM by zen-cart.cn
  1265.         if ($attributes_values->fields['options_values_id'] == $values_values->fields['products_options_values_id']) {
  1266.           echo "\n" . '<option name="' . $values_values->fields['products_options_values_name'] . '" value="' . $values_values->fields['products_options_values_id'] . '" SELECTED>' . $values_values->fields['products_options_values_name'] . $show_option_name . '</option>';
  1267.         } else {
  1268.           echo "\n" . '<option name="' . $values_values->fields['products_options_values_name'] . '" value="' . $values_values->fields['products_options_values_id'] . '">' . $values_values->fields['products_options_values_name'] . $show_option_name . '</option>';
  1269.         }
  1270.         $values_values->MoveNext();
  1271.       }
  1272. ?>
  1273. <?php
  1274. // set radio values attributes_display_only
  1275.     switch ($attributes_values->fields['attributes_display_only']) {
  1276.       case '0': $on_attributes_display_only = false; $off_attributes_display_only = true; break;
  1277.       case '1': $on_attributes_display_only = true; $off_attributes_display_only = false; break;
  1278.       default: $on_attributes_display_only = false; $off_attributes_display_only = true;
  1279.     }
  1280. // set radio values attributes_default
  1281.     switch ($attributes_values->fields['product_attribute_is_free']) {
  1282.       case '0': $on_product_attribute_is_free = false; $off_product_attribute_is_free = true; break;
  1283.       case '1': $on_product_attribute_is_free = true; $off_product_attribute_is_free = false; break;
  1284.       default: $on_product_attribute_is_free = false; $off_product_attribute_is_free = true;
  1285.     }
  1286. // set radio values attributes_default
  1287.     switch ($attributes_values->fields['attributes_default']) {
  1288.       case '0': $on_attributes_default = false; $off_attributes_default = true; break;
  1289.       case '1': $on_attributes_default = true; $off_attributes_default = false; break;
  1290.       default: $on_attributes_default = false; $off_attributes_default = true;
  1291.     }
  1292. // set radio values attributes_discounted
  1293.     switch ($attributes_values->fields['attributes_discounted']) {
  1294.       case '0': $on_attributes_discounted = false; $off_attributes_discounted = true; break;
  1295.       case '1': $on_attributes_discounted = true; $off_attributes_discounted = false; break;
  1296.       default: $on_attributes_discounted = false; $off_attributes_discounted = true;
  1297.     }
  1298. // set radio values attributes_price_base_included
  1299.     switch ($attributes_values->fields['attributes_price_base_included']) {
  1300.       case '0': $on_attributes_price_base_included = false; $off_attributes_price_base_included = true; break;
  1301.       case '1': $on_attributes_price_base_included = true; $off_attributes_price_base_included = false; break;
  1302.       default: $on_attributes_price_base_included = false; $off_attributes_price_base_included = true;
  1303.     }
  1304. // set radio values attributes_required
  1305.     switch ($attributes_values->fields['attributes_required']) {
  1306.       case '0': $on_attributes_required = false; $off_attributes_required = true; break;
  1307.       case '1': $on_attributes_required = true; $off_attributes_required = false; break;
  1308.       default: $on_attributes_required = false; $off_attributes_required = true;
  1309.     }
  1310. // set image overwrite
  1311.   $on_overwrite = true;
  1312.   $off_overwrite = false;
  1313. // set image delete
  1314.   $on_image_delete = false;
  1315.   $off_image_delete = true;
  1316.  
  1317. ?>
  1318.             </select>&nbsp;</td>
  1319.  
  1320. </table></td></tr>
  1321.  
  1322. <!-- bof: Edit Prices -->
  1323. <tr>
  1324.   <td class="attributeBoxContent">
  1325.     <table border="1" cellpadding="4" cellspacing="2" align="left" width="100%">
  1326.       <tr>
  1327.         <td align="right" class="pageHeading"><?php echo TEXT_SAVE_CHANGES . '&nbsp;&nbsp;' . zen_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id ) . '">'; ?><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</td>
  1328.       </tr>
  1329.     </table>
  1330.   </td>
  1331. </tr>
  1332.  
  1333. <tr><td>
  1334.   <table border="0">
  1335.     <tr>
  1336.       <td colspan="3" class="pageHeading"><?php echo TEXT_PRICES_AND_WEIGHTS; ?></td>
  1337.     </tr>
  1338.     <tr>
  1339.       <td class="attributeBoxContent">
  1340.         <table border="1" cellpadding="4" cellspacing="2" align="left">
  1341.           <tr>
  1342.             <td align="center" class="smallText">&nbsp;<?php echo TABLE_HEADING_OPT_PRICE; ?><br /><input type="text" name="price_prefix" value="<?php echo $attributes_values->fields['price_prefix']; ?>" size="2">&nbsp;<input type="text" name="value_price" value="<?php echo $attributes_values->fields['options_values_price']; ?>" size="6">&nbsp;</td>
  1343.             <td align="center" class="smallText">&nbsp;<?php echo TABLE_HEADING_OPT_WEIGHT; ?><br /><input type="text" name="products_attributes_weight_prefix" value="<?php echo $attributes_values->fields['products_attributes_weight_prefix']; ?>" size="2">&nbsp;<input type="text" name="products_attributes_weight" value="<?php echo $attributes_values->fields['products_attributes_weight']; ?>" size="6">&nbsp;</td>
  1344.             <td align="center" class="smallText">&nbsp;<?php echo TABLE_HEADING_OPT_SORT_ORDER; ?><br /><input type="text" name="products_options_sort_order" value="<?php echo $attributes_values->fields['products_options_sort_order']; ?>" size="4">&nbsp;</td>
  1345.             <td align="center" class="smallText">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_ONETIME; ?><br />&nbsp;<input type="text" name="attributes_price_onetime" value="<?php echo $attributes_values->fields['attributes_price_onetime']; ?>" size="6">&nbsp;</td>
  1346.           </tr>
  1347.         </table>
  1348.       </td>
  1349.  
  1350. <?php if (ATTRIBUTES_ENABLED_PRICE_FACTOR == 'true') { ?>
  1351.       <td class="attributeBoxContent">
  1352.         <table border="1" cellpadding="4" cellspacing="2" align="left">
  1353.           <tr>
  1354.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR . ' ' . TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_OFFSET; ?><br />&nbsp;<input type="text" name="attributes_price_factor" value="<?php echo $attributes_values->fields['attributes_price_factor']; ?>" size="6">&nbsp;&nbsp;<input type="text" name="attributes_price_factor_offset" value="<?php echo $attributes_values->fields['attributes_price_factor_offset']; ?>" size="6">&nbsp;</td>
  1355.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_ONETIME . ' ' . TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_OFFSET_ONETIME; ?><br />&nbsp;<input type="text" name="attributes_price_factor_onetime" value="<?php echo $attributes_values->fields['attributes_price_factor_onetime']; ?>" size="6">&nbsp;&nbsp;<input type="text" name="attributes_price_factor_onetime_offset" value="<?php echo $attributes_values->fields['attributes_price_factor_onetime_offset']; ?>" size="6">&nbsp;</td>
  1356.           </tr>
  1357.         </table>
  1358.       </td>
  1359. <?php
  1360.     } else {
  1361.       echo zen_draw_hidden_field('attributes_price_factor', $attributes_values->fields['attributes_price_factor']);
  1362.       echo zen_draw_hidden_field('attributes_price_factor_offset', $attributes_values->fields['attributes_price_factor_offset']);
  1363.       echo zen_draw_hidden_field('attributes_price_factor_onetime', $attributes_values->fields['attributes_price_factor_onetime']);
  1364.       echo zen_draw_hidden_field('attributes_price_factor_onetime_offset', $attributes_values->fields['attributes_price_factor_onetime_offset']);
  1365.     } // ATTRIBUTES_ENABLED_PRICE_FACTOR
  1366. ?>
  1367.  
  1368.     </tr>
  1369.   </table>
  1370. </td></tr>
  1371.  
  1372. <?php if (ATTRIBUTES_ENABLED_QTY_PRICES == 'true') { ?>
  1373.     <tr>
  1374.       <td class="attributeBoxContent">
  1375.         <table border="1" cellpadding="4" cellspacing="2" align="left">
  1376.           <tr>
  1377.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_QTY_PRICES; ?><br />&nbsp;<input type="text" name="attributes_qty_prices" value="<?php echo $attributes_values->fields['attributes_qty_prices']; ?>" size="60">&nbsp;</td>
  1378.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_QTY_PRICES_ONETIME; ?><br />&nbsp;<input type="text" name="attributes_qty_prices_onetime" value="<?php echo $attributes_values->fields['attributes_qty_prices_onetime']; ?>" size="60">&nbsp;</td>
  1379.           </tr>
  1380.         </table>
  1381.       </td>
  1382.     </tr>
  1383. <?php
  1384.     } else {
  1385.       echo zen_draw_hidden_field('attributes_qty_prices', $attributes_values->fields['attributes_qty_prices']);
  1386.       echo zen_draw_hidden_field('attributes_qty_prices_onetime', $attributes_values->fields['attributes_qty_prices_onetime']);
  1387.     } // ATTRIBUTES_ENABLED_QTY_PRICES
  1388. ?>
  1389.  
  1390. <?php if (ATTRIBUTES_ENABLED_TEXT_PRICES == 'true') { ?>
  1391.     <tr>
  1392.       <td class="attributeBoxContent">
  1393.         <table border="1" cellpadding="4" cellspacing="2" align="left">
  1394.           <tr>
  1395.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_WORDS . ' ' . TABLE_HEADING_ATTRIBUTES_PRICE_WORDS_FREE; ?><br />&nbsp;<input type="text" name="attributes_price_words" value="<?php echo $attributes_values->fields['attributes_price_words']; ?>" size="6">&nbsp;&nbsp;<input type="text" name="attributes_price_words_free" value="<?php echo $attributes_values->fields['attributes_price_words_free']; ?>" size="6">&nbsp;</td>
  1396.             <td align="center" class="smallText" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS . ' ' . TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS_FREE; ?><br />&nbsp;<input type="text" name="attributes_price_letters" value="<?php echo $attributes_values->fields['attributes_price_letters']; ?>" size="6">&nbsp;&nbsp;<input type="text" name="attributes_price_letters_free" value="<?php echo $attributes_values->fields['attributes_price_letters_free']; ?>" size="6">&nbsp;</td>
  1397.           </tr>
  1398.         </table>
  1399.       </td>
  1400.     </tr>
  1401. <?php
  1402.     } else {
  1403.       echo zen_draw_hidden_field('attributes_price_words', $attributes_values->fields['attributes_price_words']);
  1404.       echo zen_draw_hidden_field('attributes_price_words_free', $attributes_values->fields['attributes_price_words_free']);
  1405.       echo zen_draw_hidden_field('attributes_price_letters', $attributes_values->fields['attributes_price_letters']);
  1406.       echo zen_draw_hidden_field('attributes_price_letters_free', $attributes_values->fields['attributes_price_letters_free']);
  1407.     } // ATTRIBUTES_ENABLED_TEXT_PRICES
  1408. ?>
  1409.  
  1410. <!-- eof: Edit Prices -->
  1411.  
  1412. <tr><td class="attributeBoxContent">
  1413. <table border="1" cellpadding="4" cellspacing="2">
  1414.  
  1415.               <tr >
  1416.                 <td class="attributeBoxContent" align="center" width="50"><?php echo TEXT_ATTRIBUTES_FLAGS; ?></td>
  1417.                 <td class="smallText" align="center" width="150" bgcolor="#ffff00"><strong><?php echo TEXT_ATTRIBUTES_DISPLAY_ONLY . '</strong><br>' . zen_draw_radio_field('attributes_display_only', '0', $off_attributes_display_only) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_display_only', '1', $on_attributes_display_only) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1418.                 <td class="smallText" align="center" width="150" bgcolor="#2C54F5"><strong><?php echo TEXT_ATTRIBUTES_IS_FREE . '</strong><br>' . zen_draw_radio_field('product_attribute_is_free', '0', $off_product_attribute_is_free) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('product_attribute_is_free', '1', $on_product_attribute_is_free) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1419.                 <td class="smallText" align="center" width="150" bgcolor="#ffa346"><strong><?php echo TEXT_ATTRIBUTES_DEFAULT . '</strong><br>' . zen_draw_radio_field('attributes_default', '0', $off_attributes_default) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_default', '1', $on_attributes_default) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1420.                 <td class="smallText" align="center" width="150" bgcolor="#ff00ff"><strong><?php echo TEXT_ATTRIBUTE_IS_DISCOUNTED . '</strong><br>' . zen_draw_radio_field('attributes_discounted', '0', $off_attributes_discounted) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_discounted', '1', $on_attributes_discounted) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1421.                 <td class="smallText" align="center" width="150" bgcolor="#d200f0"><strong><?php echo TEXT_ATTRIBUTE_PRICE_BASE_INCLUDED . '</strong><br>' . zen_draw_radio_field('attributes_price_base_included', '0', $off_attributes_price_base_included) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_price_base_included', '1', $on_attributes_price_base_included) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1422.                 <td align="center" class="smallText" width="150" bgcolor="#FF0606"><strong><?php echo TEXT_ATTRIBUTES_REQUIRED . '</strong><br>' . zen_draw_radio_field('attributes_required', '0', $off_attributes_required) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_required', '1', $on_attributes_required) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1423.               </tr>
  1424.  
  1425. </table></td></tr>
  1426.  
  1427. <?php if (ATTRIBUTES_ENABLED_IMAGES == 'true') { ?>
  1428.  
  1429. <?php
  1430. // edit
  1431. // attributes images
  1432.   $dir = @dir(DIR_FS_CATALOG_IMAGES);
  1433.   $dir_info[] = array('id' => '', 'text' => "Main Directory");
  1434.   while ($file = $dir->read()) {
  1435.     if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
  1436.       $dir_info[] = array('id' => $file . '/', 'text' => $file);
  1437.     }
  1438.   }
  1439.   $dir->close();
  1440.  
  1441.   sort($dir_info);
  1442.  
  1443.   if ($attributes_values->fields['attributes_image'] != '') {
  1444.     $default_directory = substr( $attributes_values->fields['attributes_image'], 0,strpos( $attributes_values->fields['attributes_image'], '/')+1);
  1445.   } else {
  1446.     $default_directory = 'attributes/';
  1447.   }
  1448. ?>
  1449. <tr><td class="attributeBoxContent">
  1450. <table border="0" cellpadding="4" cellspacing="2">
  1451.  
  1452.           <tr class="attributeBoxContent">
  1453.             <td>&nbsp;</td>
  1454.             <td colspan="5">
  1455.               <table>
  1456.                 <tr class="attributeBoxContent">
  1457.                   <td class="main" valign="top">&nbsp;</td>
  1458.                   <td class="main" valign="top"><?php echo TEXT_ATTRIBUTES_IMAGE . '<br />' . zen_draw_file_field('attributes_image') . '<br />' . zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $attributes_values->fields['attributes_image']  . zen_draw_hidden_field('attributes_previous_image', $attributes_values->fields['attributes_image']); ?></td>
  1459.                   <td class="main" valign="top"><?php echo TEXT_ATTRIBUTES_IMAGE_DIR . '<br />' . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory); ?></td>
  1460.                   <td class="main" valign="middle"><?php echo ($attributes_values->fields['attributes_image'] != '' ? zen_image(DIR_WS_CATALOG_IMAGES . $attributes_values->fields['attributes_image']) : ''); ?></td>
  1461.                   <td class="main" valign="top"><?php echo TEXT_IMAGES_OVERWRITE . '<br />' . zen_draw_radio_field('overwrite', '0', $off_overwrite) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('overwrite', '1', $on_overwrite) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1462.                   <td class="main" valign="top"><?php echo TEXT_IMAGES_DELETE . '<br />' . zen_draw_radio_field('image_delete', '0', $off_image_delete) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('image_delete', '1', $on_image_delete) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1463.                 </tr>
  1464.               </table>
  1465.             </td>
  1466.             <td>&nbsp;</td>
  1467.           </tr>
  1468.  
  1469. </table></td></tr>
  1470. <?php
  1471.     } else {
  1472.       echo zen_draw_hidden_field('attributes_previous_image', $attributes_values->fields['attributes_image']);
  1473.       echo zen_draw_hidden_field('attributes_image', $attributes_values->fields['attributes_image']);
  1474.     } // ATTRIBUTES_ENABLED_IMAGES
  1475. ?>
  1476.  
  1477. <?php
  1478.       if (DOWNLOAD_ENABLED == 'true') {
  1479.         $download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount
  1480.                              from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
  1481.                              where products_attributes_id='" . $attributes_values->fields['products_attributes_id'] . "'";
  1482.         $download = $db->Execute($download_query_raw);
  1483.         if ($download->RecordCount() > 0) {
  1484.           $products_attributes_filename = $download->fields['products_attributes_filename'];
  1485.           $products_attributes_maxdays  = $download->fields['products_attributes_maxdays'];
  1486.           $products_attributes_maxcount = $download->fields['products_attributes_maxcount'];
  1487.         }
  1488. ?>
  1489. <tr><td class="attributeBoxContent">
  1490. <table border="0" cellpadding="4" cellspacing="2">
  1491.           <tr class="attributeBoxContent">
  1492.             <td colspan="5">
  1493.                 <tr class="attributeBoxContent">
  1494.                   <td class="attributeBoxContent" valign="top"><?php echo TABLE_HEADING_DOWNLOAD; ?>&nbsp;</td>
  1495.                   <td class="attributeBoxContent"><?php echo TABLE_TEXT_FILENAME . '<br />' . zen_draw_input_field('products_attributes_filename', $products_attributes_filename, zen_set_field_length(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, 'products_attributes_filename', 35)); ?>&nbsp;</td>
  1496.                   <td class="attributeBoxContent"><?php echo TABLE_TEXT_MAX_DAYS . '<br />' . zen_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?>&nbsp;</td>
  1497.                   <td class="attributeBoxContent"><?php echo TABLE_TEXT_MAX_COUNT . '<br />' . zen_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?>&nbsp;</td>
  1498.                 </tr>
  1499.  
  1500. </table></td></tr>
  1501. </td></tr>
  1502.  
  1503. <?php
  1504.       }
  1505. ?>
  1506.  
  1507. </td></tr>
  1508. </table></td></tr>
  1509.  
  1510.           <tr>
  1511.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1512.           </tr>
  1513.           <tr>
  1514.             <td colspan="10"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  1515.           </tr>
  1516.  
  1517. <?php
  1518.     } elseif (($action == 'delete_product_attribute') && ($_GET['attribute_id'] == $attributes_values->fields['products_attributes_id'])) {
  1519. ?>
  1520.           <tr>
  1521.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1522.           </tr>
  1523.           <tr class="attributeBoxContent">
  1524.             <td align="left" colspan="6" class="pageHeading"><?php echo PRODUCTS_ATTRIBUTES_DELETE; ?></td><td colspan="3" align="center" class="pageHeading"><?php echo PRODUCTS_ATTRIBUTES_DELETE; ?></td>
  1525.             <td colspan="3" align="center" class="attributeBoxContent">&nbsp;</td>
  1526.           </tr>
  1527.           <tr>
  1528.             <td class="attributeBoxContent">&nbsp;<b><?php echo $attributes_values->fields["products_attributes_id"]; ?></b>&nbsp;</td>
  1529.             <td class="attributeBoxContent">&nbsp;<b><?php echo $products_name_only; ?></b>&nbsp;</td>
  1530.             <td class="attributeBoxContent">&nbsp;<b><?php echo $options_name; ?></b>&nbsp;</td>
  1531.             <td class="attributeBoxContent">&nbsp;<b><?php echo $values_name; ?></b>&nbsp;</td>
  1532.             <td align="right" class="attributeBoxContent">&nbsp;<b><?php echo $attributes_values->fields["options_values_price"]; ?></b>&nbsp;</td>
  1533.             <td align="center" class="attributeBoxContent">&nbsp;<b><?php echo $attributes_values->fields["price_prefix"]; ?></b>&nbsp;</td>
  1534.             <td colspan="3" align="center" class="attributeBoxContent">&nbsp;<b><?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=delete_attribute&attribute_id=' . $_GET['attribute_id'] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">'; ?><?php echo zen_image_button('button_confirm.gif', IMAGE_CONFIRM); ?></a>&nbsp;&nbsp;<?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id ) . '">'; ?><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</b></td>
  1535.             <td colspan="3" align="center" class="attributeBoxContent">&nbsp;</td>
  1536.           </tr>
  1537.           <tr class="attributeBoxContent">
  1538.             <td colspan="10" class="attributeBoxContent">&nbsp;</td>
  1539.           </tr>
  1540.           <tr>
  1541.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1542.           </tr>
  1543.           <tr>
  1544. <?php
  1545.     } else {
  1546. // attributes display listing
  1547.  
  1548. // calculate current total attribute price
  1549. // $attributes_values
  1550. $attributes_price_final = zen_get_attributes_price_final($attributes_values->fields["products_attributes_id"], 1, $attributes_values, 'false');
  1551. $attributes_price_final_value = $attributes_price_final;
  1552. $attributes_price_final = $currencies->display_price($attributes_price_final, zen_get_tax_rate(1), 1);
  1553. $attributes_price_final_onetime = zen_get_attributes_price_final_onetime($attributes_values->fields["products_attributes_id"], 1, $attributes_values);
  1554. $attributes_price_final_onetime = $currencies->display_price($attributes_price_final_onetime, zen_get_tax_rate(1), 1);
  1555. ?>
  1556.             <td class="smallText">&nbsp;<?php echo $attributes_values->fields["products_attributes_id"]; ?>&nbsp;</td>
  1557.             <td class="smallText">&nbsp;<?php // echo $products_name_only; ?>&nbsp;</td>
  1558.             <td class="smallText">&nbsp;<?php echo $options_name; ?>&nbsp;</td>
  1559.             <td class="smallText">&nbsp;<?php echo ($attributes_values->fields['attributes_image'] != '' ? zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif') . '&nbsp;' : '&nbsp;&nbsp;') . $values_name; ?>&nbsp;</td>
  1560.             <td align="right" class="smallText">&nbsp;<?php echo $attributes_values->fields["price_prefix"]; ?>&nbsp;<?php echo $attributes_values->fields["options_values_price"]; ?>&nbsp;</td>
  1561.             <td align="right" class="smallText">&nbsp;<?php echo $attributes_values->fields["products_attributes_weight_prefix"]; ?>&nbsp;<?php echo $attributes_values->fields["products_attributes_weight"]; ?>&nbsp;</td>
  1562.             <td align="right" class="smallText">&nbsp;<?php echo $attributes_values->fields["products_options_sort_order"]; ?>&nbsp;</td>
  1563. <?php
  1564. // '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_display_only' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter) . '">' .
  1565. // $marker = '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter) . '">';
  1566. if ($action == '') {
  1567. ?>
  1568. <td>
  1569.   <table border="0" align="center" cellpadding="2" cellspacing="2">
  1570.       <tr>
  1571.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["attributes_display_only"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_display_only' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_off.gif', LEGEND_ATTRIBUTES_DISPLAY_ONLY) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_display_only' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', LEGEND_ATTRIBUTES_DISPLAY_ONLY)) . '</a>'; ?></td>
  1572.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["product_attribute_is_free"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_product_attribute_is_free' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_blue_off.gif', LEGEND_ATTRIBUTES_IS_FREE) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_product_attribute_is_free' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_blue_on.gif', LEGEND_ATTRIBUTES_IS_FREE)) . '</a>'; ?></td>
  1573.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["attributes_default"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_default' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_orange_off.gif', LEGEND_ATTRIBUTES_DEFAULT) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_default' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_orange_on.gif', LEGEND_ATTRIBUTES_DEFAULT)) . '</a>' ?></td>
  1574.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["attributes_discounted"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_discounted' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_pink_off.gif', LEGEND_ATTRIBUTE_IS_DISCOUNTED) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_discounted' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_pink_on.gif', LEGEND_ATTRIBUTE_IS_DISCOUNTED)) . '</a>'; ?></td>
  1575.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["attributes_price_base_included"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_price_base_included' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_purple_off.gif', LEGEND_ATTRIBUTE_PRICE_BASE_INCLUDED) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_price_base_included' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_purple_on.gif', LEGEND_ATTRIBUTE_PRICE_BASE_INCLUDED)) . '</a>'; ?></td>
  1576.         <td class="smallText" align="center"><?php echo ($attributes_values->fields["attributes_required"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_required' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_off.gif', LEGEND_ATTRIBUTES_REQUIRED) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_required' . '&attributes_id=' . $attributes_values->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', LEGEND_ATTRIBUTES_REQUIRED)) . '</a>'; ?></td>
  1577.       </tr>
  1578.     </table>
  1579. </td>
  1580. <?php } ?>
  1581. <?php
  1582.   $new_attributes_price= '';
  1583.   if ($attributes_values->fields["attributes_discounted"]) {
  1584.     $new_attributes_price = zen_get_attributes_price_final($attributes_values->fields["products_attributes_id"], 1, '', 'false');
  1585.     $new_attributes_price = zen_get_discount_calc($products_filter, true, $new_attributes_price);
  1586.     if ($new_attributes_price != $attributes_price_final_value) {
  1587.       $new_attributes_price = '|' . $currencies->display_price($new_attributes_price, zen_get_tax_rate(1), 1);
  1588.     } else {
  1589.       $new_attributes_price = '';
  1590.     }
  1591.   }
  1592. ?>
  1593.             <td align="right" class="smallText"><?php echo $attributes_price_final . $new_attributes_price . ' ' . $attributes_price_final_onetime; ?></td>
  1594. <?php
  1595.   if ($action != '') {
  1596. ?>
  1597.             <td width='120' align="center" class="smallText">&nbsp;</td>
  1598. <?php
  1599.   } else {
  1600. ?>
  1601.             <td align="center" class="smallText">&nbsp;<?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=update_attribute&attribute_id=' . $attributes_values->fields['products_attributes_id'] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id ) . '">'; ?><?php echo zen_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>&nbsp;&nbsp;<?php echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=delete_product_attribute&attribute_id=' . $attributes_values->fields['products_attributes_id'] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id ) , '">'; ?><?php echo zen_image_button('button_delete.gif', IMAGE_DELETE); ?></a>&nbsp;</td>
  1602. <?php
  1603.   }
  1604. ?>
  1605. <?php
  1606. // bof: show filename if it exists
  1607.       if (DOWNLOAD_ENABLED == 'true') {
  1608.         $download_display_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount
  1609.                              from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
  1610.                              where products_attributes_id='" . $attributes_values->fields['products_attributes_id'] . "'";
  1611.         $download_display = $db->Execute($download_display_query_raw);
  1612.         if ($download_display->RecordCount() > 0) {
  1613.  
  1614. // Moved to /admin/includes/configure.php
  1615.   if (!defined('DIR_FS_DOWNLOAD')) define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
  1616.  
  1617.   $filename_is_missing='';
  1618.   if ( !file_exists(DIR_FS_DOWNLOAD . $download_display->fields['products_attributes_filename']) ) {
  1619.     $filename_is_missing = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif');
  1620.   } else {
  1621.     $filename_is_missing = zen_image(DIR_WS_IMAGES . 'icon_status_green.gif');
  1622.   }
  1623. ?>
  1624.           </tr>
  1625.  
  1626.           <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
  1627.             <td colspan="3" class="smallText">&nbsp;</td>
  1628.             <td colspan="4"><table>
  1629.               <tr>
  1630.                 <td class="smallText"><?php echo $filename_is_missing . '&nbsp;' . TABLE_TEXT_FILENAME; ?></td>
  1631.                 <td class="smallText">&nbsp;&nbsp;<?php echo $download_display->fields['products_attributes_filename']; ?>&nbsp;</td>
  1632.                 <td class="smallText">&nbsp;&nbsp;<?php echo TABLE_TEXT_MAX_DAYS_SHORT; ?></td>
  1633.                 <td class="smallText">&nbsp;&nbsp;<?php echo $download_display->fields['products_attributes_maxdays']; ?>&nbsp;</td>
  1634.                 <td class="smallText">&nbsp;&nbsp;<?php echo TABLE_TEXT_MAX_COUNT_SHORT; ?></td>
  1635.                 <td class="smallText">&nbsp;&nbsp;<?php echo $download_display->fields['products_attributes_maxcount']; ?>&nbsp;</td>
  1636.               </tr>
  1637.             </table></td>
  1638.  
  1639.  
  1640. <?php
  1641.         } // show downloads
  1642.       }
  1643. // eof: show filename if it exists
  1644. ?>
  1645. <?php
  1646.     }
  1647.     $max_attributes_id_values = $db->Execute("select max(products_attributes_id) + 1
  1648.                                              as next_id from " . TABLE_PRODUCTS_ATTRIBUTES);
  1649.  
  1650.     $next_id = $max_attributes_id_values->fields['next_id'];
  1651.  
  1652. //////////////////////////////////////////////////////////////
  1653. // BOF: Add dividers between Product Names and between Option Names
  1654.     $attributes_values->MoveNext();
  1655.     if (!$attributes_values->EOF) {
  1656.       if ($current_attributes_products_id != $attributes_values->fields['products_id']) {
  1657. ?>
  1658.           <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
  1659.             <td colspan="10"><table width="100%"><td>
  1660.               <tr>
  1661.                 <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td>
  1662.               </tr>
  1663.             </table></td></tr>
  1664. <?php
  1665.   } else {
  1666.     if ($current_attributes_options_id != $attributes_values->fields['options_id']) {
  1667. ?>
  1668.           <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
  1669.             <td colspan="10"><table width="100%"><td>
  1670.               <tr>
  1671.                 <td><?php echo zen_draw_separator('pixel_black.gif', '100%', '1'); ?></td>
  1672.               </tr>
  1673.             </table></td></tr>
  1674. <?php
  1675.     }
  1676.   }
  1677. }
  1678. // EOF: Add dividers between Product Names and between Option Names
  1679. //////////////////////////////////////////////////////////////
  1680. ?>
  1681.           </tr>
  1682.  
  1683. <?php
  1684.   }
  1685.   if (($action != 'update_attribute' and $action != 'delete_product_attribute')) {
  1686. ?>
  1687.           <tr>
  1688.             <td colspan="10"><?php echo zen_black_line(); ?></td>
  1689.           </tr>
  1690.  
  1691. <!-- bof_adding -->
  1692. <tr class="attributeBoxContent"><td colspan="10"><table border="0" width="100%">
  1693.  
  1694.   <tr class="attributeBoxContent">
  1695.     <td class="pageHeading">
  1696.       <table border="0" width="100%">
  1697.         <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2" width="100%">
  1698.  
  1699.           <tr class="attributeBoxContent">
  1700.             <td class="pageHeading">&nbsp;<?php echo PRODUCTS_ATTRIBUTES_ADDING; ?></td>
  1701.             <td class="main"><?php echo TEXT_ATTRIBUTES_INSERT_INFO; ?></td>
  1702.               <td align="center" class="attributeBoxContent" height="30" valign="bottom">&nbsp;
  1703.               <?php
  1704.                 if ($action == '') {
  1705.                   echo zen_image_submit('button_insert.gif', IMAGE_INSERT);
  1706.                 } else {
  1707.                   // hide button
  1708.                 }
  1709.               ?>
  1710.             &nbsp;
  1711.               </td>
  1712.  
  1713.           </tr>
  1714.  
  1715.         </table></td></tr>
  1716.       </table>
  1717.     </td>
  1718.   </tr>
  1719.  
  1720. <!-- bof Option Names and Values -->
  1721.   <tr class="attributeBoxContent">
  1722.     <td class="pageHeading">
  1723.       <table border='0' width="100%">
  1724.         <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1725.           <tr class="attributeBoxContent"><td><table><tr>
  1726.             <td class="attributeBoxContent" width="40">&nbsp;<?php echo $next_id; ?>&nbsp;</td>
  1727.             <td class="pageHeading" valign="top">&nbsp;
  1728.               <input type="hidden" name="products_id" value="<?php echo $products_filter; ?>">
  1729.               <input type="hidden" name="current_category_id" value="<?php echo $current_category_id; ?>">
  1730.               <?php
  1731.                   $show_model = zen_get_products_model($products_filter);
  1732.                   if(!empty($show_model)) {
  1733.                     $show_model = " - (" . $show_model . ")";
  1734.                   }
  1735.                 echo zen_clean_html(zen_get_products_name($products_filter)) . $show_model;
  1736.               ?>
  1737.             </td>
  1738.           </tr></table></td></tr>
  1739.           <tr class="attributeBoxContent"><td><table><tr>
  1740.             <td class="attributeBoxContent" width="40">&nbsp;</td>
  1741.             <td class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME . '<br />'; ?>
  1742.               <select name="options_id" id="OptionName" onChange="update_option(this.form)" size="<?php echo ($action != 'delete_attribute' ? "15" : "1"); ?>">
  1743. <?php
  1744.     $options_values = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS . "
  1745.                                    where language_id = '" . $_SESSION['languages_id'] . "'
  1746.                                    order by products_options_name");
  1747.  
  1748.     while (!$options_values->EOF) {
  1749.       echo '              <option name="' . $options_values->fields['products_options_name'] . '" value="' . $options_values->fields['products_options_id'] . '">' . $options_values->fields['products_options_name'] . '&nbsp;&nbsp;&nbsp;[' . translate_type_to_name($options_values->fields['products_options_type']) . ']' . ($show_name_numbers ? ' &nbsp; [ #' . $options_values->fields['products_options_id'] . ' ] ' : '' ) . '</option>' . "\n";
  1750.       $options_values->MoveNext();
  1751.     }
  1752. ?>
  1753.             </select>&nbsp;</td>
  1754.             <td class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE . '<br />'; ?>
  1755.             <select name="values_id[]" id="OptionValue" multiple="multiple" size="<?php echo ($action != 'delete_attribute' ? "15" : "1"); ?>">
  1756.   <option selected>&lt;-- Please select an Option Name from the list ... </option>
  1757. </select>&nbsp;</td>
  1758.  
  1759. <script language="javascript" type="text/javascript"><!--
  1760.   function update_option(theForm) {
  1761.     // if nothing to do, abort
  1762.     if (!theForm || !theForm.elements["options_id"] || !theForm.elements["values_id[]"]) return;
  1763.     if (!theForm.options_id.options[theForm.options_id.selectedIndex]) return;
  1764.  
  1765.     // enable hourglass
  1766.     document.body.style.cursor = "wait";
  1767.  
  1768.     // set initial values
  1769.     var SelectedOption = theForm.options_id.options[theForm.options_id.selectedIndex].value;
  1770.     var theField = document.getElementById("OptionValue");
  1771.  
  1772.     // reset the array of pulldown options so it can be repopulated
  1773.     var Opts = theField.options.length;
  1774.     while(Opts > 0) {
  1775.       Opts = Opts - 1;
  1776.       theField.options[Opts] = null;
  1777.     }
  1778.  
  1779. <?php  echo zen_js_option_values_list('SelectedOption', 'theField'); ?>
  1780.  
  1781.     // turn off hourglass
  1782.     document.body.style.cursor = "default";
  1783.   }
  1784. -->
  1785. </script>
  1786. <?php
  1787.  
  1788. $chk_defaults = $db->Execute("select products_type from " . TABLE_PRODUCTS . " where products_id=" . $products_filter);
  1789. // set defaults for adding attributes
  1790.  
  1791. $on_product_attribute_is_free = (zen_get_show_product_switch($products_filter, 'ATTRIBUTE_IS_FREE', 'DEFAULT_', '') == 1 ? true : false);
  1792. $off_product_attribute_is_free = ($on_product_attribute_is_free == 1 ? false : true);
  1793. $on_attributes_display_only = (zen_get_show_product_switch($products_filter, 'ATTRIBUTES_DISPLAY_ONLY', 'DEFAULT_', '') == 1 ? true : false);
  1794. $off_attributes_display_only = ($on_attributes_display_only == 1 ? false : true);
  1795. $on_attributes_default = (zen_get_show_product_switch($products_filter, 'ATTRIBUTES_DEFAULT', 'DEFAULT_', '') == 1 ? true : false);
  1796. $off_attributes_default = ($on_attributes_default == 1 ? false : true);
  1797. $on_attributes_discounted = (zen_get_show_product_switch($products_filter, 'ATTRIBUTES_DISCOUNTED', 'DEFAULT_', '') == 1 ? true : false);
  1798. $off_attributes_discounted = ($on_attributes_discounted == 1 ? false : true);
  1799. $on_attributes_price_base_included = (zen_get_show_product_switch($products_filter, 'ATTRIBUTES_PRICE_BASE_INCLUDED', 'DEFAULT_', '') == 1 ? true : false);
  1800. $off_attributes_price_base_included = ($on_attributes_price_base_included == 1 ? false : true);
  1801. $on_attributes_required = (zen_get_show_product_switch($products_filter, 'ATTRIBUTES_REQUIRED', 'DEFAULT_', '') == 1 ? true : false);
  1802. $off_attributes_required = ($on_attributes_required == 1 ? false : true);
  1803.  
  1804. $default_price_prefix = zen_get_show_product_switch($products_filter, 'PRICE_PREFIX', 'DEFAULT_', '');
  1805. $default_price_prefix = ($default_price_prefix == 1 ? '+' : ($default_price_prefix == 2 ? '-' : ''));
  1806. $default_products_attributes_weight_prefix  = zen_get_show_product_switch($products_filter, 'PRODUCTS_ATTRIBUTES_WEIGHT_PREFIX', 'DEFAULT_', '');
  1807. $default_products_attributes_weight_prefix  = ($default_products_attributes_weight_prefix  == 1 ? '+' : ($default_products_attributes_weight_prefix == 2 ? '-' : ''));
  1808.  
  1809. // set defaults for copying
  1810. $on_overwrite = true;
  1811. $off_overwrite = false;
  1812. ?>
  1813.             </select>&nbsp;</td>
  1814.           </tr></table></td></tr>
  1815.  
  1816. <?php // split here ?>
  1817.         </table></td></tr>
  1818.       </table>
  1819.     </td>
  1820.   </tr>
  1821. <!-- eof Option Name and Value -->
  1822.  
  1823. <!-- bof Prices and Weight -->
  1824.   <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1825.     <tr>
  1826.       <td colspan="2" class="pageHeading"><?php echo TEXT_PRICES_AND_WEIGHTS; ?></td>
  1827.     </tr>
  1828.     <tr>
  1829.       <td class="attributeBoxContent">
  1830.         <table border="1" cellpadding="4" cellspacing="2">
  1831.           <tr>
  1832.             <td align="center" class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_OPT_PRICE . '<br />'; ?><input type="text" name="price_prefix" size="2" value="<?php echo $default_price_prefix; ?>">&nbsp;<input type="text" name="value_price" size="6">&nbsp;</td>
  1833.             <td align="center" class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_OPT_WEIGHT . '<br />'; ?><input type="text" name="products_attributes_weight_prefix" size="2" value="<?php echo $default_products_attributes_weight_prefix; ?>">&nbsp;<input type="text" name="products_attributes_weight" size="6">&nbsp;</td>
  1834.             <td align="center" class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_OPT_SORT_ORDER; ?><br /><input type="text" name="products_options_sort_order" value="" size="4">&nbsp;</td>
  1835.             <td align="center" class="attributeBoxContent">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_ONETIME . '<br />'; ?><input type="text" name="attributes_price_onetime" size="6">&nbsp;</td>
  1836.           </tr>
  1837.         </table>
  1838.       </td>
  1839.  
  1840. <?php if (ATTRIBUTES_ENABLED_PRICE_FACTOR == 'true') { ?>
  1841.       <td class="attributeBoxContent">
  1842.         <table border="1" cellpadding="4" cellspacing="2">
  1843.           <tr>
  1844.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR . '&nbsp;&nbsp;' . TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_OFFSET . '<br />'; ?><input type="text" name="attributes_price_factor" size="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="attributes_price_factor_offset" size="6">&nbsp;</td>
  1845.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_ONETIME . '&nbsp;&nbsp;' . TABLE_HEADING_ATTRIBUTES_PRICE_FACTOR_OFFSET_ONETIME . '<br />'; ?><input type="text" name="attributes_price_factor_onetime" size="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="attributes_price_factor_onetime_offset" size="6">&nbsp;</td>
  1846.           </tr>
  1847.         </table>
  1848.       </td>
  1849.     </tr>
  1850. <?php
  1851.     } // ATTRIBUTES_ENABLED_PRICE_FACTOR
  1852. ?>
  1853.  
  1854. <?php if (ATTRIBUTES_ENABLED_QTY_PRICES == 'true') { ?>
  1855.     <tr>
  1856.       <td colspan="2" class="attributeBoxContent">
  1857.         <table border="1" cellpadding="4" cellspacing="2">
  1858.           <tr>
  1859.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_QTY_PRICES . '<br />'; ?><input type="text" name="attributes_qty_prices" size="60">&nbsp;</td>
  1860.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_QTY_PRICES_ONETIME . '<br />'; ?><input type="text" name="attributes_qty_prices_onetime" size="60">&nbsp;</td>
  1861.           </tr>
  1862.         </table>
  1863.       </td>
  1864.     </tr>
  1865. <?php } // ATTRIBUTES_ENABLED_QTY_PRICES ?>
  1866.  
  1867. <?php if (ATTRIBUTES_ENABLED_TEXT_PRICES == 'true') { ?>
  1868.     <tr>
  1869.       <td colspan="2" class="attributeBoxContent">
  1870.         <table border="1" cellpadding="4" cellspacing="2">
  1871.           <tr>
  1872.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_WORDS . '&nbsp;&nbsp;' . TABLE_HEADING_ATTRIBUTES_PRICE_WORDS_FREE . '<br />'; ?><input type="text" name="attributes_price_words" size="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="attributes_price_words_free" size="6">&nbsp;</td>
  1873.             <td align="center" class="attributeBoxContent" nowrap="nowrap">&nbsp;<?php echo TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS . '&nbsp;&nbsp;' . TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS_FREE . '<br />'; ?><input type="text" name="attributes_price_letters" size="6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="attributes_price_letters_free" size="6">&nbsp;</td>
  1874.           </tr>
  1875.         </table>
  1876.       </td>
  1877.     </tr>
  1878. <?php } // ATTRIBUTES_ENABLED_TEXT_PRICES ?>
  1879.  
  1880.   </table></td></tr>
  1881.  
  1882. <!-- eof Option Name and Value -->
  1883.  
  1884. <!-- bof Attribute Flags -->
  1885. <tr class="attributeBoxContent">
  1886.   <td class="pageHeading">
  1887.     <table border='0' width="100%">
  1888.       <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1889.  
  1890.             <tr><td class="attributeBoxContent"><table border="1" cellpadding="4" cellspacing="2">
  1891.  
  1892.               <tr >
  1893.                 <td class="smallText" align="center" width="50"><?php echo TEXT_ATTRIBUTES_FLAGS; ?></td>
  1894.                 <td class="smallText" align="center" width="150" bgcolor="#ffff00"><strong><?php echo TEXT_ATTRIBUTES_DISPLAY_ONLY . '</strong><br>' . zen_draw_radio_field('attributes_display_only', '0', $off_attributes_display_only) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_display_only', '1', $on_attributes_display_only) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1895.                 <td class="smallText" align="center" width="150" bgcolor="#2C54F5"><strong><?php echo TEXT_ATTRIBUTES_IS_FREE . '</strong><br>' . zen_draw_radio_field('product_attribute_is_free', '0', $off_product_attribute_is_free) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('product_attribute_is_free', '1', $on_product_attribute_is_free) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1896.                 <td class="smallText" align="center" width="150" bgcolor="#ffa346"><strong><?php echo TEXT_ATTRIBUTES_DEFAULT . '</strong><br>' . zen_draw_radio_field('attributes_default', '0', $off_attributes_default) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_default', '1', $on_attributes_default) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1897.                 <td class="smallText" align="center" width="150" bgcolor="#ff00ff"><strong><?php echo TEXT_ATTRIBUTE_IS_DISCOUNTED . '</strong><br>' . zen_draw_radio_field('attributes_discounted', '0', $off_attributes_discounted) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_discounted', '1', $on_attributes_discounted) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1898.                 <td class="smallText" align="center" width="150" bgcolor="#d200f0"><strong><?php echo TEXT_ATTRIBUTE_PRICE_BASE_INCLUDED . '</strong><br>' . zen_draw_radio_field('attributes_price_base_included', '0', $off_attributes_price_base_included) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_price_base_included', '1', $on_attributes_price_base_included) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1899.                 <td align="center" class="smallText" width="150" bgcolor="#FF0606"><strong><?php echo TEXT_ATTRIBUTES_REQUIRED . '</strong><br>' . zen_draw_radio_field('attributes_required', '0', $off_attributes_required) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('attributes_required', '1', $on_attributes_required) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1900.               </tr>
  1901.  
  1902. </table></td></tr>
  1903.  
  1904.       </table></td></tr>
  1905.     </table>
  1906.   </td>
  1907. </tr>
  1908. <!-- eof Attribute Flags -->
  1909.  
  1910. <?php if (ATTRIBUTES_ENABLED_IMAGES == 'true') { ?>
  1911. <?php
  1912. // add
  1913. // attributes images
  1914.   $dir = @dir(DIR_FS_CATALOG_IMAGES);
  1915.   $dir_info[] = array('id' => '', 'text' => "Main Directory");
  1916.   while ($file = $dir->read()) {
  1917.     if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
  1918.       $dir_info[] = array('id' => $file . '/', 'text' => $file);
  1919.     }
  1920.   }
  1921.   $dir->close();
  1922.   sort($dir_info);
  1923.  
  1924.   $default_directory = 'attributes/';
  1925. ?>
  1926.  
  1927. <!-- bof Attribute Images -->
  1928. <tr class="attributeBoxContent">
  1929.   <td class="pageHeading">
  1930.     <table border='0' width="100%">
  1931.       <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2" width="100%">
  1932.  
  1933.         <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1934.           <tr class="attributeBoxContent">
  1935.             <td>&nbsp;</td>
  1936.             <td class="main" valign="top">&nbsp;</td>
  1937.  
  1938. <!--
  1939.             <td class="main" valign="top">xxx<?php echo TEXT_ATTRIBUTES_IMAGE . '<br />' . zen_draw_file_field('attributes_image') . '<br />' . zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $attributes_values->fields['attributes_image'] . zen_draw_hidden_field('attributes_image', $attributes_values->fields['attributes_image']); ?></td>
  1940. -->
  1941.  
  1942.             <td class="main" valign="top"><?php echo TEXT_ATTRIBUTES_IMAGE . '<br />' . zen_draw_file_field('attributes_image'); ?></td>
  1943.  
  1944.             <td class="main" valign="top"><?php echo TEXT_ATTRIBUTES_IMAGE_DIR . '<br />' . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory); ?></td>
  1945.             <td class="main" valign="top"><?php echo TEXT_IMAGES_OVERWRITE . '<br />' . zen_draw_radio_field('overwrite', '0', $off_overwrite) . '&nbsp;' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('overwrite', '1', $on_overwrite) . '&nbsp;' . TABLE_HEADING_YES; ?></td>
  1946.           </tr>
  1947.         </table></td>
  1948.  
  1949.         <td width="200">
  1950.           <table align="right">
  1951.             <tr>
  1952.               <td align="center" class="attributeBoxContent" height="30" valign="bottom">&nbsp;
  1953.               <?php
  1954.                 if ($action == '') {
  1955.                   echo zen_image_submit('button_insert.gif', IMAGE_INSERT);
  1956.                 } else {
  1957.                   // hide button
  1958.                 }
  1959.               ?>
  1960.             &nbsp;
  1961.               </td>
  1962.             </tr>
  1963.           </table>
  1964.  
  1965.         </td></tr>
  1966.  
  1967.       </table></td></tr>
  1968.     </table>
  1969.   </td>
  1970. </tr>
  1971. <!-- eof Attribute Images -->
  1972. <?php } // ATTRIBUTES_ENABLED_IMAGES ?>
  1973.  
  1974. <?php
  1975.       if (DOWNLOAD_ENABLED == 'true') {
  1976.         $products_attributes_maxdays  = DOWNLOAD_MAX_DAYS;
  1977.         $products_attributes_maxcount = DOWNLOAD_MAX_COUNT;
  1978. ?>
  1979. <!-- bof Down loads ON -->
  1980. <tr class="attributeBoxContent">
  1981.   <td class="pageHeading">
  1982.     <table border='0' width="100%">
  1983.       <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1984.  
  1985.         <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  1986.           <tr class="attributeBoxContent">
  1987.             <td class="attributeBoxContent" valign="top"><?php echo TABLE_HEADING_DOWNLOAD; ?>&nbsp;</td>
  1988.             <td class="attributeBoxContent"><?php echo TABLE_TEXT_FILENAME . '<br />' . zen_draw_input_field('products_attributes_filename', $products_attributes_filename, zen_set_field_length(TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, 'products_attributes_filename', 35)); ?>&nbsp;</td>
  1989.             <td class="attributeBoxContent"><?php echo TABLE_TEXT_MAX_DAYS . '<br />' . zen_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?>&nbsp;</td>
  1990.             <td class="attributeBoxContent"><?php echo TABLE_TEXT_MAX_COUNT . '<br />' . zen_draw_input_field('products_attributes_maxcount', $products_attributes_maxcount, 'size="5"'); ?>&nbsp;</td>
  1991.           </tr>
  1992.         </table></td></tr>
  1993.  
  1994.       </table></td></tr>
  1995.     </table>
  1996.   </td>
  1997. </tr>
  1998. <!-- eof Downloads ON -->
  1999.  
  2000. <?php
  2001.       } else {
  2002. ?>
  2003. <!-- bof Down loads OFF -->
  2004. <tr class="attributeBoxContent">
  2005.   <td class="pageHeading">
  2006.     <table border='0' width="100%">
  2007.       <tr><td class="attributeBoxContent"><table border="1" cellpadding="4" cellspacing="2">
  2008.  
  2009.         <tr><td class="attributeBoxContent"><table border="0" cellpadding="4" cellspacing="2">
  2010.           <tr class="attributeBoxContent">
  2011.             <td class="attributeBoxContent"><?php echo TEXT_DOWNLOADS_DISABLED; ?>&nbsp;</td>
  2012.           </tr>
  2013.         </table></td></tr>
  2014.  
  2015.       </table></td></tr>
  2016.     </table>
  2017.   </td>
  2018. </tr>
  2019. <!-- eof Downloads OFF -->
  2020. <?php
  2021.       } // end of DOWNLOAD_ENABLED section
  2022. ?>
  2023. <?php
  2024.   }
  2025. ?>
  2026.         </table></form></td>
  2027. <?php
  2028. } // EOF: attributes preview
  2029. ?>
  2030.       </tr>
  2031. <?php
  2032. } // end of attributes
  2033. ?>
  2034.     </table></td>
  2035.  
  2036. </table></td></tr>
  2037. <!-- eof_adding -->
  2038.  
  2039. <!-- products_attributes_eof //-->
  2040.   </tr>
  2041. </table>
  2042. <!-- body_text_eof //-->
  2043. <!-- footer //-->
  2044. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  2045. <!-- footer_eof //-->
  2046. </body>
  2047. </html>
  2048. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  2049.  


cron