Merge branch 'patch-1' of https://github.com/gjones2/Freeside
[freeside.git] / httemplate / elements / select-did.html
1 <%doc>
2
3 Example:
4
5   include('/elements/select-did.html',
6             #can't actuall change from phonenum yet# 'field'   => 'phonenum',
7
8             'svcpart' => 5,
9             #OR
10             'object' => $svc_phone,
11          );
12
13 </%doc>
14 % if ( $use_selector ) {
15
16 %   if ( $export->option('restrict_selection') eq 'non-tollfree'
17 %                   || !$export->option('restrict_selection') ) {
18     <TABLE>
19       <TR>
20
21 %       if ( $export->get_dids_npa_select ) {
22
23         <TD VALIGN="top">
24           <% include('/elements/select-state.html',
25                        'prefix'        => 'phonenum_', #$field.'_',
26                        'country'       => $country,
27                        'svcpart'       => $svcpart,
28                        'disable_empty' => 0,
29                        'empty_label'   => 'Select state',
30                     )
31           %>
32           <BR><FONT SIZE="-1">State</FONT>
33         </TD>
34
35           <TD VALIGN="top">
36             <% include('/elements/select-areacode.html',
37                          'state_prefix' => 'phonenum_', #$field.'_',
38                          'svcpart'      => $svcpart,
39                          'empty'        => 'Select area code',
40                       )
41             %>
42             <BR><FONT SIZE="-1">Area code</FONT>
43           </TD>
44
45           <TD VALIGN="top">
46             <% include('/elements/select-exchange.html',
47                          'svcpart' => $svcpart,
48                          'empty'   => 'Select exchange',
49                       )
50             %>
51             <BR><FONT SIZE="-1">City / Exchange</FONT>
52           </TD>
53
54 %       } else {
55
56         <TD VALIGN="top">
57           <% include('/elements/select.html',
58                        'field'    => 'phonenum_state',
59                        'id'       => 'phonenum_state',
60                        'options'  => [ '', @{ $export->get_dids } ],
61                        'labels'   => { '' => 'Select province' },
62                        'onchange' => 'phonenum_state_changed(this);',
63                     )
64           %>
65           <BR><FONT SIZE="-1">Province</FONT>
66         </TD>
67
68           <TD VALIGN="top">
69             <% include('/elements/select-region.html',
70                          'state_prefix'  => 'phonenum_', #$field.'_',
71                          'svcpart'       => $svcpart,
72                          'empty'         => 'Select region',
73                       )
74             %>
75             <BR><FONT SIZE="-1">Region</FONT>
76           </TD>
77
78 %       }
79
80         <TD VALIGN="top">
81           <% include('/elements/select-phonenum.html',
82                        'svcpart'  => $svcpart,
83                        'empty'    => 'Select phone number',
84                        'bulknum'  => $bulknum,
85                        'multiple' => $multiple,
86                        'region'   => ! $export->get_dids_npa_select,
87                     )
88           %>
89           <BR><FONT SIZE="-1">Phone number</FONT>
90         </TD>
91
92       </TR>
93     </TABLE>
94
95 % } 
96 %   if (     ( $export->option('restrict_selection') eq 'tollfree'
97 %                || !$export->option('restrict_selection')
98 %            )
99 %        and $export->get_dids_can_tollfree
100 %      ) {
101             <font size="-1">Toll-free</font>
102             <% include('/elements/select-phonenum.html',
103                        'svcpart' => $svcpart,
104                        'empty'   => 'Select phone number',
105                        'tollfree' => 1,
106                        'prefix' => 'tollfree',
107                        'bulknum' => 0,
108                     )
109             %>
110 %       }
111
112 %       if ( $bulknum ) {
113             <div id="bulkdid" style="padding-top: 11px">
114 %               my $i;
115 %               for($i=0; $i < $bulknum; $i++) {
116                     <div id="bulkdid_<%$i%>" style="display: none">
117                         <input type="checkbox" id="checkbox_bulkdid_<%$i%>"
118                             name="bulkdid" value="">
119                         <label for="checkbox_bulkdid_<%$i%>" 
120                             id="label_bulkdid_<%$i%>"></label>
121                     </div>
122 %               }
123             </div>
124 %       }
125
126 % } else {
127
128     <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
129
130 % }
131 <%init>
132
133 my %opt = @_;
134
135 my $conf = new FS::Conf;
136
137 #false laziness w/tr-select-did.html
138 #XXX make sure this comes through on errors too
139 my $svcpart  = $opt{'svcpart'}
140             || $opt{'object'}->svcpart
141             || $opt{'object'}->cust_svc->svcpart;
142
143 my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
144 die "unknown svcpart $svcpart" unless $part_svc;
145
146 my @exports = $part_svc->part_export_did;
147 if ( scalar(@exports) > 1 ) {
148   die "more than one DID-providing export attached to svcpart $svcpart";
149 }
150 my $export = '';
151 $export = $exports[0] if scalar(@exports);
152
153 my $use_selector = scalar(@exports) ? 1 : 0;
154
155 my $bulknum = $opt{'bulknum'} || 0; #Bulk DID orders via ordering system, vs.
156 my $multiple = $opt{'multiple'} || 0; #just selecting a bunch at a time
157
158 my $country  = ( $export && $export->option('country') )
159             || $conf->config('countrydefault')
160             || 'US';
161
162 #my $field = $opt{'field'} || 'phonenum';
163
164 </%init>