[freeside-devel] Package Selections for pre14
ivan
ivan at 420.am
Sun Jun 23 12:39:08 PDT 2002
On Sun, Jun 23, 2002 at 03:22:00PM -0400, Stephen Bechard wrote:
> I have modified the view/cust_main.cgi so that it reads in the REMOTE_USER
> and then builds the list of the available packages that this user can sell
> based on their agent_type and only single svc_acct packages. I also added
> a sort to the packages so they are alphabetically by the pkg name. :)
Agents do not correspond to otaker / REMOTE_USER. Most users use these
fields for separate things.
If you want this functionality, it should require a configuration option
to turn it on, not be the default.
(Also, use `getotaker', not $cgi->remote_user)
On Sun, Jun 23, 2002 at 03:22:00PM -0400, Stephen Bechard wrote:
> > Still investigating the agent and agent_type versus the .htaccess user.
>
> > > I was wondering if there are issues with the Add Customer
> > > piece of pre14 as the select list of First Packages that
> > > are available to use do not match any user agent or agent_type
> > > that I have configured on the system. I have tried tracking
> > > down exactly what it is looking and tried matching the packages
> > > accordingly, but still no luck. I current only have one Package
> > > available and there doesn't seem to be anything special about it.
> > >
> > > I tried logging in as a different agent and still only that
> > > one package is available. Is seems as the agent and agent_type
> > > tables do not effect this list of options.
> > >
> > > I am noticing similar problems with the Order Package
> > > selection list for existing customers, as it seems to only reads
> > > the first agent-type packages that are not disabled.
> > >
> > > I am also noticing this in the Signup Page.
> > >
> > > I did not notice this in previous builds of Freeside, but I am still
> > > in the testing/learning phases and didn't play around with multiple
> > > agents and agent_types before now.
>
> I found that the agent and agent_type were not check when adding new
> packages or ordering them for existing customers. I had the time so...
>
> I have modified the view/cust_main.cgi so that it reads in the REMOTE_USER
> and then builds the list of the available packages that this user can sell
> based on their agent_type and only single svc_acct packages. I also added
> a sort to the packages so they are alphabetically by the pkg name. :)
>
> Here is the diff:
> --- /tarballs/freeside-1.4.0pre14/httemplate/view/cust_main.cgi Mon Jun
> 10 15:44:45 2002
> +++ /aspdocs/view/cust_main.cgi Sun Jun 23 15:09:52 2002
> @@ -250,23 +250,41 @@
>
> print '</TD></TR></TABLE>';
>
> -print '<BR>'.
> - '<FORM ACTION="'.popurl(2).'edit/process/quick-cust_pkg.cgi"
> METHOD="POST">'.
> - qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">!.
> - '<SELECT NAME="pkgpart"><OPTION> ';
> +print "<BR>\n";
>
> -foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=>
> $agent->typenum }) ) {
> - my $pkgpart = $type_pkgs->pkgpart;
> -# my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } )
> -# or do { warn "unknown type_pkgs.pkgpart $pkgpart"; next; };
> - my $part_pkg =
> - qsearchs('part_pkg', { 'pkgpart' => $pkgpart, 'disabled' => '' } )
> - or next;
> - print qq!<OPTION VALUE="$pkgpart">!. $part_pkg->pkg. ' - '.
> - $part_pkg->comment;
> -}
> + # Lets get the REMOTE_USER and their agent_type
> + # to build the list of packages that they can order.
> + $cgi = new CGI;
> + $remote_user = $cgi->remote_user;
> + my $agents_hash = qsearchs( 'agent', { 'agent' => $remote_user } );
> + my $pkgpart;
> + my %typenum;
> + foreach my $agent ( $agents_hash ) {
> + next if $typenum{$agent->typenum}++;
> + #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{
> $agent->pkgpart_hashref }
> + foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; }
> #5.004_04 workaround
> + }
> + #eslaf
>
> -print '</SELECT><INPUT TYPE="submit" VALUE="Order Package"><BR>';
> + my @part_pkg = grep { $pkgpart->{ $_->pkgpart } }
> + qsearch( 'part_pkg', { 'disabled' => '' } );
> +
> + if ( @part_pkg ) {
> + print '<FORM ACTION="'.popurl(2).'edit/process/quick-cust_pkg.cgi"
> METHOD="POST">'. "\n".
> + qq!<INPUT TYPE="hidden" NAME="custnum" VALUE="$custnum">\n!;
> + print qq!<BR>\n<SELECT NAME="pkgpart">\n!;
> + print qq!<OPTION VALUE="">(none)\n!;
> +
> + # Resort the @part_pkg alphabetically by pkg name.
> + foreach my $part_pkg ( sort { $a->pkg cmp $b->pkg } @part_pkg ) {
> + print qq!<OPTION VALUE="!,
> + $part_pkg->pkgpart, '"';
> + print ">", $part_pkg->pkg, " - ", $part_pkg->comment. "\n";
> + }
> + print "</SELECT>\n";
> + print '<INPUT TYPE="submit" VALUE="Order Package"><BR>'. "\n";
> + print "</FORM>\n";
> + }
>
> print <<END;
> <SCRIPT>
>
>
> I have also done the same changes for the edit/cust_main.cgi file.
> Here is the diff:
>
>
> --- /tarballs/freeside-1.4.0pre14/httemplate/edit/cust_main.cgi Thu May
> 9 11:21:00 2002
> +++ /aspdocs/edit/cust_main.cgi Sun Jun 23 15:10:53 2002
> @@ -390,20 +390,17 @@
> # pry the wrong place for this logic. also pretty expensive
> #use FS::part_pkg;
>
> - #false laziness, copied from FS::cust_pkg::order
> + # Lets get the REMOTE_USER and their agent_type
> + # to build the list of packages that they can order.
> + $cgi = new CGI;
> + $remote_user = $cgi->remote_user;
> + my $agents_hash = qsearchs( 'agent', { 'agent' => $remote_user } );
> my $pkgpart;
> - if ( scalar(@agents) == 1 ) {
> - # $pkgpart->{PKGPART} is true iff $custnum may purchase PKGPART
> - my($agent)=qsearchs('agent',{'agentnum'=> $agentnum });
> - $pkgpart = $agent->pkgpart_hashref;
> - } else {
> - #can't know (agent not chosen), so, allow all
> - my %typenum;
> - foreach my $agent ( @agents ) {
> - next if $typenum{$agent->typenum}++;
> - #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{
> $agent->pkgpart_hashref }
> - foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; }
> #5.004_04 workaround
> - }
> + my %typenum;
> + foreach my $agent ( $agents_hash ) {
> + next if $typenum{$agent->typenum}++;
> + #fixed in 5.004_05 #$pkgpart->{$_}++ foreach keys %{
> $agent->pkgpart_hashref }
> + foreach ( keys %{ $agent->pkgpart_hashref } ) { $pkgpart->{$_}++; }
> #5.004_04 workaround
> }
> #eslaf
>
> @@ -419,7 +416,8 @@
>
> print qq!<OPTION VALUE="">(none)!;
>
> - foreach my $part_pkg ( @part_pkg ) {
> + # Resort the @part_pkg alphabetically by pkg name.
> + foreach my $part_pkg ( sort { $a->pkg cmp $b->pkg } @part_pkg ) {
> print qq!<OPTION VALUE="!,
> # $part_pkg->pkgpart. "_". $pkgpart{ $part_pkg->pkgpart },
> '"';
> $part_pkg->pkgpart. "_". $part_pkg->svcpart, '"';
>
> I haven't got to the Signup Page yet, but that one will come later.
>
> Enjoy,
> Steve
>
--
_ivan
More information about the freeside-devel
mailing list