Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
StockAdjustmentsControlled.php
03-06-2012, 10:32 PM, (This post was last modified: 03-06-2012, 10:56 PM by Soujiro.)
#1
StockAdjustmentsControlled.php
In the last version i try to do an Adjustment on a serial controlled item and i get the following error

This page can only be opened if a stock adjustment for a controlled item has been entered

Doing some research show me that the problem is that vaule of $identifier var is diferent to the value in the $_SESSION var key ($_SESSION['Adjustment'.$identifier])

$identifier=1331036872
[Adjustment1331036399] => StockAdjustment Object

I believe that the problem is in line 454 of StockAdjustments.php
[<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=ADD">'._('Add').'</a>]';
It should be
[<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=ADD&identifier='.$identifier.'">'._('Add').'</a>]';
Reply
03-07-2012, 01:56 AM,
#2
RE: StockAdjustmentsControlled.php
Well i do more research it seems the whole code is messed up, al least with serial items i apply the following patches to get it working but i need to confirm they are fine.

StockAdjustments.diff
Code:
@@ -10,7 +10,8 @@
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');

-if (empty($_GET['identifier'])) {
+if (isset($_POST['identifier'])) $identifier=$_POST['identifier'];  //this fix serial items session when sending the form
+elseif (empty($_GET['identifier'])) {
    /*unique session identifier to ensure that there is no conflict with other adjustment sessions on the same machine  */
    $identifier=date('U');
} else {
@@ -79,10 +80,8 @@
    if ($_POST['Quantity']=='' OR !is_numeric(filter_number_format($_POST['Quantity']))){
        $_POST['Quantity']=0;
    }
-} else {
-    $_POST['Quantity']=0;
-}
-$_SESSION['Adjustment' . $identifier]->Quantity = filter_number_format($_POST['Quantity']);
+    $_SESSION['Adjustment' . $identifier]->Quantity = filter_number_format($_POST['Quantity']);     //this fix problems when returning form StockAdjustmentsControlled
+}

echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Inventory Adjustment') . '" alt="" />' . ' ' . _('Inventory Adjustment') . '</p>';

@@ -435,10 +434,10 @@
} else {
    $Narrative ='';
}
-
+//this enable long comments on why, also need to modify stockmoves table, field reference to varchar(250)
echo '<tr>
        <td>'. _('Comments On Why').':</td>
-        <td><input type="text" name="Narrative" size="32" maxlength="30" value="' . $Narrative . '" /></td>
+        <td><textarea name="Narrative"  cols="50" rows="5">'.$_SESSION['Adjustment']->Narrative.'</textarea></td>
    </tr>';

echo '<tr><td>'._('Adjustment Quantity').':</td>';
@@ -448,10 +447,13 @@
        if ($_SESSION['Adjustment' . $identifier]->StockLocation == ''){
            $_SESSION['Adjustment' . $identifier]->StockLocation = $_SESSION['UserStockLocation'];
        }
+        //this fix problem with session and serial items in post form
+        echo '<input type="hidden" name="identifier" value="' . $identifier . '" />';  
+        //this fix problem with session and serial items in calls to StockAdjustmesControlled.php
        echo '<input type="hidden" name="Quantity" value="' . $_SESSION['Adjustment' . $identifier]->Quantity . '" />
                '.locale_number_format($_SESSION['Adjustment' . $identifier]->Quantity,$DecimalPlaces) .' &nbsp; &nbsp; &nbsp; &nbsp;
-                [<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=REMOVE">'._('Remove').'</a>]
-                [<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=ADD">'._('Add').'</a>]';
+                [<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=REMOVE&identifier='.$identifier.'">'._('Remove').'</a>]
+                [<a href="'.$rootpath.'/StockAdjustmentsControlled.php?AdjType=ADD&identifier='.$identifier.'">'._('Add').'</a>]';
} else {
    echo '<input type="text" class="number" name="Quantity" size="12" maxlength="12" value="' . locale_number_format($Quantity,$DecimalPlaces) . '" />';
}

StockAdjustmentsControlled.diff
Code:
@@ -45,7 +45,7 @@
/*****  get the page going now... *****/
echo '<div class="centre">';

-echo '<br /><a href="'.$rootpath.'/StockAdjustments.php">' . _('Back to Adjustment Screen') . '</a>';
+echo '<br /><a href="'.$rootpath.'/StockAdjustments.php?identifier='.$identifier.'">' . _('Back to Adjustment Screen') . '</a>'; //this fix the returning to stock adjustments

echo '<br /><font size="2"><b>'. _('Adjustment of controlled item').' ' . $LineItem->StockID  . ' - ' . $LineItem->ItemDescription ;

@@ -72,8 +72,8 @@

/*TotalQuantity set inside this include file from the sum of the bundles
of the item selected for adjusting */
-$_SESSION['Adjustment'.$identifier]->Quantity = $TotalQuantity;
-
+//this is a litle check, if not adjustment then not modify Quantity
+if  ($TotalQuantity!=0) $_SESSION['Adjustment'.$identifier]->Quantity = $TotalQuantity;
/*Also a multi select box for adding bundles to the adjustment without keying, showing only when keying */
include('includes/footer.inc');
?>
Reply
03-07-2012, 06:34 PM,
#3
RE: StockAdjustmentsControlled.php
Hi, Soujiro,

Thanks for reporting this bugs and hard working to find a solution. I've reviewed those codes and fixed it in SVN.
The main reason for this bug is that $identifier is missing in some places.
I've attached the revised file for your reference.
Thanks and best regards!
Exson


Attached Files
.zip   StockAdjustments.zip (Size: 6.14 KB / Downloads: 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)