koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4 Bookfund.pm


From: Antoine Farnault
Subject: [Koha-cvs] koha/C4 Bookfund.pm
Date: Mon, 31 Jul 2006 14:36:41 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Antoine Farnault <toins>        06/07/31 14:36:41

Modified files:
        C4             : Bookfund.pm 

Log message:
        3 New functions : NewBookFund, DelBookFund & SearchBookFund.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Bookfund.pm?cvsroot=koha&r1=1.1&r2=1.2

Patches:
Index: Bookfund.pm
===================================================================
RCS file: /sources/koha/koha/C4/Bookfund.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Bookfund.pm 27 Jul 2006 13:39:00 -0000      1.1
+++ Bookfund.pm 31 Jul 2006 14:36:40 -0000      1.2
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Bookfund.pm,v 1.1 2006/07/27 13:39:00 toins Exp $
+# $Id: Bookfund.pm,v 1.2 2006/07/31 14:36:40 toins Exp $
 
 
 use strict;
@@ -26,7 +26,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.1 $' =~ /\d+/g; shift(@v) . "." . join( 
"_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.2 $' =~ /\d+/g; shift(@v) . "." . join( 
"_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -46,9 +46,11 @@
 @ISA    = qw(Exporter);
 @EXPORT = qw(
     &GetBookFund &GetBookFunds &GetBookFundBreakdown &GetCurrencies
+    &NewBookFund
     &ModBookFund &ModCurrencies
     &Countbookfund
     &ConvertCurrency
+    &DelBookFund
 );
 
 =head1 FUNCTIONS
@@ -280,6 +282,33 @@
     return ( $spent, $comtd );
 }
 
+=head3 NewBookFund
+
+=over 4
+
+&NewBookFund(bookfundid, bookfundname, branchcode);
+
+this function create a new bookfund into the database.
+
+=back
+
+=cut 
+
+sub NewBookFund{
+    my ($bookfundid, $bookfundname, $branchcode) = @_;
+    $branchcode = undef unless $branchcode;
+    my $dbh = C4::Context->dbh;
+    my $query = "
+        INSERT
+        INTO aqbookfund
+            (bookfundid, bookfundname, branchcode)
+        VALUES
+            (?, ?, ?)
+    ";
+    my $sth=$dbh->prepare($query);
+    $sth->execute($bookfundid,$bookfundname,$branchcode);
+}
+
 #-------------------------------------------------------------#
 
 =head3 ModBookFund
@@ -319,6 +348,64 @@
 
 #-------------------------------------------------------------#
 
+=head3 SearchBookFund
+
+=over 4
address@hidden = SearchBookFund(
+        $bookfundid,$filter,$filter_bookfundid,
+        $filter_bookfundname,$filter_branchcode);
+
+this function searchs among the bookfunds corresponding to our filtering rules.
+
+=back
+
+=cut
+
+sub SearchBookFund {
+    my $dbh = C4::Context->dbh;
+    my ($filter,
+        $filter_bookfundid,
+        $filter_bookfundname,
+        $filter_branchcode
+       ) = @_;
+
+    my @bindings;
+
+    my $query = "
+        SELECT  bookfundid,
+                bookfundname,
+                bookfundgroup,
+                branchcode
+        FROM aqbookfund
+        WHERE 1 = 1";
+
+    if ($filter) {
+        if ($filter_bookfundid) {
+            $query.= "AND bookfundid = ?";
+            push @bindings, $filter_bookfundid;
+        }
+        if ($filter_bookfundname) {
+            $query.= "AND bookfundname like ?";
+            push @bindings, '%'.$filter_bookfundname.'%';
+        }
+        if ($filter_branchcode) {
+            $query.= "AND branchcode = ?";
+            push @bindings, $filter_branchcode;
+        }
+    }
+    $query.= "ORDER BY bookfundid";
+
+    my $sth = $dbh->prepare($query);
+    $sth->execute(@bindings);
+    my @results;
+    while (my $row = $sth->fetchrow_hashref) {
+        push @results, $row;
+    }
+    return @results;
+}
+
+#-------------------------------------------------------------#
+
 =head3 ModCurrencies
 
 =over 4
@@ -408,6 +495,36 @@
     return ( $price / $cur );
 }
 
+#-------------------------------------------------------------#
+
+=head3 DelBookFund
+
+=over 4
+
+&DelBookFund($bookfundid);
+this function delete a bookfund which has $bokfundid as parameter on 
aqbookfund table and delete the approriate budget.
+
+=back
+
+=cut
+
+sub DelBookFund {
+    my $bookfundid = shift;
+    my $dbh = C4::Context->dbh;
+    my $query = "
+        DELETE FROM aqbookfund
+        WHERE bookfundid=?
+    ";
+    my $sth=$dbh->prepare($query);
+    $sth->execute($bookfundid);
+    $sth->finish;
+    $query = "
+        DELETE FROM aqbudget where bookfundid=?
+    ";
+    $sth=$dbh->prepare($query);
+    $sth->execute($bookfundid);
+    $sth->finish;
+}
 
 END { }    # module clean-up code here (global destructor)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]