PHP / MySQL Stock Control System

Hello,
I have created a stock control system to allow admin staff to keep track of incoming and outgoing stock.

However I have now been told that they want to be able to process several items to one department at a time.

I would like to know what the best way of doing this is, I was thinking about something along the lines of a Shopping Basket but have never dealt wth anything like this before.

A demonstration version of the system can be found at http://www.sm2.atchosting.co.uk/demo/

Feel free to have a look at that to see how it works at the moment. :slight_smile:

I will update the thread later with a link to the Source Code.

Best Regards,
Ben

Do you mean on the “Process Order” screen - to be able to keep picking from a list and then send 2 or more items into the order?

yes that is what I mean

Sorry for the delay with providing the source code, unfortunately I was away over the weekend and did not have access to the internet.

http://www.sm2.atchosting.co.uk/source.zip

If anyone has any problems accessing the Source Code please let me know.

Best Regards,
Ben

There’s a few ways of doing the same thing.

I did similar by having a text area on a page, and each time they want to pick an item I popped up a new window and used JS parent.opener to send back the code number and a text description into the text area.

I liked using that idea because, a) if ppl know the id number of the item they can just tap it in themselves, b) they can easily delete an item.

Its just a matter of analysing the numbers in the text area when the form is submitted, and maybe giving them visual confirmation of what they just did, or asking them to confirm before really committing.

You could do the same with frames, or with Ajax, or purely JS on a page - there should be some examples on javascript.intenet.com of how to shift values from one picklist to a text area.

right ok thank you for that I shall explore those routes, is there any possibility of seeing what you did as an example?

Best Regards,
Ben

The whole thing is handled inside a framework (CodeIgniter) so is splintered around the place. The model is really basic, probably much like yours.

Which part do need a hand with? Is it just the JS shifting around of variables from popup windows?

Firstly I have never really done much work with Javascript, and secondly I dont quite understand how putting the data into a text field would then allow me to query the database to carry out all of the necessary functions.

Sorry if I am making things difficult for you but I am quite new to using PHP and am still learning.

Best Regards,
Ben

Ok, if you dont use/understand JS, this would be a bridge too far for you.

Try this instead:

How about you make an “optional page” ( “Ordering more than one product? Go here” ) that has all your products and an input box for how many can be ordered of each type.

From your screen:


<option value="270198">Bic Pen BLUE</option>
<option value="270185">Bic Pens BLACK</option>
<option value="335614">Bic Pens RED</option>
<option value="284966">Bin Blue </option>
etc

On the user page you could echo a list like this:


<form .... method = post>
<input type=text name="product[270198]" value="">Bic Pen BLUE<br />
<input type=text name="product[248966]" value="">Bn BLUE<br />
... //etc
</form>

Lets say they enter 150 on that input box… so then on your postback form you’d do something like:


echo $_POST['product'][270198] // and you'd see "150"

Then you could see how to deal with anything where each $_POST[‘product’] array contains a value, and save it.

(hint L use print_r( $_POST[‘product’] ); to see what is being sent )

What you’d likely want to do though is then set a min and max order number for each item. I mean do you want to process an order for 1 pen or 100 waste paper baskets, y’know what I mean … just in case of user error.

Even if you don’t use the idea as is, hacking it up should get you going …

thank you for that, I shall have a go and see what I come up with, someone else has recommended I use sessions and create something a bit like a shopping basket, what is your view on this?

Best Regards,
Ben

I dion’t really see how a shopping basket would do.

However, the use of sessions is a good idea - it’s up to you how to implement them though.

If your app is on an intranet only, then yes go for sessions.

If your understanding of security is shaky, and you app is available to anyone over the web, then OK, use sessions but read a lot on security and sessions.

I’d say test/mock up both methods, especially when you are thinking of your worst user y’know the technophobe who forgot their glasses today and wants to order just 3 pens and 100 waste paper baskets.

How do you confirm what is being done, how do you abandon the basket, how do you take things out …

That kind of real world requirement.

(can someone really order 100 waste paper baskets when you probably only carry a stock of what, 3?)

If youv’e never passed around multi-dimensional arrays from form to page, then you may find that tricky enough for now, and I’d advise you try that method first - while you’re at it, if you aren’t familiar with the ~80 php array based functions, well this’ll sure get you started.