[otrs-cvs] otrs/Kernel/Modules AgentTicketProcess.pm, 1.34, 1.35 AdminProcessManagementActivityDialog.pm, 1.33, 1.34

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/Modules
In directory lancelot:/tmp/cvs-serv21194/Kernel/Modules

Modified Files:
	AgentTicketProcess.pm AdminProcessManagementActivityDialog.pm 
Log Message:
 - 2013-01-31 Fixed bug#9077 - Process Management: TicketType not available as field for activity dialogs.

Author: cr

Index: AgentTicketProcess.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/Modules/AgentTicketProcess.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -2 -u -d -r1.34 -r1.35
--- AgentTicketProcess.pm	30 Jan 2013 00:16:29 -0000	1.34
+++ AgentTicketProcess.pm	31 Jan 2013 13:45:54 -0000	1.35
@@ -31,4 +31,5 @@
 use Kernel::System::Priority;
 use Kernel::System::CustomerUser;
+use Kernel::System::Type;
 use Kernel::System::VariableCheck qw(:all);
 
@@ -79,4 +80,5 @@
     );
     $Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
+    $Self->{TypeObject}         = Kernel::System::Type->new(%Param);
     $Self->{DynamicField}       = $Self->{DynamicFieldObject}->DynamicFieldListGet(
         Valid      => 1,
@@ -1815,4 +1817,42 @@
             $RenderedFields{$CurrentField} = 1;
         }
+
+        # render Type
+        elsif ( $Self->{NameToID}->{$CurrentField} eq 'TypeID' )
+        {
+
+            # We don't render Fields twice,
+            # if there was already a Config without ID, skip this field
+            next DIALOGFIELD if $RenderedFields{ $Self->{NameToID}->{$CurrentField} };
+
+            my $Response = $Self->_RenderType(
+                ActivityDialogField => $ActivityDialog->{Fields}{$CurrentField},
+                FieldName           => $CurrentField,
+                DescriptionShort    => $ActivityDialog->{Fields}{$CurrentField}{DescriptionShort},
+                Ticket              => \%Ticket || {},
+                Error               => \%Error || {},
+                FormID              => $Self->{FormID},
+                GetParam            => $Param{GetParam},
+                AJAXUpdatableFields => $AJAXUpdatableFields,
+            );
+
+            if ( !$Response->{Success} ) {
+
+                # does not show header and footer again
+                if ( $Self->{AJAXDialog} ) {
+                    return $Self->{LayoutObject}->Error(
+                        Message => $Response->{Message},
+                    );
+                }
+
+                $Self->{LayoutObject}->FatalError(
+                    Message => $Response->{Message},
+                );
+            }
+
+            $Output .= $Response->{HTML};
+
+            $RenderedFields{ $Self->{NameToID}->{$CurrentField} } = 1;
+        }
     }
 
@@ -3422,4 +3462,140 @@
 }
 
+sub _RenderType {
+    my ( $Self, %Param ) = @_;
+
+    for my $Needed (qw(FormID)) {
+        if ( !$Param{$Needed} ) {
+            return {
+                Success => 0,
+                Message => "Got no $Needed in _RenderType!",
+            };
+        }
+    }
+    if ( !IsHashRefWithData( $Param{ActivityDialogField} ) ) {
+        return {
+            Success => 0,
+            Message => "Got no ActivityDialogField in _RenderType!"
+        };
+    }
+
+    my $Types = $Self->_GetTypes(
+        %{ $Param{GetParam} },
+    );
+
+    my %Data = (
+        Label            => $Self->{LayoutObject}->{LanguageObject}->Get("Type"),
+        FieldID          => 'TypeID',
+        FormID           => $Param{FormID},
+        MandatoryClass   => '',
+        ValidateRequired => '',
+    );
+
+    # If field is required put in the necessary variables for
+    # ValidateRequired class input field, Mandatory class for the label
+    if ( $Param{ActivityDialogField}->{Display} && $Param{ActivityDialogField}->{Display} == 2 ) {
+        $Data{ValidateRequired} = 'Validate_Required';
+        $Data{MandatoryClass}   = 'Mandatory';
+    }
+
+    my $SelectedValue;
+
+    my $TypeIDParam = $Param{GetParam}{TypeID};
+    if ($TypeIDParam) {
+        $SelectedValue = $Self->{TypeObject}->TypeLookup(
+            TypeID => $TypeIDParam,
+        );
+    }
+
+    if ( $Param{FieldName} eq 'Type' ) {
+
+        if ( !$SelectedValue ) {
+
+            # Fetch DefaultValue from Config
+            if (
+                defined $Param{ActivityDialogField}->{DefaultValue}
+                && $Param{ActivityDialogField}->{DefaultValue} ne ''
+                )
+            {
+                $SelectedValue = $Self->{TypeObject}->TypeLookup(
+                    Type => $Param{ActivityDialogField}->{DefaultValue},
+                );
+            }
+            if ($SelectedValue) {
+                $SelectedValue = $Param{ActivityDialogField}->{DefaultValue};
+            }
+        }
+    }
+    else {
+        if ( !$SelectedValue ) {
+            if (
+                defined $Param{ActivityDialogField}->{DefaultValue}
+                && $Param{ActivityDialogField}->{DefaultValue} ne ''
+                )
+            {
+                $SelectedValue = $Self->{TypeObject}->TypeLookup(
+                    Type => $Param{ActivityDialogField}->{DefaultValue},
+                );
+            }
+        }
+    }
+
+    # Get TicketValue
+    if ( IsHashRefWithData( $Param{Ticket} ) && !$SelectedValue ) {
+        $SelectedValue = $Param{Ticket}->{Type};
+    }
+
+    # set server errors
+    my $ServerError;
+    if ( IsHashRefWithData( $Param{Error} ) && $Param{Error}->{'TypeID'} ) {
+        $ServerError = 'ServerError';
+    }
+
+    # build Service string
+    $Data{Content} = $Self->{LayoutObject}->BuildSelection(
+        Data          => $Types,
+        Name          => 'TypeID',
+        Class         => $ServerError,
+        SelectedValue => $SelectedValue,
+        PossibleNone  => 1,
+        Sort          => 'AlphanumericValue',
+        Translation   => 0,
+        Max           => 200,
+    );
+
+    # set fields that will get an AJAX loader icon when this field changes
+    $Data{FieldsToUpdate} = $Self->_GetFieldsToUpdateStrg(
+        TriggerField        => 'TypeID',
+        AJAXUpdatableFields => $Param{AJAXUpdatableFields},
+    );
+
+    $Self->{LayoutObject}->Block(
+        Name => $Param{ActivityDialogField}->{LayoutBlock} || 'rw:Type',
+        Data => \%Data,
+    );
+
+    # set mandatory label marker
+    if ( $Data{MandatoryClass} && $Data{MandatoryClass} ne '' ) {
+        $Self->{LayoutObject}->Block(
+            Name => 'LabelSpan',
+            Data => {},
+        );
+    }
+
+    if ( $Param{DescriptionShort} ) {
+        $Self->{LayoutObject}->Block(
+            Name => $Param{ActivityDialogField}->{LayoutBlock} || 'rw:Type:DescriptionShort',
+            Data => {
+                DescriptionShort => $Param{DescriptionShort},
+            },
+        );
+    }
+
+    return {
+        Success => 1,
+        HTML => $Self->{LayoutObject}->Output( TemplateFile => 'ProcessManagement/Type' ),
+    };
+}
+
 sub _StoreActivityDialog {
     my ( $Self, %Param ) = @_;
@@ -4703,4 +4879,19 @@
 }
 
+sub _GetTypes {
+    my ( $Self, %Param ) = @_;
+
+    # get type
+    my %Type;
+    if ( $Param{QueueID} || $Param{TicketID} ) {
+        %Type = $Self->{TicketObject}->TicketTypeList(
+            %Param,
+            Action => $Self->{Action},
+            UserID => $Self->{UserID},
+        );
+    }
+    return \%Type;
+}
+
 sub _GetAJAXUpdatableFields {
     my ( $Self, %Param ) = @_;

Author: cr

Index: AdminProcessManagementActivityDialog.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/Modules/AdminProcessManagementActivityDialog.pm,v
retrieving revision 1.33
retrieving revision 1.34
diff -2 -u -d -r1.33 -r1.34
--- AdminProcessManagementActivityDialog.pm	22 Jan 2013 08:04:55 -0000	1.33
+++ AdminProcessManagementActivityDialog.pm	31 Jan 2013 13:45:55 -0000	1.34
@@ -77,4 +77,8 @@
     }
 
+    if ( $Self->{ConfigObject}->Get('Ticket::Type') ) {
+        $Self->{AvailableFields}->{Type} = 'TypeID';
+    }
+
     my $DynamicFieldList = $Self->{DynamicFieldObject}->DynamicFieldList(
         ObjectType => [ 'Ticket', 'Article' ],
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.