Qtpro :: problème de requete

Messagepar cymbeline » Mer 16 Mai 2007, 12:18

Bonjour,

Je suis dans l'installation de QT pro, j'ai déjà réalisé la partie admin.

Dans le backoffice, je selectionne un produit et si je clique sur le bouton "inventaire" ou "stock", j'obtiens une erreur de requete :

Code: Tout sélectionner
1146 - La table 'oscss.products_description' n'existe pas

select products_name,products_options_name as _option,products_attributes.options_id as _option_id,products_options_values_name as _value,products_attributes.options_values_id as _value_id from products_description, products_attributes,products_options,products_options_values where products_attributes.products_id=products_description.products_id and products_attributes.products_id=29 and products_attributes.options_id=products_options.products_options_id and products_attributes.options_values_id=products_options_values.products_options_values_id and products_description.language_id=1 and products_options_values.language_id=1 and products_options.products_options_track_stock=1 and products_options.language_id=1 order by products_attributes.options_id, products_attributes.options_values_id

[TEP STOP]

Je ne vois meme pas d'ou part cette requete avec oscss ??

Dans ma dB les tables sont prefixées OSC_ :(

Help ?

Merci
cymbeline
Membre très actif
 
Messages: 265
Inscription: Mer 06 Sep 2006, 20:01
Localisation: Nevers

Messagepar Mali » Mer 16 Mai 2007, 14:30

t'as rentré une requete SQL ? laquelle ?
PS : tu peux placer le lien de cette contrib ? (ou du moins sa version)

merci

mali
Mali
Membre très actif
 
Messages: 234
Inscription: Mer 29 Mar 2006, 20:39

Messagepar cymbeline » Mer 16 Mai 2007, 15:13

En fait la requete par du fichier : adminstock.php, l'appel se fait je pense lorsque l'on clique sur le bouton inventaire et devrait afficher un page avec le stock par produit et attributs.

Code: Tout sélectionner
$q=tep_db_query($sql="select products_name,products_options_name as _option,products_attributes.options_id as _option_id,products_options_values_name as _value,products_attributes.options_values_id as _value_id from ".
                  "products_description, products_attributes,products_options,products_options_values where ".
                  "products_attributes.products_id=
           and ".
                  "products_attributes.products_id=" . (int)$VARS['product_id'] . " and ".
                  "products_attributes.options_id=products_options.products_options_id and ".
                  "products_attributes.options_values_id=products_options_values.products_options_values_id and ".
                  "products_description.language_id=" . (int)$languages_id . " and ".
                  "products_options_values.language_id=" . (int)$languages_id . " and products_options.products_options_track_stock=1 and ".
                  "products_options.language_id=" . (int)$languages_id . " order by products_attributes.options_id, products_attributes.options_values_id");

Ma base est oscss
les prefixes des tables sont : osc

dans mon fichier adminincludesconfigure.php j'ai bien
Code: Tout sélectionner
 define('DB_DATABASE', 'oscss');
 define('DB_TABLE_PREFIX', 'osc_');

Dans mon fichier adminincludesdatabase_table.php, j'ai ajouté ceci

Code: Tout sélectionner
//++++ QT Pro: Begin Changed code
  define('TABLE_PRODUCTS_STOCK', DB_TABLE_PREFIX .  'products_stock');
//++++ QT Pro: End Changed Code

la requete fait appel à products_description, il est renseigné ainsi dans ce meme fichier :

define('TABLE_PRODUCTS_DESCRIPTION', DB_TABLE_PREFIX . 'products_description');

Je cherche l'erreur, c'est un peu comme si i y avait omission du DB_TABLE_PREFIX quelque part ?, je met ci dessous le fichier stock.php complet si quelqu'un voit quelque chose.

Merci

stock.php
Code: Tout sélectionner
<?php
/*
      QT Pro Version 4.1
 
      stock.php
 
      Contribution extension to:
        osCommerce, Open Source E-Commerce Solutions
        http://www.oscommerce.com
     
      Copyright (c) 2004, 2005 Ralph Day
      Released under the GNU General Public License
 
      Based on prior works released under the GNU General Public License:
        QT Pro prior versions
          Ralph Day, October 2004
          Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman
          FREEZEHELL - 08/11/2003 freezehell@hotmail.com Copyright (c) 2003 IBWO
          Joseph Shain, January 2003
        osCommerce MS2
          Copyright (c) 2003 osCommerce
         
      Modifications made:
        11/2004 - Add input validation
                  clean up register globals off problems
                  use table name constant for products_stock instead of hard coded table name
        03/2005 - Change $_SERVER to $HTTP_SERVER_VARS for compatibility with older php versions
       
*******************************************************************************************
 
      QT Pro Stock Add/Update
 
      This is a page to that is linked from the osCommerce admin categories page when an
      item is selected.  It displays a products attributes stock and allows it to be updated.

*******************************************************************************************

  $Id: stock.php,v 1.00 2003/08/11 14:40:27 IBWO Exp $

  Enhancement module for osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
 
  Credit goes to original QTPRO developer.
  Attributes Inventory - FREEZEHELL - 08/11/2003 freezehell@hotmail.com
  Copyright (c) 2003 IBWO

  Released under the GNU General Public License
*/
  require('includes/application_top.php');

  if ($HTTP_SERVER_VARS['REQUEST_METHOD']=="GET") {
    $VARS=$_GET;
  } else {
    $VARS=$_POST;
  }
  if ($VARS['action']=="Add") {
    $inputok = true;
    if (!(is_numeric($VARS['product_id']) and ($VARS['product_id']==(int)$VARS['product_id']))) $inputok = false;
    while(list($v1,$v2)=each($VARS)) {
      if (preg_match("/^option(d+)$/",$v1,$m1)) {
        if (is_numeric($v2) and ($v2==(int)$v2)) $val_array[]=$m1[1]."-".$v2;
        else $inputok = false;
      }
    }
    if (!(is_numeric($VARS['quantity']) and ($VARS['quantity']==(int)$VARS['quantity']))) $inputok = false;

    if (($inputok)) {
      sort($val_array, SORT_NUMERIC);
      $val=join(",",$val_array);
      $q=tep_db_query("select products_stock_id as stock_id from " . TABLE_PRODUCTS_STOCK . " where products_id=" . (int)$VARS['product_id'] . " and products_stock_attributes='" . $val . "' order by products_stock_attributes");
      if (tep_db_num_rows($q)>0) {
        $stock_item=tep_db_fetch_array($q);
        $stock_id=$stock_item[stock_id];
        if ($VARS['quantity']=intval($VARS['quantity'])) {
          tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity=" . (int)$VARS['quantity'] . " where products_stock_id=$stock_id");
        } else {
          tep_db_query("delete from " . TABLE_PRODUCTS_STOCK . " where products_stock_id=$stock_id");
        }
      } else {
        tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " values (0," . (int)$VARS['product_id'] . ",'$val'," . (int)$VARS['quantity'] . ")");
      }
      $q=tep_db_query("select sum(products_stock_quantity) as summa from " . TABLE_PRODUCTS_STOCK . " where products_id=" . (int)$VARS['product_id'] . " and products_stock_quantity>0");
      $list=tep_db_fetch_array($q);
      $summa= (empty($list[summa])) ? 0 : $list[summa];
      tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity=$summa where products_id=" . (int)$VARS['product_id']);
      if (($summa<1) && (STOCK_ALLOW_CHECKOUT == 'false')) {
        tep_db_query("update " . TABLE_PRODUCTS . " set products_status='0' where products_id=" . (int)$VARS['product_id']);
      }
    }
  }
  if ($VARS['action']=="Update") {
    tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity=" . (int)$VARS['quantity'] . " where products_id=" . (int)$VARS['product_id']);
    if (($VARS['quantity']<1) && (STOCK_ALLOW_CHECKOUT == 'false')) {
      tep_db_query("update " . TABLE_PRODUCTS . " set products_status='0' where products_id=" . (int)$VARS['product_id']);
    }
  }
  if ($VARS['action']=="Apply to all") {

  }
  $q=tep_db_query($sql="select products_name,products_options_name as _option,products_attributes.options_id as _option_id,products_options_values_name as _value,products_attributes.options_values_id as _value_id from ".
                  "products_description, products_attributes,products_options,products_options_values where ".
                  "products_attributes.products_id=
          and ".
                  "products_attributes.products_id=" . (int)$VARS['product_id'] . " and ".
                  "products_attributes.options_id=products_options.products_options_id and ".
                  "products_attributes.options_values_id=products_options_values.products_options_values_id and ".
                  "products_description.language_id=" . (int)$languages_id . " and ".
                  "products_options_values.language_id=" . (int)$languages_id . " and products_options.products_options_track_stock=1 and ".
                  "products_options.language_id=" . (int)$languages_id . " order by products_attributes.options_id, products_attributes.options_values_id");
 //list($product_name,$option_name,$option_id,$value,$value_id)
  if (tep_db_num_rows($q)>0) {
    $flag=1;
    while($list=tep_db_fetch_array($q)) {
      $options[$list[_option_id]][]=array($list[_value],$list[_value_id]);
      $option_names[$list[_option_id]]=$list[_option];
      $product_name=$list[products_name];
    }
 }
 //Commented out so items with 0 stock will show up in the stock report.
 else {
  //  $flag=0;
   $q=tep_db_query("select products_quantity,products_name from " . TABLE_PRODUCTS . " p,products_description pd where pd.products_id=" . (int)$VARS['product_id'] . " and p.products_id=" . (int)$VARS['product_id']);
    $list=tep_db_fetch_array($q);
    $db_quantity=$list[products_quantity];
    $product_name=stripslashes($list[products_name]);
  }
?>
<!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">
</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="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo PRODUCTS_STOCK.": $product_name" . '<td align="right"><a href="' . tep_href_link(FILENAME_CATEGORIES, '&pID=' . $product_id . '&action=new_product') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a></td><br><br>'; ?></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><form action="<? echo $PHP_SELF;?>" method=get>
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
<?php
  $title_num=1;
  if ($flag) {
    while(list($k,$v)=each($options)) {
      echo "<td class="dataTableHeadingContent">&nbsp;&nbsp;$option_names[$k]</td>";
      $title[$title_num]=$k;
    }
    echo "<td class="dataTableHeadingContent"><span class=smalltext>Quantity</span></td><td width="100%">&nbsp;</td>";
    echo "</tr>";
    $q=tep_db_query("select * from " . TABLE_PRODUCTS_STOCK . " where products_id=" . $VARS['product_id'] . " order by products_stock_attributes");
    while($rec=tep_db_fetch_array($q)) {
      $val_array=explode(",",$rec[products_stock_attributes]);
      echo "<tr>";
      foreach($val_array as $val) {
        if (preg_match("/^(d+)-(d+)$/",$val,$m1)) {
          echo "<td class=smalltext>&nbsp;&nbsp;&nbsp;".tep_values_name($m1[2])."</td>";
        } else {
          echo "<td>&nbsp;</td>";
        }
      }
      for($i=0;$i<sizeof($options)-sizeof($val_array);$i++) {
        echo "<td>&nbsp;</td>";
      }
      echo "<td class=smalltext>&nbsp;&nbsp;&nbsp;&nbsp;$rec[products_stock_quantity]</td><td>&nbsp;</td></tr>";
    }
    echo "<tr>";
    reset($options);
    $i=0;
    while(list($k,$v)=each($options)) {
      echo "<td class=dataTableHeadingRow><select name=option$k>";
      foreach($v as $v1) {
        echo "<option value=".$v1[1].">".$v1[0];
      }
      echo "</select></td>";
      $i++;
    }
  } else {
    $i=1;
    echo "<td class=dataTableHeadingContent>Quantity</td>";
  }
  echo "<td class=dataTableHeadingRow><input type=text name=quantity size=4 value="" . $db_quantity . ""><input type=hidden name=product_id value="" . $VARS['product_id'] . "">&nbsp;</td><td width="100%" class=dataTableHeadingRow>&nbsp;<input type=submit name=action value=" . ($flag?"Add":"Update") . ">&nbsp;</td><td width="100%" class=dataTableHeadingRow>&nbsp;</td>";
?>
              </tr>
            </table></td>
          </tr>
        </table>
        </form></td>
      </tr>
<tr><td><br>
<?php  echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, '', 'NONSSL') . '" class="menuBoxContentLink">Back to Products Category</a> &nbsp;&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_STATS_LOW_STOCK_ATTRIB, '', 'NONSSL') . '" class="menuBoxContentLink">Back to Low Stock Report for Attributes</a>';?>
</td></tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
cymbeline
Membre très actif
 
Messages: 265
Inscription: Mer 06 Sep 2006, 20:01
Localisation: Nevers

Messagepar cymbeline » Mer 16 Mai 2007, 20:42

RE :

Dans adminstock.php

J'ai modifié la requête comme ceci

Code: Tout sélectionner
  $q=tep_db_query($sql="SELECT products_name,products_options_name
                        AS _option,osc_products_attributes.options_id
           AS _option_id,products_options_values_name
           AS _value,osc_products_attributes.options_values_id
            AS _value_id
           FROM "."osc_products_description, osc_products_attributes,osc_products_options,osc_products_options_values
           WHERE "."osc_products_attributes.products_id=osc_products_description.products_id
            AND "."osc_products_attributes.products_id=" . (int)$VARS['product_id'] . "
            AND "."osc_products_attributes.options_id=osc_products_options.products_options_id
           AND "."osc_products_attributes.options_values_id=osc_products_options_values.products_options_values_id and ".
                               "osc_products_description.language_id=" . (int)$languages_id . "
              AND "."osc_products_options_values.language_id=" . (int)$languages_id . "
            AND osc_products_options.products_options_track_stock=1
            AND "."osc_products_options.language_id=" . (int)$languages_id . "
           ORDER BY osc_products_attributes.options_id, osc_products_attributes.options_values_id");

et aussi celle-ci juste après

Code: Tout sélectionner
//Commented out so items with 0 stock will show up in the stock report.
 else {
  //  $flag=0;
   $q=tep_db_query("SELECT products_quantity,products_name
                    FROM " . TABLE_PRODUCTS . " p,osc_products_description pd where pd.products_id=" . (int)$VARS['product_id'] . "
          AND p.products_id=" . (int)$VARS['product_id']);
    $list=tep_db_fetch_array($q);
    $db_quantity=$list[products_quantity];
    $product_name=stripslashes($list[products_name]);
  }

j'ai aussi rajouter ça, sinon, les menus du site partent en sucette :

<td class="menuboxheading" align="center"><?php echo strftime(DATE_FORMAT_LONG); ?></td>

dans

Code: Tout sélectionner
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo TABLE_HEADING_TITLE; ?></td>
            <td class="menuboxheading" align="center"><?php echo strftime(DATE_FORMAT_LONG); ?></td>
          </tr>
        </table></td>

Cela fonctionne :P

++ pour la suite
Dernière édition par cymbeline le Mer 16 Mai 2007, 20:43, édité 1 fois.
cymbeline
Membre très actif
 
Messages: 265
Inscription: Mer 06 Sep 2006, 20:01
Localisation: Nevers


Retourner vers Plugin

 


  • Articles en relation
    Réponses
    Vus
    Dernier message

Qui est en ligne

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

cron