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