RT#33410: Package GB add-ons
[freeside.git] / httemplate / misc / order_pkg.html
1 <& /elements/header-popup.html, {
2      'title' =>  $quotationnum ? mt('Add package to quotation')
3                                : mt('Order new package'),
4      'nobr'  => 1,
5    }
6 &>
7
8 <& /elements/init_calendar.html &>
9
10 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
11
12 <& /elements/error.html &>
13
14 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
15
16 <INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main ? $cust_main->custnum : '' %>">
17 <INPUT TYPE="hidden" NAME="prospectnum" VALUE="<% $prospect_main ? $prospect_main->prospectnum : '' %>">
18 <INPUT TYPE="hidden" NAME="qualnum" VALUE="<% scalar($cgi->param('qualnum')) |h %>">
19 <INPUT TYPE="hidden" NAME="quotationnum" VALUE="<% $quotationnum %>">
20 % if ( $svcpart ) {
21     <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
22 % }
23
24 % my $num_sales = $agent->num_sales;
25 % my $conf_pkg_referral = $conf->exists('pkg_referral');
26 % my $show_sales = $num_sales && $conf_pkg_referral;
27 % my $show_sales_table = $num_sales || $conf_pkg_referral;
28
29 % if ( $show_sales ) {
30   <FONT CLASS="fsinnerbox-title"><% mt('Sales') |h %></FONT>
31 % }
32 % if ( $show_sales_table ) {
33   <% ntable("#cccccc") %>
34 % }
35
36 <& /elements/tr-select-sales.html,
37      'curr_value' => scalar($cgi->param('salesnum')),
38      'agentnum'   => $agent->agentnum,
39      'th'         => 1,
40 &>
41
42 % if ( $conf->exists('pkg_referral') ) {
43   <& /elements/tr-select-part_referral.html,
44                'curr_value'    => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
45                'disable_empty' => 1,
46                'multiple'      => $conf->exists('pkg_referral-multiple'),
47                'colspan'       => 7,
48   &>
49 % }
50
51 % if ( $show_sales_table ) {
52   </TABLE><BR>
53 % }
54
55 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
56 <% ntable("#cccccc") %>
57
58 % if ( $part_pkg ) {
59     <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
60     <TR>
61       <TH ALIGN="right"><% mt('Package') |h %></TH>
62       <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
63     </TR>
64 % } else {
65     <& /elements/tr-select-cust-part_pkg.html,
66                  'curr_value'    => $pkgpart,
67                  'classnum'      => -1,
68                  'cust_main'     => $cust_main,
69                  'prospect_main' => $prospect_main,
70     &>
71 % }
72
73 <& /elements/tr-input-pkg-quantity.html, curr_value => $quantity &>
74
75 % unless ( $quotationnum ) {
76
77 %   if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
78 %     my $what = lc(FS::payby->shortname($cust_main->payby));
79       <TR>
80         <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
81         <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
82       </TR>
83 %   }
84
85     <TR>
86       <TH ALIGN="right"><% mt('Start') |h %> </TD>
87       <TD COLSPAN=6>
88         <INPUT TYPE="radio" NAME="start" ID="start_now" VALUE="" <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>>Now
89         &emsp;
90         <INPUT TYPE="radio" NAME="start" ID="start_on_hold" VALUE="on_hold" <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>>On hold
91         &emsp;
92         <INPUT TYPE="radio" NAME="start" ID="start_on_date" VALUE="on_date" <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>>On date
93
94         <& /elements/input-date-field.html,{
95                     'name'      => 'start_date',
96                     'format'    => $date_format,
97                     'value'     => '',
98                     'noinit'    => 1,
99                   } &>
100       </TD>
101     </TR>
102
103     <TR>
104       <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
105       <TD COLSPAN=6>
106         <& /elements/input-date-field.html,{
107                     'name'      => 'contract_end',
108                     'format'    => $date_format,
109                     'value'     => '',
110                     'noinit'    => 1,
111                     } &>
112       </TD>
113     </TR>
114
115 % }
116
117 </TABLE><BR>
118
119 <% include('/misc/cust_pkg_usageprice.html',
120      'pkgpart' => $pkgpart
121    ) %>
122 <BR>
123
124 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
125 % my $waive_setup_fee   = $curuser->access_right('Waive setup fee');
126 %
127 % if ( $discount_cust_pkg || $waive_setup_fee ) {
128   <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
129   <% ntable("#cccccc") %>
130
131 %   if ( $waive_setup_fee ) {
132       <TR>
133         <TH ALIGN="right"><% mt('Waive setup fee') |h %> </TH>
134         <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="waive_setup" VALUE="Y"></TD>
135       </TR>
136 %   }
137
138 %   if ( $discount_cust_pkg ) {
139       <& /elements/tr-select-discount.html,
140                'element_etc' => 'DISABLED',
141                'colspan'     => 7,
142                'cgi'         => $cgi,
143       &>
144 %   }
145
146   </TABLE><BR>
147
148 % }
149
150
151 % my $lock_locationnum = scalar($cgi->param('lock_locationnum'));
152 % my $contact_title = $lock_locationnum ? 'Contact'
153 %                                       : 'Contact and Location';
154 <FONT CLASS="fsinnerbox-title"><% mt($contact_title) |h %></FONT>
155 <% ntable("#cccccc") %>
156
157 <& /elements/tr-select-contact.html,
158              'cgi'           => $cgi,
159              'cust_main'     => $cust_main,
160              'prospect_main' => $prospect_main,
161 &>
162
163 % if ( $cgi->param('lock_locationnum') ) {
164
165     <INPUT TYPE  = "hidden"
166            NAME  = "locationnum"
167            ID    = "locationnum"
168            VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
169     >
170
171 % } else {
172
173     <& /elements/tr-select-cust_location.html,
174                  'cgi'           => $cgi,
175                  'cust_main'     => $cust_main,
176                  'prospect_main' => $prospect_main,
177     &>
178
179 % }
180
181 </TABLE>
182
183 % unless ( $cgi->param('lock_locationnum') ) {
184
185   <& /elements/standardize_locations.html,
186                 'form'        => "OrderPkgForm",
187                 'callback'    => 'document.OrderPkgForm.submit()',
188                 'with_census' => 1,
189                 'with_census_functions' => 1,
190   &>
191
192 % }
193
194 <BR>
195 % my $onclick = $cgi->param('lock_locationnum')
196 %                 ? 'document.OrderPkgForm.submit()'
197 %                 : 'standardize_new_location()';
198 <INPUT NAME    = "submitButton"
199        TYPE    = "button"
200        VALUE   = "<% mt("Order Package") |h %>"
201        onClick = "this.disabled=true; <% $onclick %>;"
202        <% $pkgpart ? '' : 'DISABLED' %>
203 >
204
205 </FORM>
206 </BODY>
207 </HTML>
208 <%init>
209
210 my $curuser = $FS::CurrentUser::CurrentUser;
211
212 die "access denied"
213   unless $curuser->access_right('Order customer package');
214
215 my $conf = new FS::Conf;
216 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
217
218 my $cust_main = '';
219 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
220   my $custnum = $1;
221   $cust_main = qsearchs({
222     'table'     => 'cust_main',
223     'hashref'   => { 'custnum' => $custnum },
224     'extra_sql' => ' AND '. $curuser->agentnums_sql,
225   });
226 }
227
228 my $prospect_main = '';
229 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
230   my $prospectnum = $1;
231   $prospect_main = qsearchs({
232     'table'     => 'prospect_main',
233     'hashref'   => { 'prospectnum' => $prospectnum },
234     'extra_sql' => ' AND '. $curuser->agentnums_sql,
235   });
236 }
237
238 my $quotationnum = '';
239 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
240   $quotationnum = $1;
241 }
242
243 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
244
245 my $agent =  $cust_main ? $cust_main->agent
246                         : $prospect_main->agent;
247
248 my $part_pkg = '';
249 if ( $cgi->param('lock_pkgpart') ) {
250   $part_pkg = qsearchs({
251     'table'     => 'part_pkg',
252     'hashref'   => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
253     'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql($agent),
254   })
255     or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
256 }
257
258 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
259
260 my $quantity = 1;
261 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
262   $quantity = $1;
263 }
264
265 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
266
267 my $svcpart = scalar($cgi->param('svcpart'));
268
269 </%init>