|
SAlut à tous,
je viens de faire une page permettant d'afficher la liste complete des produits contenu dans la base avec leur état : soit actif ou inactif.
Pour faire la liste, je suis parti de la contrib allproduct et en voici le code apres mes quelques modifs.
| CODE | <?php /* $Id: stats_products_viewed.php,v 1.2 2003/09/24 15:18:15 wilt 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'); ?> <!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" src="includes/general.js"></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"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td align="left" class="dataTableHeadingContent">Produit</td> <td align="center" class="dataTableHeadingContent">Status</td>
</tr> <?php
$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); while ($languages = tep_db_fetch_array($languages_query)) { $languages_array[] = array('id' => $languages['languages_id'], 'name' => $languages['name'], 'code' => $languages['code'], 'image' => $languages['image'], 'directory' => $languages['directory']); } for ($i=0; $i<sizeof($languages_array); $i++) { $this_language_id = $languages_array[$i]['id']; $this_language_name = $languages_array[$i]['name']; $this_language_code = $languages_array[$i]['code']; $this_language_image = $languages_array[$i]['image']; $this_language_directory = $languages_array[$i]['directory']; echo " <tr>\n";
$products_query = tep_db_query("SELECT p.products_id, p.products_status, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id=s.products_id WHERE p.products_id = pd.products_id AND pd.language_id = $this_language_id ORDER BY pd.products_name");
$products_array = array(); while($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id'=> $products['products_id'], 'name' => $products['products_name'], 'status' => $products['products_status'],); } // $cPath = tep_db_query("SELECT categories_id from" . TABLE_CATEGORIES . "c," . TABLE_CATEGORIES_ID);
$num_prods = sizeof($products_array); // This optimizes that slow FOR loop...
for ($i = 0; $i < $num_prods; $i++) // Traverse Rows { $this_id = $products_array[$i]['id']; $this_name = $products_array[$i]['name']; $this_status = $products_array[$i]['status'];
echo "<tr class='dataTableRow'>"; echo "<td class='dataTableContent' align='left'>$this_name</td>"; //echo "<td class='dataTableContent' align='center'>" . $cPath . "</td>";
//Début Affichage Status if ($this_status == '1') { echo "<td class='dataTableContent' align='center'>" . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=0&products_id=' . $this_id . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a></td>'; } else { echo "<td class='dataTableContent' align='center'>" . '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=setflag&flag=1&products_id=' . $this_id . '&cPath=' . $cPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a> ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10) . '</td>'; } //Fin Affichage Status
echo "</tr>\n"; } } ?> </table></td> </tr> </table></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //-->
<!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> |
L'affichage des produits fonctionne ainsi que l'état des produits par les icones vertes ou rouges. J'ai repris le meme affichage que si l'on devait passé par le catégories/Produits. Tout va bien juste qu'au changement d'état du produit. Il ne trouve pas le lien car il manque le cPatch ou plutot la valeur de la variable $cPath. J'ai pu régler le probleme sur le product_id mais là, je séche sur le cPath Donc, j'aurai besoin d'une aide pour finir ce petit bout de code //////////////////////////////// J ai remis le post dans contributions ////////////////////////////////
--------------------
MS2.2-RC1-FR W3C Creload 6.0 SP1.2 RC2, Template Thema 5
|