Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort by...


duranike

Recommended Posts

Can someone help me figure out how to sort this by attriubute id?

 

<?php
/*
     QT Pro Version 4.0
 
     stats_low_stock_attrib.php
 
     Contribution extension to:
       osCommerce, Open Source E-Commerce Solutions
       http://www.oscommerce.com
    
     Copyright (c) 2004 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 - Clean up to not replicate for all languages
                 Handle multiple attributes per product
                 Ignore attributes that stock isn't tracked for
                 Remove unused code
       
********************************************************************************
***********
 
     QT Pro Low Stock Report
 
     This report lists all products and products attributes that have stock less than
     the reorder level configured in the osCommerce admin site

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

 $Id: stats_products.php,v 1.22 2002/03/07 20:30:00 harley_vb Exp $
 (v 1.3 by Tom Wojcik aka TomThumb 2004/07/03)
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
?>
<!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'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%"  valign="top" align="left"><table border="0" align="left" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" align="left" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           
         </tr>

       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" align="left" cellspacing="0" cellpadding="0">
     
         <tr>
           <td valign="top" align="left"><table border="0" align="left" width="400" cellspacing="0" cellpadding="2">
             <br>
              <tr class="main">- Sizes marked in <font color=blue>BLUE</font> are qtys. over 10</tr>
              <tr class="main">- Sizes marked in <font color=red>RED</font> are qtys. at or below 0</tr><br>
<?php
 $products_query_raw = "select p.products_id, pd.products_name, p.products_quantity,p.products_price, l.name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_LANGUAGES . " l where p.products_id = pd.products_id and p.products_id = pd.products_id and l.languages_id = pd.language_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name ASC";
 
 $products_query = tep_db_query($products_query_raw);
 while ($products = tep_db_fetch_array($products_query)) {
     $products_id = $products['products_id'];

     // check for product or attributes below reorder level
     $products_stock_query=tep_db_query("SELECT products_stock_attributes, products_stock_quantity 
                                         FROM " . TABLE_PRODUCTS_STOCK . " 
                                         WHERE products_id=" . $products['products_id'] ." 
                                         AND products_stock_quantity < '" . STOCK_REORDER_LEVEL ."' 
                                         ORDER BY products_stock_attributes");
     $products_stock_rows=tep_db_num_rows($products_stock_query);
     if (($products['products_quantity'] < STOCK_REORDER_LEVEL) || ($products_stock_rows > 0)) {
       $products_quantity=($products_stock_rows > 0) ? ' ' : $products['products_quantity'];
       
?>
<tr class="tableRow">
              <td class="formAreaTitle"><?php echo '<font size="+1"><strong>' . $products['products_name'] .  '</strong></font>' .$products_quantity; ?> </td>

              <td class="dataTableContent"><?php echo $products_quantity; ?></td>
            
             </tr>
            
             
             <?php
             
              /////////////////  Add Attributes
              

              
       if ($products_stock_rows > 0) {
      	 $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name
                                                      FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib 
                                                      WHERE patrib.products_id='" . $products['products_id'] . "' 
                                                      AND patrib.options_id = popt.products_options_id 
                                                      AND popt.products_options_track_stock = '1' 
                                                      AND popt.language_id = '" . (int)$languages_id . "' 
                                                      ORDER BY patrib.products_attributes_id");
?>
           <tr class="dataTableRow">
             <td>
               <table border="0"  width="100%" align="right" cellspacing="0" cellpadding="2">
                 <tr class="dataTableRow">
                

                <?php echo " " ?>
            <?php echo " " ?> 
            </tr>
<?php
        
   
         // now display the attribute value names, table the html for quantity & price to get everything
         // to line up right
         $jmytime=1;
         $quantity_html_table="                <table border=\"0\"width=\"30\" align=\"left\" cellspacing=\"0\" cellpadding=\"2\">\n";
         $quantity_html_table.="             <tr align=\"left\" class=\"dataTableRow\" onmouseover=\"rowOverEffect(this)\" onmouseout=\"rowOutEffect(this)\" ><td class=\"main\" colspan=\"1\"> </td></tr>\n";
              echo "              <td  class=smalltext><b>SIZE</b></td>\n";
              $quantity_html_table.="                    <td align=\"left\" class=smalltext><b>QTY</b></td>\n";
        while($products_stock_values=tep_db_fetch_array($products_stock_query)) {
           $attributes=explode(",",$products_stock_values['products_stock_attributes']);
           echo "                   <tr align=\"left\" class=\"dataTableRow\" onmouseover=\"rowOverEffect(this)\" onmouseout=\"rowOutEffect(this)\" ><td class=\"main\" colspan=\"1\">\n";
           $quantity_html_table.="                  <tr class=\"dataTableRowSelected\">\n";
         
           foreach($attributes as $attribute) {
             $attr=explode("-",$attribute);
             if($products_stock_values['products_stock_quantity'] > 10){
            	 
             echo "                    <td align=\"left\" class=smalltext ><font color=blue>".tep_values_name($attr[1])."</font></td>\n";
              $quantity_html_table.="                    <td align=\"left\" class=smalltext><font color=blue>" . $products_stock_values['products_stock_quantity'] . "</font></td>\n";
           }else if($products_stock_values['products_stock_quantity'] < 1){
             echo "                    <td class=smalltext><font color=red>".tep_values_name($attr[1])."</font></td>\n";
              $quantity_html_table.="                    <td class=smalltext><font color=red>" . $products_stock_values['products_stock_quantity'] . "</font></td>\n";
           }else{
              echo "                    <td class=smalltext>".tep_values_name($attr[1])."</td>\n";
               $quantity_html_table.="                    <td class=smalltext>" . $products_stock_values['products_stock_quantity'] . "</td>\n";
           }
           }
           echo "                  </tr>\n";
          
           $quantity_html_table.="                  </tr>\n";
          
         }
         echo "                </table>\n";
         echo "              </td>\n";
         $quantity_html_table.="                </table>\n";
        
         echo "              <td class=smalltext>" . $quantity_html_table . "</td>\n";
       
         echo "            </tr>\n";
       }
     }
 ////////////////////////// End Attributes
 }
?>
             <tr>
               <td colspan="1"><?php echo tep_draw_separator(); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...