Welcome Guest, Not a member yet? Register   Sign In
Ideas for Approval Matrix in CI


Need help. Can't think on how I can handle this problem. I need an approval matrix system. Here's the plan:

I have 4 users, "QA", "Team Lead", "Manager", "Human Resource"

  1. The QA will generate a form.
  2. The form will go to "Team Lead" for his/her approval.
  3. Once approved, the form will go to "Manager".
  4. Once approved again by the Manager, the form will now go to "HR"
  5. Once approved, this form will go back to "Team Leader" to create an Notice-to-Explain (NTE)
  6. When done, this will passed to the agent, responding to the NTE, confirming and submit.
  7. After the submission, the TL will receive the NTE to generate a PDF (with DOCX Templating). And save the PDF to server and save the filepath/name to the database.
Now, I know it sounds complicated (for me), but I need some ideas on how to create this.

My first idea was to use a JSON string instead of creating a separate columns for them. After the QA created a form, I will create an array of approval matrix then save as JSON. But I think this idea is bad.

The next idea was to create a new table and create a column for the approval structure/matrix. I will name them descriptively (is that the right term?)

Table Name: tbl_approval_matrix
Then I'll add 1 or 0 for TRUE and FALSE. But my worries about this technique is "what if the management decided to add one approval step like the BOSS should approve this form first before sending the form to HR?" and also I need to record the date when did they approved or rejected the form. Also I need to assign this to a user (QA, TL, Manager, HR, Agent).

And also the form should go back one step backward if rejected (ex: HR rejected the form, the form should return to Manager for review)

Sorry for my bad English. I don't have any ideas right now and I only have 1 week to finish this approval matrix. And by the way, while I'm typing this, I'm on PANIC MODE.
Thank you for the help. Hope you understand my bad English.

There's one problem with having matrix - these flows can change, and this is where more flexibility will pay off, god knows I've paid the price of having to re-write simple solutions quite few times.

It's probably slightly more work at first, but here's how I would do it.

Have table with different phases / states:
1 - teamlead approval
2 - manager approval
3 - hr approval
10 - approved

Then, I add current state ID to form table, it starts with 1, and you can easily query DB to get all "pending manager approval" rows.

When user approves, you have approvals log table that keeps form ID, user ID who approved it, timestamp, and approval phase / state ID), and you move the form state ID to next state.

You can eventually expand this system relatively easily, like keeping different options in DB too (if current state is 1, and you approve, it moves to state 2, if you reject, it'll move to state 10).

Based on your suggestion, I have to create multiple tables for the approval matrix? Correct me if I'm wrong.

You don't need the log table necessarily, but IMHO it's good idea to have record of who did what when.

I need that too. I'll try to work on this then I'll get back to you after my dev and testing. Hope your suggestion works.

If this forum can give a hundred reputation points, I'll give you twice of that. Thank you.

+respect  Shy


For some reason, I found your idea a little complex for me. Any new alternatives?

Or maybe some examples?


Maybe this is what your looking for.

How to design database request/approval tables
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

(08-24-2018, 09:25 AM)InsiteFX Wrote: Maybe this is what your looking for.

How to design database request/approval tables

Yes, exactly. That question makes more sense.

So.. how to design database request/approval tables?

This way you can have a form and add more users (personel).

table users

table forms
appoved_by ie approved_name or the integer id from above table

make the forms table the way you want, but the first table users will allow you
to add to it later if they decide they want a boss etc;

Just a rough go at it you will need to decide how you want it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB