
#####
State
#####


****
NAME
****


Kernel::System::State - state lib


***********
DESCRIPTION
***********


All ticket state functions.


****************
PUBLIC INTERFACE
****************


new()
=====


create an object


.. code-block:: perl

     my $StateObject = $Kernel::OM->Get('Kernel::System::State');



StateAdd()
==========


add new states


.. code-block:: perl

     my $ID = $StateObject->StateAdd(
         Name    => 'New State',
         Comment => 'some comment',
         ValidID => 1,
         TypeID  => 1,
         Color   => '#FF8A25',
         UserID  => 123,
     );



StateGet()
==========


get state attributes


.. code-block:: perl

     my %State = $StateObject->StateGet(
         Name  => 'New State',
     );
 
     my %State = $StateObject->StateGet(
         ID    => 123,
     );


returns


.. code-block:: perl

     my %State = (
         Name       => "new",
         ID         => 1,
         TypeName   => "new",
         TypeID     => 1,
         ValidID    => 1,
         Comment    => "New ticket created by customer.",
         Color      => "#FF8A25",
         CreateTime => "2010-11-29 11:04:04",
         ChangeTime => "2010-11-29 11:04:04",
     );



StateUpdate()
=============


update state attributes


.. code-block:: perl

     $StateObject->StateUpdate(
         ID      => 123,
         Name    => 'New State',
         Comment => 'some comment',
         ValidID => 1,
         TypeID  => 1,
         Color   => '#FF8A25',
         UserID  => 123,
     );



StateGetStatesByType()
======================


get list of states for a type or a list of state types.

Get all states with state type open and new:
(available: new, open, closed, pending reminder, pending auto, removed, merged)


.. code-block:: perl

     my @List = $StateObject->StateGetStatesByType(
         StateType => ['open', 'new'],
         Result    => 'ID',              # HASH|ID|Name
     );


Get all state types used by config option named like
Ticket::ViewableStateType for "Viewable" state types.


.. code-block:: perl

     my %List = $StateObject->StateGetStatesByType(
         Type   => 'Viewable',
         Result => 'HASH',               # HASH|ID|Name
     );



StateList()
===========


get state list as a hash of ID, Name pairs


.. code-block:: perl

     my %List = $StateObject->StateList(
         UserID => 123,
     );
 
     my %List = $StateObject->StateList(
         UserID => 123,
         Valid  => 1, # is default
     );
 
     my %List = $StateObject->StateList(
         UserID => 123,
         Valid  => 0,
     );


returns


.. code-block:: perl

     my %List = (
         1 => "new",
         2 => "closed successful",
         3 => "closed unsuccessful",
         4 => "open",
         5 => "removed",
         6 => "pending reminder",
         7 => "pending auto close+",
         8 => "pending auto close-",
         9 => "merged",
     );



StateLookup()
=============


returns the id or the name of a state


.. code-block:: perl

     my $StateID = $StateObject->StateLookup(
         State => 'closed successful',
     );
 
     my $State = $StateObject->StateLookup(
         StateID => 2,
     );



StateTypeList()
===============


get state type list as a hash of ID, Name pairs


.. code-block:: perl

     my %ListType = $StateObject->StateTypeList(
         UserID => 123,
     );


returns


.. code-block:: perl

     my %ListType = (
         1 => "new",
         2 => "open",
         3 => "closed",
         4 => "pending reminder",
         5 => "pending auto",
         6 => "removed",
         7 => "merged",
     );



StateTypeLookup()
=================


returns the id or the name of a state type


.. code-block:: perl

     my $StateTypeID = $StateObject->StateTypeLookup(
         StateType => 'pending auto',
     );


or


.. code-block:: perl

     my $StateType = $StateObject->StateTypeLookup(
         StateTypeID => 1,
     );





