[Koha-cvs] koha C4/Koha.pm koha-tmpl/intranet-tmpl/prog/en...

Henri-Damien LAURENT laurenthdl at alinto.com
Mon Feb 27 19:15:41 CET 2006


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch: 	
Changes by:	Henri-Damien LAURENT <hdl at savannah.gnu.org>	06/02/27 18:15:41

Modified files:
	C4             : Koha.pm 
Added files:
	koha-tmpl/intranet-tmpl/prog/en/tools: overduerules.tmpl 
	tools          : overduerules.pl 

Log message:
	Adding getletters to Koha.pm :
	allow to get a list of letters for a module.
	
	overduerules is a tool relying on letter.pl
	It will allow ppl to manage three levels of overdue thanks to a brand new overduenotice script to come out soon.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Koha.pm.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/koha-tmpl/intranet-tmpl/prog/en/tools/overduerules.tmpl?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/tools/overduerules.pl?rev=1.1

Patches:
Index: koha/C4/Koha.pm
diff -u koha/C4/Koha.pm:1.27 koha/C4/Koha.pm:1.28
--- koha/C4/Koha.pm:1.27	Fri Jan  6 16:39:37 2006
+++ koha/C4/Koha.pm	Mon Feb 27 18:15:41 2006
@@ -61,7 +61,7 @@
 			&getframeworks &getframeworkinfo
 			&getauthtypes &getauthtype
 			&getallthemes &getalllanguages
-			&getallbranches
+			&getallbranches &getletters
 			$DEBUG);
 
 use vars qw();
@@ -300,6 +300,57 @@
 	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
 
   $itemtypes = &getitemtypes();





More information about the Koha-cvs mailing list