Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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
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!


# 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
        print TIMESHEET ("Timesheet for week commencing $day-$month-$y

#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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2023-01-30 15:36 GMT
Find Nodes?
    Voting Booth?

    No recent polls found