
##########
NumberBase
##########


****
NAME
****


Kernel::System::Ticket::NumberBase - Common functions for ticket number generators


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


IsDateBased()
=============


informs if the current number counter has a reset with every new day or not. All generators
need to implement this function.


.. code-block:: perl

     my $IsDatebased = $TicketNumberObject->IsDateBased();



TicketNumberCounterAdd()
========================


Add a new unique ticket counter entry. These counters are used by the different number generators
    to generate unique \ ``TicketNumber``\ s


.. code-block:: perl

     my $Counter = $TicketNumberObject->TicketNumberCounterAdd(
         Offset      => 123,
     );


Returns:


.. code-block:: perl

     my $Counter = 123;  # undef in case of an error


This method has logic to generate unique numbers even though concurrent processes might write to the
same table. The algorithm runs as follows:
- Insert a new record into the \ ``ticket_number_counter``\  table with a \ ``counter``\  value of 0.
- Then update all preceding records including and up to the current one that still have value 0 and compute the correct value for each, which depends on the previous record.

This works well also if concurrent processes write to the records at the same time, because they will compute the same (unique) values for the counters.


TicketNumberCounterDelete()
===========================


Remove a ticket counter entry.


.. code-block:: perl

     my $Success = $TicketNumberObject->TicketNumberCounterDelete(
         CounterID => 123,
     );


Returns:


.. code-block:: perl

     my $Success = 1;  # false in case of an error



TicketNumberCounterIsEmpty()
============================


Check if there are no records in ticket_number_counter DB table.


.. code-block:: perl

     my $IsEmpty = $TicketNumberObject->TicketNumberCounterIsEmpty();


Returns:


.. code-block:: perl

     my $IsEmpty = 1;  # 0 if it is not empty and undef in case of an error



TicketNumberCounterCleanup()
============================


Removes old counters from the system.


.. code-block:: perl

     my $Success = $TicketNumberObject->TicketNumberCounterCleanup();


Returns:


.. code-block:: perl

     my $Success = 1;  # or false in case of an error



TicketCreateNumber()
====================


Creates a unique ticket number.


.. code-block:: perl

     my $TicketNumber = $TicketNumberObject->TicketCreateNumber();


Returns:


.. code-block:: perl

     my $TicketNumber = 456;




*****************
PRIVATE INTERFACE
*****************


_GetUID()
=========


Generates a unique identifier.


.. code-block:: perl

     my $UID = $TicketNumberObject->_GetUID();


Returns:


.. code-block:: perl

     my $UID = 14906327941360ed8455f125d0450277;





