Quickly Update Product Stock
#1
Posted 20 March 2005 - 07:12 PM
Contribution:
http://www.oscommerce.com/community/contributions,558
Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294
FedEx Automated Labels -- Contribution 2244
RMA Returns system -- Contribution 1136
Sort Products By Dropdown -- Contribution 4312
Ultimate SEO URLs -- Contribution 2823
Credit Class & Gift Voucher -- Contribution 282
Cross-Sell -- Contribution 5347
#2
Posted 20 March 2005 - 08:30 PM
Since you have them listed going across the screen, in my instance, the screen scrolls about 3 pages to the right.
Plus, it was not including ALL my catagories, there were 3 catagories left out.
This is the change that I have made in order to fix it AND give it a nice look and feel...
I made all my changes between the <!-- body //--> and <!-- body_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<?php
if ($menu_dhtml == false ) { // add for dhtml_menu
echo '<td width="' . BOX_WIDTH . '" valign="top">';
echo '<table border="0" width="' . BOX_WIDTH . '" cellspacing="1" cellpadding="1" class="columnLeft">';
echo '<!-- left_navigation //-->';
require(DIR_WS_INCLUDES . 'column_left.php');
echo '<!-- left_navigation_eof //-->';
echo '</table>';
echo '</td>';
} else {
}
?>
<!-- body_text //-->
<td width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading">Quick Stock Update<br><?php echo tep_draw_separator('pixel_trans.gif', '100%', '4'); ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<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">
<td class="dataTableHeadingContent"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td class="pageHeadingsmaller"><br>Choose the category where you want to change the products within</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
if ($HTTP_POST_VARS['stock_update']) {
//set counter
$stock = 0;
$status_a = 0;
$status_d = 0;
while (list($key, $items) = each($stock_update)) {
// update the quantity in stock and image
$sql = "UPDATE products SET products_quantity = '".$items['stock']."', products_model = '".$items['model']."', products_price = '".$items['price']."', products_weight = '".$items['weight']."' WHERE products_id = $key";
$update = tep_db_query($sql);
$stock_i++;
// we're de-re-activating the selected products
if ($HTTP_POST_VARS['update_status']) {
if ($items['stock'] >= 1 ) {
$dereac = tep_db_query("UPDATE products SET products_status = 1 WHERE products_id = $key");
$status_a++;
} else {
$dereac = tep_db_query("UPDATE products SET products_status = 0 WHERE products_id = $key");
$status_d++;
}
}
}
}
?>
<br><form method="post" action="quick_stockupdate.php">
<?php
// first select all categories that have 0 as parent:
$sql = tep_db_query("SELECT c.categories_id, cd.categories_name from categories c, categories_description cd WHERE c.parent_id = 0 AND c.categories_id = cd.categories_id AND cd.language_id = 1");
echo ' <table border="0">';
echo ' <tr>';
while ($parents = tep_db_fetch_array($sql)) {
// check if the parent has products
$check = tep_db_query("SELECT products_id FROM products_to_categories WHERE categories_id = '" . $parents['categories_id'] . "'");
$tree = tep_get_category_tree();
$dropdown= tep_draw_pull_down_menu('cat_id', $tree, '', 'onchange="this.form.submit();"'); //single
$all_list = ' <form method="post" action="quick_stockupdate.php"><th class="smallText" align="left" valign="top">Categories:<br>' . $dropdown . '</form></th>';
}
echo $all_list;
echo ' </tr>';
echo ' </table>';
echo ' </form>';
echo ' </td>';
echo ' </tr>';
echo ' </table>';
// see if there is a category ID:
if ($HTTP_POST_VARS['cat_id']) {
// start the table
echo ' <br><form method="post" action="quick_stockupdate.php">';
echo ' <table width="100%" border="0" cellspacing=0 cellpadding=2>';
$i = 0;
// get all active prods in that specific category
$sql2 = tep_db_query("SELECT p.products_model, p.products_id, p. products_quantity, p.products_status, p.products_weight, p.products_price, pd.products_name from products p, products_to_categories ptc, products_description pd where p.products_id = ptc.products_id and p.products_id = pd.products_id and language_id = $languages_id and ptc.categories_id = '" . $HTTP_POST_VARS['cat_id'] . "' order by pd.products_name");
echo ' <tr class="dataTableHeadingRow">';
echo ' <td width="35" class="dataTableHeadingContent"> <b>ID#</b></td>';
echo ' <td class="dataTableHeadingContent"> <b>SKU #</b></td>';
echo ' <td width="400" class="dataTableHeadingContent"> <b>Name</b></td>';
echo ' <td class="dataTableHeadingContent"> <b>Weight</b></td>';
echo ' <td class="dataTableHeadingContent"> <b>Price</b></td>';
echo ' <td class="dataTableHeadingContent"> <b>Stock</b></td>';
echo ' </tr>';
// added changes thowden 10/2004 stock_update becomes a multi-dim array
while ($results = tep_db_fetch_array($sql2)) {
$i++;
echo ' <tr class="dataTableRow">';
echo ' <td class="dataTableContent"> ' . $results['products_id'] . ' </td>';
echo ' <td class="dataTableContent"> <input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '"> </td>';
echo ' <td class="dataTableContent"> ' . $results['products_name'] . ' </td>';
echo ' <td class="dataTableContent"> <input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '"> </td>';
echo ' <td class="dataTableContent"> <input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '"> </td>';
echo ' <td class="dataTableContent"> <input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? ' <font color="ff0000"><b>not active</b></font>' : ' <font color="009933"><b>active</b></font> </td>');
echo ' </tr>';
if ($i == $max_cols) {
$i = 0;
}
}
echo '</table><table border="0" width="100%" cellspacing=2 cellpadding=2><tr>';
echo '<input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">';
echo '</tr><br><td align="center" colspan="10" class="smallText">';
echo '<input type="checkbox" name="update_status" CHECKED>Check to set status on each individual product based on items in stock<br><i>( one or more in stock will become <font color="009933"><b>active</b></font> / zero in stock will become <font color="ff0000"><b>not active</b></font> )</i><p>';
echo '<input type="submit" value="Update"></td></tr></form>';
} //if
?>
</tr>
</table>
</td>
</tr>
</table>
</td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
BTW, what does this do???
/// optional parameter to set max products per row: $max_cols = 6;
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#3
Posted 22 March 2005 - 12:58 AM
As far as the $max_cols = 6; It was just some old code along with the $i= stuff that was used when the module grouped everything into columns instead of rows, the columns are much easier to read and that is no longer used.
I think I prefer the 2 spacing in b/t the cells though as it is easier to read with all the columns more like a spreadsheet.. but thats just me.
I'll post your fixes as a new version.
For anyone that wants 0 spacing in between the cells or to add more spacing just find this line:
echo ' <br><form method="post" action="quick_stockupdate.php">'; echo ' <table width="100%" border="0" cellspacing=2 cellpadding=2>';and change cellspacing= to whatever you want.
Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294
FedEx Automated Labels -- Contribution 2244
RMA Returns system -- Contribution 1136
Sort Products By Dropdown -- Contribution 4312
Ultimate SEO URLs -- Contribution 2823
Credit Class & Gift Voucher -- Contribution 282
Cross-Sell -- Contribution 5347
#4
Posted 22 March 2005 - 01:17 AM
Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294
FedEx Automated Labels -- Contribution 2244
RMA Returns system -- Contribution 1136
Sort Products By Dropdown -- Contribution 4312
Ultimate SEO URLs -- Contribution 2823
Credit Class & Gift Voucher -- Contribution 282
Cross-Sell -- Contribution 5347
#5
Posted 22 March 2005 - 09:16 AM
homewetbar, on Mar 21 2005, 07:17 PM, said:
All you have to do is add NOWRAP to the table data. In fact, you can do that to all your TD tags like this...
<td class="dataTableContent" nowrap>
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#6
Posted 22 March 2005 - 09:17 AM
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#7
Posted 22 March 2005 - 09:23 AM
ie:
while ($results = tep_db_fetch_array($sql2)) {
$i++;
echo ' <tr class="dataTableRow">';
echo ' <td class="dataTableContent" nowrap> ' . $results['products_id'] . ' </td>';
echo ' <td class="dataTableContent" nowrap> <input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '"> </td>';
echo ' <td class="dataTableContent" nowrap> ' . $results['products_name'] . ' </td>';
echo ' <td class="dataTableContent" nowrap> <input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '"> </td>';
echo ' <td class="dataTableContent" nowrap> <input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '"> </td>';
echo ' <td class="dataTableContent" nowrap> <input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? ' <font color="ff0000"><b>not active</b></font>' : ' <font color="009933"><b>active</b></font> </td>');
echo ' </tr>';
if ($i == $max_cols) {
$i = 0;
}
}
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#8
Posted 22 March 2005 - 09:34 AM
You could also remove the width="400" for the "Name" tag as follows
From:
echo ' <td width="400" class="dataTableHeadingContent"> <b>Name</b></td>';
To this:
echo ' <td class="dataTableHeadingContent"> <b>Name</b></td>';
ALSO...
I just noticed that some of the HTML coding was way off when I looked at the source code of the Admin Page.
Look for:
if ($i == $max_cols) {
$i = 0;
}
}
echo '.........
Change the "echo" lines below that to look like this:
if ($i == $max_cols) {
$i = 0;
}
}
echo '</table><br><br><input type="hidden" name="cat_id" value="' . $HTTP_POST_VARS['cat_id'] . '">';
echo '<table border="0" width="100%" cellspacing=2 cellpadding=2><tr>';
echo '<td align="center" colspan="10" class="smallText"><input type="checkbox" name="update_status" CHECKED>Check to set status on each individual product based on items in stock<br><i>( one or more in stock will become <font color="009933"><b>active</b></font> / zero in stock will become <font color="ff0000"><b>not active</b></font> )</i><p><input type="submit" value="Update"></td>';
echo '</tr></table>';
echo '</form>';
Ok, am I done yet, probably not, but I think so for now
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#9
Posted 22 March 2005 - 11:01 AM
I have just installed V2.4 - a contribution that coud be very usefull to my site.
- but i get nothing.
Just for information I have a lot of products (15000+) and many catagories
I have added the link from the admin catalog menu and followed the readme file - not mutch can go wrong here.
I also added the language line in the language file your language.php BOX_CATALOG_QUICK_STOCKUPDATE as it was missing from the readme file.
But when entering the Quick stock update page all I'm getting is an almost blank page.
This is a copy op the page
Quick Stock Update
Choose the category where you want to change the products within
© 2002 Tomorn K. - http://www.phpthailand.com
E-Commerce Engine Copyright © 2003 osCommerce
osCommerce provides no warranty and is redistributable under the GNU General Public License
Powered by osCommerce
does anyone know what im missing
Christian
#10
Posted 22 March 2005 - 02:22 PM
It's only the first sentence - please select a category.. or smth like this.. and then it's empty.. I can't figure what is wrong..
#11
Posted 22 March 2005 - 10:08 PM
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#12
Posted 22 March 2005 - 10:41 PM
PopTheTop, on Mar 22 2005, 11:08 PM, said:
Hi
Thanks for your reply
There is no version 3. but I tryed version 2.3 , 2.3a and the latest 2.4 with the same result - sligtly different header text as it is changed in 2.4
I also looked at some of the earlyer versions to see if there was a file that was left behind - no result - so...
But could it be something to do with a timeout due to many products / categories ?
Christian
#13
Posted 23 March 2005 - 12:51 AM
christian glass, on Mar 22 2005, 10:41 PM, said:
Thanks for your reply
There is no version 3. but I tryed version 2.3 , 2.3a and the latest 2.4 with the same result - sligtly different header text as it is changed in 2.4
I also looked at some of the earlyer versions to see if there was a file that was left behind - no result - so...
But could it be something to do with a timeout due to many products / categories ?
Christian
Humm are you seeing the drop down? You need to select the category to see anything after the drop down box... I just redownloaded it to check and it works perfectly here. Maybe a timeout problem like you said, I only have about 150 products here.
Also Purchased (AP) Preselection (cuts this resource hogging query down to nothing) -- Contribution 3294
FedEx Automated Labels -- Contribution 2244
RMA Returns system -- Contribution 1136
Sort Products By Dropdown -- Contribution 4312
Ultimate SEO URLs -- Contribution 2823
Credit Class & Gift Voucher -- Contribution 282
Cross-Sell -- Contribution 5347
#14
Posted 23 March 2005 - 07:15 AM
homewetbar, on Mar 23 2005, 01:51 AM, said:
Hi
There is no drop down
only the top og page with the text
Quick Stock Update
Choose the category where you want to change the products within
Christian
#15
Posted 23 March 2005 - 09:19 AM
Works just great for me:
Running MSIE v6.00.2800.1612
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#16
Posted 23 March 2005 - 10:05 AM
PopTheTop, on Mar 23 2005, 10:19 AM, said:
Works just great for me:
Running MSIE v6.00.2800.1612
I'm running
version 6.0.2900.2180.xpsp-sp2_rtm.040803-2158
Christian
#17
Posted 29 March 2005 - 03:52 PM
#18
Posted 29 March 2005 - 04:02 PM
Did you load the page and viewed the HTML source code through your web browser to see if there is a problem with the HTML code that is causing it not to display correctly?
PopTheTop
Published osC Contributions:
- eCheck Payment Module v3.1
- Reviews in Product Display v2.0
- Fancier Invoice & Packingslip v6.1
- Admin Notes / Customer Notes v2.2
- Customer Zip & State Validation v2.2
- Search Box with Dropdown Category Menu v1.0
Pop your camper's top today!
It's a popup thing...
You wouldn't understand
#19
Posted 29 March 2005 - 06:18 PM
In html there is '<form method="post" action="quick_stockupdate.php">' and </form>, but there is nothing actual in between. (in fact, only this: "<table border="0"><tr> </tr></table>")
As far as I understand, there is only 3 steps, and no db changes.
#20
Posted 29 March 2005 - 07:29 PM
christian glass> I have a lot of products (15000+)
Maybe that's the key?
I have about 2000 products and got same problem Christian had.
And, to make it clear, there is no point in browser comparing, as no info is outputting to html (my post above).









