Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Stocktaking Cost Contrib Support Question


Guest

Recommended Posts

I downloaded and installed the Stocktaking cost contribution

http://www.oscommerce.com/community/contri...rch,stock+value

 

I want to exclude not only certain categories but certain products from being displayed in the stocktake as some of my products are drop shipped items and therefore i dont need their value included in our stocktake :)

 

anyone know how to do this ?

Link to comment
Share on other sites

lol i just sat down and instead of being idle figured it out myself

 

see my new code for the stocktaking_cost.php file in /admin

 

<?php

/*

$Id: stocktaking_cost.php,v 0.1 2005/04/08 23:13:45 Exp $

version 0.0 - 2005/04/07 by djebaz

version 0.1 - 2005/04/08 by thdt98 / phocea

version 0.2 - 2005/04/08 mods by phocea / thdt98

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

// entry for bouncing csv string back as file

if (isset($_POST['csv'])) {

if ($HTTP_POST_VARS['saveas']) { // rebound posted csv as save file

$savename= $HTTP_POST_VARS['saveas'] . ".csv";

}

else $savename='unknown.csv';

$csv_string = '';

if ($HTTP_POST_VARS['csv']) $csv_string=$HTTP_POST_VARS['csv'];

if (strlen($csv_string)>0){

header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");

header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT');

header("Cache-Control: no-cache, must-revalidate");

header("Pragma: no-cache");

header("Content-Type: Application/octet-stream");

header("Content-Disposition: attachment; filename=$savename");

echo $csv_string;

}

else echo "CSV string empty";

exit;

};

 

// to exclude an category id

$exc_cat_id = array();

$exc_cat_id[1] = 34;

$exc_cat_id[2] = 14;

$exc_cat_id[3] = 15;

$exc_cat_id[4] = 28;

$exc_cat_id[5] = 29;

$exc_cat_id[6] = 33;

 

// To exclude a Product ID

$exc_prod_id=array();

$exc_prod_id[1]=109;

 

$csv_separator = ",";

$language_code = (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) ? $HTTP_GET_VARS['language'] : DEFAULT_LANGUAGE;

?>

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

</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 HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

<tr>

<td class="main">

<?php

$excluded_categories_query = tep_db_query("SELECT cd.categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION . " cd

WHERE cd.language_id = FLOOR($languages_id)

AND cd.categories_id IN (". implode(",", $exc_cat_id) . ")");

$exc_cat_name = array();

while ($excluded_categories = tep_db_fetch_array($excluded_categories_query)) {

$exc_cat_name[$i] = $excluded_categories['categories_name'];

$i++;

}

echo EXCLUDE_ID . implode(", ", $exc_cat_name);

?>

</td>

</tr>

 

<tr><td class="main">

<?php

$excluded_products_query = tep_db_query("SELECT cd.products_name FROM " . TABLE_PRODUCTS_DESCRIPTION . " cd

WHERE cd.language_id = FLOOR($languages_id)

AND cd.products_id IN (". implode(",", $exc_prod_id) . ")");

$exc_prod_name = array();

while ($excluded_products = tep_db_fetch_array($excluded_products_query)) {

$exc_prod_name[$p] = $excluded_products['products_name'];

$p++;

}

echo EXCLUDE_ID . implode(", ", $exc_prod_name);

?>

</td></tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIE; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NAME; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_QT; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PURCHASE_PRICE; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TOT_PURCHASE_PRICE; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_SALE_PRICE; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TOT_SALE_PRICE; ?></td>

</tr>

<?php

$csv_accum .= TABLE_HEADING_CATEGORIE . $csv_separator .

TABLE_HEADING_NAME . $csv_separator .

TABLE_HEADING_QT . $csv_separator .

TABLE_HEADING_PURCHASE_PRICE . $csv_separator .

TABLE_HEADING_TOT_PURCHASE_PRICE . $csv_separator .

TABLE_HEADING_SALE_PRICE . $csv_separator .

TABLE_HEADING_TOT_SALE_PRICE . $csv_separator . "\n";

 

$included_categories_query = tep_db_query("SELECT c.categories_id, c.parent_id, cd.categories_name

FROM " . TABLE_CATEGORIES . " c

LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON c.categories_id = cd.categories_id

WHERE cd.language_id = FLOOR($languages_id)

AND c.categories_id NOT IN (" . implode(",", $exc_cat_id) . ")");

 

$inc_cat = array();

while ($included_categories = tep_db_fetch_array($included_categories_query)) {

$inc_cat[] = array (

'id' => $included_categories['categories_id'],

'parent' => $included_categories['parent_id'],

'name' => $included_categories['categories_name']);

}

$cat_info = array();

for ($i=0; $i<sizeof($inc_cat); $i++)

$cat_info[$inc_cat[$i]['id']] = array (

'parent'=> $inc_cat[$i]['parent'],

'name' => $inc_cat[$i]['name'],

'path' => $inc_cat[$i]['id'],

'link' => '',

'cleanlink' => ''

);

 

for ($i=0; $i<sizeof($inc_cat); $i++) {

$cat_id = $inc_cat[$i]['id'];

while ($cat_info[$cat_id]['parent'] != 0){

$cat_info[$inc_cat[$i]['id']]['path'] = $cat_info[$cat_id]['parent'] . '_' . $cat_info[$inc_cat[$i]['id']]['path'];

$cat_id = $cat_info[$cat_id]['parent'];

}

$link_array = split('_', $cat_info[$inc_cat[$i]['id']] ['path']);

for ($j=0; $j<sizeof($link_array); $j++) {

$cat_info[$inc_cat[$i]['id']]['link'] .= ' <a target="_blank" href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cat_info[$link_array[$j]]['path']) . '"><nobr>' . $cat_info[$link_array[$j]]['name'] . '</nobr></a> » ';

$cat_info[$inc_cat[$i]['id']]['cleanlink'].= $cat_info[$link_array[$j]]['name'] . '/';

}

}

 

//$products_query = tep_db_query("SELECT p.products_id, pd.products_name, p.products_quantity, p.products_cost, p.products_price, pc.categories_id FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc WHERE p.products_id = pd.products_id AND p.products_id = pc.products_id AND p.products_status = 1 AND pd.language_id = FLOOR($languages_id) ORDER BY pc.categories_id, pd.products_name");

$products_query = tep_db_query("SELECT * FROM " .TABLE_PRODUCTS." p

LEFT JOIN products_description pd ON p.products_id = pd.products_id

LEFT JOIN specials sp ON p.products_id = sp.products_id

LEFT JOIN products_to_categories p2c ON p.products_id = p2c.products_id

WHERE p.products_status = 1

AND pd.language_id = FLOOR($languages_id) AND p.products_id not in (" . implode(",",$exc_prod_id).")

AND p2c.categories_id not in (" . implode(",", $exc_cat_id) . ")

ORDER BY p2c.categories_id, pd.products_name");

 

 

$stock=0;

$stockp=0;

$tot=0;

$totp=0;

$memory = 0;

 

while($products = tep_db_fetch_array($products_query)) {

//if ($products['categories_id'] != $exc_cat_id && ($products['categories_id'] != $exc_cat_id2 )) {

$cost_item= ($products['products_cost']*$products['products_quantity']);

if ($products['specials_new_products_price']) { //if it's on special

$products['products_price'] = $products['specials_new_products_price']; //show the special price

}

$price_item= ($products['products_price']*$products['products_quantity']);

$check_id = $products['categories_id'];

$qt_item = $products['products_quantity'];

//echo $check_id;

//echo $memory;

if ($check_id != $memory) {echo

 

" <tr class=\"dataTableHeadingRow\">\n" .

' <td class="main" width="33%">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqqt_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqcost_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqprice_item . " </td>\n" .

" </tr>\n";

$tqqt_item = 0;

$tqcost_item = 0;

$tqprice_item = 0;

}

 

$tqqt_item += $qt_item;

$tqt_item += $qt_item;

$tcost_item += $cost_item;

$tqcost_item += $cost_item;

$tprice_item += $price_item;

$tqprice_item += $price_item;

 

echo

" <tr>\n" .

' <td class="main" width="33%">' . (($memory == $products['categories_id'])? '': $cat_info[$products['categories_id']]['link']) . "</td>\n" .

' <td class="dataTableContent"><a target="_blank" href="' . tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $products['products_id'] . '&origin=' . FILENAME_STOCKTAKING_COST . '?page=' . $HTTP_GET_VARS['page'], 'NONSSL') . '">' . $products['products_name'] . "</a></td>\n" .

' <td class="dataTableContent">' . $products['products_quantity'] . "</a></td>\n" .

' <td class="dataTableContent">' . round($products['products_cost'],2) . "</td>\n" .

' <td class="dataTableContent">' . $cost_item . "</td>\n" .

' <td class="dataTableContent">' . round($products['products_price'],2) . "</td>\n" .

' <td class="dataTableContent">' . $price_item . "</td>\n" .

" </tr>\n";

$tot += $stock;

$totp += $stockp;

 

// Do not repeat category if its still the same

if ($old_categorie != $cat_info[$products['categories_id']]['cleanlink']) {

$csv_cat = $cat_info[$products['categories_id']]['cleanlink'];

$old_categorie = $csv_cat;

}

 

$csv_accum .= strtr($csv_cat, "',", " ") . $csv_separator .

strtr($products['products_name'], "',", " ") . $csv_separator .

$products['products_quantity'] . $csv_separator .

round($products['products_cost'],2) . $csv_separator .

$cost_item . $csv_separator .

round($products['products_price'],2) . $csv_separator .

$price_item . $csv_separator . "\n" ;

$csv_cat = '';

//} // end exclude cat_id

$memory = $products['categories_id'];

}

?>

<?php

if ($check_id = $memory) {

echo

" <tr class=\"dataTableHeadingRow\">\n" .

' <td class="dataTableheadingContent" width="33%">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqqt_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqcost_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqprice_item . "</td>\n" .

" </tr>\n" .

 

" <tr class=\"dataTableHeadingRow\">\n" .

' <td class="dataTableheadingContent" width="33%">' . " </td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableheadingContent" colspan= 5>' . "<hr size=3></td>\n" .

" </tr>\n" .

" <tr class=\"dataTableHeadingRow\">\n" .

' <td class="dataTableheadingContent" width="33%">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tqt_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tcost_item . "</td>\n" .

' <td class="dataTableHeadingContent">' . "</td>\n" .

' <td class="dataTableHeadingContent">' . $tprice_item . "</td>\n" .

" </tr>\n";

$tqqt_item = 0;

$tqcost_item = 0;

$tqprice_item = 0;

}

?>

</table></td>

</tr><tr>

<td class="pageHeading"><?php echo TABLE_HEADING_TQT_ITEM; ?><? echo $tqt_item ?></td></tr>

<td class="pageHeading"><?php echo TABLE_HEADING_TCOST_PURCHASE_PRICE; ?><? echo "?" . $tcost_item ?></td></tr>

<td class="pageHeading"><?php echo TABLE_HEADING_TCOST_SALE_PRICE; ?><? echo "?" . $tprice_item ?></td></tr>

 

</tr>

<!-- button for Save CSV //-->

<tr>

<td class="smallText" colspan="4">

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method=post>

<input type='hidden' name='csv' value='<?php echo $csv_accum; ?>'>

<input type='hidden' name='saveas' value='stock_report'>

<!-- <input type="submit" value="<?php echo TEXT_BUTTON_REPORT_SAVE ;?>"></form>

-->

<table><tr><td>

<table><td>

<td align="right">

<?php echo '<input type="image" name="submit" src="' . DIR_WS_LANGUAGES . $language . '/images/buttons/button_export.gif" alt="' . TEXT_EXPORT_BUTTON . '" width="65" height="22"></form>'; ?>

</table></tr></td>

</td>

</tr>

</table></td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

</tr>

</table>

<!-- body_eof //-->

<?php //echo $csv_accum ?>

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

</body>

</html>

Link to comment
Share on other sites

  • 2 years later...

can you spesify the code you changed. i need this to but it dint work just by copy your code.

 

can you please do it like the normal installguides

like search for..insert after...replace and so

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