Thursday, 1 June 2017

Need help to show two arrays in one table

There are 2 option My database is constructed like this

{
    "_id" : ObjectId("58ecbb3be949603f122dfcc4"),
    "work_id" : 651853,
    "date" : ISODate("2017-04-10T00:00:00.000Z"),
    "updated_at" : ISODate("2017-04-11T11:17:42.067Z"),
    "name" : "John Doe",
    "wage_type" : [ 
        {
            "_id" : ObjectId("58ecbb567f7ed00c2ca041b6"),
            "type_ident" : "157",
            "start_string" : "020000",
            "start_time" : "02:00:00",
            "total" : "08:00:00",
            "end_time" : "09:59:59",
            "end_string" : "095959",
            "group" : "Wage Type<br/>",
            "end_date" : "2017-04-10",
            "type" : "Morning Hours",
            "start_date" : "2017-04-10",
            "time_sheet_ident" : "248288"
        }
    ],
    "campaign" : [ 
        {
            "_id" : ObjectId("58ecbb567f7ed00c2ca041b5"),
            "type_ident" : "165",
            "start_string" : "020000",
            "start_time" : "02:00:00",
            "total" : "08:00:00",
            "end_time" : "09:59:59",
            "end_string" : "095959",
            "group" : "Campaign<br/>",
            "end_date" : "2017-04-10",
            "type" : "Waitter",
            "start_date" : "2017-04-10",
            "time_sheet_ident" : "248288"
        }
    ],
    "__v" : 0,
    "created_at" : ISODate("2017-04-11T11:17:13.182Z")
}

But I find 2 difficulties First when an worker has this structure

Based on user wage

John Doe | Morning Hours | 4.00-12.00

Based on user campaign

John Doe | Waiter | 4.00-8.00
John Doe | Bartender | 8.00-12.00

And this is the other option

Jim Dow | Morning Hours | 9.00-16.00
JIm Dow | Night Hours | 16-18

Based on campaign

Jim Dow | Waitter | 9.00-18.00

What i could do till now is when the have the same start time and end time so i pass the campaign in which he worked on

The difficult part which i cant find out is when they are 2 john doe on database on different campaigns or 2 jim dow on 2 different timesheets

If u can help me thanks in advance



via Ardit Kurti

No comments:

Post a Comment