Jump to content

Multiple Approvals for Product List


spencpu

Recommended Posts

Currently am building an internal php mysql application for my company where we store products with their part numbers. I'm having trouble wrapping my head around how to have multiple approvals for each product.

The struggle is there are 3 things that need to be approved (likely a check box), but once the first checkbox is approved, it will be greyed out with the person who clicked the checkbox (grabbed by ip address) beside it.

Any help would be greatly appreciated.

Link to comment
Share on other sites

Exactly what part are you stuck on? How to store the data for the different approvals, how to create the form with variable states of the input fields or what?

 

Here is how I would create the data schema:

 

Create a second table called approvals with fields for product_id, approval_ip, approval_type & approval_date (note the date field could be a timestamp field that is set to automatically populate with the current date/time so you don't have to include it in your queries.

 

So, for the form, when loading a product form page you will JOIN the approval records on the product record when getting the data. Then, if there is a record for a specific approval type show the checkbox as checked and disabled (you could also show the approver/date next to the field if you wish). When a user submits the form, process the checkboxes and add records to the approvals table for any that are checked. I believe you can set the disabled fields such that they are not passed in the post data so you won't create duplicate records, but your code should be written such that it only creates an approval record for a product if one of that type does't already exist. The best way to do this is to create an index using BOTH the product_id & approval_type. This ensures you cannot create a duplicate approval record of the same approval type for the same record.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.