Jump to content

motorcity

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by motorcity

  1. Finally figured this out by comparing the 5.2.9 php.ini to the current php 5.3.29 php.ini The default max_input_vars = 1000 was the culprit. Thanks for all the help, I really do appreciate it. ~Motorcity Not sure how to mark this solved, but it is.
  2. Really appreciate you taking a look here. I thought that last part about tep_db_ or mysql_ query was worth a quick going over and found that using $query = tep_db_query() in the place of mysql_query didn't bother any functioning files, and it didn't change anything that doesn't work. There has to be some sort of corruption in the data that just blows my mind because it spans multiple product groups and never reared its head until this switch in php & mysql.
  3. Thanks. To be more precise on form submission $_POST['reset'] or $_POST['save'] if the script is working you get a page refresh and a new total reflecting any changes, and a revised sort order. If not working, it still refreshes the page but it changes nothing. There are a number of php notices for undefined variables and indexes, but those were there before php5.3 and are common between those versions that work and those that don't. That the posted code is exactly the same with the hard coded vendors2_id being the only difference is really the point. And it sounds like your judgement is the problem isn't in the code. With a possible check of the php configuration probably due.
  4. I should probably explain works or doesn't work. Either way the file displays a sortable list by column headings with suggested products to order based on quantity in stock. The user can override the "approved" by clicking the checkbox off. What doesn't work is RESET or SAVE the order. Thanks for looking and any suggestions you may have.
  5. I've been up down and around in circles with this script. I know it's poor coding, but it has served its purpose. Incredibly it has worked for years and what I'm sharing here is the same code used for multiple vendors and manufacturers. The part that completely throws me is that it still works after the change from PHP 5.2.9 to PHP 5.3 for half of the vendors and doesn't work on the other half. I keep going back to the database (also updated from mysql 5.0.96 to mysql 5.5.42) a single column "vendors2_id" in the products table makes the difference of whether this code works or fails for the most part, and I've been all through the database convinced that somehow there is some sort of corruption in a table or a single product, but I believe that just isn't the case. Now I'm asking two things; Is php5.3 that much more exacting than 5.2 that something here works but only half of the time? (The ONLY difference is the number used I.E. vendors2_id = 16 works, vendors2_id = 4 does not work.) Or is it absolutely a problem in my database? <?php require('includes/application_top.php'); define('MAX_RESULTS', '1000'); //set_time_limit(300); function get_products_reorder_to($products_quantity, $reorder_quantity, $shelf_pack,$products_reorder_to){ $new_reorder_to = 0; if($products_quantity < $reorder_quantity && $shelf_pack > 0){ for($new_reorder_to = $shelf_pack;($new_reorder_to + $products_quantity) < $reorder_quantity;){ $new_reorder_to += $shelf_pack; } } if($products_reorder_to > 0) $new_reorder_to = $products_reorder_to; return $new_reorder_to; } //end function if($_POST['reset']){ $reset_query = tep_db_query("select products_id, products_quantity, shelf_pack, reorder_quantity from " . TABLE_PRODUCTS . " where vendors2_id = 16 and products_quantity < reorder_quantity"); while ($reset_select = tep_db_fetch_array($reset_query)) { $jd = get_products_reorder_to($reset_select['products_quantity'], $reset_select['reorder_quantity'], $reset_select['shelf_pack'], 0); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET products_reorder_to = '" . $jd . "' WHERE vendors2_id = 16 and products_id = '" . $reset_select['products_id'] . "'"); } mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = '1' WHERE vendors2_id = 16 and products_quantity < reorder_quantity "); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = '0', products_reorder_to = '0' WHERE vendors2_id = 16 and products_quantity >= reorder_quantity "); }//post reset if($_POST['save'] || $_POST['autosave'] == '1'){ if($_POST['add2order'] != '') $idchecked = join(",", $_POST['add2order']); if($_POST['add2orderlist'] != '') $idlist = join(",", $_POST['add2orderlist']); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = 1 WHERE vendors2_id = 16 and products_id in (" . $idchecked . ")"); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = 0 WHERE vendors2_id = 16 and products_id in (" . $idlist . ") and products_id NOT in (" . $idchecked . ")"); }//post save ?> <!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 //--> <form name="order_quantity" method="post"> <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> <?php $products_query_raw = "select p.products_id, p.products_model, p.products_quantity, pd.products_name, p.products_sku, p.reorder_quantity, p.products_reorder_to, p.shelf_pack, p.vendors_product_price, pr.manufacturers_name, p2c.categories_id from " . TABLE_PRODUCTS . " p inner join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id inner join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left outer join " . TABLE_MANUFACTURERS . " pr on p.manufacturers_id = pr.manufacturers_id where p.vendors2_id = 16 and pd.language_id = '" . $languages_id. "' and p.approved=1 group by pd.products_id "; $products_query = tep_db_query($products_query_raw); while ($products = tep_db_fetch_array($products_query)) { $new_reorder_to = get_products_reorder_to($products['products_quantity'], $products['reorder_quantity'], $products['shelf_pack'], $products['products_reorder_to']); $subtotal = $new_reorder_to * $products['vendors_product_price']; $total += $subtotal; } ?> <td class="pageHeading" align="left">ABC Company</td> <td class="main" align="left">Grand Total = $<?php echo $total;?></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="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top"><table border="0" width="100%" 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 == "sku" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=sku&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_PROD_ID . '</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_INVENTORY16, 'orderby=model&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' . TABLE_HEADING_MODEL . '</a>'; ?></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_INVENTORY16, 'orderby=name&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' . TABLE_HEADING_PRODUCTS . '</a>'; ?></td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "cost" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=cost&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_PRICE_LEFT . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "shelf" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=shelf&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_SHELF . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right" bgcolor="FFCCCC"><?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_INVENTORY16, 'orderby=stock&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_QTY_LEFT . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right" bgcolor="CCFF99"><?php if (!isset($orderby) or ($orderby == "reorder" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=reorder&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_REORDER . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "reorder2" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=reorder2&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_REORDER2 . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "total" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=total&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">'. TABLE_HEADING_LINE_T. '</a>'; ?></td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "approved" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=approved&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">'.TABLE_HEADING_CHECK_T. '</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";} elseif ($orderby == "reorder") {$db_orderby = "p.reorder_quantity";} elseif ($orderby == "reorder2") {$db_orderby = "p.products_reorder_to";} elseif ($orderby == "shelf") {$db_orderby = "p.shelf_pack";} elseif ($orderby == "cost") {$db_orderby = "p.vendors_product_price";} elseif ($orderby == "sku") {$db_orderby = "p.products_sku";} elseif ($orderby == "model") {$db_orderby = "p.products_model";} elseif ($orderby == "total") {$db_orderby = "total";} elseif ($orderby == "approved") {$db_orderby = "p.approved";$secsort=",total desc";} else {$db_orderby = "p.approved";$secsort=",total desc"; $sorted='DESC';} $products_query_raw = "select p.products_id, p.products_model, p.products_quantity, pd.products_name, p.products_sku, p.reorder_quantity, p.products_reorder_to, p.shelf_pack, p.vendors_product_price, pr.manufacturers_name,(p.vendors_product_price * p.products_reorder_to) as total, p.approved, p2c.categories_id from " . TABLE_PRODUCTS . " p inner join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id inner join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left outer join " . TABLE_MANUFACTURERS . " pr on p.manufacturers_id = pr.manufacturers_id where p.vendors2_id = 16 and pd.language_id = '" . $languages_id. "' group by pd.products_id order by $db_orderby $sorted $secsort"; $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']; $new_reorder_to = get_products_reorder_to($products['products_quantity'], $products['reorder_quantity'], $products['shelf_pack'], $products['products_reorder_to']); $subtotal = $new_reorder_to * $products['vendors_product_price']; $products_approved = tep_db_query("select approved from " . TABLE_PRODUCTS . " where products_id = $products_id"); $product_approved = tep_db_fetch_array($products_approved); $p_approved = $product_approved["approved"]; if($p_approved==1) $pagetotal += $subtotal; $approvedbutton = tep_draw_checkbox_field('add2order[]',$products_id,(($p_approved==1)? 'true':'')) . ' ' . (tep_not_null(ENTRY_NEWSLETTER_TEXT) ? '<span class="inputRequirement">' . 'Approved'. '</span>': ''); echo '<input type="hidden" name="add2orderlist[]" value="'.$products_id.'">'; ?> <tr class="dataTableRow"onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td align="left" class="dataTableContent"><?php echo $rows; ?>.</td> <td align="right" class="dataTableContent"><?php echo $products['products_sku']; ?></td> <td align="left" class="dataTableContent"><?php echo $products['products_model']; ?></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $products['categories_id'] . '&pID='.$products['products_id'].'&action=new_product') . '" TARGET="_blank"><b>' . $products['products_name'] . '</a></b>'; ?></td> <td align="right" class="dataTableContent"><?php echo $products['vendors_product_price']; ?></td> <td align="right" class="dataTableContent"><?php echo $products['shelf_pack']; ?></td> <td align="right" bgcolor="FFCCCC" class="dataTableContent"><?php echo $products['products_quantity']; ?></td> <td align="right" bgcolor="CCFF99" class="dataTableContent"><?php echo $products['reorder_quantity']; ?></td> <td align="right" width="50" class="dataTableContent"><?php echo tep_draw_input_field('reorder2['.$products_id.']', $new_reorder_to, 'style="width: 100%"'); ?></td> <td align="right" class="dataTableContent"><?php echo sprintf("%01.2f",$subtotal); ?></td> <td align="right" class="dataTableContent"><?php echo $approvedbutton; ?></td> </tr> <?php //} unset($cPath_array); unset($p_category_array); } ?> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" colspan="4" align="center"><input type="submit" name="reset" value="Send/Reset Order" onClick="return confirm('Send/Reset all orders?');"></td> <td class="dataTableHeadingContent" colspan="5" align="center"><input type="submit" name="save" value="Save Order" onClick="return confirm('Save orders?');"></td> <td class="dataTableHeadingContent" colspan="2"><?php echo 'Sub Total : $'.$pagetotal; ?></td> </tr> </table></td> </tr> </form> <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> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.