X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pkg.cgi;h=4e4f4d2b2184bb57fea8321234ddffd7974a7f54;hb=2009d9cee8038aeff5b4313113fc23f546455cf5;hp=637023703a326ef7bc7948240b92fbab1ed1255c;hpb=51984ac3d3da3006809c6866fdecd4ad83610731;p=freeside.git diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi index 637023703..4e4f4d2b2 100755 --- a/httemplate/edit/cust_pkg.cgi +++ b/httemplate/edit/cust_pkg.cgi @@ -1,171 +1,250 @@ -<% -# -# $Id: cust_pkg.cgi,v 1.1 2001-07-30 07:36:04 ivan Exp $ -# -# this is for changing packages around, not editing things within the package -# -# Usage: cust_pkg.cgi custnum -# http://server.name/path/cust_pkg.cgi?custnum -# -# started with /sales/add/cust_pkg.cgi, which added packages -# ivan@voicenet.com 97-jan-5, 97-mar-21 -# -# Rewrote for new API -# ivan@voicenet.com 97-jul-7 -# -# FS::Search is no more, &cgisuidsetup needs $cgi, ivan@sisd.com 98-mar-7 -# -# Changes to allow page to work at a relative position in server -# Changed to display packages 2-wide in a table -# bmccane@maxbaud.net 98-apr-3 -# -# fixed a pretty cool bug from above which caused a visual glitch ivan@sisd.com -# 98-jun-1 -# -# $Log: cust_pkg.cgi,v $ -# Revision 1.1 2001-07-30 07:36:04 ivan -# templates!!! -# -# Revision 1.8 1999/07/21 07:34:13 ivan -# links to package browse and agent type edit if there aren't any packages to -# order. thanks to "Tech Account" -# -# Revision 1.7 1999/04/14 01:03:01 ivan -# oops, in 1.2 tree, can't do searches until [cgi|admin]suidsetup, -# bug is hidden by mod_perl persistance -# -# Revision 1.6 1999/02/28 00:03:36 ivan -# removed misleading comments -# -# Revision 1.5 1999/02/07 09:59:18 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.4 1999/01/19 05:13:38 ivan -# for mod_perl: no more top-level my() variables; use vars instead -# also the last s/create/new/; -# -# Revision 1.3 1999/01/18 09:41:28 ivan -# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl -# (good idea anyway) -# -# Revision 1.2 1998/12/17 06:17:04 ivan -# fix double // in relative URLs, s/CGI::Base/CGI/; -# - -use strict; -use vars qw( $cgi %pkg %comment $custnum $p1 @cust_pkg - $cust_main $agent $type_pkgs $count %remove_pkg $pkgparts ); -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use FS::UID qw(cgisuidsetup); -use FS::Record qw(qsearch qsearchs); -use FS::CGI qw(header popurl); -use FS::part_pkg; -use FS::type_pkgs; - -$cgi = new CGI; -&cgisuidsetup($cgi); - -%pkg = (); -%comment = (); -foreach (qsearch('part_pkg', {})) { - $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; } -print qq!!; - -unless ( $pkgparts ) { - my $p2 = popurl(2); - my $typenum = $agent->typenum; - my $agent_type = qsearchs( 'agent_type', { 'typenum' => $typenum } ); - my $atype = $agent_type->atype; - print <package definitions, or agent type -$atype not allowed to purchase -any packages.) -END +@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; + } } - -#submit -print < - - - -END -%> +