X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fcust_pkg.cgi;h=ce1c866123080ecb71eb59162e284a740089ce9f;hb=b5fbaadb1cb2893660e460a1d4a3cabe02774de7;hp=73b1907869bb94c395c85e57dd498e398ca349cf;hpb=cf16b23820da69e3c8d0156ae27e21c635bf1ec5;p=freeside.git diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi index 73b190786..ce1c86612 100755 --- a/httemplate/edit/cust_pkg.cgi +++ b/httemplate/edit/cust_pkg.cgi @@ -1,27 +1,23 @@ + <% -# -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', { 'disabled' => '' })) { +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'); } +my($custnum, %remove_pkg); if ( $cgi->param('error') ) { $custnum = $cgi->param('custnum'); %remove_pkg = map { $_ => 1 } $cgi->param('remove_pkg'); @@ -29,10 +25,10 @@ if ( $cgi->param('error') ) { my($query) = $cgi->keywords; $query =~ /^(\d+)$/; $custnum = $1; - undef %remove_pkg; + %remove_pkg = (); } -$p1 = popurl(1); +my $p1 = popurl(1); print header("Add/Edit Packages", ''); print qq!Error: !, $cgi->param('error'), @@ -44,28 +40,29 @@ print qq!
!; print qq!!; #current packages -@cust_pkg = qsearch('cust_pkg',{ 'custnum' => $custnum, 'cancel' => '' } ); +my @cust_pkg = qsearch('cust_pkg',{ 'custnum' => $custnum, 'cancel' => '' } ); if (@cust_pkg) { print < + + Pkg # + Package description +

END - my ($count) = 0 ; - print qq!! ; - foreach (@cust_pkg) { - print '' if $count == 0; + foreach (sort { $all_pkg{$a->getfield('pkgpart')} cmp $all_pkg{$b->getfield('pkgpart')} } @cust_pkg) { my($pkgnum,$pkgpart)=( $_->getfield('pkgnum'), $_->getfield('pkgpart') ); - print qq!\n!; - $count ++ ; - if ($count == 2) - { - $count = 0 ; - print qq!\n! ; - } + my $checked = $remove_pkg{$pkgnum} ? ' CHECKED' : ''; + print < + + \n + + +END } print qq!
$pkgnum: $pkg{$pkgpart} - $comment{$pkgpart}
$pkgnum:$all_pkg{$pkgpart} - $all_comment{$pkgpart}


!; } @@ -74,28 +71,40 @@ print <
END -$cust_main = qsearchs('cust_main',{'custnum'=>$custnum}); -$agent = qsearchs('agent',{'agentnum'=> $cust_main->agentnum }); +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 }); -$count = 0; -$pkgparts = 0; -print qq!!; -foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { +my $count = 0; +my $pkgparts = 0; +print < + + + + +END +#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++; - my($pkgpart)=$type_pkgs->pkgpart; next unless exists $pkg{$pkgpart}; #skip disabled ones - print qq!! if ( $count == 0 ); + #print qq!! if ( $count == 0 ); my $value = $cgi->param("pkg$pkgpart") || 0; print < - - $pkgpart: $pkg{$pkgpart} - $comment{$pkgpart}\n + + + + + END $count ++ ; - if ( $count == 2 ) { - print qq!\n! ; - $count = 0; - } + #if ( $count == 2 ) { + # print qq!\n! ; + # $count = 0; + #} } print qq!
Qty.Package Description
$pkgpart:$pkg{$pkgpart} - $comment{$pkgpart}
!;