summaryrefslogtreecommitdiff
path: root/httemplate/elements/pbx_extension.html
blob: 62a1f5172f6fa377403398ab2961a51f71a0e1b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% unless ( $opt{'js_only'} ) {

  <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">

  <TABLE STYLE="display:inline">
    <TR>

%     ###
%     # extension
%     ###
      <TD>
        <INPUT
              TYPE  = "text"
              NAME  = "<%$name%>_extension"
              ID    = "<%$id%>_extension"
              VALUE = "<% scalar($cgi->param($name.'_extension'))
                            || $pbx_extension->extension
                       %>"
              SIZE  = 5
              MAXLENGTH = 6
              <% $onchange %>
            >
        <BR>
        <FONT SIZE="-1">Extension</FONT>
      </TD>

%     ###
%     # pin
%     ###
      <TD>
        <INPUT
              TYPE  = "text"
              NAME  = "<%$name%>_pin"
              ID    = "<%$id%>_pin"
              VALUE = "<% scalar($cgi->param($name.'_pin'))
                            || $pbx_extension->pin
                       %>"
              SIZE  = 7
              MAXLENGTH = 6
              <% $onchange %>
            >
        <BR>
        <FONT SIZE="-1">PIN</FONT>
      </TD>

%     ###
%     # sip_password
%     ###
      <TD>
        <INPUT
              TYPE  = "text"
              NAME  = "<%$name%>_sip_password"
              ID    = "<%$id%>_sip_password"
              VALUE = "<% scalar($cgi->param($name.'_sip_password'))
                            || $pbx_extension->sip_password
                       %>"
              SIZE      = <% $passwordmax == 80 ? 20 : $passwordmax + 2 %>
              MAXLENGTH = <% $passwordmax + 2 %>
              <% $onchange %>
            >
        <BR>
        <FONT SIZE="-1">SIP Password</FONT>
      </TD>

%     ###
%     # phone_name
%     ###
      <TD>
        <INPUT
              TYPE  = "text"
              NAME  = "<%$name%>_phone_name"
              ID    = "<%$id%>_phone_name"
              VALUE = "<% scalar($cgi->param($name.'_phone_name'))
                            || $pbx_extension->phone_name
                       %>"
              SIZE      = 20
              MAXLENGTH = 80
              <% $onchange %>
            >
        <BR>
        <FONT SIZE="-1">Name</FONT>
      </TD>

    </TR>
  </TABLE>

% }
<%init>

my( %opt ) = @_;

my $conf = new FS::Conf;
my $passwordmax = $conf->config('sip_passwordmax') || 80;

my $name = $opt{'element_name'} || $opt{'field'} || 'extensionnum';
my $id = $opt{'id'} || 'extensionnum';

my $curr_value = $opt{'curr_value'} || $opt{'value'};

my $onchange = '';
if ( $opt{'onchange'} ) {
  $onchange = $opt{'onchange'};
  $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
  $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack.  all onchange
                                        #callbacks should act the same
  $onchange = 'onChange="'. $onchange. '"';
}

my $pbx_extension = $curr_value
  ? qsearchs('pbx_extension', { 'extensionnum' => $curr_value } )
  : new FS::pbx_extension {};

</%init>