svc_phone service and CDR billing from imported CDRs
[freeside.git] / httemplate / edit / elements / svc_Common.html
1 <%
2
3   my %opt = @_;
4
5   #my( $svcnum, $pkgnum, $svcpart, $part_svc );
6   my( $pkgnum, $svcpart, $part_svc );
7
8   #get & untaint pkgnum & svcpart
9   my($query) = $cgi->keywords; #they're not proper cgi params
10   if ( $query =~ /^pkgnum(\d+)-svcpart(\d+)$/ ) {
11     $pkgnum  = $1;
12     $svcpart = $2;
13     $cgi->delete_all(); #so the standard edit.html treats this correctly as new
14   }
15
16 %><%= include( 'edit.html',
17
18                  'menubar' => [],
19
20                  'error_callback' => sub {
21                    my( $cgi, $svc_x ) = @_;
22                    #$svcnum = $svc_x->svcnum;
23                    $pkgnum  = $cgi->param('pkgnum');
24                    $svcpart = $cgi->param('svcpart');
25
26                    $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
27                    die "No part_svc entry!" unless $part_svc;
28                  },
29
30                  'edit_callback' => sub {
31                    my( $cgi, $svc_x ) = @_;
32                    #$svcnum = $svc_x->svcnum;
33                    my $cust_svc = $svc_x->cust_svc
34                      or die "Unknown (cust_svc) svcnum!";
35
36                    $pkgnum  = $cust_svc->pkgnum;
37                    $svcpart = $cust_svc->svcpart;
38   
39                    $part_svc = qsearchs ('part_svc', { svcpart=>$svcpart });
40                    die "No part_svc entry!" unless $part_svc;
41                  },
42
43                  'new_hash_callback' => sub {
44                    #my( $cgi, $svc_x ) = @_;
45
46                    { svcpart => $svcpart };
47
48                  },
49
50                  'new_callback' => sub {
51                     my( $cgi, $svc_x ) = @_;;
52
53                     $part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
54                     die "No part_svc entry!" unless $part_svc;
55
56                     #$svcnum='';
57
58                     $svc_x->set_default_and_fixed;
59
60                  },
61
62                  'field_callback' => sub {
63                    my $f = shift;
64                    my $columndef = $part_svc->part_svc_column($f->{'field'});
65                    my $flag = $columndef->columnflag;
66                    if ( $flag eq 'F' ) {
67                      $f->{'type'} = 'fixed';
68                      $f->{'value'} = $columndef->columnvalue;
69                    }
70                  },
71
72                  'html_table_bottom' => sub {
73                    my $svc_x = shift;
74                    my $html = '';
75                    foreach my $field ($svc_x->virtual_fields) {
76                      if ($part_svc->part_svc_column($field)->columnflag ne 'F'){
77                        # If the flag is X, it won't even show up
78                        # in $svc_acct->virtual_fields.
79                        $html .=
80                          $svc_x->pvf($field)->widget( 'HTML',
81                                                       'edit', 
82                                                       $svc_x->getfield($field)
83                                                     );
84                      }
85                    }
86                    $html;
87                  },
88
89                  'html_bottom' => sub {
90                    qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!.
91                    qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!;
92                  },
93
94                  'debug' => 1,
95
96                  %opt #pass through/override params
97              )
98 %>