[freeside-commits] freeside/FS/FS inventory_class.pm, 1.2, 1.3 svc_Common.pm, 1.57, 1.58
Ivan,,,
ivan at wavetail.420.am
Thu May 20 17:09:42 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv30273/FS/FS
Modified Files:
inventory_class.pm svc_Common.pm
Log Message:
agent virt inventory, RT#7010
Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -w -d -r1.57 -r1.58
--- svc_Common.pm 1 Mar 2010 21:56:55 -0000 1.57
+++ svc_Common.pm 21 May 2010 00:09:40 -0000 1.58
@@ -735,10 +735,17 @@
$hash{'item'} = $self->getfield($field);
}
+ my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null' => 1,
+ 'table' => 'inventory_item',
+ );
+
my $inventory_item = qsearchs({
'table' => 'inventory_item',
'hashref' => \%hash,
- 'extra_sql' => 'LIMIT 1 FOR UPDATE',
+ 'extra_sql' => "AND $agentnums_sql",
+ 'order_by' => 'ORDER BY ( agentnum IS NULL ) '. #agent inventory first
+ ' LIMIT 1 FOR UPDATE',
});
unless ( $inventory_item ) {
Index: inventory_class.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/inventory_class.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- inventory_class.pm 29 Jun 2006 13:47:44 -0000 1.2
+++ inventory_class.pm 21 May 2010 00:09:40 -0000 1.3
@@ -121,10 +121,16 @@
sub num_sql {
my( $self, $sql ) = @_;
$sql = "AND $sql" if length($sql);
- my $statement =
- "SELECT COUNT(*) FROM inventory_item WHERE classnum = ? $sql";
- my $sth = dbh->prepare($statement) or die dbh->errstr. " preparing $statement";
- $sth->execute($self->classnum) or die $sth->errstr. " executing $statement";
+
+ my $agentnums_sql = $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null' => 1,
+ 'table' => 'inventory_item',
+ );
+
+ my $st = "SELECT COUNT(*) FROM inventory_item ".
+ " WHERE classnum = ? AND $agentnums_sql $sql";
+ my $sth = dbh->prepare($st) or die dbh->errstr. " preparing $st";
+ $sth->execute($self->classnum) or die $sth->errstr. " executing $st";
$sth->fetchrow_arrayref->[0];
}
More information about the freeside-commits
mailing list