init III
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# --
|
||||
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
||||
# --
|
||||
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
# the enclosed file COPYING for license information (GPL). If you
|
||||
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
||||
# --
|
||||
|
||||
package Kernel::System::ITSMConfigItem::Number::AutoIncrement;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our $ObjectManagerDisabled = 1;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Kernel::System::ITSMConfigItem::Number::AutoIncrement - config item number backend module
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All auto increment config item number functions
|
||||
|
||||
=head2 _ConfigItemNumberCreate()
|
||||
|
||||
create a new config item number
|
||||
|
||||
my $Number = $BackendObject->_ConfigItemNumberCreate(
|
||||
ClassID => 123,
|
||||
);
|
||||
|
||||
=cut
|
||||
|
||||
sub _ConfigItemNumberCreate {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
if ( !$Param{ClassID} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need ClassID!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# get system id
|
||||
my $SystemID = $Kernel::OM->Get('Kernel::Config')->Get('SystemID');
|
||||
|
||||
# get current counter
|
||||
my $CurrentCounter = $Self->CurrentCounterGet(
|
||||
ClassID => $Param{ClassID},
|
||||
Type => 'AutoIncrement',
|
||||
) || 0;
|
||||
|
||||
CIPHER:
|
||||
for my $Cipher ( 1 .. 1_000_000_000 ) {
|
||||
|
||||
# create new number
|
||||
my $Number = $SystemID . $Param{ClassID} . sprintf( "%06d", ( $CurrentCounter + $Cipher ) );
|
||||
|
||||
# find existing number
|
||||
my $Duplicate = $Self->ConfigItemNumberLookup(
|
||||
ConfigItemNumber => $Number,
|
||||
);
|
||||
|
||||
next CIPHER if $Duplicate;
|
||||
|
||||
# set counter
|
||||
$Self->CurrentCounterSet(
|
||||
ClassID => $Param{ClassID},
|
||||
Type => 'AutoIncrement',
|
||||
Counter => ( $CurrentCounter + $Cipher ),
|
||||
);
|
||||
|
||||
return $Number;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 TERMS AND CONDITIONS
|
||||
|
||||
This software is part of the OTRS project (L<https://otrs.org/>).
|
||||
|
||||
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
||||
the enclosed file COPYING for license information (GPL). If you
|
||||
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user