How to make trigger function to make daily entering-exiting report?
Let's assume every "in" is followed by an "out" event. In that case you can do:

SELECT worker_id, 
    the_date as in_date, 
    the_time as in_time,
    lead(the_date) over w as out_date, 
    lead(the_time) over w as out_time,
    -- Check if it is really an out event
    (lead(in_or_out) over w) = 0 as out
FROM daily_report
-- Filter for in events
WHERE in_or_out = 1 AND worker_id = [your_worker_id]
-- specify the window function
WINDOW w AS (order by the_date, the_time)
GROUP BY worker_id;


You didn't write which PG version do you have. A better approach is to have LATERAL JOINs (available since 9.3):

SELECT worker_id, i.the_date, i.the_time, o.the_date, o.the_time
FROM daily_report i
LEFT JOIN LATERAL (
    SELECT r.the_date, r.the_time 
    FROM daily_report r 
    WHERE 
        in_or_out = 0 AND r.worker_id = i.worker_id
        (
            (r.the_date = i.the_date and r.the_time &gt; i.the_time) OR 
            (r.the_date &gt; i.the_date)
        )
    ORDER BY 1, 2
    LIMIT 1
) o ON true
WHERE in_or_out = 1 AND worker_id = [your_worker_id]


This is a more generic query and will give you back better results if the data is somehow not completely correct.