X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pkg.cgi;h=4e4f4d2b2184bb57fea8321234ddffd7974a7f54;hb=4639e25a658d9a0bf295415642fae8e8cdad846a;hp=174d4dde171027b87bd5d93cc846d67a68a27575;hpb=2c757d7db4cb6a7b9655de13206fcc84fb7ce61f;p=freeside.git diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi index 174d4dde1..4e4f4d2b2 100755 --- a/httemplate/edit/cust_pkg.cgi +++ b/httemplate/edit/cust_pkg.cgi @@ -1,150 +1,250 @@ -<% - -my %pkg = (); -my %comment = (); -my %all_pkg = (); -my %all_comment = (); -#foreach (qsearch('part_pkg', { 'disabled' => '' })) { -# $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); -# $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); -#} -foreach (qsearch('part_pkg', {} )) { - $all_pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); - $all_comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); - next if $_->disabled; - $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); - $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); +<%doc> + + Bulk package Edit Page + + +<& /elements/header-cust_main.html, + view => 'packages', + cust_main => $cust_main, + include_selectize => 1, +&> +<% include('/elements/error.html') %> + + + +
+ + + +

+ + <% include( '/elements/select-cust_location.html', + cust_main => $cust_main, + addnew => 0, + onchange => 'javascript:location_changed(this);', + ) %>
+ + Bulk-edit works with one customer location at a time + +

+ + + + + + + + + +% 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; + + + + + +% } + +
+ Pkg # + + Current Packages
+
+ Selected packages are removed.
+ Attached services are moved to the new package selected below + +
+ + #<% $cust_pkg->pkgnum %> + +% } +
+ + + + + + + + + + + + + +% for my $part_pkg ( @part_pkg_enabled ) { +% my $id = sprintf 'qty_part_pkg[%s]', $part_pkg->pkgpart; + + + + + +% } + +
+ <% include('/elements/selectize/select-multiple-pkg_class.html', + id => 'filter_pkg_class', + onchange => 'pkg_class_filter_onchange', + ) %> +
QtyClassOrder New Packages
+ + <% $part_pkg->classname || '(none)' %><% $part_pkg->pkg %>
+ + + +
+ +<% 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; } - -my($custnum, %remove_pkg); -if ( $cgi->param('error') ) { - $custnum = $cgi->param('custnum'); - %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); -} else { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $custnum = $1; - %remove_pkg = (); -} - -my $p1 = popurl(1); - -%><%= include('/elements/header.html', "Add/Edit Packages", '') %> - -<% if ( $cgi->param('error') ) { %> - Error: <%= $cgi->param('error') %> -<% } %> - -
- - - -<% -#current packages -my @cust_pkg = qsearch('cust_pkg', { 'custnum' => $custnum, 'cancel' => '' } ); - -if (@cust_pkg) { -%> - - Current packages - select to remove (services are moved to a new package below) - - - - - -

- - <% - - foreach ( sort { $all_pkg{ $a->getfield('pkgpart') } - cmp $all_pkg{ $b->getfield('pkgpart') } - } - @cust_pkg - ) - { - my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') ); - my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : ''; - - %> - - - - - - - - <% } %> - -
Pkg #Package description
><%= $pkgnum %>:<%= $all_pkg{$pkgpart} %> - <%= $all_comment{$pkgpart} %>
-

- -<% } %> - -Order new packages -

- -<% -my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); -my $agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum }); - -my %agent_pkgs = map { ( $_->pkgpart , $all_pkg{$_->pkgpart} ) } - qsearch('type_pkgs',{'typenum'=> $agent->typenum }); - -my $count = 0; -my $pkgparts = 0; -%> - - - - - - - -<% -#foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { -foreach my $pkgpart ( sort { $agent_pkgs{$a} cmp $agent_pkgs{$b} } - keys(%agent_pkgs) ) { - $pkgparts++; - next unless exists $pkg{$pkgpart}; #skip disabled ones - #print qq!! if ( $count == 0 ); - my $value = $cgi->param("pkg$pkgpart") || 0; -%> - - - - - - - -<% - $count ++ ; - #if ( $count == 2 ) { - # print qq!\n! ; - # $count = 0; - #} +@part_pkg_enabled = + sort { $a->classname cmp $b->classname || $a->pkg cmp $b->pkg } + @part_pkg_enabled; + +my @cust_pkg; +my %cust_pkg_supp_of; +for my $cust_pkg ( + qsearch( + cust_pkg => { + custnum => $custnum, + cancel => '', + } + ) +) { + if ( my $main_pkgnum = $cust_pkg->main_pkgnum ) { + $cust_pkg_supp_of{ $main_pkgnum } //= []; + push @{ $cust_pkg_supp_of{ $main_pkgnum } }, $cust_pkg; + } else { + $cust_pkg_supp_of{ $cust_pkg->pkgnum } //= []; + push @cust_pkg, $cust_pkg; + } } -%> - -
Qty.Package Description
- " VALUE="<%= $value %>" SIZE="2" MAXLENGTH="2"> - <%= $pkgpart %>:<%= $pkg{$pkgpart} %> - <%= $comment{$pkgpart}%>
- -<% unless ( $pkgparts ) { - my $p2 = popurl(2); - my $typenum = $agent->typenum; - my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } ); - my $atype = $agent_type->atype; -%> - - (No package definitions, - or agent type - <%= $atype %> - is not allowed to purchase any packages.) - -<% } %> - -

- -

- -<%= include('/elements/footer.html') %> +