[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5338] trunk/LedgerSMB/Scripts/timecard.pm



Revision: 5338
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5338&view=rev
Author:   einhverfr
Date:     2012-12-11 14:52:36 +0000 (Tue, 11 Dec 2012)
Log Message:
-----------
New timecards workflow scripts

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/timecard.pm

Modified: trunk/LedgerSMB/Scripts/timecard.pm
===================================================================
--- trunk/LedgerSMB/Scripts/timecard.pm	2012-12-11 10:23:00 UTC (rev 5337)
+++ trunk/LedgerSMB/Scripts/timecard.pm	2012-12-11 14:52:36 UTC (rev 5338)
@@ -12,6 +12,16 @@
 LedgerSMB.  Timecards are used to track time and materials consumed in the 
 process of work, from professional services to payroll and manufacturing.
 
+=cut
+
+package LedgerSMB::Scripts::timecard;
+use LedgerSMB::Template;
+use LedgerSMB::Timecard;
+use LedgerSMB::Timecard::Type;
+use LedgerSMB::Report::Timecard;
+use LedgerSMB::Company::Config;
+use DateTime;
+
 =head1 ROUTINES
 
 =over
@@ -25,6 +35,25 @@
 
 sub display {
     my ($request) = @_;
+    $request->{non_billable} ||= 0;
+    if ($request->{in_hour} and $request->{in_min}) {
+        my $request->{min_used} = ($request->{in_hour} * 60) + $request->{in_min} - 
+                                ($request->{out_hour} * 60) - $request->{out_min};
+        $request->{qty} = $min_used/60 - $request->{non_billable};
+    } else { # Default to current date and time
+        my $now = DateTime->now;
+        $request->{in_hour} = $now->hour unless defined $request->{in_hour};
+        $request->{in_min} = $now->minute unless defined $request->{in_min};
+    }
+    $request->{total} = $request->{qty} + $request->{non_billable};
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => 'UI/timecards',
+        template => 'timecard',
+        format   => 'HTML'
+    );
+
 }
 
 =item save
@@ -45,6 +74,14 @@
 
 sub print {
     my ($request) = @_;
+    my $timecard = LedgerSMB::Timecard->new(%$request);
+    my $template = LedgerSMB::Template->new(
+        user     => $request->{_user},
+        locale   => $request->{_locale},
+        path     => $LedgerSMB::Company_Config::settings->{templates},
+        template => 'timecard',
+        format   => $request->{format} || 'HTML'
+    );
 }
 
 =item timecard_report
@@ -55,6 +92,8 @@
 
 sub timecard_report{
     my ($request) = @_;
+    my $report = LedgerSMB::Report::Timecards->new(%$request);
+    $report->render($request);
 }
 
 =item generate_order
@@ -65,6 +104,7 @@
 
 sub generate_order {
     my ($request) = @_;
+    # TODO after beta 1
 }
 
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.