liste déroulante d'attribut et changement d'image

Messagepar ornythorink » Ven 09 Fév 2007, 18:19

Bonjour

j'espère qu'il n'y pas déjà une réponse sinon merci de me ré-aiguiller ;)
Le sytème d'attribut est plutôt bien fait j'ai compris comment il fonctionnait en utilisant la boutique de test,
mais avant de choisir oscss qui me plait bien je voudrait être sur de savoir si on peut faire une chose:

-lorsque que l'on change un attribut d'un produit comme la couleur, ce serait vraiment bien que l'image du produit change dynamiquement, je pourrai le recoder moi même mais pourquoi réinventer la roue ou choisir la mauvaise solution

merci d'avance, très agréable se suivre les questions /réponses ici wink.gif

ornythorink
ornythorink
Membre inactif
 
Messages: 3
Inscription: Jeu 16 Nov 2006, 14:15

Messagepar masremi » Jeu 05 Fév 2009, 00:30

Bonjour,

Je vois que c'est une vieille proposition ... mais qui me serait grandement utile !!! quelqu'un avait travaillé dessus ? :rolleyes:

Avez-vous une solution pour mettre une image sur un "attribut" ? je sais que cela existe avec oscommerce mais j'ai pas trouvé la réponse ici ! Peut etre ai-je mal cherché !!!

Merci d'avance. :)
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar j4k » Jeu 05 Fév 2009, 10:23

si il existe une contrib oscommerce, il est possible de la rendre compatible oscss.

Sinon il est facile de développer ce genre de fonctionnalité à partir des attributs et un peu d'ajax.
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar masremi » Jeu 05 Fév 2009, 15:13

Salut !

En fait, je viens juste d'installer et découvrir oscss !!! et je dois dire que je suis un peu perdu dans le code et je ne sais pas si les contributions oscommerce sont facilement convertible !

Car j'ai vu que qpro par exemple semble etre un vrai calvaire à mettre en place ...

Dans mon cas, je voudrais seulement une image, la contributio oscommerce est celle ci : Image sur attribut

Si tu as un peu de temps, regarde s'il te semble facilement transposable. ;)

De mon coté j'y jete un coup d'oeil à peine je réussi à trouver 2-3 heures pour faire des essais !!!

Merci d'avance de vos suggestions. :)
Dernière édition par masremi le Jeu 05 Fév 2009, 15:14, édité 1 fois.
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar masremi » Sam 07 Fév 2009, 14:16

Ciao a tous !!!!

Bon alors voila le début de mes recherches :
J'ai déjà trouvé où mettre les options !!!
Fichier products_attributes.php dans le répertoire /admin/includes/langages/french
Code: Tout sélectionner
// ajout de l'option image attribut
define('TEXT_PRODUCTS_ATTRIBUT_IMAGE', 'Image de l'attribut :');
define('TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE', 'Image de l'attribut :');
define('TABLE_HEADING_OPT_IMAGE', 'Image');

Puis dnas le fichier products_attributes.php du répertoire /admin
Remplacer de la ligne 521 à 639 l'ancienne "form" par la nouvelle :
Code: Tout sélectionner
                <td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
              </tr>
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</td>
                <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE; ?>&nbsp;</td>
       <? //ajout de la colonne "Image" ?>
       <td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_IMAGE; ?>&nbsp;</td>
                <td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
              </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 .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15" value="' . $value_name['products_options_values_name'] . '">&nbsp;<br>';
        }
?>
                <td align="center" class="smallText">&nbsp;<?php echo $values_values['products_options_values_id']; ?><input type="hidden" name="value_id" value="<?php echo $values_values['products_options_values_id']; ?>">&nbsp;</td>
                <td align="center" class="smallText">&nbsp;<?php echo "n"; ?><select name="option_id">
<?php
        $options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by products_options_name");
        while ($options_values = tep_db_fetch_array($options)) {
          echo "n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '"';
          if ($values_values['products_options_id'] == $options_values['products_options_id']) {
            echo ' selected';
          }
          echo '>' . $options_values['products_options_name'] . '</option>';
        }
?>
                </select>&nbsp;</td>
                <td class="smallText"><?php echo $inputs; ?></td>
        <td align="center" class="smallText"><? echo TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE . tep_draw_file_field('categories_image'); ?></td>
                <td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</td>
<?php
        echo '</form>';
      } else {
?>
                <td align="center" class="smallText">&nbsp;<?php echo $values_values["products_options_values_id"]; ?>&nbsp;</td>
                <td align="center" class="smallText">&nbsp;<?php echo $options_name; ?>&nbsp;</td>
                <td class="smallText">&nbsp;<?php echo $values_name; ?>&nbsp;</td>
       <? //ajout d'une "image" miniature ?>
        <td align="center" class="smallText"><? echo TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE . tep_draw_file_field('categories_image'); ?></td>
                <td align="center" class="smallText">&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_value&value_id=' . $values_values['products_options_values_id'] . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $HTTP_GET_VARS['value_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>&nbsp;&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option_value&value_id=' . $values_values['products_options_values_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a>&nbsp;</td>
<?php
      }
      $max_values_id_query = tep_db_query("select max(products_options_values_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS_VALUES);
      $max_values_id_values = tep_db_fetch_array($max_values_id_query);
      $next_id = $max_values_id_values['next_id'];
    }
?>
              </tr>
              <tr>
                <td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
              </tr>
<?php
    if ($action != 'update_option_value') {
?>
              <tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
      echo '<form name="values" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_option_values&value_page=' . $value_page, 'NONSSL') . '" method="post">';
?>
                <td align="center" class="smallText">&nbsp;<?php echo $next_id; ?>&nbsp;</td>
                <td align="center" class="smallText">&nbsp;<select name="option_id">
<?php
      $options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
      while ($options_values = tep_db_fetch_array($options)) {
        echo '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
      }

      $inputs = '';
      for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
        $inputs .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15">&nbsp;<br>';
      }
?>
                </select>&nbsp;</td>
                <td class="smallText"><input type="hidden" name="value_id" value="<?php echo $next_id; ?>"><?php echo $inputs; ?></td>
        <td align="center" class="smallText"><? echo TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE . tep_draw_file_field('categories_image'); ?></td>
                <td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?>&nbsp;</td>
<?php
      echo '</form>';
?>
              </tr>
              <tr>
                <td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
              </tr>
<?php
    }
  }
?>
            </table></td>
          </tr>
        </table></td>
<!-- option value eof //-->
      </tr>
<!-- products_attributes //-->
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">&nbsp;<?php echo HEADING_TITLE_ATRIB; ?>&nbsp;</td>
            <td>&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>

Voila pour le début !!!
Il reste le plus dur ! changer les requetes !!!
Je ne pense pas qu'il soit nécessaire de rajouter un champs "image" dans la base de donnée des attributs. J'opterai pour créer un repertoire "attributs" dans le repertoire image en CHMOD 777 et d'y enregistrer les images en les nomants simplement par le ID de l'attribut. Plus facile à gere par la suite !!!
Ok je continue mes recherches dans les prochains jours. :cool:
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar masremi » Dim 08 Fév 2009, 16:43

Ok !

J'ai trouvé pour les requetes !!! Assez simple comme fonctionnement !!!

Code: Tout sélectionner
          if ( !empty($_FILES['attribut_image']['tmp_name']) )
      {
     
          $categories_image = new upload('attribut_image', DIR_FS_CATALOG_IMAGES .'/attribut/');
     }

Par contre, j'ai pas trouvé comment changer le nom de la photo ... pour le moment, la fonction garde le meme nom que l'original ... quelqu'un a déjà modifié cette fonction pour donner la possibilité de changer de nom ?

Merci d'avance de vos conseils !!!
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar masremi » Dim 08 Fév 2009, 20:28

Salut !!!

J'espère que vous pourrez m'aider parce que là je vois pas ...

Je trouve pas sur que page apparaissent les attributs dans la zone "client" ??? quel fichier il faut modifier ???

Merci d'avance de votre aide.
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar masremi » Mer 11 Fév 2009, 00:18

Salut à tous !!

Je suis un peu décu par le silence de ce forum ...

Bon je mets toutefois le code coté "admin" qui fonctionne bien :

- Créér un repertoire dans "../images" : moi je l'ai appelé "attribut" dans mon exemple

- Mettre le repertoire en CHMOD "777"

- Ouvrir le fichier ..admin/includes/langages/french/products_attributes.php et inserer à la fin (avant "?>" )
Code: Tout sélectionner
// ajout de l'option image attribut
define('TEXT_PRODUCTS_ATTRIBUT_IMAGE', 'Image de l'attribut :');
define('TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE', 'Image de l'attribut :');
define('TABLE_HEADING_OPT_IMAGE', 'Image');

- ouvrir le fichier admin/products_attributes.php et remplacer le code par celui-ci :
[code]<?php
/*
+-----------------------------------------------------------------------+
| osCSS Open Source E-commerce |
+-----------------------------------------------------------------------+
| Copyright (c) 2005 The osCSS developers |
| |
| http://www.oscss.org |
| |
| Portions Copyright (c) 2003 osCommerce |
+-----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the GPL license, |
| available at the following url: |
| http://www.oscss.org/license/2_0.txt. |
+-----------------------------------------------------------------------+
*/

require('includes/application_top.php');
$languages = tep_get_languages();

// >>> BEGIN REGISTER_GLOBALS
// These variables are accessed directly rather than through $HTTP_GET_VARS or $_GET later in this script
link_get_variable('option_page');
link_get_variable('value_page');
link_get_variable('attribute_page');
// <<< END REGISTER_GLOBALS

$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'];

for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {
$option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$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 . "')");
// insere image de l'attribut dans le repertoire image/attribut
if ( !empty($_FILES['attribut_image']['tmp_name']) )
{
$mon_image = new upload('attribut_image'); // charge l'image
$mon_image->set_destination(DIR_FS_CATALOG_IMAGES .'/attribut/'); // spécifie la directory
if ($mon_image->parse()) {
$mon_image->set_filename($value_id. '.jpg'); // ajoute le nom de l'image
if ($mon_image->save()) {
// suite code etc ...
// tep_db_query("UPDATE ".MA_TABLE." SET image = '".$mon_image->filename."' "); // Mise à jour dans la BDD
}
}
}

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) . "', '0')");

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_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']]);

tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "' 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 . "'");
// insere image de l'attribut dans le repertoire image/attribut
if ( !empty($_FILES['attribut_image']['tmp_name']) )
{
$mon_image = new upload('attribut_image'); // charge l'image
$mon_image->set_destination(DIR_FS_CATALOG_IMAGES .'/attribut/'); // spécifie la directory
if ($mon_image->parse()) {
$mon_image->set_filename($value_id. '.jpg'); // ajoute le nom de l'image
if ($mon_image->save()) {
// suite code etc ...
// tep_db_query("UPDATE ".MA_TABLE." SET image = '".$mon_image->filename."' "); // Mise à jour dans la BDD
}
}
}

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 . "'");

unlink(DIR_FS_CATALOG_IMAGES .'/attribut/' .(int)$value_id. '.jpg'); // efface l'image si l'attribut est effacé

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;
}
}
?>
<!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/general.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>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- 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">&nbsp;<?php echo $options_values['products_options_name']; ?>&nbsp;</td>
<td>&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?>&nbsp;</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">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_PRODUCT; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE; ?>&nbsp;</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">&nbsp;<?php echo $products_values['products_id']; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $products_values['products_name']; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $products_values['products_options_values_name']; ?>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;&nbsp;<?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>&nbsp;</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="2" class="pageHeading">&nbsp;<?php echo HEADING_TITLE_OPT; ?>&nbsp;</td>
<td align="right"><br><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="3" 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) . '"> &lt;&lt; </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) . '"> &gt;&gt; </a>';
}
?>
</td>
</tr>
<tr>
<td colspan="3"><?php echo tep_black_line(); ?></td>
</tr>
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
</tr>
<tr>
<td colspan="3"><?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" enctype="multipart/form-data>';
$inputs = '';
for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
$option_name = tep_db_query("select products_options_name 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 .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="20" value="' . $option_name['products_options_name'] . '">&nbsp;<br>';
}
?>
<td align="center" class="smallText">&nbsp;<?php echo $options_values['products_options_id']; ?><input type="hidden" name="option_id" value="<?php echo $options_values['products_options_id']; ?>">&nbsp;</td>
<td class="smallText"><?php echo $inputs; ?></td>
<td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</td>
<?php
echo '</form>' . "n";
} else {
?>
<td align="center" class="smallText">&nbsp;<?php echo $options_values["products_options_id"]; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $options_values["products_options_name"]; ?>&nbsp;</td>
<td align="center" class="smallText">&nbsp;<?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>&nbsp;&nbsp;<?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>&nbsp;</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="3"><?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 .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="option_name[' . $languages[$i]['id'] . ']" size="20">&nbsp;<br>';
}
?>
<td align="center" class="smallText">&nbsp;<?php echo $next_id; ?>&nbsp;</td>
<td class="smallText"><?php echo $inputs; ?></td>
<td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?>&nbsp;</td>
<?php
echo '</form>';
?>
</tr>
<tr>
<td colspan="3"><?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 colspan="3" class="pageHeading">&nbsp;<?php echo $values_values['products_options_values_name']; ?>&nbsp;</td>
<td>&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?>&nbsp;</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">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_PRODUCT; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</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">&nbsp;<?php echo $products_values['products_id']; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $products_values['products_name']; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $products_values['products_options_name']; ?>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;&nbsp;<?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>&nbsp;</td>
</tr>
<?php
}
?>
</table></td>
</tr>
<?php
} else {
?>
<tr>
<td colspan="3" class="pageHeading">&nbsp;<?php echo HEADING_TITLE_VAL; ?>&nbsp;</td>
<td>&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?>&nbsp;</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) . '"> &lt;&lt; </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) . '"> &gt;&gt;</a> ';
}
?>
</td>
</tr>
<tr>
<td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
</tr>
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE; ?>&nbsp;</td>
<? //ajout de la colonne "Image" ?>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_IMAGE; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
</tr>
<tr>
<td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
</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" enctype="multipart/form-data" >';
$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 .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15" value="' . $value_name['products_options_values_name'] . '">&nbsp;<br>';
}
?>
<td align="center" class="smallText">&nbsp;<?php echo $values_values['products_options_values_id']; ?><input type="hidden" name="value_id" value="<?php echo $values_values['products_options_values_id']; ?>">&nbsp;</td>
<td align="center" class="smallText">&nbsp;<?php echo "n"; ?><select name="option_id">
<?php
$options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "' order by products_options_name");
while ($options_values = tep_db_fetch_array($options)) {
echo "n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '"';
if ($values_values['products_options_id'] == $options_values['products_options_id']) {
echo ' selected';
}
echo '>' . $options_values['products_options_name'] . '</option>';
}
?>
</select>&nbsp;</td>
<td class="smallText"><?php echo $inputs; ?></td>
<td align="center" class="smallText"><? echo TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE . tep_draw_file_field('attribut_image'); ?></td>
<td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</td>
<?php
echo '</form>';
} else {
?>
<td align="center" class="smallText">&nbsp;<?php echo $values_values["products_options_values_id"]; ?>&nbsp;</td>
<td align="center" class="smallText">&nbsp;<?php echo $options_name; ?>&nbsp;</td>
<td class="smallText">&nbsp;<?php echo $values_name; ?>&nbsp;</td>
<? //ajout d'une "image" miniature ?>
<td align="center" class="smallText"><? echo '<img src="../images/attribut/' .$values_values["products_options_values_id"]. '.jpg" alt="" width="30" height="30">'; ?></td>
<td align="center" class="smallText">&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=update_option_value&value_id=' . $values_values['products_options_values_id'] . (isset($HTTP_GET_VARS['value_page']) ? '&value_page=' . $HTTP_GET_VARS['value_page'] : ''), 'NONSSL') . '">'; ?><?php echo tep_image_button('button_edit.gif', IMAGE_UPDATE); ?></a>&nbsp;&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_option_value&value_id=' . $values_values['products_options_values_id'], 'NONSSL') , '">'; ?><?php echo tep_image_button('button_delete.gif', IMAGE_DELETE); ?></a>&nbsp;</td>
<?php
}
$max_values_id_query = tep_db_query("select max(products_options_values_id) + 1 as next_id from " . TABLE_PRODUCTS_OPTIONS_VALUES);
$max_values_id_values = tep_db_fetch_array($max_values_id_query);
$next_id = $max_values_id_values['next_id'];
}
?>
</tr>
<tr>
<td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
</tr>
<?php
if ($action != 'update_option_value') {
?>
<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
echo '<form name="values" action="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=add_product_option_values&value_page=' . $value_page, 'NONSSL') . '" method="post" enctype="multipart/form-data" >'; // ajout enctype="multipart/form-data" pour envoyer image
?>
<td align="center" class="smallText">&nbsp;<?php echo $next_id; ?>&nbsp;</td>
<td align="center" class="smallText">&nbsp;<select name="option_id">
<?php
$options = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
while ($options_values = tep_db_fetch_array($options)) {
echo '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
}

$inputs = '';
for ($i = 0, $n = sizeof($languages); $i < $n; $i ++) {
$inputs .= $languages[$i]['code'] . ':&nbsp;<input type="text" name="value_name[' . $languages[$i]['id'] . ']" size="15">&nbsp;<br>';
}
?>
</select>&nbsp;</td>
<td class="smallText"><input type="hidden" name="value_id" value="<?php echo $next_id; ?>"><?php echo $inputs; ?></td>
<? // Ajout de l'image attribut ?>
<td align="center" class="smallText"><? echo TEXT_EDIT_PRODUCTS_ATTRIBUT_IMAGE . tep_draw_file_field('attribut_image'); ?></td>
<td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?>&nbsp;</td>
<?php
echo '</form>';
?>
</tr>
<tr>
<td colspan="5"><?php echo tep_black_line(); ?></td><? // colspan passe à 5 colonnes au lieu de 4 ?>
</tr>
<?php
}
}
?>
</table></td>
</tr>
</table></td>
<!-- option value eof //-->
</tr>
<!-- products_attributes //-->
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading">&nbsp;<?php echo HEADING_TITLE_ATRIB; ?>&nbsp;</td>
<td>&nbsp;<?php echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '', '1', '53'); ?>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<?php
if ($action == 'update_attribute') {
$form_action = 'update_product_attribute';
} else {
$form_action = 'add_product_attributes';
}

if (!isset($attribute_page)) {
$attribute_page = 1;
}
$prev_attribute_page = $attribute_page - 1;
$next_attribute_page = $attribute_page + 1;
?>
<td><form name="attributes" action="<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=' . $form_action . '&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page); ?>" method="post" enctype="multipart/form-data" ><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td colspan="7" class="smallText">
<?php
$per_page = MAX_ROW_LISTS_OPTIONS;
$attributes = "select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pa.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name";
$attribute_query = tep_db_query($attributes);

$attribute_page_start = ($per_page * $attribute_page) - $per_page;
$num_rows = tep_db_num_rows($attribute_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;

$attributes = $attributes . " LIMIT $attribute_page_start, $per_page";

// Previous
if ($prev_attribute_page) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $prev_attribute_page) . '"> &lt;&lt; </a> | ';
}

for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $attribute_page) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $i) . '">' . $i . '</a> | ';
} else {
echo '<b><font color="red">' . $i . '</font></b> | ';
}
}

// Next
if ($attribute_page != $num_pages) {
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'attribute_page=' . $next_attribute_page) . '"> &gt;&gt; </a>';
}
?>
</td>
</tr>
<tr>
<td colspan="7"><?php echo tep_black_line(); ?></td>
</tr>
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_ID; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_PRODUCT; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_NAME; ?>&nbsp;</td>
<td class="dataTableHeadingContent">&nbsp;<?php echo TABLE_HEADING_OPT_VALUE; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="right">&nbsp;<?php echo TABLE_HEADING_OPT_PRICE; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_OPT_PRICE_PREFIX; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="center">&nbsp;<?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
</tr>
<tr>
<td colspan="7"><?php echo tep_black_line(); ?></td>
</tr>
<?php
$next_id = 1;
$attributes = tep_db_query($attributes);
while ($attributes_values = tep_db_fetch_array($attributes)) {
$products_name_only = tep_get_products_name($attributes_values['products_id']);
$options_name = tep_options_name($attributes_values['options_id']);
$values_name = tep_values_name($attributes_values['options_values_id']);
$rows++;
?>
<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<?php
if (($action == 'update_attribute') && ($HTTP_GET_VARS['attribute_id'] == $attributes_values['products_attributes_id'])) {
?>
<td class="smallText">&nbsp;<?php echo $attributes_values['products_attributes_id']; ?><input type="hidden" name="attribute_id" value="<?php echo $attributes_values['products_attributes_id']; ?>">&nbsp;</td>
<td class="smallText">&nbsp;<select name="products_id">
<?php
$products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");
while($products_values = tep_db_fetch_array($products)) {
if ($attributes_values['products_id'] == $products_values['products_id']) {
echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>';
} else {
echo "n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';
}
}
?>
</select>&nbsp;</td>
<td class="smallText">&nbsp;<select name="options_id">
<?php
$options = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");
while($options_values = tep_db_fetch_array($options)) {
if ($attributes_values['options_id'] == $options_values['products_options_id']) {
echo "n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '" SELECTED>' . $options_values['products_options_name'] . '</option>';
} else {
echo "n" . '<option name="' . $options_values['products_options_name'] . '" value="' . $options_values['products_options_id'] . '">' . $options_values['products_options_name'] . '</option>';
}
}
?>
</select>&nbsp;</td>
<td class="smallText">&nbsp;<select name="values_id">
<?php
$values = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id ='" . $languages_id . "' order by products_options_values_name");
while($values_values = tep_db_fetch_array($values)) {
if ($attributes_values['options_values_id'] == $values_values['products_options_values_id']) {
echo "n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '" SELECTED>' . $values_values['products_options_values_name'] . '</option>';
} else {
echo "n" . '<option name="' . $values_values['products_options_values_name'] . '" value="' . $values_values['products_options_values_id'] . '">' . $values_values['products_options_values_name'] . '</option>';
}
}
?>
</select>&nbsp;</td>
<td align="right" class="smallText">&nbsp;<input type="text" name="value_price" value="<?php echo $attributes_values['options_values_price']; ?>" size="6">&nbsp;</td>
<td align="center" class="smallText">&nbsp;<input type="text" name="price_prefix" value="<?php echo $attributes_values['price_prefix']; ?>" size="2">&nbsp;</td>
<td align="center" class="smallText">&nbsp;<?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?>&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '&attribute_page=' . $attribute_page, 'NONSSL') . '">'; ?><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>&nbsp;</td>
<?php
if (DOWNLOAD_ENABLED == 'true') {
$download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount
from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "
where products_attributes_id='" . $attributes_values['products_attributes_id'] . "'";
$download_query = tep_db_query($download_query_raw);
if (tep_db_num_rows($download_query) > 0) {
$download = tep_db_fetch_array($download_query);
$products_attributes_filename = $download['products_attributes_filename'];
$products_attributes_maxdays = $download['products_attributes_maxdays'];
$products_attributes_maxcount = $download['products_attributes_maxcount'];
}
?>
<tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
<td>&nbsp;</td>
<td colspan="5">
<table>
<tr class="<?php echo (!($rows % 2)? 'attributes-even' : 'attributes-odd');?>">
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_DOWNLOAD; ?>&nbsp;</td>
<td class="smallText"><?php echo TABLE_TEXT_FILENAME; ?></td>
<td class="smallText"><?php echo tep_draw_input_field('products_attributes_filename', $products_attributes_filename, 'size="15"'); ?>&nbsp;</td>
<td class="smallText"><?php echo TABLE_TEXT_MAX_DAYS; ?></td>
<td class="smallText"><?php echo tep_draw_input_field('products_attributes_maxdays', $products_attributes_maxdays, 'size="5"'); ?>&nbsp;</td>
<td class="smallText"><?php echo TABLE_TEX
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar j4k » Mer 11 Fév 2009, 11:16

Pour le frontoffice, le code php est séparé du html. A la racine se trouvent les fonctions php à modifier, et les page html se trouvent dans includes/content/

Fais nous part de ta progression et si ça bloque décris quel sont les soucis.
Je pense que c'est une fontionnalité qui peut être ajoutée au noyau d'une future version.
~ osCSS 1.2.1 ~
Avatar de l’utilisateur
j4k
Site Admin
 
Messages: 1259
Inscription: Mer 27 Avr 2005, 09:13
Localisation: France

Messagepar masremi » Jeu 12 Fév 2009, 20:23

Ok !!!

Merci beaucoup !!!

Bon malheureusement, pour des donner technique lier à internet explorer, on ne peut pas mettre de photos dans un menu déroulants ... il faudra donc passer par un menu radio. Si vous avez beaucoup d'attributs, cette solution est donc peu envisageable ...

Voici donc le code de la partie front-office :

Dans le fichier includes/functions/html_output.php ajouter :
Code: Tout sélectionner
// Output a form radio field permettant de voir l'image de l'attributs
function tep_radiobutton_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<table border="0" cellpadding="1" cellspacing="0"><label name="' . tep_output_string($name) . '"';

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);

for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<tr><td><input checked type="radio" name="' . tep_output_string($name) . '" style:"vertical-align:middle;" value="' . tep_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' SELECTED';
}

$field .= '><img src="images/attribut/' .tep_output_string($values[$i]['id']). '.jpg" alt="" width="100" height="100">   ' . tep_output_string($values[$i]['text'], array('"' => '"', ''' => ''', '<' => '<', '>' => '>')) . '</td></tr>';
}
$field .= '</label></table>';

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
}

puis dans le fichier includes/content/product_info.php
rechercher :
Code: Tout sélectionner
<?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', 'product_option',$products_options_array, $selected_attribute); ?>

Et remplacer par :
Code: Tout sélectionner
 <?php echo tep_radiobutton_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); // change le select par un choix radio pour inserer la photo ?>

Et voila le tour est joué !!! vous pouvez maintenant proposer à vos clients la photo de l'attribut !!!
Pour modifier l'aspect, il faut travailler sur la fonction. A vous de choisir les éléments que vous souhaitez afficher et la mis en page.
Dernière édition par masremi le Jeu 12 Fév 2009, 20:24, édité 1 fois.
masremi
Membre actif
 
Messages: 13
Inscription: Mar 03 Fév 2009, 01:31

Messagepar cynic- » Ven 13 Fév 2009, 12:29

Bienvenue à toi MASREMI et merci pour ton code ; je m'empresserai de le tester quand j'aurai un peu de temps.

En tout cas bravo :)
cynic-
Site Admin
 
Messages: 694
Inscription: Mar 04 Déc 2007, 13:04

Messagepar Grenouye » Dim 01 Nov 2009, 04:00

Bonjour
J'ai essayé ton code et ça marche très bien.
Mon problème est que je peux avoir une dizaine d'options (couleur) pour certains produits, je me retrouve donc avec une liste assez longue d'images.
Je n'arrive pas à changer l'aspect de la liste d'option. Quelqu'un pourrait-il me conseiller pour réussir à réorganiser les images des options, en ne les plaçant pas sur une seule colonne par exemple ?
Merci en tout cas pour ce code, je cherchais en fait comment avoir un menu déroulant classique des options mais que le choix de l'option (de couleur donc) changeait l'image du produit (n'avoir qu'une seule image changeante).
Grenouye
Membre actif
 
Messages: 52
Inscription: Sam 07 Fév 2009, 20:25

Messagepar Grenouye » Dim 01 Nov 2009, 14:44

En fait je vais laisser tomber. Le problème est que pour les produits avec options mais sans photo différente je vais être obligé de mettre une photo à chaque fois.
Je vais juste ajouter une photo avec toutes les couleurs numérotées dans l'admin et remettre le choix d'option couleur en menu déroulant.
Grenouye
Membre actif
 
Messages: 52
Inscription: Sam 07 Fév 2009, 20:25


Retourner vers Developpement

 


  • Articles en relation
    Réponses
    Vus
    Dernier message

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité

cron