spencpu Posted June 21, 2017 Share Posted June 21, 2017 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 21, 2017 Share Posted June 21, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.