Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Stock view


Maccan

Recommended Posts

Pls heeeelp!!!! :'(

 

 

Have QTpro installed and tried the contrib Stockview for qtpro but it has an error.

 

Example from stockview report:

 

Tickets ID Tickets name Tickets model Tickets status Type Quantity Total Quantity

203 small body 07751 60 0 62/68 15

203 small body 07751 60 0 74/80 15

203 small body 07751 60 0 86/92 15

225 small tunika 07156 60 0 62/68 55

225 small tunika 07156 60 0 74/80 55

225 small tunika 07156 60 0 86/92 55

225 small tunika 07156 60 0 98/104 55

225 small tunika 07156 60 0 110/116 55

225 small tunika 07156 60 0 122/128 55

225 small tunika 07156 60 0 134/140 55

 

As you can see the Quantity is incorrect, it uses the total stock value for all attributes or perhaps shows no Type Quantity.

 

But if I check the product and the page "stock" from qtpro it shows the correct quantity:

 

Products stock: small body

 

Storlek Quantity

62/68 4

74/80 9

86/92 2

 

So this page can accually see the correct quantity.

 

I am stuck here and can not see how to get this to work....

Can anybody help me to see what code I need to get the stockview to work?

 

 

*******Here are the code from the not working "stockview.php" from stockview for qtpro*********************************

 

<?php

/*

$Id: stockview.php,v 1.1 2006/02/26

 

osCommerce StockViewer with Quantity per Attribute

 

Contribution based on:

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 - 2006 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/general.js"></script>

</head>

<body>

<!-- 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 width="700" class="infoBoxContents">

<?

echo "<tr class=\"dataTableHeadingRow\"><td class=\"dataTableHeadingContent\"><b>". 'Tickets ID' . "</b></td><td class=\"dataTableHeadingContent\"><b>" . 'Tickets name' . "</b></td> <td class=\"dataTableHeadingContent\"><b>" . 'Tickets model' . "</b></td> <td class=\"dataTableHeadingContent\"><b>" . 'Tickets status' . "</b></td><td class=\"dataTableHeadingContent\"><b>" . 'Type' . "</b></td><td class=\"dataTableHeadingContent\"><b>" . 'Quantity' . "</b></td><td class=\"dataTableHeadingContent\"><b>". 'Total Quantity' . "</b></td> </tr>";

$result = mysql_query("SELECT * FROM products, products_description, products_attributes, products_options_values WHERE products.products_id = products_description.products_id and products.products_id = products_attributes.products_id and products_description.language_id = '" . $languages_id . "' and products_options_values.language_id = '" . $languages_id . "' and products_attributes.options_values_id = products_options_values.products_options_values_id ORDER BY products_description.products_name");

// echo "SELECT * FROM products, products_description, products_attributes, products_options_values WHERE products.products_id = products_description.products_id and products.products_id = products_attributes.products_id and products_description.language_id = '" . $languages_id . "' and products_attributes.options_values_id = products_options_values.products_options_values_id ORDER BY products_description.products_name";

if ($row = mysql_fetch_array($result)) {

do {

echo "<tr class=\"dataTableRow\" onmouseover=\"rowOverEffect(this)\" onmouseout=\"rowOutEffect(this)\" >

<td class='dataTableContent'> ".$row["products_id"]."</td";

echo "<td class='dataTableContent'>".$row["products_name"]."</td>";

echo "<td class='dataTableContent'>".$row["products_model"]."</td>";

echo "<td class='dataTableContent'>".$row["products_status"]."</td>";

echo "<td class='dataTableContent'>".$row["products_options_values_name"]."</td>";

echo "<td class='dataTableContent'>".$row["options_quantity"]."</td>";

echo "<td class='dataTableContent'>".$row["products_quantity"]."</td>";

echo "</tr>";

}

while($row = mysql_fetch_array($result));

}

echo "</table>\n";

?>

<!-- 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'); ?>

</body>

</html>

<?php require('includes/application_bottom.php'); ?>

 

 

 

 

 

 

******************And here are the code from working "stock.php"**********************

 

 

 

 

 

<?php

/*

QT Pro Version 4.1

 

stock.php

 

Contribution extension to:

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 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 [email protected] Copyright © 2003 IBWO

Joseph Shain, January 2003

osCommerce MS2

Copyright © 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 [email protected]

Copyright © 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=products_description.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_opti

ons_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];

}

} 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>

<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\">  $option_names[$k]</td>";

$title[$title_num]=$k;

}

echo "<td class=\"dataTableHeadingContent\"><span class=smalltext>Quantity</span></td><td width=\"100%\"> </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>   ".tep_values_name($m1[2])."</td>";

} else {

echo "<td> </td>";

}

}

for($i=0;$i<sizeof($options)-sizeof($val_array);$i++) {

echo "<td> </td>";

}

echo "<td class=smalltext>    $rec[products_stock_quantity]</td><td> </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'] . "\"> </td><td width=\"100%\" class=dataTableHeadingRow> <input type=submit name=action value=" . ($flag?"Add":"Update") . "> </td><td width=\"100%\" class=dataTableHeadingRow> </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>    <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'); ?>

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