| 1 |
use strict; |
|---|
| 2 |
use warnings; |
|---|
| 3 |
|
|---|
| 4 |
use SFLC::TimeTracker::Entry; |
|---|
| 5 |
use SFLC::TimeTracker::DB; |
|---|
| 6 |
use SFLC::TimeTracker::Question; |
|---|
| 7 |
use SFLC::TimeTracker::Input; |
|---|
| 8 |
use SFLC::TimeTracker::Category; |
|---|
| 9 |
use SFLC::TimeTracker::Reports; |
|---|
| 10 |
use POSIX; |
|---|
| 11 |
|
|---|
| 12 |
use Date::Manip; |
|---|
| 13 |
|
|---|
| 14 |
my $DATABASE = |
|---|
| 15 |
new SFLC::TimeTracker::DB("MLDBM", "/home/ircbot/TimeDB/time-data.mldbm", |
|---|
| 16 |
"/home/ircbot/TimeDB/pending-time.mldbm"); |
|---|
| 17 |
|
|---|
| 18 |
SFLC::TimeTracker::Entry::Initialize($DATABASE); |
|---|
| 19 |
SFLC::TimeTracker::Question::Initialize($DATABASE); |
|---|
| 20 |
SFLC::TimeTracker::Input::Initialize($DATABASE); |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
SFLC::TimeTracker::Entry::Initialize($DATABASE); |
|---|
| 25 |
|
|---|
| 26 |
#my $today = ParseDate($ARGV[0]); |
|---|
| 27 |
# &Date_Init("ForceDate=" . UnixDate($today, "%Y-%m-%d-%H:%M:%S")); |
|---|
| 28 |
|
|---|
| 29 |
my $today = ParseDate('now'); |
|---|
| 30 |
|
|---|
| 31 |
my $weeklyStartDate = ParseDate("1 week ago Monday at 00:00"); |
|---|
| 32 |
my $weeklyEndDate = ParseDate("last Sunday at 23:59:59"); |
|---|
| 33 |
|
|---|
| 34 |
SFLC::TimeTracker::Reports::CategoryTotals($DATABASE, 'ALL', |
|---|
| 35 |
$weeklyStartDate, $weeklyEndDate, |
|---|
| 36 |
'manager@example.org,manager@example.org,manager@example.org', <<STUFF |
|---|
| 37 |
Weekly Category Totals Report |
|---|
| 38 |
|
|---|
| 39 |
STUFF |
|---|
| 40 |
); |
|---|
| 41 |
|
|---|
| 42 |
SFLC::TimeTracker::Reports::Detail($DATABASE, 'ALL', $weeklyStartDate, |
|---|
| 43 |
$weeklyEndDate, |
|---|
| 44 |
'ALL', 'ALL', |
|---|
| 45 |
"manager\@example.org,manager\@example.org,manager\@example.org", |
|---|
| 46 |
<<STUFF |
|---|
| 47 |
Weekly Management Time Report |
|---|
| 48 |
|
|---|
| 49 |
STUFF |
|---|
| 50 |
); |
|---|
| 51 |
|
|---|
| 52 |
SFLC::TimeTracker::Reports::Summary($DATABASE, "ALL", |
|---|
| 53 |
$weeklyStartDate, $weeklyEndDate, |
|---|
| 54 |
'ALL', 'ALL', |
|---|
| 55 |
"manager\@example.org,manager\@example.org,manager\@example.org", |
|---|
| 56 |
<<STUFF |
|---|
| 57 |
Weekly Management Time Summary Report |
|---|
| 58 |
|
|---|
| 59 |
STUFF |
|---|
| 60 |
); |
|---|
| 61 |
|
|---|
| 62 |
# If last Sunday was in the same month as today, but not the same month |
|---|
| 63 |
# as the start date, then run the monthlies |
|---|
| 64 |
if (UnixDate($weeklyEndDate, '%B') eq UnixDate($today, '%B') and |
|---|
| 65 |
UnixDate($weeklyStartDate, '%B') ne UnixDate($today, '%B')) { |
|---|
| 66 |
my $lastMonth = ParseDate("last month"); |
|---|
| 67 |
|
|---|
| 68 |
my $lastDayLastMonth = ParseDate(UnixDate($lastMonth, |
|---|
| 69 |
"last day of %B %Y at 23:59:59")); |
|---|
| 70 |
my $firstDateLastMonth = ParseDate(UnixDate($lastMonth, "1 %B %Y")); |
|---|
| 71 |
my $firstDayYear = ParseDate(UnixDate($lastMonth, "1 January %Y")); |
|---|
| 72 |
|
|---|
| 73 |
SFLC::TimeTracker::Reports::Summary($DATABASE, "ALL", |
|---|
| 74 |
$firstDateLastMonth, $lastDayLastMonth, |
|---|
| 75 |
'ALL', 'ALL', "manager\@example.org", |
|---|
| 76 |
<<STUFF |
|---|
| 77 |
Monthly Management Time Summary Report |
|---|
| 78 |
|
|---|
| 79 |
STUFF |
|---|
| 80 |
); |
|---|
| 81 |
SFLC::TimeTracker::Reports::Vacation($DATABASE, 'ALL', $lastDayLastMonth, |
|---|
| 82 |
'manager@example.org', |
|---|
| 83 |
<<STUFF |
|---|
| 84 |
Monthly Staff Time-Off Report |
|---|
| 85 |
|
|---|
| 86 |
STUFF |
|---|
| 87 |
); |
|---|
| 88 |
SFLC::TimeTracker::Reports::Summary($DATABASE, "ALL", |
|---|
| 89 |
$firstDateLastMonth, $lastDayLastMonth, |
|---|
| 90 |
'admin', '(?:sick|holiday|new-child-leave)', |
|---|
| 91 |
'manager@example.org', |
|---|
| 92 |
<<STUFF |
|---|
| 93 |
Monthly Staff Holiday/Sick/Other-Leave Report |
|---|
| 94 |
|
|---|
| 95 |
STUFF |
|---|
| 96 |
); |
|---|
| 97 |
|
|---|
| 98 |
SFLC::TimeTracker::Reports::CategoryTotals($DATABASE, 'ALL', |
|---|
| 99 |
$firstDateLastMonth, $lastDayLastMonth, |
|---|
| 100 |
'manager@example.org', |
|---|
| 101 |
Monthly Category Totals Report |
|---|
| 102 |
|
|---|
| 103 |
STUFF |
|---|
| 104 |
); |
|---|
| 105 |
|
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
############################################################################### |
|---|
| 109 |
# |
|---|
| 110 |
# Local variables: |
|---|
| 111 |
# compile-command: "perl -I ../Modules -c weekly-emp-time-report.plx" |
|---|
| 112 |
# End: |
|---|
| 113 |
|
|---|