366bbac3f0ba105bdefccbc2fe12dd8600cdd552
[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 %  if ( $conf->config_bool('cust_main-require_phone') ) {
54 %    #XXX should be sticky on errors
55 %    my $ph_cust_main = FS::cust_main->new({});
56 %    foreach my $contact_phone ( $cust_contact->contact_phone ) {
57 %      my $t = $contact_phone->typename;
58 %      #countrycodes?  interface doesn't parse/take em yet
59 %      $ph_cust_main->daytime( $contact_phone->phonenum ) if $t eq 'Work';
60 %      $ph_cust_main->night(   $contact_phone->phonenum ) if $t eq 'Home';
61 %      $ph_cust_main->mobile(  $contact_phone->phonenum ) if $t eq 'Mobile';
62 %      $ph_cust_main->fax(     $contact_phone->phonenum ) if $t eq 'Fax';
63 %    }
64
65      <& /elements/tr-cust_main-phones.html,
66           'cust_main'    => $ph_cust_main,
67      &>
68 %  }
69
70 </TABLE>
71
72 %#payment info
73 %#XXX should be sticky on errors...
74 <& /edit/cust_main/billing.html, FS::cust_main->new({}),
75                                  invoicing_list => [],
76
77 &>
78
79 <BR>
80 <BR>
81 <INPUT NAME    = "submitButton"
82        TYPE    = "submit"
83        VALUE   = "<% mt("Detach package") |h %>"
84 >
85
86 %#and a cancel button?  or is the popup close sufficient?
87
88 </FORM>
89 </BODY>
90 </HTML>
91
92 <%init>
93
94 my $conf = new FS::Conf;
95 my $countrydefault = $conf->config('countrydefault') || 'US';
96
97 my $curuser = $FS::CurrentUser::CurrentUser;
98 die "access denied"
99   unless $curuser->access_right('Change customer package');
100
101 my $pkgnum = scalar($cgi->param('pkgnum'));
102 $pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
103 $pkgnum = $1;
104
105 my $cust_pkg =
106   qsearchs({
107     'table'     => 'cust_pkg',
108     'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
109     'hashref'   => { 'pkgnum' => $pkgnum },
110     'extra_sql' => ' AND '. $curuser->agentnums_sql,
111   }) or die "unknown pkgnum $pkgnum";
112
113 my $loc = $cust_pkg->cust_location_or_main;
114
115 my $cust_main = $cust_pkg->cust_main
116   or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
117          " ( pkgnum ". cust_pkg->pkgnum. ")";
118
119 my $part_pkg = $cust_pkg->part_pkg;
120
121 </%init>