1 <& /elements/header-popup.html, {
2 'title' => $quotationnum ? mt('Add package to quotation')
3 : mt('Order new package'),
8 <& /elements/init_calendar.html &>
10 <SCRIPT TYPE="text/javascript" SRC="../elements/order_pkg.js"></SCRIPT>
12 <& /elements/error.html &>
14 <FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
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 %>">
21 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
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;
29 % if ( $show_sales ) {
30 <FONT CLASS="fsinnerbox-title"><% mt('Sales') |h %></FONT>
32 % if ( $show_sales_table ) {
33 <% ntable("#cccccc") %>
36 <& /elements/tr-select-sales.html,
37 'curr_value' => scalar($cgi->param('salesnum')),
38 'agentnum' => $agent->agentnum,
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,
46 'multiple' => $conf->exists('pkg_referral-multiple'),
51 % if ( $show_sales_table ) {
55 <FONT CLASS="fsinnerbox-title"><% mt('Package') |h %></FONT>
56 <% ntable("#cccccc") %>
59 <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $part_pkg->pkgpart %>">
61 <TH ALIGN="right"><% mt('Package') |h %></TH>
62 <TD COLSPAN=6><% $part_pkg->pkg_comment |h %></TD>
65 <& /elements/tr-select-cust-part_pkg.html,
66 'curr_value' => $pkgpart,
68 'cust_main' => $cust_main,
69 'prospect_main' => $prospect_main,
73 <& /elements/tr-input-pkg-quantity.html, curr_value => $quantity &>
75 % unless ( $quotationnum ) {
77 % if ( $cust_main && $cust_main->payby =~ /^(CARD|CHEK)$/ ) {
78 % my $what = lc(FS::payby->shortname($cust_main->payby));
80 <TH ALIGN="right"><% mt("Disable automatic $what charge") |h %> </TH>
81 <TD COLSPAN=6><INPUT TYPE="checkbox" NAME="no_auto" VALUE="Y"></TD>
86 <TH ALIGN="right"><% mt('Start') |h %> </TD>
92 <% $cgi->param('start') eq '' ? 'CHECKED' : ''%>
93 <% $pkgpart ? '' : 'DISABLED' %>
100 <% $cgi->param('start') eq 'on_hold' ? 'CHECKED' : ''%>
101 <% $pkgpart ? '' : 'DISABLED' %>
104 <INPUT TYPE = "radio"
108 <% $cgi->param('start') eq 'date' ? 'CHECKED' : ''%>
109 <% $pkgpart ? '' : 'DISABLED' %>
112 <& /elements/input-date-field.html,
113 { 'name' => 'start_date',
114 'format' => $date_format,
124 <TH ALIGN="right"><% mt('Contract end date') |h %> </TD>
126 <& /elements/input-date-field.html,{
127 'name' => 'contract_end',
128 'format' => $date_format,
139 <& /elements/table-cust_pkg_usageprice.html,
140 'pkgpart' => $pkgpart
143 % my $discount_cust_pkg = $curuser->access_right('Discount customer package');
144 % my $waive_setup_fee = $curuser->access_right('Waive setup fee');
146 % if ( $discount_cust_pkg || $waive_setup_fee ) {
147 <FONT CLASS="fsinnerbox-title"><% mt('Discounting') |h %></FONT>
148 <% ntable("#cccccc") %>
149 <& /elements/tr-select-pkg-discount.html &>
155 % my $lock_locationnum = scalar($cgi->param('lock_locationnum'));
156 % my $contact_title = $lock_locationnum ? 'Contact'
157 % : 'Contact and Location';
158 <FONT CLASS="fsinnerbox-title"><% mt($contact_title) |h %></FONT>
159 <% ntable("#cccccc") %>
161 <& /elements/tr-select-contact.html,
163 'cust_main' => $cust_main,
164 'prospect_main' => $prospect_main,
167 % if ( $cgi->param('lock_locationnum') ) {
169 <INPUT TYPE = "hidden"
172 VALUE = "<% scalar($cgi->param('lock_locationnum')) |h %>"
177 <& /elements/tr-select-cust_location.html,
179 'cust_main' => $cust_main,
180 'prospect_main' => $prospect_main,
187 % unless ( $cgi->param('lock_locationnum') ) {
189 <& /elements/standardize_locations.html,
190 'form' => "OrderPkgForm",
191 'callback' => 'document.OrderPkgForm.submit()',
193 'with_census_functions' => 1,
198 % if ($quotationnum) {
200 <FONT CLASS="fsinnerbox-title"><% mt('Quotation details') |h %></FONT>
201 <TABLE ID="QuotationDetailTable" BORDER="0" BGCOLOR="#cccccc">
205 <SELECT NAME="copy_on_order">
206 <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
207 <% emt('Details will only appear on quotation') %>
209 <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
210 <% emt('Copy details to invoice when placing order') %>
215 <& /edit/elements/detail-table.html,
216 id => 'QuotationDetailTable',
217 details => $details->{'quotation_detail'},
218 field => 'quotation_detail',
223 <FONT CLASS="fsinnerbox-title"><% mt('Invoice details') |h %></FONT>
224 <TABLE ID="InvoiceDetailTable" BORDER="0" BGCOLOR="#cccccc">
225 <& /edit/elements/detail-table.html,
226 id => 'InvoiceDetailTable',
227 details => $details->{'invoice_detail'},
228 field => 'invoice_detail',
233 <FONT CLASS="fsinnerbox-title"><% mt('Package comments') |h %></FONT>
234 <TABLE ID="PackageCommentTable" BORDER="0" BGCOLOR="#cccccc">
235 <& /edit/elements/detail-table.html,
236 id => 'PackageCommentTable',
237 details => $details->{'package_comment'},
238 field => 'package_comment',
245 % my $onclick = $cgi->param('lock_locationnum')
246 % ? 'document.OrderPkgForm.submit()'
247 % : 'standardize_new_location()';
248 <INPUT NAME = "submitButton"
250 VALUE = "<% mt("Order Package") |h %>"
251 onClick = "this.disabled=true; <% $onclick %>;"
252 <% $pkgpart ? '' : 'DISABLED' %>
260 my $curuser = $FS::CurrentUser::CurrentUser;
263 unless $curuser->access_right('Order customer package');
265 my $conf = new FS::Conf;
266 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
269 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
271 $cust_main = qsearchs({
272 'table' => 'cust_main',
273 'hashref' => { 'custnum' => $custnum },
274 'extra_sql' => ' AND '. $curuser->agentnums_sql,
278 my $prospect_main = '';
279 if ( $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
280 my $prospectnum = $1;
281 $prospect_main = qsearchs({
282 'table' => 'prospect_main',
283 'hashref' => { 'prospectnum' => $prospectnum },
284 'extra_sql' => ' AND '. $curuser->agentnums_sql,
288 my $quotationnum = '';
289 if ( $cgi->param('quotationnum') =~ /^(\d+)$/ ) {
294 'invoice_detail' => [],
295 'package_comment' => [],
296 'quotation_detail' => [],
298 foreach my $field ( $cgi->param ) {
299 foreach my $detailtype ( keys %$details ) {
300 if ($field =~ /^$detailtype(\d+)$/) {
301 $details->{$detailtype}->[$1] = $cgi->param($field);
305 foreach my $detailtype ( keys %$details ) {
306 @{ $details->{$detailtype} } = grep { length($_) } @{ $details->{$detailtype} };
308 my $copy_on_order = $cgi->param('copy_on_order');
310 die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
312 my $agent = $cust_main ? $cust_main->agent
313 : $prospect_main->agent;
316 if ( $cgi->param('lock_pkgpart') ) {
317 $part_pkg = qsearchs({
318 'table' => 'part_pkg',
319 'hashref' => { 'pkgpart' => scalar($cgi->param('lock_pkgpart')) },
320 'extra_sql' => ' AND '. FS::part_pkg->agent_pkgs_sql($agent),
322 or die "unknown pkgpart ". $cgi->param('lock_pkgpart');
325 my $pkgpart = $part_pkg ? $part_pkg->pkgpart : scalar($cgi->param('pkgpart'));
328 if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
332 my $format = $date_format. ' %T %z (%Z)'; #false laziness w/REAL_cust_pkg.cgi?
334 my $svcpart = scalar($cgi->param('svcpart'));