[Koha-cvs] koha C4/Koha.pm C4/Letters.pm tools/overduerule... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Thu Sep 28 18:34:15 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/09/28 16:34:15

Modified files:
	C4             : Koha.pm Letters.pm 
	tools          : overduerules.pl 

Log message:
	moving getletters from koha.pm to Letter.pm with name GetLetters.
	Using this function in tools/overduerules.pl.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.40.2.4&r2=1.40.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Letters.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.4.2.1&r2=1.4.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/tools/overduerules.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.3&r2=1.3.2.1

Patches:
Index: C4/Koha.pm
===================================================================
RCS file: /sources/koha/koha/C4/Koha.pm,v
retrieving revision 1.40.2.4
retrieving revision 1.40.2.5
diff -u -b -r1.40.2.4 -r1.40.2.5
--- C4/Koha.pm	25 Sep 2006 14:39:19 -0000	1.40.2.4
+++ C4/Koha.pm	28 Sep 2006 16:34:15 -0000	1.40.2.5
@@ -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: Koha.pm,v 1.40.2.4 2006/09/25 14:39:19 toins Exp $
+# $Id: Koha.pm,v 1.40.2.5 2006/09/28 16:34:15 toins Exp $
 
 use strict;
 require Exporter;
@@ -25,7 +25,7 @@
 use C4::Output;
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = do { my @v = '$Revision: 1.40.2.4 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.40.2.5 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -55,6 +55,7 @@
             &GetBranches &getbranch &getbranchdetail
             &getprinters &getprinter
             &GetItemTypes &getitemtypeinfo
+	        &GetCcodes
                         get_itemtypeinfos_of
             &getframeworks &getframeworkinfo
             &getauthtypes &getauthtype
@@ -326,56 +327,6 @@
     return (\%branches);
 }
 
-=head2 getletters
-
-  $letters = &getletters($category);
-  returns informations about letters.
-  if needed, $category filters for letters given category
-  Create a letter selector with the following code
-  
-=head3 in PERL SCRIPT
-
-my $letters = getletters($cat);
-my @letterloop;
-foreach my $thisletter (keys %$letters) {
-    my $selected = 1 if $thisletter eq $letter;
-    my %row =(value => $thisletter,
-                selected => $selected,
-                lettername => $letters->{$thisletter},
-            );
-    push @letterloop, \%row;
-}
-
-
-=head3 in TEMPLATE  
-            <select name="letter">
-                <option value="">Default</option>
-            <!-- TMPL_LOOP name="letterloop" -->
-                <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="lettername" --></option>
-            <!-- /TMPL_LOOP -->
-            </select>
-
-=cut
-
-sub getletters {
-# returns a reference to a hash of references to ALL letters...
-    my $cat =@_;
-    my %letters;
-    my $dbh = C4::Context->dbh;
-    my $sth;
-       if ($cat ne ""){
-        $sth = $dbh->prepare("Select * from letter where module = \'".$cat."\' order by name");
-    } else {
-        $sth = $dbh->prepare("Select * from letter order by name");
-    }
-    $sth->execute;
-    my $count;
-    while (my $letter=$sth->fetchrow_hashref) {
-            $letters{$letter->{'code'}}=$letter->{'name'};
-            $count++;
-    }
-    return ($count,\%letters);
-}
 
 =head2 GetItemTypes
 
@@ -445,6 +396,25 @@
     return get_infos_of($query, 'itemtype');
 }
 
+# this is temporary until we separate collection codes and item types
+sub GetCcodes {
+	my $count = 0;
+	my @results;
+    my $dbh = C4::Context->dbh;
+    my $sth=$dbh->prepare("SELECT * FROM authorised_values ORDER BY authorised_value");
+    $sth->execute;
+    while (my $data=$sth->fetchrow_hashref) {
+		if ($data->{category} =/CCODE/) {
+			$count++;
+			$results[$count] = $data;
+			#warn "data: $data";
+		}
+    }
+	$sth->finish;
+    return ($count, at results);
+}
+
+
 =head2 getauthtypes
 
   $authtypes = &getauthtypes();
@@ -1318,7 +1288,7 @@
     my @languages_options;
     my $languages_hash = {en => 'English', es => 'Espa&ntilde;ol',}; #de => 'Deutsch', en => 'English', es => 'Espa&ntilde;ol', fr => 'Fran&ccedil;ais', pl => 'Polski', "zh-TW" => '&#20013;&#25991;', it => 'Italiano',};
     my $counter=0;
-    foreach my $language (getalllanguages("opac")) {
+    foreach my $language (GetLanguages("opac")) {
         next if $language eq 'images';
         next if $language eq 'itemtypeimg';
         next if $language eq 'CVS';

Index: C4/Letters.pm
===================================================================
RCS file: /sources/koha/koha/C4/Letters.pm,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -b -r1.4.2.1 -r1.4.2.2
--- C4/Letters.pm	31 Aug 2006 16:15:52 -0000	1.4.2.1
+++ C4/Letters.pm	28 Sep 2006 16:34:15 -0000	1.4.2.2
@@ -49,33 +49,60 @@
 =cut
 
 @ISA = qw(Exporter);
- at EXPORT = qw(&GetLetterList &getletter &addalert &getalert &delalert &findrelatedto &sendalerts);
+ at EXPORT = qw(&GetLetters &getletter &addalert &getalert &delalert &findrelatedto &sendalerts);
 
-=head2 GetLetterList
 
-	parameter : $module : the name of the module
-	This sub returns an array of hashes with all letters from a given module
-	Each hash entry contains :
-	- module : the module name
-	- code : the code of the letter, char(20)
-	- name : the complete name of the letter, char(200)
-	- title : the title that will be used as "subject" in mails, char(200)
-	- content : the content of the letter. Each field to be replaced by a value at runtime is enclosed in << and >>. The fields usually have the same name as in the DB 
+=head2 GetLetters
+
+  $letters = &getletters($category);
+  returns informations about letters.
+  if needed, $category filters for letters given category
+  Create a letter selector with the following code
+  
+=head3 in PERL SCRIPT
+
+my $letters = GetLetters($cat);
+my @letterloop;
+foreach my $thisletter (keys %$letters) {
+    my $selected = 1 if $thisletter eq $letter;
+    my %row =(value => $thisletter,
+                selected => $selected,
+                lettername => $letters->{$thisletter},
+            );
+    push @letterloop, \%row;
+}
+
+=head3 in TEMPLATE  
+            <select name="letter">
+                <option value="">Default</option>
+            <!-- TMPL_LOOP name="letterloop" -->
+                <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="lettername" --></option>
+            <!-- /TMPL_LOOP -->
+            </select>
 
 =cut
 
-sub GetLetterList {
-	my ($module) = @_;
+sub GetLetters {
+# returns a reference to a hash of references to ALL letters...
+    my $cat =@_;
+    my %letters;
 	my $dbh = C4::Context->dbh;
-	my $sth = $dbh->prepare("select * from letter where module=?");
-	$sth->execute($module);
-	my @result;
-	while (my $line = $sth->fetchrow_hashref) {
-		push @result,$line;
+    my $sth;
+       if ($cat ne ""){
+        $sth = $dbh->prepare("Select * from letter where module = \'".$cat."\' order by name");
+    } else {
+        $sth = $dbh->prepare("Select * from letter order by name");
 	}
-	return @result;
+    $sth->execute;
+    my $count;
+    while (my $letter=$sth->fetchrow_hashref) {
+            $letters{$letter->{'code'}}=$letter->{'name'};
+            $count++;
+    }
+    return \%letters;
 }
 
+
 sub getletter {
 	my ($module,$code) = @_;
 	my $dbh = C4::Context->dbh;

Index: tools/overduerules.pl
===================================================================
RCS file: /sources/koha/koha/tools/overduerules.pl,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -b -r1.3 -r1.3.2.1
--- tools/overduerules.pl	19 Jul 2006 08:58:38 -0000	1.3
+++ tools/overduerules.pl	28 Sep 2006 16:34:15 -0000	1.3.2.1
@@ -132,7 +132,9 @@
 	push @branchloop, \%row;
 }
 
-my ($countletters,$letters) = getletters("circulation");
+my $letters = GetLetters("circulation");
+
+my $countletters = scalar $letters;
 
 my $sth=$dbh->prepare("Select description,categorycode from categories where overduenoticerequired>0 order by description");
 $sth->execute;





More information about the Koha-cvs mailing list