+
+ function submit_form() {
+ $('#formBulkEdit').submit();
+ }
+</script>
+
+<form action="<% $fsurl %>edit/process/cust_pkg.cgi" method="POST" id="formBulkEdit">
+<input type="hidden" name="custnum" value="<% $custnum %>">
+<input type="hidden" name="action" value="bulk">
+
+<p style="margin-bottom: 2em;">
+ <label for="locationnum">Service Location</label>
+ <% include( '/elements/select-cust_location.html',
+ cust_main => $cust_main,
+ addnew => 0,
+ onchange => 'javascript:location_changed(this);',
+ ) %><br>
+ <span style="font-size: .8em; padding-left: 1em;">
+ Bulk-edit works with one customer location at a time
+ </span>
+</p>
+
+<table style="margin-bottom: 2em;">
+ <thead>
+ <tr style="background-color: #ccc;">
+ <th colspan="2" style="text-align: left;">
+ Pkg #
+ </th>
+ <th style="text-align: left;">
+ Current Packages<br>
+ <div style="font-size: .8em; padding-left: 1em; font-weight: normal;">
+ Selected packages are removed.<br>
+ Attached services are moved to the new package selected below
+ </span>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+% for my $cust_pkg ( @cust_pkg ) {
+% my $id = sprintf 'remove_cust_pkg[%s]', $cust_pkg->pkgnum;
+% my $is_displayed = $cust_main->ship_locationnum == $cust_pkg->locationnum ? 1 : 0;
+ <tr data-locationnum="<% $cust_pkg->locationnum %>" data-pkg="<% $cust_pkg->pkg |h %>" style="display: <% $is_displayed ? 'table-row' : 'none' %>;">
+ <td>
+ <input type="checkbox"
+ name="<% $id %>"
+ id="<% $id %>"
+ data-pkgnum="<% $cust_pkg->pkgnum %>"
+ data-locationnum="<% $cust_pkg->locationnum %>"
+ data-pkg="<% $part_pkg{ $cust_pkg->pkgpart }->pkg |h %>">
+ </td>
+ <td>#<% $cust_pkg->pkgnum %></td>
+ <td>
+ <label for="<% $id %>">
+ <% $part_pkg{ $cust_pkg->pkgpart }->pkg %><br>
+% for my $cust_pkg_supp ( @{ $cust_pkg_supp_of{ $cust_pkg->pkgnum }} ) {
+ <span style="font-size: .8em; padding-left: 1em;">
+ <b>Supplementary:</b> <% $part_pkg{ $cust_pkg_supp->pkgpart }->pkg %>
+ </span>
+ </label>
+% }
+ </td>
+ </tr>
+% }
+ </tbody>
+</table>
+
+<table style="margin-bottom: 2em;">
+ <thead>
+ <tr style="background-color: #ccc;">
+ <th colspan="3">
+ <% include('/elements/selectize/select-multiple-pkg_class.html',
+ id => 'filter_pkg_class',
+ onchange => 'pkg_class_filter_onchange',
+ ) %>
+ </th>
+ </tr>
+ <tr style="background-color: #ccc;">
+ <th>Qty</th>
+ <th>Class</th>
+ <th style="text-align: left;">Order New Packages</th>
+ </tr>
+ </thead>
+ <tbody>
+% for my $part_pkg ( @part_pkg_enabled ) {
+% my $id = sprintf 'qty_part_pkg[%s]', $part_pkg->pkgpart;
+ <tr data-classnum="<% $part_pkg->classnum %>">
+ <td>
+ <input type="text"
+ name="<% $id %>"
+ id="<% $id %>"
+ value="0"
+ size="2"
+ data-pkgpart="<% $part_pkg->pkgpart %>"
+ data-pkg="<% $part_pkg->pkg %>">
+ </td>
+ <td><% $part_pkg->classname || '(none)' %></td>
+ <td><% $part_pkg->pkg %></td>
+ </tr>
+% }
+ </tbody>
+</table>
+
+<input type="button" role="button" value="Order" onclick="confirm_form();">
+
+</form>
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
+
+my $custnum = $cgi->param('keywords') || $cgi->param('custnum');
+$custnum =~ /^\d+$/
+ or die "Invalid custnum($custnum)";
+
+my $cust_main = qsearchs( cust_main => { custnum => $custnum })
+ or die "Invalid custnum ($custnum)";
+
+my %part_pkg;
+my @part_pkg_enabled;
+
+for my $part_pkg ( qsearch( part_pkg => {} )) {
+ $part_pkg{ $part_pkg->pkgpart } = $part_pkg;
+ push @part_pkg_enabled, $part_pkg
+ unless $part_pkg->disabled;