11.4. Customize the customer self-registration

From open-support.info

< Book:OTRS 3.0 - Admin Manual | Chapter 11(Difference between revisions)
Jump to: navigation, search
m (1 revision: Update book/figure)
 
(4 intermediate revisions not shown)
Line 1: Line 1:
{{Book
{{Book
|next=~/Chapter 12
|next=~/Chapter 12
-
|heading=Chapter 11.4.
+
|heading=11.4.
|title=Customize the customer self-registration
|title=Customize the customer self-registration
|status=effective
|status=effective
Line 8: Line 8:
|editor=Dick6809
|editor=Dick6809
}}
}}
-
<onlyinclude>__TOC__
+
<onlyinclude>__FORCETOC__
It is possible to customize the self-registration for new customers, accessible via the customer.pl panel. New optional or required fields, like room number, address or state can be added.  
It is possible to customize the self-registration for new customers, accessible via the customer.pl panel. New optional or required fields, like room number, address or state can be added.  
Line 16: Line 16:
To display the new field for the room number in the customer.pl web interface, the .dtl file responsible for the layout in this interface has to be modified. Edit the Kernel/Output/HTML/Standard/CustomerLogin.dtl file, adding the new field around line 80 (see Script 11.9 below).  
To display the new field for the room number in the customer.pl web interface, the .dtl file responsible for the layout in this interface has to be modified. Edit the Kernel/Output/HTML/Standard/CustomerLogin.dtl file, adding the new field around line 80 (see Script 11.9 below).  
 +
{| class="script"
 +
|
<pre>
<pre>
[...]
[...]
Line 24: Line 26:
[...]
[...]
</pre>
</pre>
-
Script 11.9. Displaying a new field in the web interface.  
+
|-
-
 
+
| Script 11.9. Displaying a new field in the web interface.
 +
|}
 +
<br />
== Customer mapping ==
== Customer mapping ==
In the next step, the customer mapping has to be expanded with the new entry for the room number. To ensure that the changes are not lost after an update, put the "CustomerUser" settings from the Kernel/Config/Defaults.pm into the Kernel/Config.pm. Now change the MAP array and add the new room number field, as shown in Script 11.10.  
In the next step, the customer mapping has to be expanded with the new entry for the room number. To ensure that the changes are not lost after an update, put the "CustomerUser" settings from the Kernel/Config/Defaults.pm into the Kernel/Config.pm. Now change the MAP array and add the new room number field, as shown in Script 11.10.  
 +
{| class="script"
 +
|
<pre>
<pre>
# CustomerUser
# CustomerUser
Line 101: Line 107:
};
};
</pre>
</pre>
-
Script 11.10. Changing the map array.  
+
|-
 +
| Script 11.10. Changing the map array.
 +
|}
 +
<br />
== Customize the customer_user table in the OTRS DB ==
== Customize the customer_user table in the OTRS DB ==
The last step is to add the new room number column to the customer_user table in the OTRS database (see Script 11.11 below). In this column, the entries for the room numbers will be stored.  
The last step is to add the new room number column to the customer_user table in the OTRS database (see Script 11.11 below). In this column, the entries for the room numbers will be stored.  
 +
{| class="script"
 +
|
<pre>
<pre>
linux:~# mysql -p
linux:~# mysql -p
Line 127: Line 138:
linux:~#
linux:~#
</pre>
</pre>
-
Script 11.11. Adding a new column to the customer_user table.  
+
|-
 +
| Script 11.11. Adding a new column to the customer_user table.
 +
|}
 +
 
Now the new field for the room should be displayed in the customer.pl panel. New customers should have to insert their room number if they register a new account. If you use apache and use mod_perl for OTRS, you should restart the web server to activate the changes.</onlyinclude>
Now the new field for the room should be displayed in the customer.pl panel. New customers should have to insert their room number if they register a new account. If you use apache and use mod_perl for OTRS, you should restart the web server to activate the changes.</onlyinclude>

Latest revision as of 05:24, 24 April 2011

It is possible to customize the self-registration for new customers, accessible via the customer.pl panel. New optional or required fields, like room number, address or state can be added.

The following example shows how you can specify a required field in the customer database, in this case to store the room number of a customer.

Contents

Customizing the web interface

To display the new field for the room number in the customer.pl web interface, the .dtl file responsible for the layout in this interface has to be modified. Edit the Kernel/Output/HTML/Standard/CustomerLogin.dtl file, adding the new field around line 80 (see Script 11.9 below).

[...]
<div class="NewLine">
    <label for="Room">$Text{"Room{CustomerUser}"}</label>
    <input title="$Text{"Room Number"}" name="Room" type="text" id="UserRoom" maxlength="50" />
</div>
[...]
Script 11.9. Displaying a new field in the web interface.


Customer mapping

In the next step, the customer mapping has to be expanded with the new entry for the room number. To ensure that the changes are not lost after an update, put the "CustomerUser" settings from the Kernel/Config/Defaults.pm into the Kernel/Config.pm. Now change the MAP array and add the new room number field, as shown in Script 11.10.

# CustomerUser
# (customer database backend and settings)
$Self->{CustomerUser} = {
    Name => 'Database Backend',
    Module => 'Kernel::System::CustomerUser::DB',
    Params => {
        # if you want to use an external database, add the
        # required settings
#        DSN => 'DBI:odbc:yourdsn',
#        DSN => 'DBI:mysql:database=customerdb;host=customerdbhost',
#        User => '',
#        Password => '',
        Table => 'customer_user',
    },
    # customer unique id
    CustomerKey => 'login',
    # customer #
    CustomerID => 'customer_id',
    CustomerValid => 'valid_id',
    CustomerUserListFields => ['first_name', 'last_name', 'email'],
#    CustomerUserListFields => ['login', 'first_name', 'last_name', 'customer_id', 'email'],
    CustomerUserSearchFields => ['login', 'last_name', 'customer_id'],
    CustomerUserSearchPrefix => '',
    CustomerUserSearchSuffix => '*',
    CustomerUserSearchListLimit => 250,
    CustomerUserPostMasterSearchFields => ['email'],
    CustomerUserNameFields => ['salutation', 'first_name', 'last_name'],
    CustomerUserEmailUniqCheck => 1,
#    # show not own tickets in customer panel, CompanyTickets
#    CustomerUserExcludePrimaryCustomerID => 0,
#    # generate auto logins
#    AutoLoginCreation => 0,
#    AutoLoginCreationPrefix => 'auto',
#    # admin can change customer preferences
#    AdminSetPreferences => 1,
#    # cache time to live in sec. - cache database queries
#    CacheTTL => 0,
#    # just a read only source
#    ReadOnly => 1,
    Map => [

        # note: Login, Email and CustomerID needed!
        # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target
        [ 'UserTitle',      'Title',      'title',       1, 0, 'var', '', 0 ],
        [ 'UserFirstname',  'Firstname',  'first_name',  1, 1, 'var', '', 0 ],
        [ 'UserLastname',   'Lastname',   'last_name',   1, 1, 'var', '', 0 ],
        [ 'UserLogin',      'Username',   'login',       1, 1, 'var', '', 0 ],
        [ 'UserPassword',   'Password',   'pw',          0, 0, 'var', '', 0 ],
        [ 'UserEmail',      'Email',      'email',       1, 1, 'var', '', 0 ],
        [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
        [ 'UserPhone',      'Phone',      'phone',       1, 0, 'var', '', 0 ],
        [ 'UserFax',        'Fax',        'fax',         1, 0, 'var', '', 0 ],
        [ 'UserMobile',     'Mobile',     'mobile',      1, 0, 'var', '', 0 ],
        [ 'UserRoom',       'Room',       'room',        1, 0, 'var', '', 0 ],
        [ 'UserStreet',     'Street',     'street',      1, 0, 'var', '', 0 ],
        [ 'UserZip',        'Zip',        'zip',         1, 0, 'var', '', 0 ],
        [ 'UserCity',       'City',       'city',        1, 0, 'var', '', 0 ],
        [ 'UserCountry',    'Country',    'country',     1, 0, 'var', '', 0 ],
        [ 'UserComment',    'Comment',    'comments',    1, 0, 'var', '', 0 ],
        [ 'ValidID',        'Valid',      'valid_id',    0, 1, 'int', '', 0 ],
    ],
    # default selections
    Selections => {
        UserTitle => {
            'Mr.' => 'Mr.',
            'Mrs.' => 'Mrs.',
        },
    },
};
Script 11.10. Changing the map array.


Customize the customer_user table in the OTRS DB

The last step is to add the new room number column to the customer_user table in the OTRS database (see Script 11.11 below). In this column, the entries for the room numbers will be stored.

linux:~# mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6 to server version: 5.0.18-Debian_7-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use otrs;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> ALTER TABLE customer_user ADD room VARCHAR (200);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> quit
Bye
linux:~#
Script 11.11. Adding a new column to the customer_user table.


Now the new field for the room should be displayed in the customer.pl panel. New customers should have to insert their room number if they register a new account. If you use apache and use mod_perl for OTRS, you should restart the web server to activate the changes.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox