| 1 | # -- | ||
| 2 | # Kernel/Modules/AdminESCL.pm - admin frontend to manage slas | ||
| 3 | # Copyright (C) 2001-2010 OTRS AG, http://otrs.org/ | ||
| 4 | # -- | ||
| 5 | # $Id: AdminESCL.pm,v 1.0 2013/02/04 14:38:57 en Exp $ | ||
| 6 | # -- | ||
| 7 | # This software comes with ABSOLUTELY NO WARRANTY. For details, see | ||
| 8 | # the enclosed file COPYING for license information (AGPL). If you | ||
| 9 | # did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | ||
| 10 | # -- | ||
| 11 | |||
| 12 | package Kernel::Modules::AdminESCL; | ||
| 13 | |||
| 14 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 0 | ▶ | use Kernel::System::Service; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 18 | use Kernel::System::SLA; | ||
| 19 | use Kernel::System::Escalation; | ||
| 20 | use Kernel::System::Valid; | ||
| 21 | |||
| 22 | use Kernel::Config; | ||
| 23 | use Kernel::System::Encode; | ||
| 24 | use Kernel::System::Log; | ||
| 25 | use Kernel::System::Main; | ||
| 26 | use Kernel::System::DB; | ||
| 27 | use Kernel::System::Group; | ||
| 28 | |||
| 29 | |||
| 30 | # create common objects | ||
| 31 | my %CommonObject = (); | ||
| 32 | $CommonObject{ConfigObject} = Kernel::Config->new(); | ||
| 33 | $CommonObject{EncodeObject} = Kernel::System::Encode->new(%CommonObject); | ||
| 34 | $CommonObject{LogObject} = Kernel::System::Log->new( | ||
| 35 | LogPrefix => 'OTRS-otrs.AdminESCL.pl', | ||
| 36 | %CommonObject, | ||
| 37 | ); | ||
| 38 | $CommonObject{MainObject} = Kernel::System::Main->new(%CommonObject); | ||
| 39 | $CommonObject{DBObject} = Kernel::System::DB->new(%CommonObject); | ||
| 40 | $CommonObject{GroupObject} = Kernel::System::Group->new(%CommonObject); | ||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | use vars qw($VERSION); | ||
| 45 | $VERSION = qw($Revision: 1.0 $) [1]; | ||
| 46 | |||
| 47 | sub new { | ||
| 48 | my ( $Type, %Param ) = @_; | ||
| 49 | |||
| 50 | # allocate new hash for object | ||
| 51 | my $Self = {%Param}; | ||
| 52 | bless( $Self, $Type ); | ||
| 53 | |||
| 54 | # check all needed objects | ||
| 55 | for (qw(ParamObject DBObject LayoutObject ConfigObject LogObject)) { | ||
| 56 | if ( !$Self->{$_} ) { | ||
| 57 | $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | #add some new object | ||
| 61 | $Self->{ServiceObject} = Kernel::System::Service->new(%Param); | ||
| 62 | $Self->{SLAObject} = Kernel::System::SLA->new(%Param); | ||
| 63 | $Self->{ESCLObject} = Kernel::System::Escalation->new(%Param); | ||
| 64 | $Self->{ValidObject} = Kernel::System::Valid->new(%Param); | ||
| 65 | |||
| 66 | return $Self; | ||
| 67 | } | ||
| 68 | |||
| 69 | sub Run { | ||
| 70 | my ( $Self, %Param ) = @_; | ||
| 71 | |||
| 72 | my %Error = (); | ||
| 73 | |||
| 74 | # ------------------------------------------------------------ # | ||
| 75 | # escl edit | ||
| 76 | # ------------------------------------------------------------ # | ||
| 77 | if ( $Self->{Subaction} eq 'ESCLEdit' ) { | ||
| 78 | |||
| 79 | # header | ||
| 80 | my $Output = $Self->{LayoutObject}->Header(); | ||
| 81 | $Output .= $Self->{LayoutObject}->NavigationBar(); | ||
| 82 | |||
| 83 | # html output | ||
| 84 | $Output .= $Self->_MaskNew( | ||
| 85 | %Param, | ||
| 86 | ); | ||
| 87 | $Output .= $Self->{LayoutObject}->Footer(); | ||
| 88 | |||
| 89 | return $Output; | ||
| 90 | } | ||
| 91 | |||
| 92 | # ------------------------------------------------------------ # | ||
| 93 | # escl save | ||
| 94 | # ------------------------------------------------------------ # | ||
| 95 | elsif ( $Self->{Subaction} eq 'ESCLSave' ) { | ||
| 96 | |||
| 97 | # challenge token check for write action | ||
| 98 | $Self->{LayoutObject}->ChallengeTokenCheck(); | ||
| 99 | |||
| 100 | # get params | ||
| 101 | my %GetPerc; | ||
| 102 | my %GetParam; | ||
| 103 | #get Param details | ||
| 104 | for my $Param ( | ||
| 105 | #qw(SLAID Name Calendar FirstResponseTime FirstResponseNotify SolutionTime SolutionNotify UpdateTime UpdateNotify ValidID Comment) | ||
| 106 | qw(SLAID Name Calendar FirstResponseTime FirstResponseNotify SolutionTime SolutionNotify UpdateTime UpdateNotify ValidID Comment TypeID MinTimeBetweenIncidents) | ||
| 107 | ) { | ||
| 108 | $GetParam{$Param} = $Self->{ParamObject}->GetParam( Param => $Param ) || ''; | ||
| 109 | } | ||
| 110 | |||
| 111 | #get Percentage details | ||
| 112 | for my $ParamEscl ( | ||
| 113 | qw(SLAID Name FirstResponseRole1 FirstResponseNotify1 FirstResponseRole2 FirstResponseNotify2 FirstResponseRole3 FirstResponseNotify3 UpdateRole1 UpdateNotify1 UpdateRole2 UpdateNotify2 UpdateRole3 UpdateNotify3 SolutionRole1 SolutionNotify1 SolutionRole2 SolutionNotify2 SolutionRole3 SolutionNotify3) | ||
| 114 | ) { | ||
| 115 | $GetPerc{$ParamEscl} = $Self->{ParamObject}->GetParam( Param => $ParamEscl ) || ''; | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | # check needed stuff | ||
| 121 | %Error = (); | ||
| 122 | if ( !$GetParam{Name} ) { | ||
| 123 | $Error{'NameInvalid'} = 'ServerError'; | ||
| 124 | } | ||
| 125 | |||
| 126 | #open(FF,">>/tmp/escalation.txt"); | ||
| 127 | |||
| 128 | # if no errors occurred | ||
| 129 | if ( !%Error ) { | ||
| 130 | |||
| 131 | # get service ids | ||
| 132 | my @ServiceIDs = $Self->{ParamObject}->GetArray( Param => 'ServiceIDs' ); | ||
| 133 | $GetParam{ServiceIDs} = \@ServiceIDs; | ||
| 134 | |||
| 135 | # save to database | ||
| 136 | if ( !$GetParam{SLAID} ) { | ||
| 137 | |||
| 138 | #if ( !$GetParam{SLAID} ) { | ||
| 139 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 140 | Type => 'Error', | ||
| 141 | What => 'Message', | ||
| 142 | ); | ||
| 143 | #} | ||
| 144 | } | ||
| 145 | #start of main else part | ||
| 146 | else { | ||
| 147 | |||
| 148 | my $Success; | ||
| 149 | my $valid_id; | ||
| 150 | |||
| 151 | # update for different stage i.e FirstResponse(FR), UpdateTime(UT), SolutionTime(ST) | ||
| 152 | ##FR | ||
| 153 | ##LEVEL 1 | ||
| 154 | $Success = 1; | ||
| 155 | $valid_id = 0; | ||
| 156 | |||
| 157 | if ($GetPerc{FirstResponseRole1}) { | ||
| 158 | |||
| 159 | if ($GetPerc{FirstResponseNotify1}) { | ||
| 160 | $valid_id = 1; | ||
| 161 | } | ||
| 162 | else { | ||
| 163 | $GetPerc{FirstResponseRole1} = ''; | ||
| 164 | $GetPerc{FirstResponseNotify1} = ''; | ||
| 165 | $valid_id = 2; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | else { | ||
| 169 | $GetPerc{FirstResponseRole1} = ''; | ||
| 170 | $GetPerc{FirstResponseNotify1} = ''; | ||
| 171 | $valid_id = 2; | ||
| 172 | } | ||
| 173 | |||
| 174 | undef $Success; | ||
| 175 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 176 | SLAID => $GetPerc{SLAID}, | ||
| 177 | Level => 1, | ||
| 178 | Type => 'FR', | ||
| 179 | ValidID => $valid_id, | ||
| 180 | Notify_To => $GetPerc{FirstResponseRole1}, | ||
| 181 | Notify_Perc => $GetPerc{FirstResponseNotify1}, | ||
| 182 | |||
| 183 | ); | ||
| 184 | |||
| 185 | if ( !$Success ) { | ||
| 186 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 187 | Type => 'Error', | ||
| 188 | What => 'Message', | ||
| 189 | ); | ||
| 190 | $Success = 1; | ||
| 191 | } | ||
| 192 | |||
| 193 | ##LEVEL 2 | ||
| 194 | $Success = 1; | ||
| 195 | $valid_id = 0; | ||
| 196 | if ($GetPerc{FirstResponseRole2}) { | ||
| 197 | |||
| 198 | if ($GetPerc{FirstResponseNotify2}) { | ||
| 199 | $valid_id = 1; | ||
| 200 | } | ||
| 201 | else { | ||
| 202 | $GetPerc{FirstResponseRole2} = ''; | ||
| 203 | $GetPerc{FirstResponseNotify2} = ''; | ||
| 204 | $valid_id = 2; | ||
| 205 | } | ||
| 206 | } | ||
| 207 | else { | ||
| 208 | $GetPerc{FirstResponseRole2} = ''; | ||
| 209 | $GetPerc{FirstResponseNotify2} = ''; | ||
| 210 | $valid_id = 2; | ||
| 211 | } | ||
| 212 | |||
| 213 | undef $Success; | ||
| 214 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 215 | SLAID => $GetPerc{SLAID}, | ||
| 216 | Level => 2, | ||
| 217 | Type => 'FR', | ||
| 218 | ValidID => $valid_id, | ||
| 219 | Notify_To => $GetPerc{FirstResponseRole2}, | ||
| 220 | Notify_Perc => $GetPerc{FirstResponseNotify2}, | ||
| 221 | |||
| 222 | ); | ||
| 223 | |||
| 224 | if ( !$Success ) { | ||
| 225 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 226 | Type => 'Error', | ||
| 227 | What => 'Message', | ||
| 228 | ); | ||
| 229 | $Success = 1; | ||
| 230 | } | ||
| 231 | |||
| 232 | ##Level 3 | ||
| 233 | $Success = 1; | ||
| 234 | $valid_id = 0; | ||
| 235 | if ($GetPerc{FirstResponseRole3}) { | ||
| 236 | |||
| 237 | if ($GetPerc{FirstResponseNotify3}) { | ||
| 238 | $valid_id = 1; | ||
| 239 | } | ||
| 240 | else { | ||
| 241 | $GetPerc{FirstResponseRole3} = ''; | ||
| 242 | $GetPerc{FirstResponseNotify3} = ''; | ||
| 243 | $valid_id = 2; | ||
| 244 | } | ||
| 245 | } | ||
| 246 | else { | ||
| 247 | $GetPerc{FirstResponseRole3} = ''; | ||
| 248 | $GetPerc{FirstResponseNotify3} = ''; | ||
| 249 | $valid_id = 2; | ||
| 250 | } | ||
| 251 | |||
| 252 | undef $Success; | ||
| 253 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 254 | SLAID => $GetPerc{SLAID}, | ||
| 255 | Level => 3, | ||
| 256 | Type => 'FR', | ||
| 257 | ValidID => $valid_id, | ||
| 258 | Notify_To => $GetPerc{FirstResponseRole3}, | ||
| 259 | Notify_Perc => $GetPerc{FirstResponseNotify3}, | ||
| 260 | |||
| 261 | ); | ||
| 262 | |||
| 263 | if ( !$Success ) { | ||
| 264 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 265 | Type => 'Error', | ||
| 266 | What => 'Message', | ||
| 267 | ); | ||
| 268 | $Success = 1; | ||
| 269 | } | ||
| 270 | |||
| 271 | ##UT | ||
| 272 | ##LEVEL 1 | ||
| 273 | $Success = 1; | ||
| 274 | $valid_id = 0; | ||
| 275 | if ($GetPerc{UpdateRole1}) { | ||
| 276 | |||
| 277 | if ($GetPerc{UpdateNotify1}) { | ||
| 278 | $valid_id = 1; | ||
| 279 | } | ||
| 280 | else { | ||
| 281 | $GetPerc{UpdateRole1} = ''; | ||
| 282 | $GetPerc{UpdateNotify1} = ''; | ||
| 283 | $valid_id = 2; | ||
| 284 | } | ||
| 285 | } | ||
| 286 | else { | ||
| 287 | $GetPerc{UpdateRole1} = ''; | ||
| 288 | $GetPerc{UpdateNotify1} = ''; | ||
| 289 | $valid_id = 2; | ||
| 290 | } | ||
| 291 | |||
| 292 | undef $Success; | ||
| 293 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 294 | SLAID => $GetPerc{SLAID}, | ||
| 295 | Level => 1, | ||
| 296 | Type => 'UT', | ||
| 297 | ValidID => $valid_id, | ||
| 298 | Notify_To => $GetPerc{UpdateRole1}, | ||
| 299 | Notify_Perc => $GetPerc{UpdateNotify1}, | ||
| 300 | |||
| 301 | ); | ||
| 302 | |||
| 303 | if ( !$Success ) { | ||
| 304 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 305 | Type => 'Error', | ||
| 306 | What => 'Message', | ||
| 307 | ); | ||
| 308 | $Success = 1; | ||
| 309 | } | ||
| 310 | |||
| 311 | ##LEVEL 2 | ||
| 312 | $Success = 1; | ||
| 313 | $valid_id = 0; | ||
| 314 | if ($GetPerc{UpdateRole2}) { | ||
| 315 | |||
| 316 | if ($GetPerc{UpdateNotify2}) { | ||
| 317 | $valid_id = 1; | ||
| 318 | } | ||
| 319 | else { | ||
| 320 | $GetPerc{UpdateRole2} = ''; | ||
| 321 | $GetPerc{UpdateNotify2} = ''; | ||
| 322 | $valid_id = 2; | ||
| 323 | } | ||
| 324 | } | ||
| 325 | else { | ||
| 326 | $GetPerc{UpdateRole2} = ''; | ||
| 327 | $GetPerc{UpdateNotify2} = ''; | ||
| 328 | $valid_id = 2; | ||
| 329 | } | ||
| 330 | |||
| 331 | undef $Success; | ||
| 332 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 333 | SLAID => $GetPerc{SLAID}, | ||
| 334 | Level => 2, | ||
| 335 | Type => 'UT', | ||
| 336 | ValidID => $valid_id, | ||
| 337 | Notify_To => $GetPerc{UpdateRole2}, | ||
| 338 | Notify_Perc => $GetPerc{UpdateNotify2}, | ||
| 339 | |||
| 340 | ); | ||
| 341 | if ( !$Success ) { | ||
| 342 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 343 | Type => 'Error', | ||
| 344 | What => 'Message', | ||
| 345 | ); | ||
| 346 | $Success = 1; | ||
| 347 | } | ||
| 348 | |||
| 349 | ##LEVEL 3 | ||
| 350 | $Success = 1; | ||
| 351 | $valid_id = 0; | ||
| 352 | if ($GetPerc{UpdateRole3}) { | ||
| 353 | |||
| 354 | if ($GetPerc{UpdateNotify3}) { | ||
| 355 | $valid_id = 1; | ||
| 356 | } | ||
| 357 | else | ||
| 358 | { | ||
| 359 | $GetPerc{UpdateRole3} = ''; | ||
| 360 | $GetPerc{UpdateNotify3} = ''; | ||
| 361 | $valid_id = 2; | ||
| 362 | } | ||
| 363 | } | ||
| 364 | else { | ||
| 365 | $GetPerc{UpdateRole3} = ''; | ||
| 366 | $GetPerc{UpdateNotify3} = ''; | ||
| 367 | $valid_id = 2; | ||
| 368 | } | ||
| 369 | |||
| 370 | $Success = ""; | ||
| 371 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 372 | SLAID => $GetPerc{SLAID}, | ||
| 373 | Level => 3, | ||
| 374 | Type => 'UT', | ||
| 375 | ValidID => $valid_id, | ||
| 376 | Notify_To => $GetPerc{UpdateRole3}, | ||
| 377 | Notify_Perc => $GetPerc{UpdateNotify3}, | ||
| 378 | |||
| 379 | ); | ||
| 380 | |||
| 381 | if ( !$Success ) { | ||
| 382 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 383 | Type => 'Error', | ||
| 384 | What => 'Message', | ||
| 385 | ); | ||
| 386 | $Success = 1; | ||
| 387 | } | ||
| 388 | |||
| 389 | ##ST | ||
| 390 | ##LEVEL 1 | ||
| 391 | $Success = 1; | ||
| 392 | $valid_id = 0; | ||
| 393 | if ($GetPerc{SolutionRole1}) { | ||
| 394 | |||
| 395 | if ($GetPerc{SolutionNotify1}) { | ||
| 396 | $valid_id = 1; | ||
| 397 | } | ||
| 398 | else { | ||
| 399 | $GetPerc{SolutionRole1} = ''; | ||
| 400 | $GetPerc{SolutionNotify1} = ''; | ||
| 401 | $valid_id = 2; | ||
| 402 | } | ||
| 403 | } | ||
| 404 | else | ||
| 405 | { | ||
| 406 | $GetPerc{SolutionRole1} = ''; | ||
| 407 | $GetPerc{SolutionNotify1} = ''; | ||
| 408 | $valid_id = 2; | ||
| 409 | } | ||
| 410 | |||
| 411 | undef $Success; | ||
| 412 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 413 | SLAID => $GetPerc{SLAID}, | ||
| 414 | Level => 1, | ||
| 415 | Type => 'ST', | ||
| 416 | ValidID => $valid_id, | ||
| 417 | Notify_To => $GetPerc{SolutionRole1}, | ||
| 418 | Notify_Perc => $GetPerc{SolutionNotify1}, | ||
| 419 | |||
| 420 | ); | ||
| 421 | |||
| 422 | if ( !$Success ) { | ||
| 423 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 424 | Type => 'Error', | ||
| 425 | What => 'Message', | ||
| 426 | ); | ||
| 427 | $Success = 1; | ||
| 428 | } | ||
| 429 | |||
| 430 | ##LEVEL 2 | ||
| 431 | $Success = 1; | ||
| 432 | $valid_id = 0; | ||
| 433 | if ($GetPerc{SolutionRole2}) { | ||
| 434 | |||
| 435 | if ($GetPerc{SolutionNotify2}) { | ||
| 436 | $valid_id = 1; | ||
| 437 | } | ||
| 438 | else | ||
| 439 | { | ||
| 440 | $GetPerc{SolutionRole2} = ''; | ||
| 441 | $GetPerc{SolutionNotify2} = ''; | ||
| 442 | $valid_id = 2; | ||
| 443 | } | ||
| 444 | } | ||
| 445 | else { | ||
| 446 | $GetPerc{SolutionRole2} = ''; | ||
| 447 | $GetPerc{SolutionNotify2} = ''; | ||
| 448 | $valid_id = 2; | ||
| 449 | } | ||
| 450 | |||
| 451 | undef $Success; | ||
| 452 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 453 | SLAID => $GetPerc{SLAID}, | ||
| 454 | Level => 2, | ||
| 455 | Type => 'ST', | ||
| 456 | ValidID => $valid_id, | ||
| 457 | Notify_To => $GetPerc{SolutionRole2}, | ||
| 458 | Notify_Perc => $GetPerc{SolutionNotify2}, | ||
| 459 | |||
| 460 | ); | ||
| 461 | |||
| 462 | if ( !$Success ) { | ||
| 463 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 464 | Type => 'Error', | ||
| 465 | What => 'Message', | ||
| 466 | ); | ||
| 467 | $Success = 1; | ||
| 468 | } | ||
| 469 | |||
| 470 | ##LEVEL 3 | ||
| 471 | $Success = 1; | ||
| 472 | $valid_id = 0; | ||
| 473 | if ($GetPerc{SolutionRole3}) { | ||
| 474 | |||
| 475 | if ($GetPerc{SolutionNotify3}) { | ||
| 476 | $valid_id = 1; | ||
| 477 | } | ||
| 478 | else { | ||
| 479 | |||
| 480 | $GetPerc{SolutionRole3} = ''; | ||
| 481 | $GetPerc{SolutionNotify3} = ''; | ||
| 482 | $valid_id = 2; | ||
| 483 | } | ||
| 484 | } | ||
| 485 | else { | ||
| 486 | $GetPerc{SolutionRole3} = ''; | ||
| 487 | $GetPerc{SolutionNotify3} = ''; | ||
| 488 | $valid_id = 2; | ||
| 489 | } | ||
| 490 | |||
| 491 | undef $Success; | ||
| 492 | $Success =$Self->{ESCLObject}->ESCLAdd( | ||
| 493 | SLAID => $GetPerc{SLAID}, | ||
| 494 | Level => 3, | ||
| 495 | Type => 'ST', | ||
| 496 | ValidID => $valid_id, | ||
| 497 | Notify_To => $GetPerc{SolutionRole3}, | ||
| 498 | Notify_Perc => $GetPerc{SolutionNotify3}, | ||
| 499 | |||
| 500 | ); | ||
| 501 | |||
| 502 | if ( !$Success ) { | ||
| 503 | $Error{Message} = $Self->{LogObject}->GetLogEntry( | ||
| 504 | Type => 'Error', | ||
| 505 | What => 'Message', | ||
| 506 | ); | ||
| 507 | $Success = 1; | ||
| 508 | } | ||
| 509 | |||
| 510 | %Error = (); | ||
| 511 | #End of main else part | ||
| 512 | } | ||
| 513 | |||
| 514 | # close(FF); | ||
| 515 | |||
| 516 | if ( !%Error ) { | ||
| 517 | |||
| 518 | # update preferences | ||
| 519 | my %SLAData = $Self->{SLAObject}->SLAGet( | ||
| 520 | SLAID => $GetParam{SLAID}, | ||
| 521 | UserID => $Self->{UserID}, | ||
| 522 | ); | ||
| 523 | my %Preferences = (); | ||
| 524 | if ( $Self->{ConfigObject}->Get('SLAPreferences') ) { | ||
| 525 | %Preferences = %{ $Self->{ConfigObject}->Get('SLAPreferences') }; | ||
| 526 | } | ||
| 527 | |||
| 528 | for my $Item ( sort keys %Preferences ) { | ||
| 529 | my $Module = $Preferences{$Item}->{Module} | ||
| 530 | || 'Kernel::Output::HTML::SLAPreferencesGeneric'; | ||
| 531 | |||
| 532 | # load module | ||
| 533 | if ( !$Self->{MainObject}->Require($Module) ) { | ||
| 534 | return $Self->{LayoutObject}->FatalError(); | ||
| 535 | } | ||
| 536 | my $Object = $Module->new( | ||
| 537 | %{$Self}, | ||
| 538 | ConfigItem => $Preferences{$Item}, | ||
| 539 | Debug => $Self->{Debug}, | ||
| 540 | ); | ||
| 541 | my $Note; | ||
| 542 | my @Params = $Object->Param( SLAData => \%SLAData ); | ||
| 543 | if (@Params) { | ||
| 544 | my %GetParam = (); | ||
| 545 | for my $ParamItem (@Params) { | ||
| 546 | my @Array | ||
| 547 | = $Self->{ParamObject}->GetArray( Param => $ParamItem->{Name} ); | ||
| 548 | $GetParam{ $ParamItem->{Name} } = \@Array; | ||
| 549 | } | ||
| 550 | if ( !$Object->Run( GetParam => \%GetParam, SLAData => \%SLAData ) ) { | ||
| 551 | $Note .= $Self->{LayoutObject}->Notify( Info => $Object->Error() ); | ||
| 552 | } | ||
| 553 | } | ||
| 554 | } ## for my $Item sort keys %Preferences | ||
| 555 | return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" ); | ||
| 556 | } ## End of if !%Error | ||
| 557 | } ## if no errors occurred | ||
| 558 | |||
| 559 | # header | ||
| 560 | my $Output = $Self->{LayoutObject}->Header(); | ||
| 561 | $Output .= $Self->{LayoutObject}->NavigationBar(); | ||
| 562 | $Output .= $Error{Message} | ||
| 563 | ? $Self->{LayoutObject}->Notify( | ||
| 564 | Priority => 'Error', | ||
| 565 | Info => $Error{Message}, | ||
| 566 | ) | ||
| 567 | : ''; | ||
| 568 | |||
| 569 | # html output | ||
| 570 | $Output .= $Self->_MaskNew( | ||
| 571 | %Param, | ||
| 572 | %GetParam, | ||
| 573 | %Error, | ||
| 574 | ); | ||
| 575 | $Output .= $Self->{LayoutObject}->Footer(); | ||
| 576 | return $Output; | ||
| 577 | |||
| 578 | } ## elsif $Self->{Subaction} eq 'ESCLSave' | ||
| 579 | |||
| 580 | # ------------------------------------------------------------ # | ||
| 581 | # escl overview | ||
| 582 | # ------------------------------------------------------------ # | ||
| 583 | else { | ||
| 584 | |||
| 585 | # output header | ||
| 586 | my $Output = $Self->{LayoutObject}->Header(); | ||
| 587 | $Output .= $Self->{LayoutObject}->NavigationBar(); | ||
| 588 | |||
| 589 | # check if service is enabled to use it here | ||
| 590 | if ( !$Self->{ConfigObject}->Get('Ticket::Service') ) { | ||
| 591 | $Output .= $Self->{LayoutObject}->Notify( | ||
| 592 | Priority => 'Error', | ||
| 593 | Data => '$Text{"Please activate %s first!", "Service"}', | ||
| 594 | Link => | ||
| 595 | '$Env{"Baselink"}Action=AdminSysConfig;Subaction=Edit;SysConfigGroup=Ticket;SysConfigSubGroup=Core::Ticket#Ticket::Service', | ||
| 596 | ); | ||
| 597 | } | ||
| 598 | |||
| 599 | # output overview | ||
| 600 | $Self->{LayoutObject}->Block( | ||
| 601 | Name => 'Overview', | ||
| 602 | Data => { | ||
| 603 | %Param, | ||
| 604 | }, | ||
| 605 | ); | ||
| 606 | |||
| 607 | $Self->{LayoutObject}->Block( Name => 'ActionList' ); | ||
| 608 | $Self->{LayoutObject}->Block( Name => 'ActionAdd' ); | ||
| 609 | |||
| 610 | # output overview result | ||
| 611 | $Self->{LayoutObject}->Block( | ||
| 612 | Name => 'OverviewList', | ||
| 613 | Data => { | ||
| 614 | %Param, | ||
| 615 | }, | ||
| 616 | ); | ||
| 617 | |||
| 618 | # get service list | ||
| 619 | my %ServiceList = $Self->{ServiceObject}->ServiceList( | ||
| 620 | Valid => 0, | ||
| 621 | UserID => $Self->{UserID}, | ||
| 622 | ); | ||
| 623 | |||
| 624 | # get valid list | ||
| 625 | my %ValidList = $Self->{ValidObject}->ValidList(); | ||
| 626 | |||
| 627 | # get sla list | ||
| 628 | my %SLAList = $Self->{SLAObject}->SLAList( | ||
| 629 | Valid => 0, | ||
| 630 | UserID => $Self->{UserID}, | ||
| 631 | ); | ||
| 632 | |||
| 633 | # if there are any SLA's defined, they are shown | ||
| 634 | if (%SLAList) { | ||
| 635 | #SLAID: | ||
| 636 | for my $SLAID ( sort { lc $SLAList{$a} cmp lc $SLAList{$b} } keys %SLAList ) { | ||
| 637 | |||
| 638 | # get the sla data | ||
| 639 | my %SLAData = $Self->{SLAObject}->SLAGet( | ||
| 640 | SLAID => $SLAID, | ||
| 641 | UserID => $Self->{UserID}, | ||
| 642 | ); | ||
| 643 | |||
| 644 | # build the service list | ||
| 645 | my @ServiceList; | ||
| 646 | for my $ServiceID ( sort { lc $ServiceList{$a} cmp lc $ServiceList{$b} } @{ $SLAData{ServiceIDs} } ) { | ||
| 647 | push @ServiceList, $ServiceList{$ServiceID} || '-'; | ||
| 648 | } | ||
| 649 | |||
| 650 | # output overview list row | ||
| 651 | $Self->{LayoutObject}->Block( | ||
| 652 | Name => 'OverviewListRow', | ||
| 653 | Data => { | ||
| 654 | %SLAData, | ||
| 655 | Service => $ServiceList[0] || '-', | ||
| 656 | Valid => $ValidList{ $SLAData{ValidID} }, | ||
| 657 | }, | ||
| 658 | ); | ||
| 659 | |||
| 660 | next if scalar @ServiceList <= 1; | ||
| 661 | |||
| 662 | # remove the first service id | ||
| 663 | shift @ServiceList; | ||
| 664 | |||
| 665 | for my $ServiceName (@ServiceList) { | ||
| 666 | |||
| 667 | # output overview list row | ||
| 668 | $Self->{LayoutObject}->Block( | ||
| 669 | Name => 'OverviewListRow', | ||
| 670 | Data => { | ||
| 671 | Service => $ServiceName, | ||
| 672 | }, | ||
| 673 | ); | ||
| 674 | } | ||
| 675 | } | ||
| 676 | } | ||
| 677 | |||
| 678 | # otherwise a no data found msg is displayed | ||
| 679 | else { | ||
| 680 | $Self->{LayoutObject}->Block( | ||
| 681 | Name => 'NoDataFoundMsg', | ||
| 682 | Data => {}, | ||
| 683 | ); | ||
| 684 | } | ||
| 685 | |||
| 686 | # generate output | ||
| 687 | $Output .= $Self->{LayoutObject}->Output( | ||
| 688 | TemplateFile => 'AdminESCL', | ||
| 689 | Data => \%Param, | ||
| 690 | ); | ||
| 691 | $Output .= $Self->{LayoutObject}->Footer(); | ||
| 692 | |||
| 693 | return $Output; | ||
| 694 | } | ||
| 695 | } | ||
| 696 | |||
| 697 | sub _MaskNew { | ||
| 698 | |||
| 699 | my ( $Self, %Param ) = @_; | ||
| 700 | |||
| 701 | # get params | ||
| 702 | my %SLAData; | ||
| 703 | my %ESCLData; | ||
| 704 | my $SLA_ID; | ||
| 705 | $SLAData{SLAID} = $Self->{ParamObject}->GetParam( Param => 'SLAID' ) || ''; | ||
| 706 | |||
| 707 | if ( $SLAData{SLAID} ) { | ||
| 708 | |||
| 709 | $SLA_ID = $SLAData{SLAID}; | ||
| 710 | # get sla data | ||
| 711 | %SLAData = $Self->{SLAObject}->SLAGet( | ||
| 712 | SLAID => $SLAData{SLAID}, | ||
| 713 | UserID => $Self->{UserID}, | ||
| 714 | ); | ||
| 715 | # get escalation matrix | ||
| 716 | %ESCLData = $Self->{ESCLObject}->ESCLGet( | ||
| 717 | SLAID => $SLAData{SLAID}, | ||
| 718 | UserID => 1, | ||
| 719 | ); | ||
| 720 | |||
| 721 | } | ||
| 722 | else { | ||
| 723 | $SLAData{ServiceID} = $Self->{ParamObject}->GetParam( Param => 'ServiceID' ); | ||
| 724 | } | ||
| 725 | |||
| 726 | |||
| 727 | # get service list | ||
| 728 | my %ServiceList = $Self->{ServiceObject}->ServiceList( | ||
| 729 | Valid => 0, | ||
| 730 | UserID => $Self->{UserID}, | ||
| 731 | ); | ||
| 732 | |||
| 733 | # generate ServiceOptionStrg | ||
| 734 | $Param{ServiceOptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 735 | Data => \%ServiceList, | ||
| 736 | Name => 'ServiceIDs', | ||
| 737 | SelectedID => $SLAData{ServiceIDs} || [], | ||
| 738 | Multiple => 1, | ||
| 739 | Size => 5, | ||
| 740 | Translation => 0, | ||
| 741 | Max => 200, | ||
| 742 | ); | ||
| 743 | |||
| 744 | |||
| 745 | # generate CalendarOptionStrg | ||
| 746 | my %CalendarList; | ||
| 747 | for my $CalendarNumber ( '', 1 .. 50 ) { | ||
| 748 | if ( $Self->{ConfigObject}->Get("TimeVacationDays::Calendar$CalendarNumber") ) { | ||
| 749 | $CalendarList{$CalendarNumber} = "Calendar $CalendarNumber - " | ||
| 750 | . $Self->{ConfigObject}->Get( "TimeZone::Calendar" . $CalendarNumber . "Name" ); | ||
| 751 | } | ||
| 752 | } | ||
| 753 | $SLAData{CalendarOptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 754 | Data => \%CalendarList, | ||
| 755 | Name => 'Calendar', | ||
| 756 | SelectedID => $Param{Calendar} || $SLAData{Calendar}, | ||
| 757 | PossibleNone => 1, | ||
| 758 | ); | ||
| 759 | my %NotifyLevelList = ( | ||
| 760 | 10 => '10%', | ||
| 761 | 20 => '20%', | ||
| 762 | 30 => '30%', | ||
| 763 | 40 => '40%', | ||
| 764 | 50 => '50%', | ||
| 765 | 60 => '60%', | ||
| 766 | 70 => '70%', | ||
| 767 | 80 => '80%', | ||
| 768 | 90 => '90%', | ||
| 769 | ); | ||
| 770 | |||
| 771 | # generate the valid rolelist and append one temporary for Agent/Owner | ||
| 772 | my %RoleLevelList; | ||
| 773 | %RoleLevelList = $CommonObject{GroupObject}->RoleList( Valid => 1 ); | ||
| 774 | $RoleLevelList{-99} = 'Owner'; | ||
| 775 | |||
| 776 | |||
| 777 | # ##FR | ||
| 778 | $ESCLData{FirstResponseNotify1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 779 | Data => \%NotifyLevelList, | ||
| 780 | Name => 'FirstResponseNotify1', | ||
| 781 | SelectedID => $Param{FirstResponseNotify1} || $ESCLData{$SLA_ID}{FR}{1}{Notify_Perc}, | ||
| 782 | PossibleNone => 1, | ||
| 783 | ); | ||
| 784 | $ESCLData{FirstResponseNotify2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 785 | Data => \%NotifyLevelList, | ||
| 786 | Name => 'FirstResponseNotify2', | ||
| 787 | SelectedID => $Param{FirstResponseNotify2} || $ESCLData{$SLA_ID}{FR}{2}{Notify_Perc}, | ||
| 788 | PossibleNone => 1, | ||
| 789 | ); | ||
| 790 | $ESCLData{FirstResponseNotify3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 791 | Data => \%NotifyLevelList, | ||
| 792 | Name => 'FirstResponseNotify3', | ||
| 793 | SelectedID => $Param{FirstResponseNotify3} || $ESCLData{$SLA_ID}{FR}{3}{Notify_Perc}, | ||
| 794 | PossibleNone => 1, | ||
| 795 | ); | ||
| 796 | $ESCLData{FirstResponseRole1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 797 | Data => \%RoleLevelList, | ||
| 798 | Name => 'FirstResponseRole1', | ||
| 799 | SelectedID => $Param{FirstResponseRole1} || $ESCLData{$SLA_ID}{FR}{1}{Notify_To}, | ||
| 800 | PossibleNone => 1, | ||
| 801 | ); | ||
| 802 | $ESCLData{FirstResponseRole2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 803 | Data => \%RoleLevelList, | ||
| 804 | Name => 'FirstResponseRole2', | ||
| 805 | SelectedID => $Param{FirstResponseRole2} || $ESCLData{$SLA_ID}{FR}{2}{Notify_To}, | ||
| 806 | PossibleNone => 1, | ||
| 807 | ); | ||
| 808 | $ESCLData{FirstResponseRole3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 809 | Data => \%RoleLevelList, | ||
| 810 | Name => 'FirstResponseRole3', | ||
| 811 | SelectedID => $Param{FirstResponseRole3} || $ESCLData{$SLA_ID}{FR}{3}{Notify_To}, | ||
| 812 | PossibleNone => 1, | ||
| 813 | ); | ||
| 814 | ##UT | ||
| 815 | $ESCLData{UpdateNotify1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 816 | Data => \%NotifyLevelList, | ||
| 817 | Name => 'UpdateNotify1', | ||
| 818 | SelectedID => $Param{UpdateNotify1} || $ESCLData{$SLA_ID}{UT}{1}{Notify_Perc}, | ||
| 819 | PossibleNone => 1, | ||
| 820 | ); | ||
| 821 | $ESCLData{UpdateNotify2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 822 | Data => \%NotifyLevelList, | ||
| 823 | Name => 'UpdateNotify2', | ||
| 824 | SelectedID => $Param{UpdateNotify2} || $ESCLData{$SLA_ID}{UT}{2}{Notify_Perc}, | ||
| 825 | PossibleNone => 1, | ||
| 826 | ); | ||
| 827 | $ESCLData{UpdateNotify3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 828 | Data => \%NotifyLevelList, | ||
| 829 | Name => 'UpdateNotify3', | ||
| 830 | SelectedID => $Param{UpdateNotify3} || $ESCLData{$SLA_ID}{UT}{3}{Notify_Perc}, | ||
| 831 | PossibleNone => 1, | ||
| 832 | ); | ||
| 833 | $ESCLData{UpdateRole1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 834 | Data => \%RoleLevelList, | ||
| 835 | Name => 'UpdateRole1', | ||
| 836 | SelectedID => $Param{UpdateRole1} || $ESCLData{$SLA_ID}{UT}{1}{Notify_To}, | ||
| 837 | PossibleNone => 1, | ||
| 838 | ); | ||
| 839 | $ESCLData{UpdateRole2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 840 | Data => \%RoleLevelList, | ||
| 841 | Name => 'UpdateRole2', | ||
| 842 | SelectedID => $Param{UpdateRole2} || $ESCLData{$SLA_ID}{UT}{2}{Notify_To}, | ||
| 843 | PossibleNone => 1, | ||
| 844 | ); | ||
| 845 | $ESCLData{UpdateRole3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 846 | Data => \%RoleLevelList, | ||
| 847 | Name => 'UpdateRole3', | ||
| 848 | SelectedID => $Param{UpdateRole3} || $ESCLData{$SLA_ID}{UT}{3}{Notify_To}, | ||
| 849 | PossibleNone => 1, | ||
| 850 | ); | ||
| 851 | ##ST | ||
| 852 | $ESCLData{SolutionNotify1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 853 | Data => \%NotifyLevelList, | ||
| 854 | Name => 'SolutionNotify1', | ||
| 855 | SelectedID => $Param{SolutionNotify1} || $ESCLData{$SLA_ID}{ST}{1}{Notify_Perc}, | ||
| 856 | PossibleNone => 1, | ||
| 857 | ); | ||
| 858 | $ESCLData{SolutionNotify2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 859 | Data => \%NotifyLevelList, | ||
| 860 | Name => 'SolutionNotify2', | ||
| 861 | SelectedID => $Param{SolutionNotify2} || $ESCLData{$SLA_ID}{ST}{2}{Notify_Perc}, | ||
| 862 | PossibleNone => 1, | ||
| 863 | ); | ||
| 864 | $ESCLData{SolutionNotify3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 865 | Data => \%NotifyLevelList, | ||
| 866 | Name => 'SolutionNotify3', | ||
| 867 | SelectedID => $Param{SolutionNotify3} || $ESCLData{$SLA_ID}{ST}{3}{Notify_Perc}, | ||
| 868 | PossibleNone => 1, | ||
| 869 | ); | ||
| 870 | $ESCLData{SolutionRole1OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 871 | Data => \%RoleLevelList, | ||
| 872 | Name => 'SolutionRole1', | ||
| 873 | SelectedID => $Param{SolutionRole1} || $ESCLData{$SLA_ID}{ST}{1}{Notify_To}, | ||
| 874 | PossibleNone => 1, | ||
| 875 | ); | ||
| 876 | $ESCLData{SolutionRole2OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 877 | Data => \%RoleLevelList, | ||
| 878 | Name => 'SolutionRole2', | ||
| 879 | SelectedID => $Param{SolutionRole2} || $ESCLData{$SLA_ID}{ST}{2}{Notify_To}, | ||
| 880 | PossibleNone => 1, | ||
| 881 | ); | ||
| 882 | $ESCLData{SolutionRole3OptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 883 | Data => \%RoleLevelList, | ||
| 884 | Name => 'SolutionRole3', | ||
| 885 | SelectedID => $Param{SolutionRole3} || $ESCLData{$SLA_ID}{ST}{3}{Notify_To}, | ||
| 886 | PossibleNone => 1, | ||
| 887 | ); | ||
| 888 | ###End Here By Rohit Basu | ||
| 889 | |||
| 890 | |||
| 891 | # get valid list | ||
| 892 | my %ValidList = $Self->{ValidObject}->ValidList(); | ||
| 893 | my %ValidListReverse = reverse %ValidList; | ||
| 894 | |||
| 895 | $SLAData{ValidOptionStrg} = $Self->{LayoutObject}->BuildSelection( | ||
| 896 | Data => \%ValidList, | ||
| 897 | Name => 'ValidID', | ||
| 898 | SelectedID => $Param{ValidID} || $SLAData{ValidID} || $ValidListReverse{valid}, | ||
| 899 | ); | ||
| 900 | |||
| 901 | # output sla edit | ||
| 902 | $Self->{LayoutObject}->Block( | ||
| 903 | Name => 'Overview', | ||
| 904 | Data => { | ||
| 905 | %Param | ||
| 906 | }, | ||
| 907 | ); | ||
| 908 | |||
| 909 | $Self->{LayoutObject}->Block( Name => 'ActionList' ); | ||
| 910 | $Self->{LayoutObject}->Block( Name => 'ActionOverview' ); | ||
| 911 | |||
| 912 | $Self->{LayoutObject}->Block( | ||
| 913 | Name => 'ESCLEdit', | ||
| 914 | Data => { | ||
| 915 | %Param, | ||
| 916 | %SLAData, | ||
| 917 | %ESCLData, | ||
| 918 | }, | ||
| 919 | ); | ||
| 920 | |||
| 921 | # shows header | ||
| 922 | if ( $SLAData{SLAID} ) { | ||
| 923 | $Self->{LayoutObject}->Block( Name => 'HeaderEdit' ); | ||
| 924 | } | ||
| 925 | else { | ||
| 926 | $Self->{LayoutObject}->Block( Name => 'HeaderAdd' ); | ||
| 927 | } | ||
| 928 | |||
| 929 | # show each preferences setting | ||
| 930 | my %Preferences = (); | ||
| 931 | if ( $Self->{ConfigObject}->Get('SLAPreferences') ) { | ||
| 932 | %Preferences = %{ $Self->{ConfigObject}->Get('SLAPreferences') }; | ||
| 933 | } | ||
| 934 | for my $Item ( sort keys %Preferences ) { | ||
| 935 | my $Module = $Preferences{$Item}->{Module} | ||
| 936 | || 'Kernel::Output::HTML::SLAPreferencesGeneric'; | ||
| 937 | |||
| 938 | # load module | ||
| 939 | if ( !$Self->{MainObject}->Require($Module) ) { | ||
| 940 | return $Self->{LayoutObject}->FatalError(); | ||
| 941 | } | ||
| 942 | my $Object = $Module->new( | ||
| 943 | %{$Self}, | ||
| 944 | ConfigItem => $Preferences{$Item}, | ||
| 945 | Debug => $Self->{Debug}, | ||
| 946 | ); | ||
| 947 | my @Params = $Object->Param( SLAData => \%SLAData ); | ||
| 948 | if (@Params) { | ||
| 949 | for my $ParamItem (@Params) { | ||
| 950 | $Self->{LayoutObject}->Block( | ||
| 951 | Name => 'SLAItem', | ||
| 952 | Data => { %Param, }, | ||
| 953 | ); | ||
| 954 | if ( | ||
| 955 | ref( $ParamItem->{Data} ) eq 'HASH' | ||
| 956 | || ref( $Preferences{$Item}->{Data} ) eq 'HASH' | ||
| 957 | ) | ||
| 958 | { | ||
| 959 | $ParamItem->{'Option'} = $Self->{LayoutObject}->BuildSelection( | ||
| 960 | %{ $Preferences{$Item} }, | ||
| 961 | %{$ParamItem}, | ||
| 962 | ); | ||
| 963 | } | ||
| 964 | $Self->{LayoutObject}->Block( | ||
| 965 | Name => $ParamItem->{Block} || $Preferences{$Item}->{Block} || 'Option', | ||
| 966 | Data => { | ||
| 967 | %{ $Preferences{$Item} }, | ||
| 968 | %{$ParamItem}, | ||
| 969 | }, | ||
| 970 | ); | ||
| 971 | } | ||
| 972 | } | ||
| 973 | } | ||
| 974 | |||
| 975 | # get output back | ||
| 976 | return $Self->{LayoutObject}->Output( TemplateFile => 'AdminESCL', Data => \%Param ); | ||
| 977 | } | ||
| 978 | |||
| 979 | 1; | ||
| 980 | |||
| 981 | __END__ | ||