I'm trying to build a checklist/signoff system. Basically, I've got a form that the user fills out, see below. The user is automatically put there based on who is logged in.
http://i.imgur.com/sTysmyV.jpg
Each Checklist is attached to a specific Job number. So say a manager wants to look at Job 1000, he'll click it, navigate to "Checklists" and he'll see the checklist below.
http://i.imgur.com/kGqcyZt.jpg
Now, I have an option to select different revisions of a checklist for a job so that managers can look at different revisions.
I'm just not sure on how to string everything together.
I have 2 tables so far.
checklist_component_stock
and checklist_revision
I'm not sure how to link everything correctly in the tables so when Rev1 gets pulled up say for Job 1000, it shows the correct rows that have been created for that specific job and revision.
Assuming I'm understanding your question correctly, Each time a checklist is updated, I'm guessing that you're currently updating the existing checklist_component_stock
record, and inserting the new revision information into the checklist_revision
table..?
If so, then you need to add a revision
field into your checklist_component_stock
table, and make this part of the foreign key to the checklist_revision
table.
Then, when a checklist is changed, insert a new record into checklist_component_stock
with the new revision number, as well as inserting your new revision information into the checklist_revision
table.
Then, when you pull back a specific revision, you'll do something like:
SELECT *
FROM checklist_component_stock a
INNER JOIN checklist_revision b ON a.job_num = b.job_num
AND a.revision = b.revision
WHERE a.job_num = xxx
AND a.revision = yyy