Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

weekly timesheet generator

by multijoy (Initiate)
on Mar 23, 2005 at 19:42 UTC ( #441865=sourcecode: print w/replies, xml ) Need Help??
Category: Miscellaneous
Author/Contact Info Rich Roberts rich@jesusstolemymoped.com
Description: I'm not overly certain how useful this will be to others, but I couldn't find anything that did the same thing.
Basic concept is that it allows the user to time-stamp a weekly hours record, automagically creating each week's record.
Not much in the way of error checking, and I'm positive that the user interface could be less clunky. On the plus side, there 'aint that much to it.
The next trick will be to get it to email the timesheets as well!

#!/usr/bin/perl


# simple timesheet generator
# step 1. Get the start date for the week

use Date::Calc qw( Today Monday_of_Week Week_of_Year );
($year,$month,$day) = Today();
($year,$month,$day) = Monday_of_Week(Week_of_Year($year,$month,$day));

# step 2. See if this week's timesheet exists, if not, I'll create it

unless (-e "$day-$month-$year.txt") {
        open(TIMESHEET,">$day-$month-$year.txt") || die("Cannot Open F
+ile");
        print TIMESHEET ("Timesheet for week commencing $day-$month-$y
+ear\n");
}

#If it does exist, we need to open it, for appending 

open(TIMESHEET,">>$day-$month-$year.txt") || die("Cannot Open File");


#Now, we present the user with his timesheet options. Start shift, end
+ shift, off, hols & sick...
print "\n";
print "To start shift, push 1...\n";
print "To end shift,   push 2...\n";
print "Off?            push 3...\n";
print "Sick?           push 4...\n";
print "Holiday?        push 5...\n";

#get the times and 'tings, to use in a bit. 

($wkday,$month,$day,$time,$year) = split(/\s+/, localtime);
$dayname = substr((localtime ()), 0, 3); # finds day (three char code-
+ mon, tue etc.) from localtime

chomp ($select = <STDIN>);  #get the choice, then ye olde if statement
+s for the printing

if ($select == 1) {
        print TIMESHEET ("$dayname      $time   to      ");
} elsif ($select == 2) {
        print TIMESHEET ("$time \n");
} elsif ($select == 3) {
        print TIMESHEET ("$dayname      off\n");
} elsif ($select == 4) {
        print TIMESHEET ("$dayname      sick\n");
} elsif ($select == 5) {
        print TIMESHEET ("$dayname      holiday\n");
}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://441865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2022-01-25 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?