Logic for solving date vs hours allocation

Logic for solving date vs hours allocation

Hi All,

I am trying to achieve the below.

I can assign only 9 hours for an user in a single day. Below is the form I have submitted to database.

Resource name : John
Start Date : 1st May 2016
End Date : 31st May 2016
Hours Allocated: 5
Project: ABC

Now the above form is submitted to database. This is phase 1

Now the phase 2 is, I need to add 7 hours for John for another project XYZ for date from 15th May to 31st May 2016. But here I can add only 4 hours and not 7, because allowable limit in a day is 9 hours. So is this logic achievable? Please let me know.

Regards,
Shannila