From: <tu...@us...> - 2018-02-22 09:49:01
|
Revision: 7976 http://sourceforge.net/p/web-erp/reponame/7976 Author: turbopt Date: 2018-02-19 17:49:26 +0000 (Mon, 19 Feb 2018) Log Message: ----------- PaulT: Stocks.php: Fix navigation bar handling to avoid stockid loss and also disable navigation submit when at the first (or last) item. Change also adds a closing table tag, removes an extra double quote from two attributes, and a minor message layout improvement. Modified Paths: -------------- trunk/Stocks.php trunk/doc/Change.log Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2018-02-18 02:30:38 UTC (rev 7975) +++ trunk/Stocks.php 2018-02-19 17:49:26 UTC (rev 7976) @@ -21,10 +21,22 @@ $ItemDescriptionLanguagesArray = explode(',',$_SESSION['ItemDescriptionLanguages']);//WARNING: if the last character is a ",", there are n+1 languages. +$hasNext = true; +$hasPrev = true; + if (isset($_POST['NextItem'])){ $Result = DB_query("SELECT stockid FROM stockmaster WHERE stockid>'" . $StockID . "' ORDER BY stockid ASC LIMIT 1"); - $NextItemRow = DB_fetch_row($Result); - $StockID = $NextItemRow[0]; + + // Only change the StockID if we find a row. + // If not, the StockID is 'clobbered' with null and causes form havoc. + if ( DB_num_rows( $Result ) > 0 ) { + $NextItemRow = DB_fetch_row($Result); + $StockID = $NextItemRow[0]; + } + else { + $hasNext = false; + } + foreach ($ItemDescriptionLanguagesArray as $LanguageId) { unset($_POST['Description_' . str_replace('.','_',$LanguageId)]); } @@ -31,8 +43,17 @@ } if (isset($_POST['PreviousItem'])){ $Result = DB_query("SELECT stockid FROM stockmaster WHERE stockid<'" . $StockID . "' ORDER BY stockid DESC LIMIT 1"); - $PreviousItemRow = DB_fetch_row($Result); - $StockID = $PreviousItemRow[0]; + + // Only change the StockID if we find a row. + // If not, the StockID is 'clobbered' with null and causes form havoc. + if ( DB_num_rows( $Result ) > 0 ) { + $PreviousItemRow = DB_fetch_row($Result); + $StockID = $PreviousItemRow[0]; + } + else { + $hasPrev = false; + } + foreach ($ItemDescriptionLanguagesArray as $LanguageId) { unset($_POST['Description_' . str_replace('.','_',$LanguageId)]); } @@ -893,19 +914,22 @@ echo '<form name="ItemForm" enctype="multipart/form-data" method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; -echo '<div>'; -if (isset($StockID)){ +echo '<div> + <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> + <input type="hidden" name="New" value="'.$New.'" />'; + +if (isset($StockID) && $StockID != '' && $InputError == 0){ echo '<table width="100%"> <tr> - <td width="5%"><input style="background:url(css/previous.png);width:26px;height:43px;" type="submit" name="PreviousItem" value="" /></td> + <td width="5%"><input style="background:url(css/previous.png);width:26px;height:43px;" type="submit" name="PreviousItem" value="" ' . ($hasPrev ? '' : 'disabled') . ' /></td> <td width="90%"></td> - <td width="5%"><input style="background:url(css/next.png);width:26px;height:43px;" type="submit" name="NextItem" value="" /></td> - </tr>'; + <td width="5%"><input style="background:url(css/next.png);width:26px;height:43px;" type="submit" name="NextItem" value="" ' . ($hasNext ? '' : 'disabled') . ' /></td> + </tr> + </table>'; } -echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> - <input type="hidden" name="New" value="'.$New.'" /> - <table class="selection">'; +echo '<table class="selection">'; + if (!isset($StockID) OR $StockID=='' or isset($_POST['UpdateCategories'])) { /*If the page was called without $StockID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden StockID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ @@ -915,7 +939,7 @@ if ($New==1) { echo '<tr> <td>' . _('Item Code'). ':</td> - <td><input type="text" ' . (in_array('StockID',$Errors) ? 'class="inputerror"' : '' ) .'" data-type="no-illegal-chars" autofocus="autofocus" required="required" value="'.$StockID.'" name="StockID" size="20" maxlength="20" title ="'._('Input the stock code, the following characters are prohibited:') . ' \' " + . & \\ > <" placeholder="'._('alpha-numeric only').'" /></td> + <td><input type="text" ' . (in_array('StockID',$Errors) ? 'class="inputerror"' : '' ) . ' data-type="no-illegal-chars" autofocus="autofocus" required="required" value="'.$StockID.'" name="StockID" size="20" maxlength="20" title ="'._('Input the stock code, the following characters are prohibited:') . ' \' " + . & \\ > <" placeholder="'._('alpha-numeric only').'" /></td> </tr>'; } else { echo '<tr> @@ -1040,7 +1064,7 @@ } echo '<tr> <td>' . $LanguagesArray[$LanguageId]['LanguageName'] . ' ' . _('Long Description') . ':</td> - <td><textarea name="'. $PostVariableName . '"" cols="40" rows="3">' . stripslashes(AddCarriageReturns($_POST[$PostVariableName])) . '</textarea></td> + <td><textarea name="'. $PostVariableName . '" cols="40" rows="3">' . stripslashes(AddCarriageReturns($_POST[$PostVariableName])) . '</textarea></td> </tr>'; } } @@ -1451,10 +1475,9 @@ echo '<input type="submit" name="submit" value="' . _('Update') . '" />'; echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '" />'; - echo '<br />'; - prnMsg( _('Only click the Delete button if you are sure you wish to delete the item!') . _('Checks will be made to ensure that there are no stock movements, sales analysis records, sales order items or purchase order items for the item') . '. ' . _('No deletions will be allowed if they exist'), 'warn', _('WARNING')); + echo '<br /><br />'; + prnMsg( _('Only click the Delete button if you are sure you wish to delete the item!') . '<br />' . _('Checks will be made to ensure that there are no stock movements, sales analysis records, sales order items or purchase order items for the item') . '. ' . _('No deletions will be allowed if they exist') . '.', 'warn', _('WARNING')); echo '<br /> - <br /> <input type="submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');" />'; } @@ -1462,4 +1485,4 @@ </div> </form>'; include('includes/footer.php'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2018-02-18 02:30:38 UTC (rev 7975) +++ trunk/doc/Change.log 2018-02-19 17:49:26 UTC (rev 7976) @@ -1,5 +1,6 @@ webERP Change Log +19/2/18 PaulT: Stocks.php: Fix navigation bar handling to avoid stockid loss and also disable navigation submit when at the first (or last) item. Change also adds a closing table tag, removes an extra double quote from two attributes, and a minor message layout improvement. 17/2/18 PaulT: PO_SelectOSPurchOrder.php: Derived from Tim's code: add default current dates. (there may not yet be any purchorders records) / PaulT: do not show the order list table when there are no records to show. (avoids a table heading output without any associated row data) 17/2/18 Tim (PaulT commit): MiscFunctions.js: Set the calendar click and change handlers to reference the localStorage DateFormat instead of the element's "alt" attribute value. (Know that this update requires the localStorage change applied with commit 7973) 17/2/18 PaulT: header.php: Set the DOCTYPE to html5 declaration format, update the meta tag with Content-Type info, and add localStorage with DateFormat and Theme for upcoming changes to table column sorting and calendar handling improvements. |