|----|------------|--------------|----------|
| id | fromdate | todate | priority |
|----|------------|--------------|----------|
| 1 | 2016-01-01 | 2016-01-30 | 1 |
| 2 | 2016-01-05 | 2016-01-20 | 2 |
| 3 | 2016-01-11 | 2016-01-12 | 3 |
|----|------------|--------------|----------|
This is a sample of input in my table "test". this table shows date assigned to particular user (only one user shown here).
I need to make a schedule from this as below.
|------|--------------|--------------|-----------|
| id | fromdate | todate | priority |
|------|--------------|--------------|-----------|
| 1 | 2016-01-01 | 2016-01-05 | 1 |
| 2 | 2016-01-05 | 2016-01-11 | 2 |
| 3 | 2016-01-11 | 2016-01-12 | 3 |
| 4 | 2016-01-12 | 2016-01-20 | 2 |
| 5 | 2016-01-20 | 2016-01-30 | 1 |
|------|--------------|--------------|-----------|
Users work will be scheduled according to the priority and date. If on date 16-01-2016 he will be coming under priority 2.
so I want to get a list of all the possible date entries for the person with the priority.
Priority is when a user has 2 entries in same date the higher one should be used.
In the given example 1- 30 it is in priority 1 after that on 5th the priority is set to 2 and on 11-12 the priority is set to 3 so,after 12th the priority should be set back to 2 and on 20th the priority is back again to 1 in simple words. i need entries for an entire month...