osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> [post à effacer]affichage des produits coté admin, avec état du produit
wumpus
posté 19 Jan 2005, 12:55
Message #1


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 254
Inscrit : 18-March 04
Lieu : à 20 Km du Havre
Membre no 2148



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) . '&nbsp;&nbsp;<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>&nbsp;&nbsp;' . 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. biggrin.gif

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 sad.gif

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
Go to the top of the page
 

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 22nd May 2013 - 17:53
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)