link to customer from manual payment screen (ticket 1414)
[freeside.git] / httemplate / view / elements / svc_Common.html
1 %
2 %
3 %  # options example...
4 %  #
5 %  # 'table' => 'svc_something'
6 %  #
7 %  # 'labels' => {
8 %  #               'column' => 'Label',
9 %  #             },
10 %  #
11 %  # listref - each item is a literal column name (or method) or (notyet) coderef
12 %  # if not specified all columns (except for the primary key) will be viewable
13 %  # 'fields' => [
14 %  #             ]
15 %  #
16 %  # # defaults to "edit/$table.cgi?", will have svcnum appended
17 %  # 'edit_url' => 
18 %
19 %  my(%opt) = @_;
20 %
21 %  my $table = $opt{'table'};
22 %
23 %  my $fields = $opt{'fields'}
24 %               #|| [ grep { $_ ne 'svcnum' } dbdef->table($table)->columns ];
25 %               || [ grep { $_ ne 'svcnum' } fields($table) ];
26 %
27 %  my $svcnum;
28 %  if ( $cgi->param('svcnum') ) {
29 %    $cgi->param('svcnum') =~ /^(\d+)$/ or die "unparsable svcnum";
30 %    $svcnum = $1;
31 %  } else {
32 %    my($query) = $cgi->keywords;
33 %    $query =~ /^(\d+)$/ or die "no svcnum";
34 %    $svcnum = $1;
35 %  }
36 %  my $svc_x = qsearchs( $opt{'table'}, { 'svcnum' => $svcnum } )
37 %    or die "Unknown svcnum $svcnum in ". $opt{'table'}. " table\n";
38 %
39 %  my $cust_svc = $svc_x->cust_svc;
40 %  my($label, $value, $svcdb) = $cust_svc->label;
41 %
42 %  my $pkgnum = $cust_svc->pkgnum;
43 %
44 %  my($cust_pkg, $custnum);
45 %  if ($pkgnum) {
46 %    $cust_pkg = $cust_svc->cust_pkg;
47 %    $custnum = $cust_pkg->custnum;
48 %  } else {
49 %    $cust_pkg = '';
50 %    $custnum = '';
51 %  }
52 %
53 %
54 % if ( $custnum ) { 
55
56
57   <% include("/elements/header.html","View $label: $value") %>
58
59   <% include( '/elements/small_custview.html', $custnum, '', 1,
60      "${p}view/cust_main.cgi") %>
61   <BR>
62 % } else { 
63
64
65   <SCRIPT>
66   function areyousure(href) {
67       if (confirm("Permanently delete this <% $label %>?") == true)
68           window.location.href = href;
69   }
70   </SCRIPT>
71
72   <% include("/elements/header.html","View $label: $value", menubar(
73       "Cancel this (unaudited) $label" =>
74             "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')"
75   )) %>
76 % } 
77
78
79 Service #<B><% $svcnum %></B>
80 % my $url = $opt{'edit_url'} || $p. 'edit/'. $opt{'table'}. '.cgi?';
81 | <A HREF="<%$url%><%$svcnum%>">Edit this <% $label %></A>
82 <BR>
83
84 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
85 % foreach my $f ( @$fields ) {
86 %
87 %     my( $field, $type);
88 %     if ( ref($f) ) {
89 %       $field = $f->{'field'},
90 %       $type  = $f->{'type'} || 'text',
91 %     } else {
92 %       $field = $f;
93 %       $type = 'text';
94 %     }
95 %
96
97
98   <TR>
99     <TD ALIGN="right">
100       <% ( $opt{labels} && exists $opt{labels}->{$field} )
101               ? $opt{labels}->{$field}
102               : $field
103       %>
104     </TD>
105 %
106 %      #eventually more options for <SELECT>, etc. fields
107 %    
108
109
110     <TD BGCOLOR="#ffffff"><% $svc_x->$field %><TD>
111
112   </TR>
113 % } 
114 % foreach (sort { $a cmp $b } $svc_x->virtual_fields) { 
115
116   <% $svc_x->pvf($_)->widget('HTML', 'view', $svc_x->getfield($_)) %>
117 % } 
118
119
120 </TABLE></TD></TR></TABLE>
121
122 <BR>
123 <% joblisting({'svcnum'=>$svcnum}, 1) %>
124
125 <% include('/elements/footer.html') %>