| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 QT Pro Version 4.0 4 5 stats_low_stock_attrib.php 6 7 Contribution extension to: 8 osCMax Power E-Commerce 9 http://oscdox.com 10 11 Copyright 2006 osCMax2004 Ralph Day 12 Released under the GNU General Public License 13 14 Based on prior works released under the GNU General Public License: 15 QT Pro prior versions 16 Ralph Day, October 2004 17 Tom Wojcik aka TomThumb 2004/07/03 based on work by Michael Coffman aka coffman 18 FREEZEHELL - 08/11/2003 freezehell@hotmail.com Copyright 2006 osCMax2003 IBWO 19 Joseph Shain, January 2003 20 osCommerce MS2 21 Copyright 2006 osCMax 22 23 Modifications made: 24 11/2004 - Clean up to not replicate for all languages 25 Handle multiple attributes per product 26 Ignore attributes that stock isn't tracked for 27 Remove unused code 28 29 ******************************************************************************************* 30 31 QT Pro Low Stock Report 32 33 This report lists all products and products attributes that have stock less than 34 the reorder level configured in the osCommerce admin site 35 36 37 ******************************************************************************************* 38 39 $Id: stats_low_stock_attrib.php 3 2006-05-27 04:59:07Z user $ 40 (v 1.3 by Tom Wojcik aka TomThumb 2004/07/03) 41 osCMax Power E-Commerce 42 http://oscdox.com 43 44 Copyright 2006 osCMax2005 osCMax, 2002 osCommerce 45 46 Released under the GNU General Public License 47 */ 48 49 require ('includes/application_top.php'); 50 require (DIR_WS_CLASSES . 'currencies.php'); 51 $currencies = new currencies(); 52 ?> 53 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 54 <html <?php echo HTML_PARAMS; ?>> 55 <head> 56 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 57 <title><?php echo TITLE; ?></title> 58 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 59 </head> 60 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 61 62 63 <!-- body //--> 64 <table border="0" width="100%" cellspacing="3" cellpadding="3"> 65 <tr> 66 <td></td> 67 <!-- body_text //--> 68 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 69 <tr> 70 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 71 <tr> 72 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 73 <td class="menuboxheading" align="center"><?php echo strftime(DATE_FORMAT_LONG); ?></td> 74 </tr> 75 76 </table></td> 77 </tr> 78 <tr> 79 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 80 81 <tr> 82 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 83 <tr> 84 <td class="formAreaTitle"><?php echo TABLE_HEADING_PRODUCTS; ?></td> 85 <td class="formAreaTitle"><?php echo TABLE_HEADING_QUANTITY; ?></td> 86 87 <td class="formAreaTitle" align="right"><?php echo TABLE_HEADING_PRICE; ?> </td> 88 89 </tr> 90 <tr> 91 <td colspan="3"><hr></td> 92 </tr> 93 <?php 94 $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"; 95 96 $products_query = tep_db_query($products_query_raw); 97 while ($products = tep_db_fetch_array($products_query)) { 98 $products_id = $products['products_id']; 99 100 // check for product or attributes below reorder level 101 $products_stock_query=tep_db_query("SELECT products_stock_attributes, products_stock_quantity 102 FROM " . TABLE_PRODUCTS_STOCK . " 103 WHERE products_id=" . $products['products_id'] ." 104 AND products_stock_quantity < '" . STOCK_REORDER_LEVEL ."' 105 ORDER BY products_stock_attributes"); 106 $products_stock_rows=tep_db_num_rows($products_stock_query); 107 if (($products['products_quantity'] < STOCK_REORDER_LEVEL) || ($products_stock_rows > 0)) { 108 $products_quantity=($products_stock_rows > 0) ? ' ' : $products['products_quantity']; 109 $products_price=($products_stock_rows > 0) ? ' ' : $currencies->format($products['products_price']); 110 ?> 111 <tr class="tableRow"> 112 <td class="formAreaTitle"><?php echo '<a href="' . tep_href_link(FILENAME_STOCK, 'product_id=' . $products['products_id']) . '"><font size="+1"><strong>' . $products['products_name'] . '</strong></font></a>'; ?> </td> 113 114 <td class="dataTableContent"><?php echo $products_quantity; ?></td> 115 <td class="dataTableContent" align="right"><?php echo $products_price; ?> </td> 116 </tr> 117 118 119 <?php 120 121 ///////////////// Add Attributes 122 123 124 125 if ($products_stock_rows > 0) { 126 $products_options_name_query = tep_db_query("SELECT distinct popt.products_options_id, popt.products_options_name 127 FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib 128 WHERE patrib.products_id='" . $products['products_id'] . "' 129 AND patrib.options_id = popt.products_options_id 130 AND popt.products_options_track_stock = '1' 131 AND popt.language_id = '" . (int)$languages_id . "' 132 ORDER BY popt.products_options_id"); 133 ?> 134 <tr class="dataTableRow"> 135 <td class="main"> 136 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 137 <tr class="dataTableRow"> 138 <?php 139 // build headng line with option names 140 while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 141 echo " <td class=\"main\">" . $products_options_name['products_options_name'] . "</td>\n"; 142 } 143 ?> 144 </tr> 145 <?php 146 // buld array of attributes price delta 147 $attributes_price = array(); 148 $products_attributes_query = tep_db_query("SELECT pa.options_id, pa.options_values_id, pa.options_values_price, pa.price_prefix 149 FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa 150 WHERE pa.products_id = '" . $products['products_id'] . "'"); 151 while ($products_attributes_values = tep_db_fetch_array($products_attributes_query)) { 152 $option_price = $products_attributes_values['options_values_price']; 153 if ($products_attributes_values['price_prefix'] == "-") $option_price= -1*$option_price; 154 $attributes_price[$products_attributes_values['options_id']][$products_attributes_values['options_values_id']] = $option_price; 155 } 156 157 // now display the attribute value names, table the html for quantity & price to get everything 158 // to line up right 159 $quantity_html_table=" <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">\n"; 160 $quantity_html_table.=" <tr class=\"dataTableRow\"><td class=\"main\" colspan=\"" . sizeof($products_options_array) . "\"> </td></tr>\n"; 161 $price_html_table=" <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">\n"; 162 $price_html_table.=" <tr class=\"dataTableRow\"><td class=\"main\" colspan=\"" . sizeof($products_options_array) . "\"> </td></tr>\n"; 163 while($products_stock_values=tep_db_fetch_array($products_stock_query)) { 164 $attributes=explode(",",$products_stock_values['products_stock_attributes']); 165 echo " <tr class=\"dataTableRowSelected\">\n"; 166 $quantity_html_table.=" <tr class=\"dataTableRowSelected\">\n"; 167 $price_html_table.=" <tr class=\"dataTableRowSelected\">\n"; 168 $total_price=$products['products_price']; 169 foreach($attributes as $attribute) { 170 $attr=explode("-",$attribute); 171 echo " <td class=smalltext>".tep_values_name($attr[1])."</td>\n"; 172 $total_price+=$attributes_price[$attr[0]][$attr[1]]; 173 } 174 echo " </tr>\n"; 175 $quantity_html_table.=" <td class=smalltext>" . $products_stock_values['products_stock_quantity'] . "</td>\n"; 176 $quantity_html_table.=" </tr>\n"; 177 $price_html_table.=" <td align=\"right\" class=smalltext>" . $total_price . " </td>\n"; 178 $price_html_table.=" </tr>\n"; 179 } 180 echo " </table>\n"; 181 echo " </td>\n"; 182 $quantity_html_table.=" </table>\n"; 183 $price_html_table.=" </table>\n"; 184 echo " <td class=smalltext>" . $quantity_html_table . "</td>\n"; 185 echo " <td>" . $price_html_table . "</td>\n"; 186 echo " </tr>\n"; 187 } 188 } 189 ////////////////////////// End Attributes 190 } 191 ?> 192 <tr> 193 <td colspan="3"><?php echo tep_draw_separator(); ?></td> 194 </tr> 195 </table></td> 196 </tr> 197 </table></td> 198 </tr> 199 </table></td> 200 <!-- body_text_eof //--> 201 </tr> 202 </table> 203 <!-- body_eof //--> 204 </body> 205 </html> 206 <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |