external taxes support package locations RT10093
[freeside.git] / httemplate / misc / order_pkg.html
1 <% include('/elements/header-popup.html', 'Order new package' ) %>
2
3 <LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
4 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
5 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
6 <SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
7
8 <SCRIPT TYPE="text/javascript">
9
10   function enable_order_pkg () {
11     if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
12       document.OrderPkgForm.submitButton.disabled = false;
13       if ( document.OrderPkgForm.pkgpart.options[document.OrderPkgForm.pkgpart.selectedIndex].getAttribute('data-can_discount') == 1 ) {
14         document.OrderPkgForm.discountnum.disabled = false;
15       } else {
16         document.OrderPkgForm.discountnum.disabled = true;
17       }
18     } else {
19       document.OrderPkgForm.submitButton.disabled = true;
20       document.OrderPkgForm.discountnum.disabled = true;
21     }
22   }
23
24 </SCRIPT>
25
26 <% include('/elements/error.html') %>
27
28 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
29
30 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
31
32 <% ntable("#cccccc", 2) %>
33 <% include('/elements/tr-select-cust-part_pkg.html',
34              'curr_value' => $pkgpart,
35              'classnum'   => -1,
36              'cust_main'  => $cust_main,
37              'onchange'   => 'enable_order_pkg',
38           )
39 %>
40
41 %# false laziness w/edit/quick-charge.html
42 <TR>
43   <TH ALIGN="right">Start date </TD>
44   <TD COLSPAN=6>
45     <INPUT TYPE  = "text"
46            NAME  = "start_date"
47            SIZE  = 32
48            ID    = "start_date_text"
49            VALUE = "<% $start_date %>"
50     >
51     <IMG SRC   = "../images/calendar.png"
52          ID    = "start_date_button"
53          STYLE = "cursor: pointer"
54          TITLE = "Select date"
55     >
56     <FONT SIZE=-1>(leave blank to start immediately)</FONT>
57   </TD>
58 </TR>
59
60 <SCRIPT TYPE="text/javascript">
61   Calendar.setup({
62     inputField: "start_date_text",
63     ifFormat:   "<% $date_format %>",
64     button:     "start_date_button",
65     align:      "BR"
66   });
67 </SCRIPT>
68
69 % if ( $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
70 %   my $what = lc(FS::payby->shortname($cust_main->payby));
71     <TR>
72       <TH ALIGN="right">Disable automatic <% $what %> charge </TH>
73       <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
74     </TR>
75 % }
76
77 % if ( $curuser->access_right('Discount customer package') ) {
78   <% include('/elements/tr-select-discount.html',
79                'element_etc' => 'DISABLED',
80                'colspan'     => 7,
81                'cgi'         => $cgi,
82             )
83   %>
84 % }
85
86 % if ( $conf->exists('pkg_referral') ) {
87   <% include('/elements/tr-select-part_referral.html',
88                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
89                'disable_empty' => 1,
90                'multiple'      => $conf->exists('pkg_referral-multiple'),
91                'colspan'       => 7,
92             )
93   %>
94 % }
95
96 <% include('/elements/tr-select-cust_location.html',
97              'cgi'       => $cgi,
98              'cust_main' => $cust_main,
99           )
100 %>
101
102 </TABLE>
103
104 <% include( '/elements/standardize_locations.html',
105             'form'       => "OrderPkgForm",
106             'onlyship'   => 1,
107             'no_company' => 1,
108             'callback'   => 'document.OrderPkgForm.submit();',
109           )
110 %>
111
112 <BR>
113 <INPUT NAME="submitButton" TYPE="button" VALUE="Order Package" onClick = "this.disabled=true; standardize_locations();" <% $pkgpart ? '' : 'DISABLED' %>>
114
115 </FORM>
116 </BODY>
117 </HTML>
118 <%init>
119
120 my $curuser = $FS::CurrentUser::CurrentUser;
121
122 die "access denied"
123   unless $curuser->access_right('Order customer package');
124
125 my $conf = new FS::Conf;
126 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
127
128 $cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
129 my $custnum = $1;
130 my $cust_main = qsearchs({
131   'table'     => 'cust_main',
132   'hashref'   => { 'custnum' => $custnum },
133   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
134 });
135
136 my $pkgpart = scalar($cgi->param('pkgpart'));
137
138 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
139 my $start_date = '';
140 if( ! $conf->exists('order_pkg-no_start_date') ) {
141   $start_date = $cust_main->next_bill_date;
142   $start_date = $start_date ? time2str($format, $start_date) : '';
143 }
144
145 </%init>