Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / misc / detach_pkg.html
1 <& /elements/header-popup.html, mt("Detach Package to New Customer") &>
2
3 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
4
5 <& /elements/error.html &>
6
7 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/detach-cust_pkg.html" METHOD=POST>
8 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
9 % foreach my $f (qw( agentnum refnum )) {
10   <INPUT TYPE="hidden" NAME="<% $f %>" VALUE="<% $cust_main->$f() %>">
11 % }
12 <INPUT TYPE="hidden" NAME="referral_custnum" VALUE="<% $cust_main->custnum %>">
13 % foreach my $f (FS::cust_main->location_fields) {
14   <INPUT TYPE="hidden" NAME="<% $f %>" VALUE="<% $loc->$f() |h %>">
15 % }
16
17 <% ntable('#cccccc') %>
18
19   <TR>
20     <TH ALIGN="right"><% mt('Package') |h %></TH>
21     <TD COLSPAN=7 BGCOLOR="#dddddd">
22       <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
23     </TD>
24   </TR>
25
26 % #always should be present for detaching, yes? #if ( $cust_pkg->contactnum ) {
27 %   my $cust_contact = $cust_pkg->contact_obj;
28
29     <INPUT TYPE="hidden" NAME="first" VALUE="<% $cust_contact->get('first') |h %>">
30     <INPUT TYPE="hidden" NAME="last"  VALUE="<% $cust_contact->get('last')  |h %>">
31
32     <TR>
33       <TH ALIGN="right"><% mt('Name') %></TH>
34       <TD COLSPAN=7 BGCOLOR="#dddddd">
35         <% $cust_pkg->contact_obj->line |h %>
36       </TD>
37     </TR>
38 % #}
39
40   <TR>
41     <TH ALIGN="right" VALIGN="top"><% mt('Address') %></TH>
42     <TD COLSPAN=7 BGCOLOR="#dddddd">
43
44       <% $loc->location_label( 'join_string'     => '<BR>',
45                                'double_space'    => ' &nbsp; ',
46                                'escape_function' => \&encode_entities,
47                                'countrydefault'  => $countrydefault,
48                              )
49       %>
50     </TD>
51   </TR>
52
53 </TABLE>
54
55 %#XXX payment info
56 %#XXX should be sticky on errors...
57 <& /edit/cust_main/billing.html, FS::cust_main->new({}),
58                                  invoicing_list => [],
59
60 &>
61
62 <BR>
63 <BR>
64 <INPUT NAME    = "submitButton"
65        TYPE    = "submit"
66        VALUE   = "<% mt("Detach package") |h %>"
67 >
68
69 %#and a cancel button?  or is the popup close sufficient?
70
71 </FORM>
72 </BODY>
73 </HTML>
74
75 <%init>
76
77 my $conf = new FS::Conf;
78 my $countrydefault = $conf->config('countrydefault') || 'US';
79
80 my $curuser = $FS::CurrentUser::CurrentUser;
81 die "access denied"
82   unless $curuser->access_right('Change customer package');
83
84 my $pkgnum = scalar($cgi->param('pkgnum'));
85 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
86 $pkgnum = $1;
87
88 my $cust_pkg =
89   qsearchs({
90     'table'     => 'cust_pkg',
91     'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
92     'hashref'   => { 'pkgnum' => $pkgnum },
93     'extra_sql' => ' AND '. $curuser->agentnums_sql,
94   }) or die "unknown pkgnum $pkgnum";
95
96 my $loc = $cust_pkg->cust_location_or_main;
97
98 my $cust_main = $cust_pkg->cust_main
99   or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
100          " ( pkgnum ". cust_pkg->pkgnum. ")";
101
102 my $part_pkg = $cust_pkg->part_pkg;
103
104 </%init>