App-Dochazka-Common
view release on metacpan or search on metacpan
lib/App/Dochazka/Common.pm view on Meta::CPAN
=head1 DOCHAZKA DATA MODEL
This section describes the Dochazka data model. Conceptually, Dochazka data
can be seen to exist in the following classes of objects, all of which are
implemented by this module:
=over
=item * Policy (parameters set when database is first created)
=item * Employee (an individual employee)
=item * Privhistory (history of changes in an employee's privilege level)
=item * Schedule (a schedule)
=item * Schedhistory (history of changes in an employee's schedule)
=item * Activities (what kinds of work are recognized)
=item * Intervals (the "work", or "attendance", itself)
=item * Locks (determining whether a reporting period is locked or not)
=item * Components (Mason components, i.e. report templates)
=back
These classes are described in the following sections.
=head2 Policy
Dochazka is configurable in a number of ways. Some configuration parameters
are set once at installation time and, once set, can never be changed --
these are referred to as "site policy" parameters. Others, referred to as
"site configuration parameters" or "site params", are set in configuration
files such as C<Dochazka_SiteConfig.pm> (see L</SITE CONFIGURATION>) and
can be changed more-or-less at will.
The key difference between site policy and site configuration is that
site policy parameters cannot be changed, because changing them would
compromise the referential integrity of the underlying database.
Site policy parameters are set at installation time and are stored, as a
single JSON string, in the C<Policy> table. This table is rendered
effectively immutable by a trigger.
For details, see L<App::Dochazka::REST::Model::Policy>.
=head2 Employee
Users of Dochazka are referred to as "employees" regardless of their
legal status -- in reality they might be independent contractors, or
students, or even household pets, but as far as Dochazka is concerned they
are employees. You could say that "employee" is the Dochazka term for "user".
The purpose of the Employee table/object is to store whatever data the site
is accustomed to use to identify its employees.
Within Dochazka itself, employees are distinguished by an internal employee ID
number (EID), which is assigned by Dochazka itself when the employee record is
created. In addition, four other fields/properties are provided to identify
the employee:
=over
=item * nick
=item * sec_id
=item * fullname
=item * email
=back
All four of these, plus the C<eid> field, have C<UNIQUE> constraints defined at
the database level, meaning that duplicate entries are not permitted. However,
of the four, only C<nick> is required.
Depending on how authentication is set up, employee passwords may also be
stored in this table, using the C<passhash> and C<salt> fields.
For details, see L<App::Dochazka::REST::Model::Employee>.
=head2 Privhistory
Dochazka has four privilege levels: C<admin>, C<active>, C<inactive>, and
C<passerby>:
=over
=item * C<admin> -- employee can view, modify, and place/remove locks on her
own attendance data as well as that of other employees; she can also
administer employee accounts and set privilege levels of other employees
=item * C<active> -- employee can view her own profile, attendance data,
modify her own unlocked attendance data, and place locks on her attendance
data
=item * C<inactive> -- employee can view her own profile and attendance data
=item * C<passerby> -- employee can view her own profile
=back
Dochazka's C<privhistory> object is used to track changes in an employee's
privilege level over time. Each time an employee's privilege level changes,
a Dochazka administrator (i.e., an employee whose current privilege level is
'admin'), a record is inserted into the database (in the C<privhistory>
table). Ordinary employees (i.e. those whose current privilege level is
'active') can read their own privhistory.
Thus, with Dochazka it is possible not only to determine not only an employee's
( run in 1.996 second using v1.01-cache-2.11-cpan-9169edd2b0e )