allow manual override of phone number, RT#19883
[freeside.git] / httemplate / edit / process / svc_phone.html
1 <& elements/svc_Common.html,
2                'table'          => 'svc_phone',
3                'args_callback'  => $args_callback,
4                'value_callback' => $value_callback,
5                %opt,
6 &>
7 <%init>
8
9 my %opt = ();
10 if ( $cgi->param('bulk') ) {
11   $opt{'bulk'}     = 'phonenum';
12
13   my $cust_pkg = qsearchs('cust_pkg', { pkgnum=>scalar($cgi->param('pkgnum')) })
14     or die "unknown pkgnum";
15   my $custnum = $cust_pkg->custnum;
16
17   my $show =
18     $FS::CurrentUser::CurrentUser->default_customer_view =~ /^(jumbo|packages)$/
19       ? ''
20       : ';show=packages';
21   #my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment
22   $opt{'redirect'}= popurl(3)."view/cust_main.cgi?custnum=$custnum$show;dummy=";
23 }
24
25 my $right = $opt{'bulk'} ? 'Bulk provision customer service'
26                          :      'Provision customer service';
27
28 die "access denied"
29   unless $FS::CurrentUser::CurrentUser->access_right($right);
30
31 $cgi->param('phonenum', $cgi->param('phonenum_manual') )
32   if $cgi->param('phonenum_which') eq 'phonenum_manual';
33
34 my $tollfreephonenum = $cgi->param('tollfreephonenum');
35 $cgi->param('phonenum',$tollfreephonenum) if $tollfreephonenum =~ /^\d+$/;
36
37 my $args_callback = sub {
38   my( $cgi, $object ) = @_;
39
40   my %opt = ();
41   if ( $cgi->param('locationnum') == -1 ) {
42     my $cust_location = new FS::cust_location {
43       map { $_ => scalar($cgi->param($_)) }
44           qw( custnum address1 address2 city county state zip country )
45     };
46     $opt{'cust_location'} = $cust_location;
47   }
48
49   %opt;
50
51 };
52
53 my $value_callback = sub {
54      my ($field, $value) = @_;
55      ($field =~ /_date$/) ? parse_datetime($value) : $value;
56 };
57
58 </%init>