"Fossies" - the Fresh Open Source Software Archive

Member "otrs-5.0.40/Kernel/System/Console/Command/Admin/CustomerCompany/Add.pm" (12 Dec 2019, 3357 Bytes) of package /linux/www/otrs-5.0.40.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Add.pm" see the Fossies "Dox" file reference documentation.

    1 # --
    2 # Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
    3 # --
    4 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
    5 # the enclosed file COPYING for license information (GPL). If you
    6 # did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
    7 # --
    8 
    9 package Kernel::System::Console::Command::Admin::CustomerCompany::Add;
   10 
   11 use strict;
   12 use warnings;
   13 
   14 use base qw(Kernel::System::Console::BaseCommand);
   15 
   16 our @ObjectDependencies = (
   17     'Kernel::System::CustomerCompany',
   18 );
   19 
   20 sub Configure {
   21     my ( $Self, %Param ) = @_;
   22 
   23     $Self->Description('Add a customer company.');
   24     $Self->AddOption(
   25         Name        => 'customer-id',
   26         Description => "Company ID for the new customer company.",
   27         Required    => 1,
   28         HasValue    => 1,
   29         ValueRegex  => qr/.*/smx,
   30     );
   31     $Self->AddOption(
   32         Name        => 'name',
   33         Description => "Company name for the new customer company.",
   34         Required    => 1,
   35         HasValue    => 1,
   36         ValueRegex  => qr/.*/smx,
   37     );
   38     $Self->AddOption(
   39         Name        => 'street',
   40         Description => "Street of the new customer company.",
   41         Required    => 0,
   42         HasValue    => 1,
   43         ValueRegex  => qr/.*/smx,
   44     );
   45     $Self->AddOption(
   46         Name        => 'zip',
   47         Description => "ZIP code of the new customer company.",
   48         Required    => 0,
   49         HasValue    => 1,
   50         ValueRegex  => qr/.*/smx,
   51     );
   52     $Self->AddOption(
   53         Name        => 'city',
   54         Description => "City of the new customer company.",
   55         Required    => 0,
   56         HasValue    => 1,
   57         ValueRegex  => qr/.*/smx,
   58     );
   59     $Self->AddOption(
   60         Name        => 'country',
   61         Description => "Country of the new customer company.",
   62         Required    => 0,
   63         HasValue    => 1,
   64         ValueRegex  => qr/.*/smx,
   65     );
   66     $Self->AddOption(
   67         Name        => 'url',
   68         Description => "URL of the new customer company.",
   69         Required    => 0,
   70         HasValue    => 1,
   71         ValueRegex  => qr/.*/smx,
   72     );
   73     $Self->AddOption(
   74         Name        => 'comment',
   75         Description => "Comment for the new customer company.",
   76         Required    => 0,
   77         HasValue    => 1,
   78         ValueRegex  => qr/.*/smx,
   79     );
   80 
   81     return;
   82 }
   83 
   84 sub Run {
   85     my ( $Self, %Param ) = @_;
   86 
   87     $Self->Print("<yellow>Adding a new customer company...</yellow>\n");
   88 
   89     # add customer company
   90     if (
   91         !$Kernel::OM->Get('Kernel::System::CustomerCompany')->CustomerCompanyAdd(
   92             CustomerID             => $Self->GetOption('customer-id'),
   93             CustomerCompanyName    => $Self->GetOption('name'),
   94             CustomerCompanyStreet  => $Self->GetOption('street'),
   95             CustomerCompanyZIP     => $Self->GetOption('zip'),
   96             CustomerCompanyCity    => $Self->GetOption('city'),
   97             CustomerCompanyCountry => $Self->GetOption('country'),
   98             CustomerCompanyURL     => $Self->GetOption('url'),
   99             CustomerCompanyComment => $Self->GetOption('comment'),
  100             ValidID                => 1,
  101             UserID                 => 1,
  102         )
  103         )
  104     {
  105         $Self->PrintError("Can't add customer company.");
  106         return $Self->ExitCodeError();
  107     }
  108 
  109     $Self->Print("<green>Done.</green>\n");
  110     return $Self->ExitCodeOk();
  111 }
  112 
  113 1;