fix address ranges for sites with old NetAddr::IP versions, #26868
[freeside.git] / httemplate / edit / process / did_order.html
1 <% include( 'elements/process.html',
2                'table'       => 'did_order',
3                'viewall_dir' => 'browse',
4                'value_callback' => $value_callback,
5                'process_o2m' => {
6                     'table'  => 'did_order_item',
7                     'fields' => [ qw( msanum npa latanum ratecenternum state
8                                   quantity custnum ) ],
9                 },
10            )
11 %>
12 <%init>
13
14 die "access denied"
15   unless $FS::CurrentUser::CurrentUser->access_right('Import');
16
17 unless($cgi->param('submitted')) {
18     $cgi->param('submitted',time);
19 }
20
21 my $value_callback = sub {
22      my ($field, $value) = @_;
23      ($field =~ /ed$/ && $value !~ /^\d+$/) ? parse_datetime($value) : $value;
24 };
25
26 my @params = $cgi->param;
27 foreach my $param ( @params ) {
28     if ( $param =~ /^(orderitemnum[0-9]+)_rc_new$/ ) {
29         my $prefix = $1;
30         my $value = $cgi->param($param);
31         if( $value =~ /^[A-Za-z0-9:\- ]+$/ ) {
32             my $rc = new FS::rate_center({ description => $value });
33             my $error = $rc->insert;
34             die "error inserting new rate center: $error" if $error;
35             $cgi->param("${prefix}_ratecenternum",$rc->ratecenternum);
36         }
37     }
38     elsif ( $param =~ /^(orderitemnum[0-9]+)_custnum$/ ) {
39         my $prefix = $1;
40         my $value = $cgi->param($param);
41         if ( $value =~ /^\d+$/ ) {
42             $cgi->param("custnum",'');
43         }
44     }
45 }
46
47 </%init>