[Koha-cvs] koha admin/aqbookfund.pl admin/aqbudget.pl C4/B... [rel_3_0]

Henri-Damien LAURENT laurenthdl at alinto.com
Tue Oct 17 18:18:15 CEST 2006


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Henri-Damien LAURENT <hdl>	06/10/17 16:18:14

Modified files:
	admin          : aqbookfund.pl aqbudget.pl 
	C4             : Bookfund.pm 
	koha-tmpl/intranet-tmpl/prog/en/admin: aqbookfund.tmpl 
	updater        : updatedatabase 

Log message:
	Changing primary key in aqbookfund.
	Making it branchcode+aqbookfundid rather than simple aqbookfundid.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/admin/aqbookfund.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.29&r2=1.29.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/admin/aqbudget.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.22&r2=1.22.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Bookfund.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3&r2=1.3.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/admin/aqbookfund.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.2&r2=1.2.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/updater/updatedatabase?cvsroot=koha&only_with_tag=rel_3_0&r1=1.157.2.9&r2=1.157.2.10

Patches:
Index: admin/aqbookfund.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/aqbookfund.pl,v
retrieving revision 1.29
retrieving revision 1.29.2.1
diff -u -b -r1.29 -r1.29.2.1
--- admin/aqbookfund.pl	31 Jul 2006 15:56:06 -0000	1.29
+++ admin/aqbookfund.pl	17 Oct 2006 16:18:14 -0000	1.29.2.1
@@ -67,6 +67,7 @@
 my $input = new CGI;
 my $script_name="/cgi-bin/koha/admin/aqbookfund.pl";
 my $bookfundid=$input->param('bookfundid');
+my $branchcodeid=$input->param('branchcode')|'';
 my $pagesize = 10;
 my $op = $input->param('op') || '';
 
@@ -102,7 +103,7 @@
 	my $dataaqbookfund;
 	my $header;
 	if ($bookfundid) {
-    	$dataaqbookfund = GetBookFund($bookfundid);
+    	$dataaqbookfund = GetBookFund($bookfundid,$branchcodeid);
 	}
 	if ($bookfundid) {
 	    $header = "Modify book fund";
@@ -146,21 +147,21 @@
 elsif ($op eq 'add_validate') {
 	my $bookfundid = uc $input->param('bookfundid');
 
-    my $number = Countbookfund($bookfundid);
+    my $number = Countbookfund($bookfundid,$branchcodeid);
 
     my $bookfund_already_exists = $number > 0 ? 1 : 0;
 
     if ($bookfund_already_exists) {
         my $bookfundname = $input->param('bookfundname');
         my $branchcode = $input->param('branchcode') || undef;
-
-        ModBookFund($bookfundname,$branchcode,$bookfundid);
+         warn "name :$bookfundname branch:$branchcode";
+        ModBookFund($bookfundname,$bookfundid,$branchcode);
     }
     else {
         NewBookFund(
             $bookfundid,
             $input->param('bookfundname'),
-            $input->param('branchcode')
+            $input->param('branchcode')||''
         );
     }
     $input->redirect('aqbookfund.pl');
@@ -170,16 +171,17 @@
 # called by default form, used to confirm deletion of data in DB
 
 elsif ($op eq 'delete_confirm') {
-    my $data = GetBookFund($bookfundid);
+    my $data = GetBookFund($bookfundid,$branchcodeid);
 	$template->param(bookfundid => $bookfundid);
 	$template->param(bookfundname => $data->{'bookfundname'});
+	$template->param(branchcode => $data->{'branchcode'});
 } # END $OP eq DELETE_CONFIRM
 
 
 ################## DELETE_CONFIRMED ##################################
 # called by delete_confirm, used to effectively confirm deletion of data in DB
 elsif ($op eq 'delete_confirmed') {
-    DelBookFund(uc($input->param('bookfundid')));
+    DelBookFund(uc($input->param('bookfundid')),$branchcodeid);
 
 }# END $OP eq DELETE_CONFIRMED
 

Index: admin/aqbudget.pl
===================================================================
RCS file: /cvsroot/koha/koha/admin/aqbudget.pl,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -u -b -r1.22 -r1.22.2.1
--- admin/aqbudget.pl	21 Jul 2006 10:17:13 -0000	1.22
+++ admin/aqbudget.pl	17 Oct 2006 16:18:14 -0000	1.22.2.1
@@ -55,6 +55,7 @@
 my $script_name="/cgi-bin/koha/admin/aqbudget.pl";
 my $bookfundid=$input->param('bookfundid');
 my $aqbudgetid=$input->param('aqbudgetid');
+my $branchcodeid=$input->param('branchcode');
 my $pagesize = 20;
 my $op = $input->param('op');
 
@@ -98,7 +99,8 @@
        budgetamount,
        aqbudget.branchcode
   FROM aqbudget
-    INNER JOIN aqbookfund ON aqbudget.bookfundid = aqbookfund.bookfundid
+    INNER JOIN aqbookfund ON (aqbudget.bookfundid = aqbookfund.bookfundid AND
+      aqbudget.branchcode = aqbookfund.branchcode)
   WHERE aqbudgetid = ?
 ';
         $sth=$dbh->prepare($query);
@@ -113,11 +115,12 @@
        aqbookfund.bookfundname
   FROM aqbookfund
     LEFT JOIN branches ON aqbookfund.branchcode = branches.branchcode
-  WHERE bookfundid = ?
+  WHERE bookfundid = ? AND aqbookfund.branchcode=?
 ';
     $sth=$dbh->prepare($query);
     $sth->execute(
         defined $aqbudgetid ? $dataaqbudget->{bookfundid} : $bookfundid,
+        $branchcodeid
     );
     $dataaqbookfund=$sth->fetchrow_hashref;
     $sth->finish;
@@ -125,12 +128,14 @@
     if (defined $aqbudgetid) {
         $template->param(
             bookfundid => $dataaqbudget->{'bookfundid'},
+            branchcode => $dataaqbudget->{'branchcode'},
             bookfundname => $dataaqbudget->{'bookfundname'}
         );
     }
     else {
         $template->param(
             bookfundid => $bookfundid,
+            branchcode => $dataaqbookfund->{'branchcode'},
             bookfundname => $dataaqbookfund->{bookfundname},
         );
     }
@@ -199,7 +204,7 @@
             format_date_in_iso($input->param('startdate')),
             format_date_in_iso($input->param('enddate')),
             $input->param('budgetamount'),
-            $input->param('branch') || undef,
+            $input->param('branch') || '',
             $aqbudgetid,
         );
         $sth->finish;
@@ -218,7 +223,7 @@
             format_date_in_iso($input->param('startdate')),
             format_date_in_iso($input->param('enddate')),
             $input->param('budgetamount'),
-            $input->param('branch') || undef,
+            $input->param('branch') || '',
         );
         $sth->finish;
     }

Index: C4/Bookfund.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Bookfund.pm,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -b -r1.3 -r1.3.2.1
--- C4/Bookfund.pm	31 Jul 2006 15:58:26 -0000	1.3
+++ C4/Bookfund.pm	17 Oct 2006 16:18:14 -0000	1.3.2.1
@@ -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.3 2006/07/31 15:58:26 toins Exp $
+# $Id: Bookfund.pm,v 1.3.2.1 2006/10/17 16:18:14 hdl Exp $
 
 use strict;
 
@@ -25,7 +25,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.3 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.3.2.1 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -78,7 +78,9 @@
 =cut
 
 sub GetBookFund {
-    my $bookfundid = @_;
+    my $bookfundid = shift;
+    my $branchcode = shift;
+    $branchcode=($branchcode?$branchcode:'');
     my $dbh = C4::Context->dbh;
     my $query = "
         SELECT
@@ -88,9 +90,11 @@
             branchcode
         FROM aqbookfund
         WHERE bookfundid = ?
-    ";
+        AND branchcode = ?";
     my $sth=$dbh->prepare($query);
-    return $sth->fetchrow_hashref;
+    $sth->execute($bookfundid,$branchcode);
+    my $data=$sth->fetchrow_hashref;
+    return $data;
 }
 
 
@@ -115,7 +119,7 @@
     my @bookfundids_loop;
     my $dbh= C4::Context->dbh;
     my $query = "
-        SELECT bookfundid
+        SELECT bookfundid,branchcode
         FROM aqbookfund
     ";
     my $sth = $dbh->prepare($query);
@@ -154,7 +158,7 @@
         WHERE  aqbookfund.bookfundid=aqbudget.bookfundid
             AND startdate<now()
             AND enddate>now()
-            AND (aqbookfund.branchcode IS NULL OR aqbookfund.branchcode='' OR aqbookfund.branchcode= ? )
+            AND (aqbookfund.branchcode='' OR aqbookfund.branchcode= ? )
       GROUP BY aqbookfund.bookfundid ORDER BY bookfundname";
     }
     else {
@@ -336,7 +340,7 @@
             (?, ?, ?)
     ";
     my $sth=$dbh->prepare($query);
-    $sth->execute($bookfundid,$bookfundname,$branchcode);
+    $sth->execute($bookfundid,$bookfundname,"$branchcode");
 }
 
 #-------------------------------------------------------------#
@@ -354,16 +358,17 @@
 =cut
 
 sub ModBookFund {
-    my ($bookfundname,$branchcode,$bookfundid) = @_;
+    my ($bookfundname,$bookfundid,$branchcode) = @_;
     my $dbh = C4::Context->dbh;
     my $query = "
         UPDATE aqbookfund
-        SET    bookfundname = ?,
-               branchcode = ?
+        SET    bookfundname = ?
         WHERE  bookfundid = ?
+        AND branchcode= ?
     ";
+    warn "name : $bookfundname";
     my $sth=$dbh->prepare($query);
-    $sth->execute($bookfundname,$branchcode,$bookfundid);
+    $sth->execute($bookfundname,$bookfundid,"$branchcode");
 # budgets depending on a bookfund must have the same branchcode
 # if the bookfund branchcode is set
     if (defined $branchcode) {
@@ -407,7 +412,7 @@
                 bookfundgroup,
                 branchcode
         FROM aqbookfund
-        WHERE 1 = 1 ";
+        WHERE 1 ";
 
     if ($filter) {
         if ($filter_bookfundid) {
@@ -478,14 +483,16 @@
 
 sub Countbookfund {
     my $bookfundid = shift;
+    my $branchcode = shift;
     my $dbh = C4::Context->dbh;
     my $query ="
         SELECT COUNT(*)
         FROM   aqbookfund
         WHERE bookfundid = ?
+        AND   branchcode = ?
     ";
     my $sth = $dbh->prepare($query);
-    $sth->execute($bookfundid);
+    $sth->execute($bookfundid,$branchcode);
     return $sth->fetchrow;
 }
 
@@ -540,19 +547,21 @@
 
 sub DelBookFund {
     my $bookfundid = shift;
+    my $branchcode=shift;
     my $dbh = C4::Context->dbh;
     my $query = "
         DELETE FROM aqbookfund
         WHERE bookfundid=?
+        AND branchcode=?
     ";
     my $sth=$dbh->prepare($query);
-    $sth->execute($bookfundid);
+    $sth->execute($bookfundid,$branchcode);
     $sth->finish;
     $query = "
-        DELETE FROM aqbudget where bookfundid=?
+        DELETE FROM aqbudget where bookfundid=? and branchcode=?
     ";
     $sth=$dbh->prepare($query);
-    $sth->execute($bookfundid);
+    $sth->execute($bookfundid,$branchcode);
     $sth->finish;
 }
 

Index: koha-tmpl/intranet-tmpl/prog/en/admin/aqbookfund.tmpl
===================================================================
RCS file: /cvsroot/koha/koha/koha-tmpl/intranet-tmpl/prog/en/admin/aqbookfund.tmpl,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -b -r1.2 -r1.2.2.1
--- koha-tmpl/intranet-tmpl/prog/en/admin/aqbookfund.tmpl	13 Apr 2006 08:36:42 -0000	1.2
+++ koha-tmpl/intranet-tmpl/prog/en/admin/aqbookfund.tmpl	17 Oct 2006 16:18:14 -0000	1.2.2.1
@@ -71,9 +71,9 @@
       <!-- /TMPL_IF -->
     </td>
     <td>
-      <a href="<!-- TMPL_VAR name="scriptname" -->?op=add_form&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->">Edit</a>
-      <a href="<!-- TMPL_VAR name="scriptname" -->?op=delete_confirm&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->">Delete</a>
-      <a href="aqbudget.pl?op=add_form&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->">Add budget</a>
+      <a href="<!-- TMPL_VAR name="scriptname" -->?op=add_form&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->&amp;branchcode=<!-- TMPL_VAR name="branchcode" -->">Edit</a>
+      <a href="<!-- TMPL_VAR name="scriptname" -->?op=delete_confirm&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->&amp;branchcode=<!-- TMPL_VAR name="branchcode" -->">Delete</a>
+      <a href="aqbudget.pl?op=add_form&amp;bookfundid=<!-- TMPL_VAR name="bookfundid" -->&amp;branchcode=<!-- TMPL_VAR name="branchcode" -->">Add budget</a>
       <!-- TMPL_IF NAME="has_budgets" -->
       <a href="aqbudget.pl?filter_bookfundid=<!-- TMPL_VAR name="bookfundid" -->">Show budgets</a>
       <!-- /TMPL_IF -->
@@ -225,6 +225,10 @@
     <td><!-- TMPL_VAR name="bookfundid" --></td>
   </tr>
   <tr>
+    <th>Branch</th>
+    <td><!-- TMPL_VAR name="branchcode" --></td>
+  </tr>
+  <tr>
     <th>Name</th>
     <td><!-- TMPL_VAR name="bookfundname" --></td>
   </tr>
@@ -237,6 +241,7 @@
 <form action="<!-- TMPL_VAR name="action" -->" method="post">
   <input type="hidden" name="op" value="delete_confirmed" />
   <input type="hidden" name="bookfundid" value="<!-- TMPL_VAR name="bookfundid" -->" />
+  <input type="hidden" name="branchcode" value="<!-- TMPL_VAR name="branchcode" -->" />
 
   <div id="action">
     <input type="submit" value="Delete this Fund" />

Index: updater/updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.157.2.9
retrieving revision 1.157.2.10
diff -u -b -r1.157.2.9 -r1.157.2.10
--- updater/updatedatabase	16 Oct 2006 14:23:47 -0000	1.157.2.9
+++ updater/updatedatabase	17 Oct 2006 16:18:14 -0000	1.157.2.10
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: updatedatabase,v 1.157.2.9 2006/10/16 14:23:47 toins Exp $
+# $Id: updatedatabase,v 1.157.2.10 2006/10/17 16:18:14 hdl Exp $
 
 # Database Updater
 # This script checks for required updates to the database.
@@ -216,7 +216,7 @@
 	aqbookfund => { 'branchcode' => 'varchar(4) NULL'},
 	aqbudget => { 'branchcode' => 'varchar(4) NULL'},
 	auth_header => { 'marc' => 'BLOB NOT NULL', 'linkid' => 'BIGINT(20) NULL'},
-	auth_subfield_structure =>{ 'hidden' => 'TINYINT(3) NOT NULL default 0', 'kohafield' => 'VARCHAR(45) NOT NULL', 'linkid' =>  'TINYINT(1) NOT NULL', 'isurl' => 'TINYINT(1)'},
+	auth_subfield_structure =>{ 'hidden' => 'TINYINT(3) NOT NULL default 0', 'kohafield' => 'VARCHAR(45) NOT NULL', 'linkid' =>  'TINYINT(1) NOT NULL default 0', 'isurl' => 'TINYINT(1)', 'frameworkcode'=>'VARCHAR(8) NOT  NULL'},
 	serial =>{ 'publisheddate' => 'date', 'itemnumber'=>'text NULL','routingnotes'=>'text NULL',},
     statistics => { 'associatedborrower' => 'integer'},
 #    tablename        => { 'field' => 'fieldtype' },
@@ -1604,8 +1604,8 @@
 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
 	$marcdone=1 if ($type eq 'longtext' && $column eq 'marcxml') ;
 }
-#unless ($marcdone) {
-unless (1) { # to disable this block just to test.
+unless ($marcdone) {
+#unless (1) { # to disable this block just to test.
 	print "moving MARC record to biblioitems table\n";
 	# changing marc field type
 	$dbh->do('ALTER TABLE `biblioitems` CHANGE `marc` `marc` BLOB NULL DEFAULT NULL ');
@@ -1619,8 +1619,7 @@
 	while (my ($bibid,$biblionumber) = $sth->fetchrow) {
 		my $record = MARCgetbiblio($dbh,$bibid);
 	#Force UTF-8 in record leader
-		$record->encoding('UTF-8');
-# 		print $record->as_formatted if ($biblionumber==3902);
+# 		$record->encoding('UTF-8');
 		$sth_update->execute($record->as_usmarc(),$record->as_xml_record(),$biblionumber);
 		$totaldone++;
 		print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
@@ -1652,6 +1651,12 @@
 	}
 }    # foreach
 
+#
+# Changing aqbookfund's primary key 
+#
+$sth=$dbh->prepare("ALTER TABLE `aqbookfund` DROP PRIMARY KEY , ADD PRIMARY KEY ( `bookfundid` , `branchcode` ) ;");
+$sth->execute;
+
 
 # MOVE all tables TO UTF-8 and innoDB
 $sth = $dbh->prepare("show table status");
@@ -1843,6 +1848,10 @@
 exit;
 
 # $Log: updatedatabase,v $
+# Revision 1.157.2.10  2006/10/17 16:18:14  hdl
+# Changing primary key in aqbookfund.
+# Making it branchcode+aqbookfundid rather than simple aqbookfundid.
+#
 # Revision 1.157.2.9  2006/10/16 14:23:47  toins
 # Borrowers.branchcode must be varchar(10) too.
 #
@@ -2000,7 +2009,7 @@
 # Revision 1.130  2006/03/03 16:35:21  tipaul
 # commit for holidays and news management.
 #
-# Contrib from Tümer Garip (from Turkey) :
+# Contrib from Tmer Garip (from Turkey) :
 # * holiday :
 # in /tools/ the holiday.pl script let you define holidays (days where the library is closed), branch by branch. You can define 3 types of holidays :
 # - single day : only this day is closed





More information about the Koha-cvs mailing list