6cc63b96176ce487b2ad282d27a2b1848b1ed21d
[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
20       <TR>
21         <TD>
22           <% include('/elements/select-state.html',
23                        'prefix'        => 'phonenum_', #$field.'_',
24                        'country'       => $country,
25                        'disable_empty' => 0,
26                        'empty_label'   => 'Select state',
27                     )
28           %>
29         </TD>
30         <TD>
31           <% include('/elements/select-areacode.html',
32                        'state_prefix' => 'phonenum_', #$field.'_',
33                        'svcpart'      => $svcpart,
34                        'empty'        => 'Select area code',
35                     )
36           %>
37         </TD>
38         <TD>
39           <% include('/elements/select-exchange.html',
40                        'svcpart' => $svcpart,
41                        'empty'   => 'Select exchange',
42                     )
43           %>
44         </TD>
45         <TD>
46           <% include('/elements/select-phonenum.html',
47                        'svcpart' => $svcpart,
48                        'empty'   => 'Select phone number',
49                        'bulknum' => $bulknum,
50                     )
51           %>
52         </TD>
53       </TR>
54
55       <TR>
56         <TD><FONT SIZE="-1">State</FONT></TD>
57         <TD><FONT SIZE="-1">Area code</FONT></TD>
58         <TD><FONT SIZE="-1">City / Exchange</FONT></TD>
59         <TD><FONT SIZE="-1">Phone number</FONT></TD>
60       </TR>
61
62     </TABLE>
63
64 % } 
65 %   if ( $export->option('restrict_selection') eq 'tollfree'
66 %                   || !$export->option('restrict_selection') ) {
67             <font size="-1">Toll-free</font>
68             <% include('/elements/select-phonenum.html',
69                        'svcpart' => $svcpart,
70                        'empty'   => 'Select phone number',
71                        'tollfree' => 1,
72                        'prefix' => 'tollfree',
73                        'bulknum' => 0,
74                     )
75             %>
76 %       }
77
78 %       if ( $bulknum ) {
79             <div id="bulkdid" style="padding-top: 11px">
80 %               my $i;
81 %               for($i=0; $i < $bulknum; $i++) {
82                     <div id="bulkdid_<%$i%>" style="display: none">
83                         <input type="checkbox" id="checkbox_bulkdid_<%$i%>"
84                             name="bulkdid" value="">
85                         <label for="checkbox_bulkdid_<%$i%>" 
86                             id="label_bulkdid_<%$i%>"></label>
87                     </div>
88 %               }
89             </div>
90 %       }
91
92 % } else {
93
94     <% include( '/elements/input-text.html', %opt, 'type'=>'text' ) %>
95
96 % }
97 <%init>
98
99 my %opt = @_;
100
101 my $conf = new FS::Conf;
102 my $country = $conf->config('countrydefault') || 'US';
103
104 #false laziness w/tr-select-did.html
105 #XXX make sure this comes through on errors too
106 my $svcpart  = $opt{'svcpart'}
107             || $opt{'object'}->svcpart
108             || $opt{'object'}->cust_svc->svcpart;
109
110 my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } );
111 die "unknown svcpart $svcpart" unless $part_svc;
112
113 my @exports = $part_svc->part_export_did;
114 if ( scalar(@exports) > 1 ) {
115   die "more than one DID-providing export attached to svcpart $svcpart";
116 }
117
118 my $use_selector = scalar(@exports) ? 1 : 0;
119
120 my $export;
121 $export = $exports[0] if scalar(@exports);
122
123 my $bulknum = $opt{'bulknum'} || 0;
124
125 #my $field = $opt{'field'} || 'phonenum';
126
127 </%init>