[freeside-commits] freeside/httemplate/browse pkg_class.html, NONE,
1.1 rate.cgi, 1.2, 1.3 generic.cgi, 1.1,
NONE inventory_class.html, NONE, 1.1 part_pkg.cgi, 1.30, 1.31
Ivan,,,
ivan at wavetail.420.am
Fri Apr 21 17:58:40 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/browse
In directory wavetail:/tmp/cvs-serv26322/httemplate/browse
Modified Files:
rate.cgi part_pkg.cgi
Added Files:
pkg_class.html inventory_class.html
Removed Files:
generic.cgi
Log Message:
start of package class web UI (add/edit package classes, package class selection in package def edit)
--- generic.cgi DELETED ---
--- NEW FILE: inventory_class.html ---
<%
tie my %labels, 'Tie::IxHash',
'num_avail' => 'Available', # <FONT SIZE="-1"><A HREF="eventually">(upload batch)</A></FONT>',
'num_used' => 'In use', #'Used', #'Allocated',
'num_total' => 'Total',
;
my %link = (
'num_avail' => ';avail=1',
'num_used' => ';avail=1',
'num_total' => '',
);
my %inv_action_link = (
'num_avail' => [ 'upload batch',
$p.'misc/inventory_item-import.html?classnum=',
'classnum'
],
);
my $link = [ "${p}edit/inventory_class.html?", 'classnum' ];
%><%= include( 'elements/browse.html',
'title' => 'Inventory Classes',
'name' => 'inventory classes',
'menubar' => [ 'Add a new inventory class' =>
$p.'edit/inventory_class.html',
],
'query' => { 'table' => 'inventory_class', },
'count_query' => 'SELECT COUNT(*) FROM inventory_class',
'header' => [ '#', 'Inventory class', 'Inventory' ],
'fields' => [ 'classnum',
'classname',
sub {
#my $inventory_class = shift;
my $i_c = shift;
my $link =
$p. 'search/inventory_item.html?'.
'classnum='. $i_c->classnum;
my %actioncol = ();
foreach ( keys %inv_action_link ) {
my($label, $baseurl, $method) =
@{ $inv_action_link{$_} };
my $url = $baseurl. $i_c->$method();
$actioncol{$_} =
'<FONT SIZE="-1">'.
'('.
'<A HREF="'.$url.'">'.
$label.
'</A>'.
')'.
'</FONT>';
}
my %num = map {
$_ => $i_c->$_();
} keys %labels;
[ map {
[
{
'data' => '<B>'. $num{$_}. '</B>',
'align' => 'right',
},
{
'data' => $labels{$_},
'align' => 'left',
'link' => ( $num{$_}
? $link.$link{$_}
: ''
),
},
{ 'data' => $actioncol{$_},
'align' => 'left',
},
]
} keys %labels
];
},
],
'links' => [ $link,
$link,
'',
],
)
%>
Index: part_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/browse/part_pkg.cgi,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- part_pkg.cgi 31 Jan 2006 04:26:54 -0000 1.30
+++ part_pkg.cgi 22 Apr 2006 00:58:38 -0000 1.31
@@ -1,169 +1,236 @@
-<!-- mason kludge -->
<%
-my %search;
-if ( $cgi->param('showdisabled') ) {
- %search = ();
-} else {
+my %search = ();
+my $search = '';
+unless ( $cgi->param('showdisabled') ) {
%search = ( 'disabled' => '' );
+ $search = "( disabled = '' OR disabled IS NULL )";
}
-my @part_pkg = qsearch('part_pkg', \%search );
-my $total = scalar(@part_pkg);
-
-my $sortby;
-my %num_active_cust_pkg = ();
-my( $suspended_sth, $canceled_sth ) = ( '', '' );
+my $select = '*';
+my $orderby = 'pkgpart';
if ( $cgi->param('active') ) {
- my $active_sth = dbh->prepare(
- 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'.
- ' AND ( cancel IS NULL OR cancel = 0 )'.
- ' AND ( susp IS NULL OR susp = 0 )'
- ) or die dbh->errstr;
- foreach my $part_pkg ( @part_pkg ) {
- $active_sth->execute($part_pkg->pkgpart) or die $active_sth->errstr;
- $num_active_cust_pkg{$part_pkg->pkgpart} =
- $active_sth->fetchrow_arrayref->[0];
- }
- $sortby = sub {
- $num_active_cust_pkg{$b->pkgpart} <=> $num_active_cust_pkg{$a->pkgpart};
- };
- $suspended_sth = dbh->prepare(
- 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'.
- ' AND ( cancel IS NULL OR cancel = 0 )'.
- ' AND susp IS NOT NULL AND susp != 0'
- ) or die dbh->errstr;
+ $orderby = 'num_active';
- $canceled_sth = dbh->prepare(
- 'SELECT COUNT(*) FROM cust_pkg WHERE pkgpart = ?'.
- ' AND cancel IS NOT NULL AND cancel != 0'
- ) or die dbh->errstr;
+ $select = "
+
+ *,
+
+ ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND ( susp IS NULL OR susp = 0 )
+ ) AS num_active,
+
+ ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND ( cancel IS NULL OR cancel = 0 )
+ AND susp IS NOT NULL AND susp != 0
+ ) AS num_suspended,
+
+ ( SELECT COUNT(*) FROM cust_pkg WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND cancel IS NOT NULL AND cancel != 0
+ ) AS num_cancelled
+
+ ";
-} else {
- $sortby = sub { $a->pkgpart <=> $b->pkgpart; };
}
my $conf = new FS::Conf;
my $taxclasses = $conf->exists('enable_taxclasses');
-%>
-<%= include("/elements/header.html","Package Definition Listing",menubar( 'Main Menu' => $p )) %>
-<% unless ( $cgi->param('active') ) { %>
- One or more service definitions are grouped together into a package
- definition and given pricing information. Customers purchase packages
- rather than purchase services directly.<BR><BR>
- <A HREF="<%= $p %>edit/part_pkg.cgi"><I>Add a new package definition</I></A>
- <BR><BR>
-<% } %>
+my $html_init;
+unless ( $cgi->param('active') ) {
+ $html_init = qq!
+ One or more service definitions are grouped together into a package
+ definition and given pricing information. Customers purchase packages
+ rather than purchase services directly.<BR><BR>
+ <A HREF="${p}edit/part_pkg.cgi"><I>Add a new package definition</I></A>
+ <BR><BR>
+ !;
+}
-<%= $total %> package definitions
-<% if ( $cgi->param('showdisabled') ) { $cgi->param('showdisabled', 0); %>
- ( <a href="<%= $cgi->self_url %>">hide disabled packages</a> )
-<% } else { $cgi->param('showdisabled', 1); %>
- ( <a href="<%= $cgi->self_url %>">show disabled packages</a> )
-<% } %>
+my $posttotal;
+if ( $cgi->param('showdisabled') ) {
+ $cgi->param('showdisabled', 0);
+ $posttotal = '( <a href="'. $cgi->self_url. '">hide disabled packages</a> )';
+} else {
+ $cgi->param('showdisabled', 1);
+ $posttotal = '( <a href="'. $cgi->self_url. '">show disabled packages</a> )';
+}
-<% my $colspan = $cgi->param('showdisabled') ? 2 : 3; %>
+# ------
-<%= &table() %>
- <TR>
- <TH COLSPAN=<%= $colspan %>>Package</TH>
- <TH>Comment</TH>
-<% if ( $cgi->param('active') ) { %>
- <TH><FONT SIZE=-1>Customer<BR>packages</FONT></TH>
-<% } %>
- <TH><FONT SIZE=-1>Freq.</FONT></TH>
-<% if ( $taxclasses ) { %>
- <TH><FONT SIZE=-1>Taxclass</FONT></TH>
-<% } %>
- <TH><FONT SIZE=-1>Plan</FONT></TH>
- <TH><FONT SIZE=-1>Data</FONT></TH>
- <TH>Service</TH>
- <TH><FONT SIZE=-1>Quan.</FONT></TH>
-<% if ( dbdef->table('pkg_svc')->column('primary_svc') ) { %>
- <TH><FONT SIZE=-1>Primary</FONT></TH>
-<% } %>
+my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
- </TR>
+my @header = ( '#', 'Package', 'Comment' );
+my @fields = ( 'pkgpart', 'pkg', 'comment' );
+my $align = 'rll';
+my @links = ( $link, $link, '' );
+my @style = ( '', '', '' );
-<%
-foreach my $part_pkg ( sort $sortby @part_pkg ) {
- my @pkg_svc = $part_pkg->pkg_svc;
- my($rowspan)=scalar(@pkg_svc);
- my $plandata;
- if ( $part_pkg->plan ) {
- $plandata = $part_pkg->plandata;
- $plandata =~ s/^(\w+)=/$1 /mg;
- $plandata =~ s/\n/<BR>/g;
- } else {
- $part_pkg->plan('(legacy)');
- $plandata = "Setup ". $part_pkg->setup.
- "<BR>Recur ". $part_pkg->recur;
- }
-%>
- <TR>
- <TD ROWSPAN=<%= $rowspan %>><A HREF="<%=$p%>edit/part_pkg.cgi?<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkgpart %></A></TD>
+unless ( $cgi->param('showdisabled') ) { #its been reversed already
+ push @header, 'Status';
+ push @fields, sub { shift->disabled
+ ? '<FONT COLOR="#FF0000">DISABLED</FONT>'
+ : '<FONT COLOR="#00CC00">Active</FONT>'
+ };
+ push @links, '';
+ $align .= 'c';
+ push @style, 'b';
+}
-<% unless ( $cgi->param('showdisabled') ) { %>
- <TD ROWSPAN=<%= $rowspan %>>
- <% if ( $part_pkg->disabled ) { %>
- DISABLED
- <% } %>
- </TD>
-<% } %>
+unless ( 0 ) { #already showing only one class or something?
+ push @header, 'Class';
+ push @fields, sub { shift->classname || '(none)'; };
+ $align .= 'l';
+}
- <TD ROWSPAN=<%= $rowspan %>><A HREF="<%=$p%>edit/part_pkg.cgi?<%= $part_pkg->pkgpart %>"><%= $part_pkg->pkg %></A></TD>
- <TD ROWSPAN=<%= $rowspan %>><%= $part_pkg->comment %></TD>
+if ( $cgi->param('active') ) {
+ push @header, 'Customer<BR>packages';
+ my %col = (
+ 'active' => '00CC00',
+ 'suspended' => 'FF9900',
+ 'cancelled' => 'FF0000',
+ );
+ my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart=';
+ push @fields, sub { my $part_pkg = shift;
+ [
+ map {
+ [
+ {
+ 'data' => '<B><FONT COLOR="#'. $col{$_}. '">'.
+ $part_pkg->get("num_$_").
+ '</FONT></B>',
+ 'align' => 'right',
+ },
+ {
+ 'data' => $_,
+ 'align' => 'left',
+ 'link' => ( $part_pkg->get("num_$_")
+ ? $cust_pkg_link.
+ $part_pkg->pkgpart.
+ ";magic=$_"
+ : ''
+ ),
+ },
+ ],
+ } (qw( active suspended cancelled ))
+ ]; };
+ $align .= 'r';
+}
-<% if ( $cgi->param('active') ) { %>
- <TD ROWSPAN=<%= $rowspan %>>
- <FONT COLOR="#00CC00"><B><%= $num_active_cust_pkg{$part_pkg->pkgpart} %></B></FONT> <A HREF="<%=$p%>search/cust_pkg.cgi?magic=active;pkgpart=<%= $part_pkg->pkgpart %>">active</A><BR>
+push @header, 'Frequency';
+push @fields, sub { shift->freq_pretty; };
+$align .= 'l';
- <% $suspended_sth->execute( $part_pkg->pkgpart )
- or die $suspended_sth->errstr;
- my $num_suspended = $suspended_sth->fetchrow_arrayref->[0];
- %>
- <FONT COLOR="#FF9900"><B><%= $num_suspended %></B></FONT> <A HREF="<%=$p%>search/cust_pkg.cgi?magic=suspended;pkgpart=<%= $part_pkg->pkgpart %>">suspended</A><BR>
+if ( $taxclasses ) {
+ push @header, 'Taxclass';
+ push @fields, sub { shift->taxclass() || ' '; };
+ $align .= 'l';
+}
- <% $canceled_sth->execute( $part_pkg->pkgpart )
- or die $canceled_sth->errstr;
- my $num_canceled = $canceled_sth->fetchrow_arrayref->[0];
- %>
- <FONT COLOR="#FF0000"><B><%= $num_canceled %></B></FONT> <A HREF="<%=$p%>search/cust_pkg.cgi?magic=canceled;pkgpart=<%= $part_pkg->pkgpart %>">canceled</A>
- </TD>
-<% } %>
+push @header, 'Plan',
+ 'Data',
+ 'Services';
+ #'Service', 'Quan', 'Primary';
- <TD ROWSPAN=<%= $rowspan %>><%= $part_pkg->freq_pretty %></TD>
+push @fields, sub { shift->plan || '(legacy)' },
-<% if ( $taxclasses ) { %>
- <TD ROWSPAN=<%= $rowspan %>><%= $part_pkg->taxclass || ' ' %></TD>
-<% } %>
+ sub {
+ my $part_pkg = shift;
+ if ( $part_pkg->plan ) {
- <TD ROWSPAN=<%= $rowspan %>><%= $part_pkg->plan %></TD>
- <TD ROWSPAN=<%= $rowspan %>><%= $plandata %></TD>
+ [ map {
+ /^(\w+)=(.*)$/; #or something;
+ [
+ { 'data' => $1,
+ 'align' => 'right',
+ },
+ { 'data' => $2,
+ 'align' => 'left',
+ },
+ ];
+ }
+ split(/\n/, $part_pkg->plandata)
+ ];
-<%
- my($n)="";
- foreach my $pkg_svc ( @pkg_svc ) {
- my($svcpart)=$pkg_svc->getfield('svcpart');
- my($part_svc) = qsearchs('part_svc',{'svcpart'=> $svcpart });
- print $n,qq!<TD><A HREF="${p}edit/part_svc.cgi?$svcpart">!,
- $part_svc->getfield('svc'),"</A></TD><TD>",
- $pkg_svc->getfield('quantity'),"</TD>";
- if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
- print '<TD>';
- print 'PRIMARY' if $pkg_svc->primary_svc =~ /^Y/i;
- print '</TD>';
- }
- print "</TR>\n";
- $n="<TR>";
- }
-%>
+ } else {
- </TR>
-<% } %>
+ [ map { [
+ { 'data' => uc($_),
+ 'align' => 'right',
+ },
+ {
+ 'data' => $part_pkg->$_(),
+ 'align' => 'left',
+ },
+ ];
+ }
+ (qw(setup recur))
+ ];
- </TABLE>
- </BODY>
-</HTML>
+ }
+
+ },
+
+ sub {
+ my $part_pkg = shift;
+
+ [ map {
+ my $pkg_svc = $_;
+ my $part_svc = $pkg_svc->part_svc;
+ my $svc = $part_svc->svc;
+ if ( $pkg_svc->primary_svc =~ /^Y/i ) {
+ $svc = "<B>$svc (PRIMARY)</B>";
+ }
+ $svc =~ s/ +/ /g;
+
+ [
+ {
+ 'data' => '<B>'. $pkg_svc->quantity. '</B>',
+ 'align' => 'right'
+ },
+ {
+ 'data' => $svc,
+ 'align' => 'left',
+ 'link' => $p. 'edit/part_svc.cgi?'.
+ $part_svc->svcpart,
+ },
+ ];
+ }
+ sort { $b->primary_svc =~ /^Y/i
+ <=> $a->primary_svc =~ /^Y/i
+ }
+ $part_pkg->pkg_svc
+
+ ];
+
+ };
+
+$align .= 'lrl'; #rr';
+
+# --------
+
+my $count_query = 'SELECT COUNT(*) FROM part_pkg';
+$count_query .= " WHERE $search"
+ if $search;
+
+%><%= include( 'elements/browse.html',
+ 'title' => 'Package Definitions',
+ 'menubar' => [ 'Main Menu' => $p ],
+ 'html_init' => $html_init,
+ 'html_posttotal' => $posttotal,
+ 'name' => 'package definitions',
+ 'query' => { 'select' => $select,
+ 'table' => 'part_pkg',
+ 'hashref' => \%search,
+ 'extra_sql' => "ORDER BY $orderby",
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'links' => \@links,
+ 'align' => $align,
+ 'style' => \@style,
+ )
+%>
--- NEW FILE: pkg_class.html ---
<%
my $html_init =
'Package classes define groups of packages, for reporting and '.
'convenience purposes.<BR><BR>'.
qq!<A HREF="${p}edit/pkg_class.html"><I>Add a package class</I></A><BR><BR>!;
my $count_query = 'SELECT COUNT(*) FROM pkg_class';
my $link = [ $p.'edit/pkg_class.html?', 'classnum' ];
%><%= include( 'elements/browse.html',
'title' => 'Package classes',
'menubar' => [ 'Main menu' => $p, ],
'html_init' => $html_init,
'name' => 'package classes',
'query' => { 'table' => 'pkg_class',
'hashref' => {},
'extra_sql' => 'ORDER BY classnum',
},
'count_query' => $count_query,
'header' => [ '#', 'Class', ],
'fields' => [ 'classnum', 'classname' ],
'links' => [ $link, $link ],
)
%>
Index: rate.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/browse/rate.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rate.cgi 31 Jan 2006 04:26:54 -0000 1.2
+++ rate.cgi 22 Apr 2006 00:58:38 -0000 1.3
@@ -1,34 +1,33 @@
-<!-- mason kludge -->
-<%= include("/elements/header.html","Rate plan listing", menubar( 'Main Menu' => "$p#sysadmin" )) %>
-Rate plans, regions and prefixes for VoIP and call billing.<BR><BR>
-<A HREF="<%=$p%>edit/rate.cgi"><I>Add a rate plan</I></A>
-| <A HREF="<%=$p%>edit/rate_region.cgi"><I>Add a region</I></A>
-<BR><BR>
-<SCRIPT>
-function rate_areyousure(href) {
- if (confirm("Are you sure you want to delete this rate plan?") == true)
- window.location.href = href;
-}
-</SCRIPT>
-
-<%= table() %>
- <TR>
- <TH COLSPAN=2>Rate plan</TH>
- </TR>
+<%
-<% foreach my $rate ( sort {
- $a->getfield('ratenum') <=> $b->getfield('ratenum')
- } qsearch('rate',{}) ) {
-%>
- <TR>
- <TD><A HREF="<%= $p %>edit/rate.cgi?<%= $rate->ratenum %>"><%= $rate->ratenum %></A></TD>
- <TD><A HREF="<%= $p %>edit/rate.cgi?<%= $rate->ratenum %>"><%= $rate->ratename %></A></TD>
- </TR>
+my $html_init =
+ 'Rate plans, regions and prefixes for VoIP and call billing.<BR><BR>'.
+ qq!<A HREF="${p}edit/rate.cgi"><I>Add a rate plan</I></A>!.
+ qq! | <A HREF="${p}edit/rate_region.cgi"><I>Add a region</I></A>!.
+ '<BR><BR>
+ <SCRIPT>
+ function rate_areyousure(href) {
+ if (confirm("Are you sure you want to delete this rate plan?") == true)
+ window.location.href = href;
+ }
+ </SCRIPT>';
-<% } %>
+my $count_query = 'SELECT COUNT(*) FROM rate';
-</TABLE>
-</BODY>
-</HTML>
+my $link = [ $p.'edit/rate.cgi?', 'ratenum' ];
-
+%><%= include( 'elements/browse.html',
+ 'title' => 'Rate plans',
+ 'menubar' => [ 'Main menu' => $p, ],
+ 'html_init' => $html_init,
+ 'name' => 'rate plans',
+ 'query' => { 'table' => 'rate',
+ 'hashref' => {},
+ 'extra_sql' => 'ORDER BY ratenum',
+ },
+ 'count_query' => $count_query,
+ 'header' => [ '#', 'Rate plan', ],
+ 'fields' => [ 'ratenum', 'ratename' ],
+ 'links' => [ $link, $link ],
+ )
+%>
More information about the freeside-commits
mailing list