Link to home
Start Free TrialLog in
Avatar of Ridgejp
RidgejpFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to reduce Data Entry on a Form Submission

I have a form/page that I'm using to book in stock based on a poNumber that generates the stock items linked to that poNumber/supplier. Currently for each line (there may be 10 items for example on order) the user needs to add qty rec'd, qty outstanding, receipted by and delivery note number in the form for each line.

I want to short cut some of the data entry by having a single entry for receipted by and delivery note number but for this to populate the rows for each entry once submitted.

The code I have at the moment is as follows: -

<div class="container">	
	<form class="form" method="post" action="transit_temp.php">	
	
	<?php
	
	$poNumber = isset($_POST['poNumber']) ? $_POST['poNumber'] : false;
	
	$poNumber = $mysqli->real_escape_string($poNumber);
	
	$index=0;

	$query = 'SELECT * FROM goodsInTrans WHERE poNumber = "'.$poNumber.'"';
			
				if (!$result = $mysqli->query($query)) {
				$err
				= "QUERY FAIL: "
				. $query
				. ' ERRNO: '
				. $mysqli->errno
				. ' ERROR: '
				. $mysqli->error
				;
				trigger_error($err, E_USER_ERROR);
				}		
	
				while ($row = $result->fetch_object())
				
				{ 

				?>
					<div class="form-group row">
						<div class=""><input type="hidden" 				class="form-control" 	name="data[<?php echo $index; ?>][supplier]" 			value="<?php echo $row->supplier ?>"/></div>
						<div class="col-xs-3"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][sku]"	 				value="<?php echo $row->sku ?>"/></div>
						<div class="col-xs-4"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][skuSupplier]"	 		value="<?php echo $row->skuSupplier ?>"/></div>
						<div class="col-xs-2"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][deliveryNote]"	 	value="" 	placeholder="Delivery Note"/></div>
						<div class="col-xs-1"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][unitsRequired]" 		value="<?php echo $row->unitsRequired ?>"/></div>
						<div class="col-xs-1"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][unitsReceived]" 		value="" 	placeholder="Rec'd"/></div>
						<div class="col-xs-1"><input type="text" 		class="form-control" 	name="data[<?php echo $index; ?>][unitsOutstanding]" 	value="" 	placeholder="O/S"/></div>
						
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][poNumber]"	 			value="<?php echo $row->poNumber ?>"/></div>
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][dateOfPurchaseOrder]"	value="<?php echo $row->dateOfPurchaseOrder ?>"/></div>
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][skuSupplier]"			value="<?php echo $row->skuSupplier ?>"/></div>
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][cartonsSize]"			value="<?php echo $row->cartonsSize ?>"/></div>
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][cartonsRequired]"		value="<?php echo $row->cartonsRequired ?>"/></div>
						<div class=""><input type="hidden" 		class="form-control" 			name="data[<?php echo $index;?>][receipt]"	 			value="Henry Ford"/></div>
					</div>
					
				<?php
				
				$index++;					
				}
				
				?>
					<div class="form-group">
						<button type="submit" name="submit1" class="form-control btn btn-primary form-inline">Submit Stock Transfer</button>
					</div>		
	</form>

Open in new window

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Not quite sure what you are asking?

Where is the data ultimately going to?
Avatar of Ridgejp

ASKER

The data rows sit in a table named ‘goodsInTrans’ (or goods in transit)  awaiting the stock to arrive.

Once it arrives we process the stock using the form (based on the unique poNumber) adding actual qty’s shipped etc before pressing submit where it is transferred into a final table called goodsIn which serves as a record of stock inbound and later is used to update the inventory table qty’s.

It currently works fine but I’d like to improve it so that instead of repeating the delivery note number and the name of the person who receipted the stock on each row, that in the form there’s just one field for the ‘receipted by’ and one field for ‘delivery note number’ regardless of whether there’s one line of stock or 100.

Then when the data is transferred those two fields also update the tables rows in the goodsIn tables along with the other data transferred.

Does that make better sense?
It currently works fine but I’d like to improve it so that instead of repeating the delivery note number and the name of the person who receipted the stock on each row, that in the form there’s just one field for the ‘receipted by’ and one field for ‘delivery note number’ regardless of whether there’s one line of stock or 100.
I got that I was hoping to see actual data - much easier to talk around.

Let's try to distill out the essence of what you want to do without getting too much into the detail of your business model.

The way I understand it - you have a form that has multiple rows.
Each row has common information with the rows above and below it
Each row has some unique information you want to capture.
You don't want to have to repeat the common information as fields for capture - you rather want the only fields to be the ones that are unique per row.
When the data is submitted, however, you need the common values for when you insert the record into the target table.

Is that correct?

If so let's see what the input data looks like and what the target table looks like.

Also, there needs to be a field on your form somewhere that stores some value (PONumber or record id - whatever is the unique id for your order) that you can pass back to the processing script.
Avatar of Ridgejp

ASKER

Ok ... give me 5mins.
Avatar of Ridgejp

ASKER

Table 1 - goodsInTrans
dateOfPurchaseOrder
poNumber
supplier
sku
skuSupplier
unitsRequired
receiptedBy

Table 2 - goodsIn
dateOfPurchaseOrder
poNumber
supplier
sku
skuSupplier
unitsRequired
unitsReceived
unitsOutstanding
deliveryNoteNumber
receiptedBy
Avatar of Ridgejp

ASKER

The upload into goodsInTrans is via a CSV file from a purchase order. I'll upload some sample data now - 2mins.
Avatar of Ridgejp

ASKER

Sample data enclosed.

The form currently takes the data from goodsInTrans (sample enclosed) and adds both new and unique data e.g: -

unitsReceived
unitsOutstanding

The common data for each form entry is

deliveryNoteNumber
receiptedBy

When there's just a few lines it's fine but sometimes we can have 30-40 lines of data.

J
Avatar of Ridgejp

ASKER

Sorry file is here.
goodsInTrans---Sample-Data.csv
still not clear - was my synopsis earlier in the ballpark?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.