Rubin Remus Posted November 23, 2009 Share Posted November 23, 2009 Hi, I'm using an OSC contrib, "InventoryReport", I've got it working brilliantly, but I'd like to add a further field to the report. I would like it to display the category name for each item, so items can be displayed by category. The code is below, and I imagine it's very easy for somebody who knows what they're doing, but I don't... :-( Any help is much appreciated! Thanks! <?php // require('includes/application_top.php'); define('MAX_RESULTS', '200'); ?> <!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 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'); $sorted = $HTTP_GET_VARS['sorted']; $orderby = $HTTP_GET_VARS['orderby']; if ($sorted !== "ASC" and $sorted !== "DESC") $sorted = "ASC"; ?> <!-- 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> </table></td> </tr> <tr> <td><table border="0" width="90%" cellspacing="0" cellpadding="2"> <tr> <td valign="top"><table border="0" width="95%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NUMBER; ?></td> <td class="dataTableHeadingContent"><?php if (!isset($orderby) or ($orderby == "name" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY, 'orderby=name&sorted='. $to_sort) . '" class="headerLink">' . TABLE_HEADING_PRODUCTS . '</a>'; ?></td> <td class="dataTableHeadingContent"><?php if (!isset($orderby) or ($orderby == "model" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY, 'orderby=model&sorted='. $to_sort) . '" class="headerLink">' .TABLE_HEADING_PROD_ID . '</a>'; ?></td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "stock" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY, 'orderby=stock&sorted='. $to_sort) . '" class="headerLink">' .TABLE_HEADING_QTY_LEFT . '</a>'; ?> </td> </tr> <?php if ($HTTP_GET_VARS['page'] > 1) $rows = $HTTP_GET_VARS['page'] * 20 - 20; if ($orderby == "name") {$db_orderby = "pd.products_name";} elseif ($orderby == "stock") {$db_orderby = "p.products_quantity";} else {$db_orderby = "pd.products_name";} $products_query_raw = "select p.products_id, p.products_quantity, pd.products_name, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . $languages_id. "' group by pd.products_id order by $db_orderby $sorted"; $products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_RESULTS, $products_query_raw, $products_query_numrows); $products_query = tep_db_query($products_query_raw); while ($products = tep_db_fetch_array($products_query)) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } $products_id = $products['products_id']; $last_category_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = $products_id"); $last_category = tep_db_fetch_array($last_category_query); $p_category = $last_category["categories_id"]; do { $p_category_array[] = $p_category; $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = $p_category"); $last_category = tep_db_fetch_array($last_category_query); $p_category = $last_category["parent_id"]; } while ($p_category); $cPath_array = array_reverse($p_category_array); ?> <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='<?php echo tep_href_link(FILENAME_CATEGORIES, tep_get_path() . '&pID=' . $products['products_id'] . '&action=new_product', 'NONSSL'); ?>'"> <td align="left" class="dataTableContent"><?php echo $rows; ?>.</td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, tep_get_path() . '&pID=' . $products['products_id']) . '" class="blacklink">' . $products['products_name'] . '</a>'; ?></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, tep_get_path() . '&pID=' . $products['products_id'], 'NONSSL') . '&action=new_product">' . $products['products_model'] . '</a>'; ?></td> <td align="right" class="dataTableContent"><?php echo $products['products_quantity']; ?></td> </tr> <?php unset($cPath_array); unset($p_category_array); } ?> </table></td> </tr> <tr> <td colspan="3"><table border="0" width="90%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], "orderby=" . $orderby . "&sorted=" . $sorted); ?> </td> </tr> </table></td> </tr> </table></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_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'); ?> Quote Link to comment Share on other sites More sharing options...
Rubin Remus Posted November 24, 2009 Author Share Posted November 24, 2009 Any help available here? Thanks. Quote Link to comment Share on other sites More sharing options...
Rubin Remus Posted November 30, 2009 Author Share Posted November 30, 2009 Hi everyone, I'm still stuck here. Any ideas at all would be useful... Thanks, RR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.