[Rt-commit] rt branch, 4.4/user-time-worked, repushed

Craig Kaiser craig at bestpractical.com
Fri Jun 11 14:29:21 EDT 2021


The branch 4.4/user-time-worked was deleted and repushed:
       was 621cf9d4bccdd4fa815c8758f3f8fbf7b329bc63
       now f1b838d3ef29cc83df2afd2b41594ad467fbd27e

1: dbeff42074 ! 1: 783700b0e3 Create a standard RT Time Worked report
    @@ -76,40 +76,61 @@
     +
     +<div class="user-timeworked-form-content">
     +    <form method="POST">
    -+        <div style="display: inline-block">
    -+            <div class="add-user">
    -+                <input style="width: 17em" class="user-time-worked-input" name="user_req"
    -+                    data-autocomplete="Users"
    -+                    data-autocomplete-return="Name"
    -+                    placeholder="<% loc("Find a user...") %>" Value = <% $user_req %>
    -+                >
    -+            </div>
    -+            <div>
    -+                <& /Elements/SelectDate, ShowTime => 0, Name => 'startdate', Default => $startdate &>
    -+            </div>
    -+            <div>
    -+                <& /Elements/SelectDate, ShowTime => 0, Name => 'enddate', Default => $enddate  &>
    -+            </div>
    -+        </div>
    -+        <div style="display: inline-block; vertical-align: top;">
    -+            <& /Elements/SelectQueue, Multiple => 1, Size => 4, Name => 'queue_limit', Id => 'queues', Default => ($queues||'') &>
    -+        </div>
    -+        <div>
    -+            <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>
    -+        </div>
    ++      <table>
    ++        <tr>
    ++          <td align="right">
    ++            <label>User:</label>
    ++          </td>
    ++          <td align="right">
    ++            <input style="width: 17em" class="user-time-worked-input" name="user_req"
    ++                data-autocomplete="Users"
    ++                data-autocomplete-return="Name"
    ++                placeholder="<% loc("Find a user...") %>" Value = <% $user_req %>
    ++            >
    ++          </td>
    ++        </tr>
    ++        <tr>
    ++          <td align="right">
    ++            <label>Start Date:</label>
    ++          </td>
    ++          <td align="right">
    ++            <& /Elements/SelectDate, ShowTime => 0, Name => 'startdate', Default => $startdate &>
    ++          </td>
    ++        </tr>
    ++        <tr>
    ++          <td align="right">
    ++            <label>End Date:</label>
    ++          </td>
    ++          <td align="">
    ++            <& /Elements/SelectDate, ShowTime => 0, Name => 'enddate', Default => $enddate  &>
    ++          </td>
    ++        </tr>
    ++        <tr>
    ++          <td align="right">
    ++            <label>Sort By:</label>
    ++          </td>
    ++          <td>
    ++            <select name="SortBy">
    ++              <option value="Date" <% $SortBy eq 'Date' ? 'checked="checked"' : '' |n%> value="DateWorked"><&|/l&>Date time worked</&></option>
    ++              <option value="User" <% $SortBy eq 'User' ? 'checked="checked"' : '' |n%> value="ByUser"><&|/l&>By User</&></option>
    ++              <option value="Ticket" <% $SortBy eq 'Ticket' ? 'checked="checked"' : '' |n%> value="ByTicket"><&|/l&>By Ticket</&></option>
    ++              <option value="Queue" <% $SortBy eq 'Queue' ? 'checked="checked"' : '' |n%> value="ByQueue"><&|/l&>By Queue</&></option>
    ++            </select>
    ++          </td>
    ++        </tr>
    ++        <tr>
    ++          <td align="right">
    ++            <label>Queue:</label>
    ++          </td>
    ++          <td>
    ++            <& /Elements/SelectQueue, Name => 'queue', Id => 'queue', Default => $queue &>
    ++          </td>
    ++        </tr>
    ++        <tr>
    ++          <td></td>
    ++          <td align="right"><button type="submit"><&|/l&>See Time</&></button></td>
    ++        </tr>
    ++      </table>
     +    </form>
     +</div>
     +
    @@ -131,13 +152,19 @@
     +% my ($total_time_mins, $total_time_hours);
     +%       foreach my $time (@{$data->{$delimeter} }) {
     +            <tr class="<% $line_type %>">
    -+                <td class="collection-as-table"><% $time->{Id} %></td>
    ++                <td class="collection-as-table">
    ++                  <a href="<% RT->Config->Get('WebPath')."/Ticket/Display.html?id=$time->{Id}" %>"><% $time->{Id} %></a>
    ++                </td>
     +                <td class="collection-as-table"><% $time->{Subject} %></td>
     +                <td class="collection-as-table"><% $time->{Queue} %></td>
     +                <td class="collection-as-table"><% $time->{Status} %></td>
    -+                <td class="collection-as-table"><% $time->{Owner} %></td>
    ++                <td class="collection-as-table">
    ++                  <a href="<% RT->Config->Get('WebPath')."Admin/Users/Modify.html?id=$time->{OwnerId}" %>"><% $time->{Owner} %></a>
    ++                </td>
     +                <td class="collection-as-table"><% $time->{Time} %></td>
    -+                <td class="collection-as-table"><% $time->{Worker} %></td>
    ++                <td class="collection-as-table">
    ++                  <a href="<% RT->Config->Get('WebPath')."Admin/Users/Modify.html?id=$time->{WorkerId}" %>"><% $time->{Worker} %></a>
    ++                </td>
     +            </tr>
     +%       $line_type = $line_type eq "oddline" ? "evenline" : "oddline";
     +%       $total_time_mins += $time->{TimeMin};
    @@ -161,24 +188,24 @@
     +
     +    # If we have a value for start date, parse it into an RT::Date object
     +    if ($startdate) {
    -+        $start_date->Set( Format => 'unknown', Value => $startdate );
    ++        $start_date->Set( Format => 'unknown', Value => $startdate, Timezone => 'User' );
     +
     +        # And then get it back as an ISO string for display purposes, in the form field and
     +        # report header
    -+        $startdate = $start_date->AsString( Format => 'ISO', Timezone => 'UTC' );
    ++        $startdate = $start_date->AsString( Format => 'ISO', Timezone => 'User' );
     +    }
     +
     +    # Same treatment for end date
     +    if ($enddate) {
     +        $end_date->Set( Format => 'unknown', Value => $enddate );
    -+        $enddate = $end_date->AsString( Format => 'ISO', Timezone => 'UTC' );
    ++        $enddate = $end_date->AsString( Format => 'ISO', Timezone => 'User' );
     +    }
     +
     +    # Get a new transactions object to hold transaction search results for this ticket
     +    my $trans = RT::Transactions->new( $session{'CurrentUser'} );
     +
     +    my $txns = RT::Transactions->new($session{CurrentUser});
    -+    $txns->Limit( FIELD => 'ObjectType', VALUE    => 'RT::Ticket' );
    ++    $txns->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
     +    if ( $user_req ) {
     +        my $user = RT::User->new( $session{'CurrentUser'} );
     +        my ($ret, $msg) = $user->Load( $user_req );
    @@ -190,14 +217,10 @@
     +        }
     +    }
     +    $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 => '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 $see_group = 1;
    -+    $see_group = 0 unless $session{'CurrentUser'}->HasRight( Right => 'SeeGroup', Object => $RT::System );
    -+
     +
     +    while ( my $txn = $txns->Next ) {
     +        my $ticket = $txn->TicketObj;
    @@ -206,13 +229,8 @@
     +        my ($ret, $msg) = $worker->Load( $txn->Creator );
     +        push @results, $msg unless $ret;
     +
    -+        if ( !$see_group ) {
    -+            next unless $worker->Name eq $session{'CurrentUser'}->Name;
    -+        }
    -+
    -+        if ( $queue_limit && $ticket->QueueObj ) {
    -+            $queue_limit = [$queue_limit] unless ref $queue_limit eq 'ARRAY';
    -+            next unless grep $_ eq $ticket->QueueObj->id, @{$queue_limit};
    ++        if ( $queue && $ticket->QueueObj ) {
    ++            next unless $queue eq $ticket->QueueObj->Id;
     +        }
     +
     +        $total_time_worked = $total_time_worked + $txn->TimeTaken;
    @@ -233,19 +251,18 @@
     +        }
     +
     +        push @{$data->{$delimeter}}, {DayWorked => $day_worked, Id => $ticket->Id, Subject => $ticket->Subject, Queue => $ticket->QueueObj->Name,
    -+            Status => $ticket->Status, Owner => $ticket->OwnerObj->Name, Time => $time_hours > 1 ? $time_hours . ' hours (' . $txn->TimeTaken . '  minutes)' : $txn->TimeTaken . ' minutes',
    -+                TimeMin => $txn->TimeTaken, TimeHours => $time_hours, Worker => $worker->Name};
    ++            Status => $ticket->Status, OwnerId => $ticket->OwnerObj->Id, Owner => $ticket->OwnerObj->Name, Time => $time_hours > 1 ? $time_hours . ' hours (' . $txn->TimeTaken . '  minutes)' : $txn->TimeTaken . ' minutes',
    ++                TimeMin => $txn->TimeTaken, TimeHours => $time_hours, Worker => $worker->Name, WorkerId => $worker->Id};
     +    }
     +}
     +</%INIT>
     +
     +<%ARGS>
    -+$startdate    => undef
    -+$enddate      => undef
    -+$queues       => undef
    ++$startdate    => ''
    ++$enddate      => ''
     +$user_req     => undef
     +$SortBy       => 'date'
     +$data         => undef
    -+$queue_limit  => undef
    ++$queue        => undef
     +</%ARGS>
     
2: 621cf9d4bc = 2: f1b838d3ef Add docs for User Time Worked Report



More information about the rt-commit mailing list