Jump to content



Latest News: (loading..)

- - - - -

Quickly Update Product Stock


  • Please log in to reply
176 replies to this topic

#1   homewetbar

homewetbar
  • Members
  • 699 posts
  • Real Name:Keith W.
  • Location:USA

Posted 20 March 2005 - 07:12 PM

Please post questions regarding the Quickly Update Product Stock contribution in this forum instead of on the contribution page.

Contribution:
http://www.oscommerce.com/community/contributions,558
Most Valuable OsCommerce Contributions:
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 20 March 2005 - 08:30 PM

There is a problem with your contribution for sites with many catagories...

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">&nbsp;<b>ID#</b></td>';
    echo '              <td class="dataTableHeadingContent">&nbsp;<b>SKU #</b></td>';
    echo '              <td width="400" class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;<b>Name</b></td>';
    echo '              <td class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;<b>Weight</b></td>';
    echo '              <td class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Price</b></td>';
    echo '              <td class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;' . $results['products_id'] . '&nbsp;</td>';
       echo '              <td class="dataTableContent">&nbsp;<input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent">&nbsp;&nbsp;&nbsp;' . $results['products_name'] . '&nbsp;</td>';
   echo '              <td class="dataTableContent">&nbsp;&nbsp;&nbsp;<input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent">&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent">&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? '&nbsp;&nbsp;<font color="ff0000"><b>not active</b></font>' : '&nbsp;&nbsp;<font color="009933"><b>active</b></font>&nbsp;</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;

L8r,
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   homewetbar

homewetbar
  • Members
  • 699 posts
  • Real Name:Keith W.
  • Location:USA

Posted 22 March 2005 - 12:58 AM

Nice PopTheTop, the menu works much better now! That was starting to get on my nerves, it was my next item to fix.

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.
Most Valuable OsCommerce Contributions:
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   homewetbar

homewetbar
  • Members
  • 699 posts
  • Real Name:Keith W.
  • Location:USA

Posted 22 March 2005 - 01:17 AM

Something about the reformating of the code in your version PopTheTop is causing some items with not active to roll onto a the next line so I will omit that part in the update.
Most Valuable OsCommerce Contributions:
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 22 March 2005 - 09:16 AM

homewetbar, on Mar 21 2005, 07:17 PM, said:

Something about the reformating of the code in your version PopTheTop is causing some items with not active to roll onto a the next line so I will omit that part in the update.

<{POST_SNAPBACK}>



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>

L8r,
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 22 March 2005 - 09:17 AM

What is wrapping? Is it products with long names?
L8r,
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 22 March 2005 - 09:23 AM

I have a screen reso;lution of 1024 x 768 and I have no problem of line wrapping. Just add the code as stated above and you will no longer have that problem, instead of wrapping, it will scroll off the screen a bit to the right but everything will stay on one line.

ie:
    while ($results = tep_db_fetch_array($sql2)) {
       $i++;
       echo '            <tr class="dataTableRow">';
   echo '              <td class="dataTableContent" nowrap>&nbsp;' . $results['products_id'] . '&nbsp;</td>';
       echo '              <td class="dataTableContent" nowrap>&nbsp;<input type="text" size="16" name="stock_update[' . $results['products_id'] . '][model]" value="' . $results['products_model'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent" nowrap>&nbsp;&nbsp;&nbsp;' . $results['products_name'] . '&nbsp;</td>';
   echo '              <td class="dataTableContent" nowrap>&nbsp;&nbsp;&nbsp;<input type="text" size="6" name="stock_update[' . $results['products_id'] . '][weight]" value="' . $results['products_weight'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="9" name="stock_update[' . $results['products_id'] . '][price]" value="' . $results['products_price'] . '">&nbsp;</td>';
   echo '              <td class="dataTableContent" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" size="4" name="stock_update[' . $results['products_id'] . '][stock]" value="' . $results['products_quantity'] . '">' . (($results['products_status'] == 0) ? '&nbsp;&nbsp;<font color="ff0000"><b>not active</b></font>' : '&nbsp;&nbsp;<font color="009933"><b>active</b></font>&nbsp;</td>');
       echo '            </tr>';
       if ($i == $max_cols) {
         $i = 0;
       }
    }

L8r,
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 22 March 2005 - 09:34 AM

Sorry, one more thing...

You could also remove the width="400" for the "Name" tag as follows

From:
    echo '              <td width="400" class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;<b>Name</b></td>';


To this:
    echo '              <td class="dataTableHeadingContent">&nbsp;&nbsp;&nbsp;&nbsp;<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  ;)
L8r,
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   christian glass

christian glass
  • Members
  • 19 posts
  • Real Name:christian glass

Posted 22 March 2005 - 11:01 AM

Hi

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   necrolust

necrolust
  • Members
  • 39 posts
  • Real Name:Saank

Posted 22 March 2005 - 02:22 PM

yeap.. I also installed the latest version but i get the same thing..
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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 22 March 2005 - 10:08 PM

Hmmm. that is funny. Well, not so funny for you guys. I have had no problems at all. Did you try installing version 3?
L8r,
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   christian glass

christian glass
  • Members
  • 19 posts
  • Real Name:christian glass

Posted 22 March 2005 - 10:41 PM

PopTheTop, on Mar 22 2005, 11:08 PM, said:

Hmmm. that is funny. Well, not so funny for you guys. I have had no problems at all. Did you try installing version 3?

<{POST_SNAPBACK}>


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   homewetbar

homewetbar
  • Members
  • 699 posts
  • Real Name:Keith W.
  • Location:USA

Posted 23 March 2005 - 12:51 AM

christian glass, on Mar 22 2005, 10:41 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

<{POST_SNAPBACK}>



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.
Most Valuable OsCommerce Contributions:
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   christian glass

christian glass
  • Members
  • 19 posts
  • Real Name:christian glass

Posted 23 March 2005 - 07:15 AM

homewetbar, on Mar 23 2005, 01:51 AM, said:

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.

<{POST_SNAPBACK}>


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   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 23 March 2005 - 09:19 AM

Well, then let's compare web browsers here...

Works just great for me:
Running MSIE v6.00.2800.1612
L8r,
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   christian glass

christian glass
  • Members
  • 19 posts
  • Real Name:christian glass

Posted 23 March 2005 - 10:05 AM

PopTheTop, on Mar 23 2005, 10:19 AM, said:

Well, then let's compare web browsers here...

Works just great for me:
Running MSIE v6.00.2800.1612

<{POST_SNAPBACK}>


I'm running

version 6.0.2900.2180.xpsp-sp2_rtm.040803-2158

Christian

#17   wand

wand
  • Members
  • 7 posts
  • Real Name:Alexander Chislov
  • Location:moscow

Posted 29 March 2005 - 03:52 PM

Got only 'Choose the category where you want to change the products within' after install. What's wrong?

#18   PopTheTop

PopTheTop
  • Members
  • 886 posts
  • Real Name:Scooter
  • Location:St. Louis, MO

Posted 29 March 2005 - 04:02 PM

Don't know. That is strange. Did you try to re-install it again or go through step by step on the instructions to be certain you installed it correctly to the "T"?

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?
L8r,
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   wand

wand
  • Members
  • 7 posts
  • Real Name:Alexander Chislov
  • Location:moscow

Posted 29 March 2005 - 06:18 PM

I did reinstall but no help.
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   wand

wand
  • Members
  • 7 posts
  • Real Name:Alexander Chislov
  • Location:moscow

Posted 29 March 2005 - 07:29 PM

homewetbar> I only have about 150 products
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).