[Rt-commit] rt branch, 4.4/user-time-worked, repushed
Craig Kaiser
craig at bestpractical.com
Thu May 6 17:10:58 EDT 2021
The branch 4.4/user-time-worked was deleted and repushed:
was 8be55a1bb50ad818da43763b0c59b2962a895c68
now 621cf9d4bccdd4fa815c8758f3f8fbf7b329bc63
1: 59b48b16b3 ! 1: dbeff42074 Create a standard RT Time Worked report
@@ -95,12 +95,17 @@
+ <& /Elements/SelectQueue, Multiple => 1, Size => 4, Name => 'queue_limit', Id => 'queues', Default => ($queues||'') &>
+ </div>
+ <div>
-+ <& /Elements/Checkbox, Name => 'ByUser' &>
-+ Sort By User
-+ <& /Elements/Checkbox, Name => 'ByTicket' &>
-+ Sort By Ticket
-+ <& /Elements/Checkbox, Name => 'ByQueue' &>
-+ Sort By Queue
++ <input <% $SortBy eq 'Date' ? 'checked="checked"' : '' |n%> checked="checked" type="radio" name="SortBy" id="DateWorked" value="Date">
++ <label for="DateWorked"><&|/l&>Date time worked</&></label>
++
++ <input <% $SortBy eq 'User' ? 'checked="checked"' : '' |n%> type="radio" name="SortBy" id="ByUser" value="User">
++ <label for="ByUser"><&|/l&>By User</&></label>
++
++ <input <% $SortBy eq 'Ticket' ? 'checked="checked"' : '' |n%> type="radio" name="SortBy" id="ByTicket" value="Ticket">
++ <label for="ByTicket"><&|/l&>By Ticket</&></label>
++
++ <input <% $SortBy eq 'Queue' ? 'checked="checked"' : '' |n%> type="radio" name="SortBy" id="ByQueue" value="Queue">
++ <label for="ByQueue"><&|/l&>By Queue</&></label>
+ </div>
+ <div>
+ <button type="submit">See Time</button>
@@ -169,23 +174,26 @@
+ $enddate = $end_date->AsString( Format => 'ISO', Timezone => 'UTC' );
+ }
+
-+
+ # Get a new transactions object to hold transaction search results for this ticket
+ my $trans = RT::Transactions->new( $session{'CurrentUser'} );
+
-+ my $user = RT::User->new($session{'CurrentUser'});
-+ my ($ret, $msg) = $user->Load( $user_req );
-+ push @results, $msg unless $ret;
-+
+ my $txns = RT::Transactions->new($session{CurrentUser});
-+ $txns->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
-+ $txns->Limit( FIELD => 'Creator', VALUE => $user->id ) unless !$user->id;
-+ $txns->Limit( FIELD => 'TimeTaken', VALUE => 0, OPERATOR => '!=' );
-+ $txns->Limit( FIELD => 'Created', VALUE => $start_date->ISO(Timezone => 'user'), OPERATOR => '>=' );
-+ $txns->Limit( FIELD => 'Created', VALUE => $end_date->ISO(Timezone => 'user'), OPERATOR => '<=', ENTRYAGGREGATOR => 'AND');
++ $txns->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
++ if ( $user_req ) {
++ my $user = RT::User->new( $session{'CurrentUser'} );
++ my ($ret, $msg) = $user->Load( $user_req );
++ if ( $ret && $user->Id ) {
++ $txns->Limit( FIELD => 'Creator', VALUE => $user->id )
++ }
++ else {
++ push @results, "Could not load user, report not limited to user: $user_req";
++ }
++ }
++ $txns->Limit( FIELD => 'TimeTaken', VALUE => 0, OPERATOR => '!=' );
++ $txns->Limit( FIELD => 'Created', VALUE => $start_date->ISO(Timezone => 'user'), OPERATOR => '>=' );
++ $txns->Limit( FIELD => 'Created', VALUE => $end_date->ISO(Timezone => 'user'), OPERATOR => '<=', ENTRYAGGREGATOR => 'AND');
+
+ my $total_time_worked = 0;
-+ my $delim = $ByUser ? 'User' : $ByTicket ? 'Ticket' : $ByQueue ? 'Queue' : undef;
+
+ my $see_group = 1;
+ $see_group = 0 unless $session{'CurrentUser'}->HasRight( Right => 'SeeGroup', Object => $RT::System );
@@ -198,7 +206,7 @@
+ my ($ret, $msg) = $worker->Load( $txn->Creator );
+ push @results, $msg unless $ret;
+
-+ if ( ! $see_group ) {
++ if ( !$see_group ) {
+ next unless $worker->Name eq $session{'CurrentUser'}->Name;
+ }
+
@@ -214,11 +222,11 @@
+ $time_hours = int($time_hours * 10**2) / 10**2;
+
+ my $delimeter;
-+ if ( $delim && $delim eq 'User' ) {
++ if ( $SortBy eq 'User' ) {
+ $delimeter = 'User: ' . $worker->Name;
-+ } elsif ( $delim && $delim eq 'Ticket' ) {
++ } elsif ( $SortBy eq 'Ticket' ) {
+ $delimeter = $ticket->Id . ': ' . $ticket->Subject;
-+ } elsif ( $delim && $delim eq 'Queue' ) {
++ } elsif ( $SortBy eq 'Queue' ) {
+ $delimeter = 'Queue: ' . $ticket->QueueObj->Name;
+ } else {
+ $delimeter = $day_worked;
@@ -229,18 +237,15 @@
+ TimeMin => $txn->TimeTaken, TimeHours => $time_hours, Worker => $worker->Name};
+ }
+}
-+
+</%INIT>
+
+<%ARGS>
-+$startdate => undef
-+$enddate => undef
-+$queues => undef
-+$user_req => undef
-+$ByUser => undef
-+$ByQueue => undef
-+$ByTicket => undef
-+$data => undef
-+$queue_limit => undef
++$startdate => undef
++$enddate => undef
++$queues => undef
++$user_req => undef
++$SortBy => 'date'
++$data => undef
++$queue_limit => undef
+</%ARGS>
2: 8be55a1bb5 = 2: 621cf9d4bc Add docs for User Time Worked Report
More information about the rt-commit
mailing list