Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkOrderEntry.php does weird stuff when DB has more than 10 manufactured items (and no pagination buttons) #338

Open
pakricard opened this issue Jan 3, 2025 · 1 comment

Comments

@pakricard
Copy link
Collaborator

Hi all:

In latest WorkOrderEntry.php, when DB (or just one category) has more than 10 manufactured items, the SQL in line 506:

	$SQL = "SELECT  stockmaster.stockid,
					description,
					stockmaster.units
				FROM stockmaster
				INNER JOIN stockcategory
					ON stockmaster.categoryid=stockcategory.categoryid
				WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='M')
					AND stockmaster.description " . LIKE . " '" . $SearchString . "'
					AND stockmaster.categoryid " . LIKE . " '" . $_POST['StockCat'] . "'
					AND stockmaster.stockid " . LIKE . " '" . $SearchCode . "'
					AND stockmaster.discontinued=0
					AND mbflag='M'
					AND (SELECT COUNT(bom.parent) FROM bom WHERE bom.parent=stockmaster.stockid)>0
				ORDER BY stockmaster.stockid";

Returns more than 10 rows.

Then the modified query in line 550 should return $_SESSION['DisplayRecordsMax'] rows (by default 20 rows).

Selecting one item (in this example the first one, marked in yellow) and clicking "add to work order":

image

The item marked in blue (position 11) has not been selected.

After clicking on Add to Work Order

image

Two items are added to the work order, which is wrong.

The script always adds the item selected (position i) and another one, (in position 10 + i)

As I can see, it is due to the rewritten logic in the foreach loop in line 77

	foreach ($_POST as $Key => $Value) {
		if (substr($Key, 0, 7) == 'StockID') {
			$Index = substr($Key, -1);
			if ($_POST['Quantity' . $Index] > 0) {

So, if user only selects item in position 1, the condition

$_POST['Quantity' . $Index] > 0

is true for item 1, but also item in position 11, 21, 31, etc.

Besides this, no pagination buttons are shown (to move to the next or previous page).

The logic of the script was changed completely on Tim's commit done on 05 Set 2024 "Change the data input forms to use

rather than the uglier which should only be used to display tables of data.". Not sure of the reasons for the change of logic.

Previous version 09 August 2020 worked OK.

@dalers
Copy link
Collaborator

dalers commented Jan 8, 2025

Hi @pakricard I presume @timschofield intended only to change the presentation and not any business logic. At this point, it might be simplest to manually merge the logic from the old file back into the latest file.

Regarding the missing pagination buttons, perhaps this is only a pagination issue and not related to the change in logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants