Security fix changed to use mod/attendance:viewreports capability.

Refactored the code.