Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Option Type Feature v1.6 (for osc 2.2 MS2)


Guest

Recommended Posts

Yes I did because none of the columns matched up and the HTML table datas were way off. But that should be it.

 

I moved the comment into another table data so it would be displayed under the column heading.

 

Here's a copy of the file.

 

PRODUCT_ATTRINBUTES.PHP

<?php

/*

 $Id: products_attributes.php,v 1.52 2003/07/10 20:46:01 dgw_ Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

 

 require('includes/application_top.php');

 $languages = tep_get_languages();

 

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

 if (tep_not_null($action)) {

   $page_info = '';

   if (isset($HTTP_GET_VARS['option_page'])) $page_info .= 'option_page=' . $HTTP_GET_VARS['option_page'] . '&';

   if (isset($HTTP_GET_VARS['value_page'])) $page_info .= 'value_page=' . $HTTP_GET_VARS['value_page'] . '&';

   if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';

   if (tep_not_null($page_info)) {

     $page_info = substr($page_info, 0, -1);

   }

 

   switch ($action) {

     case 'add_product_options':

       $products_options_id = tep_db_prepare_input($HTTP_POST_VARS['products_options_id']);

       $option_name_array = $HTTP_POST_VARS['option_name'];

       $option_type = $HTTP_POST_VARS['option_type']; //clr 030714 update to add option type to products_option

   $option_length = $HTTP_POST_VARS['option_length']; //clr 030714 update to add option length to products_option

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

   $option_comment = $HTTP_POST_VARS['option_comment']; //clr 030714 update to add option comment to products_option

 

         tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id, products_options_type, products_options_length, products_options_comment) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . $option_comment[$languages[$i]['id']]  . "')");

       }

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'add_product_option_values':

       $value_name_array = $HTTP_POST_VARS['value_name'];

       $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

 

         tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$value_id . "', '" . (int)$languages[$i]['id'] . "', '" . tep_db_input($value_name) . "')");

       }

 

       tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$option_id . "', '" . (int)$value_id . "')");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'add_product_attributes':

       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);

       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

 

       tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

       if (DOWNLOAD_ENABLED == 'true') {

         $products_attributes_id = tep_db_insert_id();

 

         $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

         $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

         $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

         if (tep_not_null($products_attributes_filename)) {

           tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");

         }

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_option_name':

       $option_name_array = $HTTP_POST_VARS['option_name'];

    $option_type = $HTTP_POST_VARS['option_type']; //clr 030714 update to add option type to products_option

    $option_length = $HTTP_POST_VARS['option_length']; //clr 030714 update to add option length to products_option

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

   $option_comment = $HTTP_POST_VARS['option_comment']; //clr 030714 update to add option comment to products_option

 

         tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "', products_options_type = '" . $option_type . "', products_options_length = '" . $option_length . "', products_options_comment = '" . $option_comment[$languages[$i]['id']] . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_value':

       $value_name_array = $HTTP_POST_VARS['value_name'];

       $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

 

         tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . tep_db_input($value_name) . "' where products_options_values_id = '" . tep_db_input($value_id) . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

       }

 

       tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " set products_options_id = '" . (int)$option_id . "'  where products_options_values_id = '" . (int)$value_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_product_attribute':

       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);

       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

       $attribute_id = tep_db_prepare_input($HTTP_POST_VARS['attribute_id']);

 

       tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "' where products_attributes_id = '" . (int)$attribute_id . "'");

 

       if (DOWNLOAD_ENABLED == 'true') {

         $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

         $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

         $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

         if (tep_not_null($products_attributes_filename)) {

           tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "'");

         }

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_option':

       $option_id = tep_db_prepare_input($HTTP_GET_VARS['option_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$option_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_value':

       $value_id = tep_db_prepare_input($HTTP_GET_VARS['value_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int)$value_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_attribute':

       $attribute_id = tep_db_prepare_input($HTTP_GET_VARS['attribute_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . (int)$attribute_id . "'");

 

// added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled

       tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id = '" . (int)$attribute_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

   }

 }

 

//CLR 030312 add function to draw pulldown list of option types

// Draw a pulldown for Option Types

function draw_optiontype_pulldown($name, $default = '') {

 $values = array();

 $values[] = array('id' => 0, 'text' => 'Select');

 $values[] = array('id' => 1, 'text' => 'Text');

 $values[] = array('id' => 2, 'text' => 'Radio');

 $values[] = array('id' => 3, 'text' => 'Checkbox');

 $values[] = array('id' => 4, 'text' => 'Textarea');

 return tep_draw_pull_down_menu($name, $values, $default);

}

 

//CLR 030312 add function to translate type_id to name

// Translate option_type_values to english string

function translate_type_to_name($opt_type) {

 if ($opt_type == 0) return 'Select';

 if ($opt_type == 1) return 'Text';

 if ($opt_type == 2) return 'Radio';

 if ($opt_type == 3) return 'Checkbox';

 if ($opt_type == 4) return 'Textarea';

 return 'Error ' . $opt_type;

}

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/menu.js"></script>

 

<script language="javascript"><!--

function go_option() {

 if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {

   location = "<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . ($HTTP_GET_VARS['option_page'] ? $HTTP_GET_VARS['option_page'] : 1)); ?>&option_order_by="+document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value;

 }

}

//--></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

 <tr>

<?php

 if ($menu_dhtml == false ) {     // add for dhtml_menu

  echo '<td width="' . BOX_WIDTH . '" valign="top">';

  echo '<table border="0" width="' . BOX_WIDTH . '" cellspacing="1" cellpadding="1" class="columnLeft">';

  echo '<!-- left_navigation //-->';

  require(DIR_WS_INCLUDES . 'column_left.php');

  echo '<!-- left_navigation_eof //-->';

  echo '</table>';

  echo '</td>';

 } else {

 

 }

?>

<!-- body_text //-->

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<!-- options and values//-->

     <tr>

       <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">

         <tr>

           <td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">

<!-- options //-->

<?php

 if ($action == 'delete_product_option') { // delete product option

   $options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$HTTP_GET_VARS['option_id'] . "' and language_id = '" . (int)$languages_id . "'");

   $options_values = tep_db_fetch_array($options);

?>

             <tr>

               <td class="pageHeading"> <?php echo $options_values['products_options_name']; ?> </td>

               <td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>

             </tr>

             <tr>

               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

   $products = tep_db_query("select p.products_id, pd.products_name, pov.products_options_values_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pov.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_id='" . (int)$HTTP_GET_VARS['option_id'] . "' and pov.products_options_values_id = pa.options_values_id order by pd.products_name");

   if (tep_db_num_rows($products)) {

?>

                 <tr class="dataTableHeadingRow">

                   <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>

                 </tr>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

     $rows = 0;

     while ($products_values = tep_db_fetch_array($products)) {

       $rows++;

?>

                 <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

                   <td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_name']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_options_values_name']; ?> </td>

                 </tr>

<?php

     }

?>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

                 <tr>

                   <td colspan="3" class="main"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td align="right" colspan="3" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   } else {

?>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option&option_id=' . $HTTP_GET_VARS['option_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['order_by']) ? 'order_by=' . $HTTP_GET_VARS['order_by'] . '&' : '') . (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   }

?>

               </table></td>

             </tr>

<?php

 } else {

   if (isset($HTTP_GET_VARS['option_order_by'])) {

     $option_order_by = $HTTP_GET_VARS['option_order_by'];

   } else {

     $option_order_by = 'products_options_id';

   }

?>

             <tr>

               <td colspan="3" class="pageHeading"> <?php echo HEADING_TITLE_OPT; ?></td>

               <td colspan="3" align="right" class="smallText">Sort By: <form name="option_order_by" action="<?php echo FILENAME_PRODUCTS_ATTRIBUTES; ?>"><select name="selected" onChange="go_option()"><option value="products_options_id"<?php if ($option_order_by == 'products_options_id') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_ID; ?></option><option value="products_options_name"<?php if ($option_order_by == 'products_options_name') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_NAME; ?></option></select></form></td>

             </tr>

             <tr>

               <td colspan="6" class="smallText">

<?php

   $per_page = MAX_ROW_LISTS_OPTIONS;

   $options = "select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by " . $option_order_by;

   if (!isset($option_page)) {

     $option_page = 1;

   }

   $prev_option_page = $option_page - 1;

   $next_option_page = $option_page + 1;

 

   $option_query = tep_db_query($options);

 

   $option_page_start = ($per_page * $option_page) - $per_page;

   $num_rows = tep_db_num_rows($option_query);

 

   if ($num_rows <= $per_page) {

     $num_pages = 1;

   } else if (($num_rows % $per_page) == 0) {

     $num_pages = ($num_rows / $per_page);

   } else {

     $num_pages = ($num_rows / $per_page) + 1;

   }

   $num_pages = (int) $num_pages;

 

   $options = $options . " LIMIT $option_page_start, $per_page";

 

   // Previous

   if ($prev_option_page)  {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $prev_option_page) . '"> << </a> | ';

   }

 

   for ($i = 1; $i <= $num_pages; $i++) {

     if ($i != $option_page) {

       echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $i) . '">' . $i . '</a> | ';

     } else {

       echo '<b><font color=red>' . $i . '</font></b> | ';

     }

   }

 

   // Next

   if ($option_page != $num_pages) {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $next_option_page) . '"> >> </a>';

   }

//CLR 030212 - Add column for option type

?>

               </td>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

     <td align="center" class="dataTableHeadingContent">Type</td>

        <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_LENGTH; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_COMMENT; ?> </td>

               <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   $next_id = 1;

   $rows = 0;

   $options = tep_db_query($options);

   while ($options_values = tep_db_fetch_array($options)) {

     $rows++;

?>

             <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

     if (($action == 'update_option') && ($HTTP_GET_VARS['option_id'] == $options_values['products_options_id'])) {

       echo '<form name="option" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_name', 'NONSSL') . '" method="post">';

       $inputs = '';

       for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {

         $option_name = tep_db_query("select products_options_name, products_options_length, products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");

         $option_name = tep_db_fetch_array($option_name);

      $inputs .= '<input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_name'] . '">';

       }

//CLR 030212 - Add column for option type

?>

         <td align="center" class="smallText"> <?php echo $options_values['products_options_id']; ?><input type="hidden" name="option_id" value="<?php echo $options_values['products_options_id']; ?>"> </td>

     <td class="smallText"><?php echo $inputs; ?></td>

     <td class="smallText"><?php echo draw_optiontype_pulldown('option_type', $options_values['products_options_type']); ?></td>

      <td class="smallText"><?php echo '<input type="text" name="option_length" size="4" value="' . $option_name['products_options_length'] . '">'; ?></td>

     <td class="smallText"><?php echo '<input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_comment'] . '">'; ?></td>

               <td class="smallText" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a></td>

<?php

       echo '</form>' . "\n";

     } else {

//CLR 030212 - Add column for option type

?>

               <td align="center" class="smallText"> <?php echo $options_values["products_options_id"]; ?> </td>

               <td class="smallText"><?php echo $options_values["products_options_name"]; ?></td>

               <td class="smallText"><?php echo translate_type_to_name($options_values["products_options_type"]); ?></td>

     <td align="center" class="smallText"><?php echo $options_values["products_options_length"]; ?></td>

     <td class="smallText"><?php echo $options_values["products_options_comment"]; ?></td>

               <td align="center" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option&option_id=' . $options_values['products_options_id'] . '&option_order_by=' . $option_order_by . '&option_page=' . $option_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_product_option&option_id=' . $options_values['products_options_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a></td>

<?php

     }

?>

             </tr>

<?php

     $max_options_id_query = tep_db_query("select max(products_options_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS);

     $max_options_id_values = tep_db_fetch_array($max_options_id_query);

     $next_id = $max_options_id_values['next_id'];

   }

?>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   if ($action != 'update_option') {

?>

             <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

     echo '<form name="options" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_options&option_page=' . $option_page, 'NONSSL') . '" method="post"><input type="hidden" name="products_options_id" value="' . $next_id . '">';

     $inputs = '';

     for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {

 $inputs .= '<input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="15">';

     }

//CLR 030212 - Add column for option type

?>

               <td align="center" class="smallText"> <?php echo $next_id; ?> </td>

               <td class="smallText"><?php echo $inputs; ?></td>

     <td class="smallText"><?php echo draw_optiontype_pulldown('option_type', $options_values['products_options_type']); ?></td>

      <td align="center" class="smallText"><?php echo '<input type="text" name="option_length" size="2" value="32">'; ?></td>

               <td class="smallText"><?php echo '<input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="15">'; ?></td>

               <td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>

<?php

     echo '</form>';

?>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   }

 }

?>

           </table></td>

<!-- options eof //-->

           <td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">

<!-- value //-->

<?php

 if ($action == 'delete_option_value') { // delete product option value

   $values = tep_db_query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$HTTP_GET_VARS['value_id'] . "' and language_id = '" . (int)$languages_id . "'");

   $values_values = tep_db_fetch_array($values);

?>

             <tr>

               <td class="pageHeading"> <?php echo $values_values['products_options_values_name']; ?> </td>

             </tr>

             <tr>

               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

   $products = tep_db_query("select p.products_id, pd.products_name, po.products_options_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and po.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_values_id='" . (int)$HTTP_GET_VARS['value_id'] . "' and po.products_options_id = pa.options_id order by pd.products_name");

   if (tep_db_num_rows($products)) {

?>

                 <tr class="dataTableHeadingRow">

                   <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

                 </tr>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

     while ($products_values = tep_db_fetch_array($products)) {

       $rows++;

?>

                 <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

                   <td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_name']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_options_name']; ?> </td>

                 </tr>

<?php

     }

?>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   } else {

?>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_value&value_id=' . $HTTP_GET_VARS['value_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&option_page=' . $option_page . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $value_page : '') . (isset($HTTP_GET_VARS['attribute_page']) ? '&attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   }

?>

              </table></td>

             </tr>

<?php

 } else {

?>

             <tr>

               <td colspan="3" class="pageHeading"> <?php echo HEADING_TITLE_VAL; ?> </td>

               <td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>

             </tr>

             <tr>

               <td colspan="4" class="smallText">

<?php

   $per_page = MAX_ROW_LISTS_OPTIONS;

   $values = "select pov.products_options_values_id, pov.products_options_values_name, pov2po.products_options_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov left join " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " pov2po on pov.products_options_values_id = pov2po.products_options_values_id where pov.language_id = '" . (int)$languages_id . "' order by pov.products_options_values_id";

   if (!isset($value_page)) {

     $value_page = 1;

   }

   $prev_value_page = $value_page - 1;

   $next_value_page = $value_page + 1;

 

   $value_query = tep_db_query($values);

 

   $value_page_start = ($per_page * $value_page) - $per_page;

   $num_rows = tep_db_num_rows($value_query);

 

   if ($num_rows <= $per_page) {

     $num_pages = 1;

   } else if (($num_rows % $per_page) == 0) {

     $num_pages = ($num_rows / $per_page);

   } else {

     $num_pages = ($num_rows / $per_page) + 1;

   }

   $num_pages = (int) $num_pages;

 

   $values = $values . " LIMIT $value_page_start, $per_page";

 

   // Previous

   if ($prev_value_page)  {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_order_by=' . $option_order_by . '&value_page=' . $prev_value_page) . '"> << </a> | ';

   }

 

   for ($i = 1; $i <= $num_pages; $i++) {

     if ($i != $value_page) {

        echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $i) . '">' . $i . '</a> | ';

     } else {

        echo '<b><font color=red>' . $i . '</font></b> | ';

     }

   }

 

   // Next

   if ($value_page != $num_pages) {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $next_value_page) . '"> >></a> ';

   }

?>

               </td>

             </tr>

             <tr>

               <td colspan="4"><?php echo tep_black_line(); ?></td>

             </tr>

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>

               <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

             <tr>

               <td colspan="4"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   $next_id = 1;

   $rows = 0;

   $values = tep_db_query($values);

   while ($values_values = tep_db_fetch_array($values)) {

     $options_name = tep_options_name($values_values['products_options_id']);

     $values_name = $values_values['products_options_values_name'];

     $rows++;

?>

             <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

     if (($action == 'update_option_value') && ($HTTP_GET_VARS['value_id'] == $values_values['products_options_values_id'])) {

       echo '<form name="values" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_value', 'NONSSL') . '" method="post">';

       $inputs = '';

       for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {

         $value_name = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_values['products_options_values_id'] . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

         $value_name = tep_db_fetch_array($value_name);

         $inputs .= '<input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15" value="' . $value_name['products_options_values_name'] . '">';

       }

?>

               <td align="center" class="smallText"> <?php echo $values_values['products_options_values_id']; ?><input type="hidden" name="value_id" value="<?php echo $values_values['products_options_values_id']; ?>"> </td>

               <td align="center" class="smallText"> <?php echo "\n"; ?><select name=

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • Replies 799
  • Created
  • Last Reply

Top Posters In This Topic

By the way, all gets saved except for the comments. I did not know if that was clear or not.

 

The text attributes are saved, but if I enter a comment, the comment does not get saved. And if I manually add it in the database, then go back to Admin and edit that same test attribute, the comment that I added manually in the database is lost.

 

That happens when I edit the comment or leave it alone and edit the name or size or whatever. When I click on the update button, it looses the saved comments.

 

I know I moved some things around, but it should have not made any difference to the commands or anything, I thought that I just changed the way it was being displayed on the screen and that is it.

 

If you can help, please do so.

Edited by PopTheTop

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Aha..got your error.

 

You must know that the "comment" inputbox can be multi-language, so it must be included in an iteration on the available languages.

Around line 381, you must put here the code to display the comments box and NOT display it on line 389 (outside the for). Other solution would be to modify the case "'add_product_options' at line 28 and put the comments field outside the "for" statement. It's up to you to decide. I also got some problems with this extra comment field.

 

Normally, everywhere you see the field "products_options_name", you should see the field "products_options_comment" beneath.

 

Cannot post your fixed code but I think you know what I mean.

 

Didier

Link to comment
Share on other sites

YES YES YES! Thanks so much! I fixed it. This is what I did...

 

<?php
     if (($action == 'update_option') && ($HTTP_GET_VARS['option_id'] == $options_values['products_options_id'])) {
       echo '<form name="option" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_name', 'NONSSL') . '" method="post">';
       $inputs = '';
       for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
         $option_name = tep_db_query("select products_options_name, products_options_length, products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");
         $option_name = tep_db_fetch_array($option_name);
   $inputs .= '<td class="smallText"><input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_name'] . '"></td>' .
      	 '<td class="smallText">' . draw_optiontype_pulldown('option_type', $options_values['products_options_type']) . '</td>' .
      	 '<td class="smallText"><input type="text" name="option_length" size="4" value="' . $option_name['products_options_length'] . '"></td>' .
      	 '<td class="smallText"><input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_comment'] . '"></td>';
       }
//CLR 030212 - Add column for option type
?>
         <td align="center" class="smallText"> <?php echo $options_values['products_options_id']; ?><input type="hidden" name="option_id" value="<?php echo $options_values['products_options_id']; ?>"> </td>
     <?php echo $inputs; ?>
               <td class="smallText" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a></td>
<?php

 

Here is the whole file. Workes great and everything in now aligned and where it is supposed to be...

 

<?php

/*

 $Id: products_attributes.php,v 1.52 2003/07/10 20:46:01 dgw_ Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

 

 require('includes/application_top.php');

 $languages = tep_get_languages();

 

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

 if (tep_not_null($action)) {

   $page_info = '';

   if (isset($HTTP_GET_VARS['option_page'])) $page_info .= 'option_page=' . $HTTP_GET_VARS['option_page'] . '&';

   if (isset($HTTP_GET_VARS['value_page'])) $page_info .= 'value_page=' . $HTTP_GET_VARS['value_page'] . '&';

   if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&';

   if (tep_not_null($page_info)) {

     $page_info = substr($page_info, 0, -1);

   }

 

   switch ($action) {

     case 'add_product_options':

       $products_options_id = tep_db_prepare_input($HTTP_POST_VARS['products_options_id']);

       $option_name_array = $HTTP_POST_VARS['option_name'];

       $option_type = $HTTP_POST_VARS['option_type'];

   $option_length = $HTTP_POST_VARS['option_length'];

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

     $option_comment = $HTTP_POST_VARS['option_comment'];

 

         tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id, products_options_type, products_options_length, products_options_comment) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . $option_comment[$languages[$i]['id']]  . "')");

       }

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'add_product_option_values':

       $value_name_array = $HTTP_POST_VARS['value_name'];

       $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

 

         tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$value_id . "', '" . (int)$languages[$i]['id'] . "', '" . tep_db_input($value_name) . "')");

       }

 

       tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$option_id . "', '" . (int)$value_id . "')");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'add_product_attributes':

       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);

       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

 

       tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

       if (DOWNLOAD_ENABLED == 'true') {

         $products_attributes_id = tep_db_insert_id();

 

         $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

         $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

         $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

         if (tep_not_null($products_attributes_filename)) {

           tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");

         }

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_option_name':

       $option_name_array = $HTTP_POST_VARS['option_name'];

    $option_type = $HTTP_POST_VARS['option_type'];

    $option_length = $HTTP_POST_VARS['option_length'];

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

     $option_comment = $HTTP_POST_VARS['option_comment'];

 

         tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "', products_options_type = '" . $option_type . "', products_options_length = '" . $option_length . "', products_options_comment = '" . $option_comment[$languages[$i]['id']] . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_value':

       $value_name_array = $HTTP_POST_VARS['value_name'];

       $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']);

       $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']);

 

       for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

         $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]);

 

         tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . tep_db_input($value_name) . "' where products_options_values_id = '" . tep_db_input($value_id) . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

       }

 

       tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " set products_options_id = '" . (int)$option_id . "'  where products_options_values_id = '" . (int)$value_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'update_product_attribute':

       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);

       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

       $attribute_id = tep_db_prepare_input($HTTP_POST_VARS['attribute_id']);

 

       tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "' where products_attributes_id = '" . (int)$attribute_id . "'");

 

       if (DOWNLOAD_ENABLED == 'true') {

         $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

         $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

         $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

         if (tep_not_null($products_attributes_filename)) {

           tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "'");

         }

       }

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_option':

       $option_id = tep_db_prepare_input($HTTP_GET_VARS['option_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$option_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_value':

       $value_id = tep_db_prepare_input($HTTP_GET_VARS['value_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'");

       tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int)$value_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

     case 'delete_attribute':

       $attribute_id = tep_db_prepare_input($HTTP_GET_VARS['attribute_id']);

 

       tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . (int)$attribute_id . "'");

 

// added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled

       tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id = '" . (int)$attribute_id . "'");

 

       tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

       break;

   }

 }

 

//CLR 030312 add function to draw pulldown list of option types

// Draw a pulldown for Option Types

function draw_optiontype_pulldown($name, $default = '') {

 $values = array();

 $values[] = array('id' => 0, 'text' => 'Select');

 $values[] = array('id' => 1, 'text' => 'Text');

 $values[] = array('id' => 2, 'text' => 'Radio');

 $values[] = array('id' => 3, 'text' => 'Checkbox');

 $values[] = array('id' => 4, 'text' => 'Textarea');

 return tep_draw_pull_down_menu($name, $values, $default);

}

 

//CLR 030312 add function to translate type_id to name

// Translate option_type_values to english string

function translate_type_to_name($opt_type) {

 if ($opt_type == 0) return 'Select';

 if ($opt_type == 1) return 'Text';

 if ($opt_type == 2) return 'Radio';

 if ($opt_type == 3) return 'Checkbox';

 if ($opt_type == 4) return 'Textarea';

 return 'Error ' . $opt_type;

}

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/menu.js"></script>

 

<script language="javascript"><!--

function go_option() {

 if (document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value != "none") {

   location = "<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . ($HTTP_GET_VARS['option_page'] ? $HTTP_GET_VARS['option_page'] : 1)); ?>&option_order_by="+document.option_order_by.selected.options[document.option_order_by.selected.selectedIndex].value;

 }

}

//--></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

 <tr>

<?php

 if ($menu_dhtml == false ) {     // add for dhtml_menu

  echo '<td width="' . BOX_WIDTH . '" valign="top">';

  echo '<table border="0" width="' . BOX_WIDTH . '" cellspacing="1" cellpadding="1" class="columnLeft">';

  echo '<!-- left_navigation //-->';

  require(DIR_WS_INCLUDES . 'column_left.php');

  echo '<!-- left_navigation_eof //-->';

  echo '</table>';

  echo '</td>';

 } else {

 

 }

?>

<!-- body_text //-->

   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<!-- options and values//-->

     <tr>

       <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">

         <tr>

           <td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">

<!-- options //-->

<?php

 if ($action == 'delete_product_option') { // delete product option

   $options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$HTTP_GET_VARS['option_id'] . "' and language_id = '" . (int)$languages_id . "'");

   $options_values = tep_db_fetch_array($options);

?>

             <tr>

               <td class="pageHeading"> <?php echo $options_values['products_options_name']; ?> </td>

               <td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>

             </tr>

             <tr>

               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

   $products = tep_db_query("select p.products_id, pd.products_name, pov.products_options_values_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pov.language_id = '" . (int)$languages_id . "' and pd.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_id='" . (int)$HTTP_GET_VARS['option_id'] . "' and pov.products_options_values_id = pa.options_values_id order by pd.products_name");

   if (tep_db_num_rows($products)) {

?>

                 <tr class="dataTableHeadingRow">

                   <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>

                 </tr>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

     $rows = 0;

     while ($products_values = tep_db_fetch_array($products)) {

       $rows++;

?>

                 <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

                   <td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_name']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_options_values_name']; ?> </td>

                 </tr>

<?php

     }

?>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

                 <tr>

                   <td colspan="3" class="main"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td align="right" colspan="3" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   } else {

?>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option&option_id=' . $HTTP_GET_VARS['option_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['order_by']) ? 'order_by=' . $HTTP_GET_VARS['order_by'] . '&' : '') . (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   }

?>

               </table></td>

             </tr>

<?php

 } else {

   if (isset($HTTP_GET_VARS['option_order_by'])) {

     $option_order_by = $HTTP_GET_VARS['option_order_by'];

   } else {

     $option_order_by = 'products_options_id';

   }

?>

             <tr>

               <td colspan="3" class="pageHeading"> <?php echo HEADING_TITLE_OPT; ?></td>

               <td colspan="3" align="right" class="smallText">Sort By: <form name="option_order_by" action="<?php echo FILENAME_PRODUCTS_ATTRIBUTES; ?>"><select name="selected" onChange="go_option()"><option value="products_options_id"<?php if ($option_order_by == 'products_options_id') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_ID; ?></option><option value="products_options_name"<?php if ($option_order_by == 'products_options_name') { echo ' SELECTED'; } ?>><?php echo TEXT_OPTION_NAME; ?></option></select></form></td>

             </tr>

             <tr>

               <td colspan="6" class="smallText">

<?php

   $per_page = MAX_ROW_LISTS_OPTIONS;

   $options = "select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by " . $option_order_by;

   if (!isset($option_page)) {

     $option_page = 1;

   }

   $prev_option_page = $option_page - 1;

   $next_option_page = $option_page + 1;

 

   $option_query = tep_db_query($options);

 

   $option_page_start = ($per_page * $option_page) - $per_page;

   $num_rows = tep_db_num_rows($option_query);

 

   if ($num_rows <= $per_page) {

     $num_pages = 1;

   } else if (($num_rows % $per_page) == 0) {

     $num_pages = ($num_rows / $per_page);

   } else {

     $num_pages = ($num_rows / $per_page) + 1;

   }

   $num_pages = (int) $num_pages;

 

   $options = $options . " LIMIT $option_page_start, $per_page";

 

   // Previous

   if ($prev_option_page)  {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $prev_option_page) . '"> << </a> | ';

   }

 

   for ($i = 1; $i <= $num_pages; $i++) {

     if ($i != $option_page) {

       echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $i) . '">' . $i . '</a> | ';

     } else {

       echo '<b><font color=red>' . $i . '</font></b> | ';

     }

   }

 

   // Next

   if ($option_page != $num_pages) {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_page=' . $next_option_page) . '"> >> </a>';

   }

//CLR 030212 - Add column for option type

?>

               </td>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

     <td align="center" class="dataTableHeadingContent">Type</td>

        <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_LENGTH; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_COMMENT; ?> </td>

               <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   $next_id = 1;

   $rows = 0;

   $options = tep_db_query($options);

   while ($options_values = tep_db_fetch_array($options)) {

     $rows++;

?>

             <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

     if (($action == 'update_option') && ($HTTP_GET_VARS['option_id'] == $options_values['products_options_id'])) {

       echo '<form name="option" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_name', 'NONSSL') . '" method="post">';

       $inputs = '';

       for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {

         $option_name = tep_db_query("select products_options_name, products_options_length, products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");

         $option_name = tep_db_fetch_array($option_name);

   $inputs .= '<td class="smallText"><input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_name'] . '"></td>' .

        '<td class="smallText">' . draw_optiontype_pulldown('option_type', $options_values['products_options_type']) . '</td>' .

        '<td class="smallText"><input type="text" name="option_length" size="4" value="' . $option_name['products_options_length'] . '"></td>' .

        '<td class="smallText"><input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="15" value="' . $option_name['products_options_comment'] . '"></td>';

       }

//CLR 030212 - Add column for option type

?>

         <td align="center" class="smallText"> <?php echo $options_values['products_options_id']; ?><input type="hidden" name="option_id" value="<?php echo $options_values['products_options_id']; ?>"> </td>

     <?php echo $inputs; ?>

               <td class="smallText" align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?> <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a></td>

<?php

       echo '</form>' . "\n";

     } else {

//CLR 030212 - Add column for option type

?>

               <td align="center" class="smallText"> <?php echo $options_values["products_options_id"]; ?> </td>

               <td class="smallText"><?php echo $options_values["products_options_name"]; ?></td>

               <td class="smallText"><?php echo translate_type_to_name($options_values["products_options_type"]); ?></td>

     <td align="center" class="smallText"><?php echo $options_values["products_options_length"]; ?></td>

     <td class="smallText"><?php echo $options_values["products_options_comment"]; ?></td>

               <td align="center" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option&option_id=' . $options_values['products_options_id'] . '&option_order_by=' . $option_order_by . '&option_page=' . $option_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>  <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_product_option&option_id=' . $options_values['products_options_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a></td>

<?php

     }

?>

             </tr>

<?php

     $max_options_id_query = tep_db_query("select max(products_options_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS);

     $max_options_id_values = tep_db_fetch_array($max_options_id_query);

     $next_id = $max_options_id_values['next_id'];

   }

?>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   if ($action != 'update_option') {

?>

             <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

     echo '<form name="options" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_options&option_page=' . $option_page, 'NONSSL') . '" method="post"><input type="hidden" name="products_options_id" value="' . $next_id . '">';

     $inputs = '';

     for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {

 $inputs .= '<td class="smallText"><input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="15"></td>' .

      '<td class="smallText">' . draw_optiontype_pulldown('option_type', $options_values['products_options_type']) . '</td>' .

       '<td align="center" class="smallText"><input type="text" name="option_length" size="2" value="32"></td>' .

      '<td class="smallText"><input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="15"></td>';

     }

//CLR 030212 - Add column for option type

?>

               <td align="center" class="smallText"> <?php echo $next_id; ?> </td>

     <?php echo $inputs; ?>

     <td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>

<?php

     echo '</form>';

?>

             </tr>

             <tr>

               <td colspan="6"><?php echo tep_black_line(); ?></td>

             </tr>

<?php

   }

 }

?>

           </table></td>

<!-- options eof //-->

           <td valign="top" width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="2">

<!-- value //-->

<?php

 if ($action == 'delete_option_value') { // delete product option value

   $values = tep_db_query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$HTTP_GET_VARS['value_id'] . "' and language_id = '" . (int)$languages_id . "'");

   $values_values = tep_db_fetch_array($values);

?>

             <tr>

               <td class="pageHeading"> <?php echo $values_values['products_options_values_name']; ?> </td>

             </tr>

             <tr>

               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

   $products = tep_db_query("select p.products_id, pd.products_name, po.products_options_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS . " po, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and po.language_id = '" . (int)$languages_id . "' and pa.products_id = p.products_id and pa.options_values_id='" . (int)$HTTP_GET_VARS['value_id'] . "' and po.products_options_id = pa.options_id order by pd.products_name");

   if (tep_db_num_rows($products)) {

?>

                 <tr class="dataTableHeadingRow">

                   <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ID; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT; ?> </td>

                   <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

                 </tr>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

<?php

     while ($products_values = tep_db_fetch_array($products)) {

       $rows++;

?>

                 <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

                   <td align="center" class="smallText"> <?php echo $products_values['products_id']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_name']; ?> </td>

                   <td class="smallText"> <?php echo $products_values['products_options_name']; ?> </td>

                 </tr>

<?php

     }

?>

                 <tr>

                   <td colspan="3"><?php echo tep_black_line(); ?></td>

                 </tr>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_WARNING_OF_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($HTTP_GET_VARS['value_page']) ? 'value_page=' . $HTTP_GET_VARS['value_page'] . '&' : '') . (isset($HTTP_GET_VARS['attribute_page']) ? 'attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   } else {

?>

                 <tr>

                   <td class="main" colspan="3"><br><?php echo TEXT_OK_TO_DELETE; ?></td>

                 </tr>

                 <tr>

                   <td class="main" align="right" colspan="3"><br><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_value&value_id=' . $HTTP_GET_VARS['value_id'], 'NONSSL') . '">'; ?><?php echo tep_image_button('button_delete.gif', ' delete '); ?></a>   <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&option_page=' . $option_page . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $value_page : '') . (isset($HTTP_GET_VARS['attribute_page']) ? '&attribute_page=' . $attribute_page : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', ' cancel '); ?></a> </td>

                 </tr>

<?php

   }

?>

              </table></td>

             </tr>

<?php

 } else {

?>

             <tr>

               <td colspan="3" class="pageHeading"> <?php echo HEADING_TITLE_VAL; ?> </td>

               <td> <?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?> </td>

             </tr>

             <tr>

               <td colspan="4" class="smallText">

<?php

   $per_page = MAX_ROW_LISTS_OPTIONS;

   $values = "select pov.products_options_values_id, pov.products_options_values_name, pov2po.products_options_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov left join " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " pov2po on pov.products_options_values_id = pov2po.products_options_values_id where pov.language_id = '" . (int)$languages_id . "' order by pov.products_options_values_id";

   if (!isset($value_page)) {

     $value_page = 1;

   }

   $prev_value_page = $value_page - 1;

   $next_value_page = $value_page + 1;

 

   $value_query = tep_db_query($values);

 

   $value_page_start = ($per_page * $value_page) - $per_page;

   $num_rows = tep_db_num_rows($value_query);

 

   if ($num_rows <= $per_page) {

     $num_pages = 1;

   } else if (($num_rows % $per_page) == 0) {

     $num_pages = ($num_rows / $per_page);

   } else {

     $num_pages = ($num_rows / $per_page) + 1;

   }

   $num_pages = (int) $num_pages;

 

   $values = $values . " LIMIT $value_page_start, $per_page";

 

   // Previous

   if ($prev_value_page)  {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'option_order_by=' . $option_order_by . '&value_page=' . $prev_value_page) . '"> << </a> | ';

   }

 

   for ($i = 1; $i <= $num_pages; $i++) {

     if ($i != $value_page) {

        echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $i) . '">' . $i . '</a> | ';

     } else {

        echo '<b><font color=red>' . $i . '</font></b> | ';

     }

   }

 

   // Next

   if ($value_page != $num_pages) {

     echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, (isset($option_order_by) ? 'option_order_by=' . $option_order_by . '&' : '') . 'value_page=' . $next_value_page) . '"> >></a> ';

   }

?>

               </td>

             </tr>

             <tr>

               <td colspan="4"><?php echo tep_black_line(); ?></td>

             </tr>

             <tr class="dataTableHeadingRow">

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_ID; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_NAME; ?> </td>

               <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_VALUE; ?> </td>

               <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_ACTION; ?> </td>

             </tr>

             <tr>

               <td colspan="4"><?php echo tep_black_line(); ?></td>

             </tr>

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Now, if I could only find a way to add the attributes to the ADD PRODUCT page. Any ideas?

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Now, if I could only find a way to add the attributes to the ADD PRODUCT page. Any ideas?

There are a lot of contributions that display the attributes on the product page instead of on the option page. Far better if you have a lot of products.

I did it on my own but search for "attrib" in the contributions. I'm sure you will find something.

 

FYI, the table "products_attrbibutes" has not been changed for the OTF module. No need to adapt.

 

Didier.

Link to comment
Share on other sites

Not sure if this is just a problem with me or what...

 

But I just downloaded and installed the new Product Option Type Feature version (1.7?).

 

The admin/product_attributes.php wasn't displaying the actual drop-down select menu for product option type... under the section on the top left, where you create new product options.

 

I discovered that a line seems to be missing from the new version of that file in the admin directory.

 

See below... from around line 414:

 

//CLR 030212 - Add column for option type

?>

<td align="center" class="smallText"> <?php echo $next_id; ?> </td>

<td class="smallText" colspan="2"><?php echo $inputs; ?></td>

<?php // Line that seems to be missing is the very next line below ?>

<td class="smallText"><?php echo draw_optiontype_pulldown('option_type'); ?></td>

<td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>

<?php

echo '</form>';

 

 

 

I put that one line in... and that seems to have fixed the problem.

 

I checked the downloaded .zip file... which I pulled straight from the contributions downloads about one hour ago... and it too is missing this line.

 

 

So, have I discovered something here? Or am I crazy and misunderstanding that this drop-down was replaced with something else or some other code?

 

 

Thanks!

 

-= Dave =-

Link to comment
Share on other sites

Hello Dave,

 

In fact, you must first save a new option and choose AFTERWARDS the option type. I agree with you that is not correct. I will also try out your fix and publish a new version v1.71 asap (together with the product_info.php correction post #120).

 

Thanks for doing the bug report !

 

Didier.

Link to comment
Share on other sites

If you look at my file posted above, you will see that I added that in so that you can add the new stuff in when you create it AND edit it. Pretty easy to do.

 

I thought that it was left out by accident too and I just entered it in myself and it works great.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

:thumbsup:

 

I just published version 1.71 of this contribution with 2 bug fixes. Here is the changelog :

 

v1.71 Release November 17, 2004 (Didier Debbaut)

 

- fixed product_info.php page line 27 : dropped opening html comment tag that has no closing tag (oeps..shame on me :-( )

- fixed /admin/products_attributes.php (added lines 418 and 419) : when creating a new option, you can enter immediately the type and length. Thanks to Scott Moore for this bug report.

 

You can get it here : Product Attributes - Option Type Feature v1.71

 

Thanks to all people for testing and bugreporting !

 

Didier.

Link to comment
Share on other sites

Hi,

 

Not sure if anyone has come across this issue before, its proving to be a bit of a problem.

 

I need to use 3 text boxes for a product. For example the person enters in:

 

line1 = AAAAAAAAAAA

line2 = BBBBBBBBBBB

line3 = CCCCCCCCCC

 

Everything is fine until the person creates an account, then all of a sudden as they get to the confirmation screen they see that the lines have been jumbled, for example to:

 

line2=BBBBBBBBBB

line3=CCCCCCCCC

line1=AAAAAAAAAA

 

I am not sure how this happens, the jumbling is always random and not alphabetically related.

 

Any help would be much appreciated.

Link to comment
Share on other sites

Hmmm, I do not have that problem on our site at https://www.popthetop.com/catalog/index.php

 

I have 3 lines setup for 2 of my products. I went to the site, added it to the cart and created an account as I went through checkout.

 

The 3 lines stayed as

 

line1 = AAAAAAAAAAA

line2 = BBBBBBBBBBB

line3 = CCCCCCCCCC

 

all the way through the checkout process and even in my order e-mails.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Is a known bug. I added an option sort order for the products page, but in the shopping cart, order, etc. there is a random order of the options. It all depends of the order the records have been stored in the customer_basket and order table. I saw some posts about this with a solution. Search a bit for "attributes sort order".

 

Is an off-topic question for this thread cause the problem is NOT linked to the OTF feature.

 

Didier.

Link to comment
Share on other sites

I've installed this contribution and I am having a problem with option names not persisting.

 

when going from product_info.php to shopping_cart.php the option names aren't transferred.

 

For example, I have several, let's say on product info I have a text area called from and a select box called style. The select box works fine, but the text field doesn't. When I click the add to cart button, the value is then displayed in the shopping cart, but not the name. The names of the options aren't sent via email either, except for the select.

 

Product name

- asdf

- Style Fancy

(where the text field should be prepended with TO: and the select is correctly prepended with Style)

 

Email:

data from text area, but not name

Style Fancy

 

 

I've diffed all the files and don't see anything silly. Any ideas?

Link to comment
Share on other sites

Mmmm I signed up a test account with your shop (sorry to be a nuisance) I had the same problem with your site as on mine, a quick test on your product resulted in:

 

Travel Trailer Camping Log & Diary

 

Selected Options:

- Custom Line #3: CCCCCCCCCCCCCC

- Custom Line #2: GGGGGGGGGGGGG

- Custom Line #1: XXXXXXXXXXXXXXX

 

But as spaceboy has said, looking back now it happens with standard attributes so I will stop the thread hijack ;)

 

Where your site differs however is that yours displays [ - Custom Line #1: XXXXXXXX ] where mine misses off the text label and simply displays [ - XXXXXXXX ]. If I can get that fixed, the earlier problem wouldnt matter as I can see which is line 1, line 2 and line 3. (same problem the poster above is having I think)

Edited by K3D
Link to comment
Share on other sites

Mmmm I signed up a test account with your shop (sorry to be a nuisance) I had the same problem with your site as on mine, a quick test on your product resulted in:

 

Travel Trailer Camping Log & Diary

 

Selected Options:

  - Custom Line #3: CCCCCCCCCCCCCC

  - Custom Line #2: GGGGGGGGGGGGG

  - Custom Line #1: XXXXXXXXXXXXXXX

 

But as spaceboy has said, looking back now it happens with standard attributes so I will stop the thread hijack ;)

 

Where your site differs however is that yours displays [ - Custom Line #1: XXXXXXXX ] where mine misses off the text label and simply displays [ - XXXXXXXX ].  If I can get that fixed, the earlier problem wouldnt matter as I can see which is line 1, line 2 and line 3.  (same problem the poster above is having I think)

 

That's the exact same thing i'm seeing. No option label. I posted directly above you. I installed http://www.oscommerce.com/community/contri...,attribute+sort to get rid of my sorting problems, but I still have the no option name problem.

Link to comment
Share on other sites

That's the exact same thing i'm seeing.? No option label.? I posted directly above you.? I installed http://www.oscommerce.com/community/contri...,attribute+sort to get rid of my sorting problems, but I still have the no option name problem.

 

I figured it out, im gutted to say it was in the read me. so apologies to everyone having to read my posts. However I will spend the time enlightening you. The problem is, is that I had multiple TEXT fields defined in the table PRODUCT_OPTIONS_VALUES. (readme is explicit about only having one TEXT field)

 

What you need to do is go there via phpmyadmin and convert one of your existing text boxes to read as follows:

 

Edit | Delete | 0 | 1 | TEXT (0 for product_options_values_id is important)

 

You then need to go into your attributes for each product (bottom of page) and change the option value to TEXT where applicable.

 

I think this was everything that I done, it now works flawlessly.

 

* Solicitation

Edited by 241
Link to comment
Share on other sites

Your contrib really looks great - and I would really like to use it with static attributes - http://www.oscommerce.com/community/contributions,2143 - as I also need to add some "none-selectable options" - ie. attributes - which is then used with the "compare products" contribution, to form a nice looking product comparison page :)

 

I'm going to see if I can get it them working together myself - but perhaps it would be best to simply add the features of "static attributes" to "option type features" - in a way, so it's still supported by "compare products" - which btw. supports both contributions :)

 

If I get it working, I'll gladly give you a diff or whatever you want, so we can get a "definitive" options/attributes contrib out :)

Link to comment
Share on other sites

I figured it out, im gutted to say it was in the read me. so apologies to everyone having to read my posts.? However I will spend the time enlightening you.? The problem is, is that I had multiple TEXT fields defined in the table PRODUCT_OPTIONS_VALUES. (readme is explicit about only having one TEXT field)

 

What you need to do is go there via phpmyadmin and convert one of your existing text boxes to read as follows:

 

Edit | Delete | 0 | 1 | TEXT? ? ? (0 for product_options_values_id is important)

 

You then need to go into your attributes for each product (bottom of page) and change the option value to TEXT where applicable.

 

I think this was everything that I done, it now works flawlessly.?

 

Man, how embarassing. Thanks for the heads up. I guess I need to tell myself to RTFM.

Edited by 241
Link to comment
Share on other sites

Hmmm, no.

 

Actually, you do not even add the Option Values at the upper right. You just create your Product Options and then the ONE Option Values as explained, then add it to the product at the bottom and for the Option Values pull-down menu, you choose TEXT

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Very nice contrib indeed...

 

I have a question though. What if we want to be displayed as a list?

  • List No. 1 => Black
  • List No. 2 => Green
  • List No. 3 => Red
  • List No. 4 => Orange
  • List No. 5 => Blue

without using checkboxes, drop down list, or radio buttons...

 

I know you can use wysiwyg editor for this at the description page. But creating it from Products Attributes make it more dynamic and you can add/edit/delete these options more easily through Products Attributes.

Edited by Z3RatuL

There's a diference between living & BEING ALIVE!

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I am successfully using the Option Type Feature, but I notice that customers sometimes forget to enter the required data that is asked for in the fields. How would I go about making those fields required? I assume javascript is the way to go, but I'm not sure about the code or where to place it.

 

Anyone else done this?

 

Thanks!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...