[freeside-commits] freeside/FS/FS inventory_class.pm,1.3,1.4
Ivan,,,
ivan at wavetail.420.am
Fri May 21 16:35:26 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv4351/FS/FS
Modified Files:
inventory_class.pm
Log Message:
reporting on agent inventory, RT#7010
Index: inventory_class.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/inventory_class.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- inventory_class.pm 21 May 2010 00:09:40 -0000 1.3
+++ inventory_class.pm 21 May 2010 23:35:24 -0000 1.4
@@ -115,7 +115,10 @@
=cut
sub num_avail {
- shift->num_sql('( svcnum IS NULL OR svcnum = 0 )');
+ my( $self, $sql ) = @_;
+ $sql .= ' AND ' if length($sql);
+ $sql .= '( svcnum IS NULL OR svcnum = 0 )';
+ $self->num_sql($sql);
}
sub num_sql {
@@ -142,7 +145,10 @@
=cut
sub num_used {
- shift->num_sql("svcnum IS NOT NULL AND svcnum > 0 ");
+ my( $self, $sql ) = @_;
+ $sql .= ' AND ' if length($sql);
+ $sql .= 'svcnum IS NOT NULL AND svcnum > 0 ';
+ $self->num_sql($sql);
}
=item num_total
@@ -153,7 +159,95 @@
=cut
sub num_total {
- shift->num_sql('');
+ my( $self, $sql ) = @_;
+ $self->num_sql($sql);
+}
+
+=back
+
+=head1 CLASS METHODS
+
+=over 4
+
+=item searchcell_factory
+
+=cut
+
+sub countcell_factory {
+ my($class, %opt) = @_;
+
+ my $p = $opt{p};
+
+ my $sql = $opt{'agentnum'} ? 'agentnum = '.$opt{'agentnum'} : '';
+
+ use Tie::IxHash;
+ 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' => ';used=1',
+ 'num_total' => '',
+ );
+
+ my %inv_action_link = (
+ 'num_avail' => [ 'upload batch',
+ $p.'misc/inventory_item-import.html?classnum=',
+ 'classnum'
+ ],
+ );
+
+ sub {
+ my $inventory_class = shift;
+
+ my $link =
+ $p. 'search/inventory_item.html?'.
+ 'classnum='. $inventory_class->classnum;
+ $link .= ';agentnum='.$opt{'agentnum'} if $opt{'agentnum'};
+
+ my %actioncol = ();
+ foreach ( keys %inv_action_link ) {
+ my($label, $baseurl, $method) =
+ @{ $inv_action_link{$_} };
+ my $url = $baseurl. $inventory_class->$method();
+ $actioncol{$_} =
+ '<FONT SIZE="-1">'.
+ '('.
+ '<A HREF="'.$url.'">'.
+ $label.
+ '</A>'.
+ ')'.
+ '</FONT>';
+ }
+
+ my %num = map {
+ $_ => $inventory_class->$_($sql);
+ } keys %labels;
+
+ [ map {
+ [
+ {
+ 'data' => '<B>'. $num{$_}. '</B>',
+ 'align' => 'right',
+ },
+ {
+ 'data' => $labels{$_},
+ 'align' => 'left',
+ 'link' => ( $num{$_}
+ ? $link.$link{$_}
+ : ''
+ ),
+ },
+ { 'data' => $actioncol{$_},
+ 'align' => 'left',
+ },
+ ]
+ } keys %labels
+ ];
+ };
}
=back
More information about the freeside-commits
mailing list