js/payone/core/onlinebanktransfer.js   A
last analyzed

Complexity

Total Complexity 33
Complexity/F 3.67

Size

Lines of Code 144
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 33
dl 0
loc 144
rs 9.3999
c 1
b 0
f 0
cc 0
nc 1
mnd 5
bc 31
fnc 9
bpm 3.4444
cpm 3.6666
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A onlinebanktransfer.js ➔ copyOnlineBankTransferSepaIban 0 6 1
1
/**
2
 *
3
 * NOTICE OF LICENSE
4
 *
5
 * This source file is subject to the GNU General Public License (GPL 3)
6
 * that is bundled with this package in the file LICENSE.txt
7
 *
8
 * DISCLAIMER
9
 *
10
 * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
11
 * versions in the future. If you wish to customize Payone_Core for your
12
 * needs please refer to http://www.payone.de for more information.
13
 *
14
 * @category        Payone
15
 * @package         js
16
 * @subpackage      payone
17
 * @copyright       Copyright (c) 2012 <[email protected]> - www.noovias.com
18
 * @author          Matthias Walter <[email protected]>
19
 * @license         <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
20
 * @link            http://www.noovias.com
21
 */
22
23
/**
24
 *
25
 * @param element
26
 * @param country
27
 * @param currency
28
 */
29
function payoneSwitchOnlineBankTransfer(element, country, currency) 
30
{
31
    if (element == undefined) {
32
        return;
33
    }
34
35
    var ElementValue = element.value;
36
    var ElementValueSplit = ElementValue.split('_');
37
    var typeId = ElementValueSplit[0];
38
    var typeCode = ElementValueSplit[1];
39
40
    $("payone_online_bank_transfer_obt_type").setValue(typeCode);
41
    $("payone_online_bank_transfer_config_id").setValue(typeId);
42
43
    var accountNumberWrap = $('account_number_wrap');
44
    var bankCodeWrap = $('bank_code_wrap');
45
    var sepaIbanWrap = $('sepa_iban_wrap');
46
    var sepaBicWrap = $('sepa_bic_wrap');
47
    var bankGroupWrapAt = $('bank_group_wrap_at');
48
    var bankGroupWrapNl = $('bank_group_wrap_nl');
49
50
    var accountNumberInput = $('payone_online_bank_transfer_account_number');
51
    var bankCodeInput = $('payone_online_bank_transfer_bank_code');
52
    var sepaIbanInput = $('payone_online_bank_transfer_sepa_iban');
53
    var sepaBicInput = $('payone_online_bank_transfer_sepa_bic');
54
    var bankGroupSelectAt = $('payone_online_bank_transfer_bank_group_at');
55
    var bankGroupSelectNl = $('payone_online_bank_transfer_bank_group_nl');
56
    var sofortueberweisungShowIban = $('payone_online_bank_transfer_pnt_show_iban');
57
58
    if (ElementValue == '' || typeCode == 'PFF' || typeCode == 'PFC' || typeCode == 'P24') {
59
        disableAll();
60
    } else if (typeCode == 'PNT') {
61
        disableAll();
62
        if (country == 'CH' && currency == 'CHF') {
63
            enableAccountNumber();
64
            enableBankCode();
65
        } else {
66
            if (sofortueberweisungShowIban.value == 1) {
67
                enableSepaIban();
68
                enableSepaBic();
69
            } else {
70
                disableAll();
71
            }
72
        }
73
    } else if (typeCode == 'GPY') {
74
        disableAll();
75
        enableSepaIban();
76
        enableSepaBic();
77
    } else if (typeCode == 'EPS') {
78
        disableAll();
79
        enableBankGroupAt();
80
    } else if (typeCode == 'IDL') {
81
        disableAll();
82
        enableBankGroupNl();
83
    }
84
85
    function disableAll() 
86
    {
87
        if(accountNumberWrap) {
88
            accountNumberWrap.hide();
89
            accountNumberInput.setAttribute("disabled", "disabled");
90
        }
91
92
        if(bankCodeWrap) {
93
            bankCodeWrap.hide();
94
            bankCodeInput.setAttribute("disabled", "disabled");
95
        }
96
97
        if(sepaIbanWrap) {
98
            sepaIbanWrap.hide();
99
            sepaIbanInput.setAttribute("disabled", "disabled");
100
        }
101
102
        if(sepaBicWrap) {
103
            sepaBicWrap.hide();
104
            sepaBicInput.setAttribute("disabled", "disabled");
105
        }
106
107
        if(bankGroupWrapAt) {
108
            bankGroupWrapAt.hide();
109
            bankGroupSelectAt.setAttribute("disabled", "disabled");
110
        }
111
112
        if(bankGroupWrapNl) {
113
            bankGroupWrapNl.hide();
114
            bankGroupSelectNl.setAttribute("disabled", "disabled");
115
        }
116
    }
117
118
    function enableAccountNumber() 
119
    {
120
        if(accountNumberWrap) {
121
            accountNumberWrap.show();
122
            accountNumberInput.removeAttribute("disabled");
123
        }
124
    }
125
126
    function enableBankCode() 
127
    {
128
        if(bankCodeWrap) {
129
            bankCodeWrap.show();
130
            bankCodeInput.removeAttribute("disabled");
131
        }
132
    }
133
134
    function enableSepaIban() 
135
    {
136
        if(sepaIbanWrap) {
137
            sepaIbanWrap.show();
138
            sepaIbanInput.removeAttribute("disabled");
139
        }
140
    }
141
142
    function enableSepaBic() 
143
    {
144
        if(sepaBicWrap) {
145
            sepaBicWrap.show();
146
            sepaBicInput.removeAttribute("disabled");
147
        }
148
    }
149
150
    function enableBankGroupAt() 
151
    {
152
        if(bankGroupWrapAt) {
153
            bankGroupWrapAt.show();
154
            bankGroupSelectAt.removeAttribute("disabled");
155
        }
156
    }
157
158
    function enableBankGroupNl() 
159
    {
160
        if(bankGroupWrapNl) {
161
            bankGroupWrapNl.show();
162
            bankGroupSelectNl.removeAttribute("disabled");
163
        }
164
    }
165
}
166
167
function copyOnlineBankTransferSepaIban(code) 
168
{
169
    var input_sepa_iban_xxx_el = $(code + '_sepa_iban_xxx');
170
    var input_sepa_iban_el = $(code + '_sepa_iban');
171
    input_sepa_iban_el.value = input_sepa_iban_xxx_el.value;
172
}
173