[Koha-patches] [PATCH] Addressing bug 1782
Henri-Damien LAURENT
henridamien at koha-fr.org
Tue May 6 15:25:37 CEST 2008
Adding New Systempreference AddPatronLists
This systempreference allow administrator to choose if patrons are created on categorycode lists or category_type ones.
Overloading GetBorrowerCategory so that if no parameter provided, it returns the list of category records
Changing memberentry.pl in order to use the categorycode when provided.
---
C4/Members.pm | 39 ++++++++++++++------
admin/systempreferences.pl | 1 +
installer/data/mysql/en/mandatory/sysprefs.sql | 1 +
.../1-Obligatoire/unimarc_standard_systemprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 11 ++++++
.../prog/en/includes/patron-toolbar.inc | 17 +++++----
kohaversion.pl | 2 +-
members/member.pl | 11 +++++-
members/memberentry.pl | 4 +-
members/members-home.pl | 10 +++++-
10 files changed, 74 insertions(+), 23 deletions(-)
diff --git a/C4/Members.pm b/C4/Members.pm
index 72c8770..18ca449 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -1335,23 +1335,40 @@ sub GetborCatFromCatType {
Given the borrower's category code, the function returns the corresponding
data hashref for a comprehensive information display.
+
+ $arrayref_hashref = &GetBorrowercategory;
+If no category code provided, the function returns all the categories.
=cut
sub GetBorrowercategory {
my ($catcode) = @_;
my $dbh = C4::Context->dbh;
- my $sth =
- $dbh->prepare(
-"SELECT description,dateofbirthrequired,upperagelimit,category_type
- FROM categories
- WHERE categorycode = ?"
- );
- $sth->execute($catcode);
- my $data =
- $sth->fetchrow_hashref;
- $sth->finish();
- return $data;
+ if ($catcode){
+ my $sth =
+ $dbh->prepare(
+ "SELECT description,dateofbirthrequired,upperagelimit,category_type
+ FROM categories
+ WHERE categorycode = ?"
+ );
+ $sth->execute($catcode);
+ my $data =
+ $sth->fetchrow_hashref;
+ $sth->finish();
+ return $data;
+ }
+ else {
+ my $sth =
+ $dbh->prepare(
+ "SELECT *
+ FROM categories order by description"
+ );
+ $sth->execute;
+ my $data =
+ $sth->fetchall_arrayref({});
+ $sth->finish();
+ return $data;
+ }
} # sub getborrowercategory
=head2 ethnicitycategories
diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index f3cbad0..3822d13 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -174,6 +174,7 @@ my %tabsysprefs;
$tabsysprefs{NoReturnSetLost}="Patrons";
$tabsysprefs{MaxFine}="Patrons";
$tabsysprefs{NotifyBorrowerDeparture}="Patrons";
+ $tabsysprefs{AddPatronLists}="Patrons";
$tabsysprefs{PatronsPerPage}="Patrons";
# I18N/L10N
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index c3637ab..56f9dfe 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -183,3 +183,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RenewSerialAddsSuggestion',0,'If ON, adds a new suggestion at serial subscription renewal',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable, value,options,type, explanation) VALUES ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons');
diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
index aa82437..91cb88d 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -185,3 +185,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACItemHolds','1','Si activé, les adhérents peuvent placer des réservations sur un exemplaire spécifique. Sinon, il ne peuvent que réserver le prochain disponible.','','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GranularPermissions','0','Use detailed staff user permissions',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RenewSerialAddsSuggestion',0,'Si activé, génère une suggestion d\'achat à chaque Renouvellement d\'abonnement',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable, value,options,type, explanation) VALUES ('AddPatronLists','categorycode','categorycode|category_type','Choice','Slectionner categorycode ou category_type permet d\'afficher la liste des catégories ou des types de catégories à l\'ajout d\'un lecteur');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index e612244..4dcb11d 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -1480,6 +1480,17 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.00.00.079";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ my ($print_error) = $dbh->{PrintError};
+ $dbh->{PrintError} = 0;
+
+ $dbh->do("INSERT INTO `systempreferences` (variable, value,options,type, explanation)VALUES
+ ('AddPatronLists','categorycode','categorycode|category_type','Choice','Allow user to choose what list to pick up from when adding patrons')");
+ print "Upgrade to $DBversion done (add browser table if not already present)\n";
+ SetVersion ($DBversion);
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc
index ad572f9..1baeee2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc
@@ -5,11 +5,14 @@
// prepare DOM for YUI Toolbar
$(document).ready(function() {
+<!--TMPL_IF Name="AddPatronLists_categorycode"-->
+<!--TMPL_ELSE-->
$("#addchild").parent().remove();
$("#addprofessional").parent().remove();
$("#addorganisation").parent().remove();
$("#addstaff").parent().remove();
$("#addstatistical").parent().remove();
+<!--/TMPL_IF-->
$("#newmenuc").empty();
yuiToolbar();
});
@@ -19,12 +22,16 @@
function yuiToolbar() {
var newmenu = [
+<!--TMPL_IF Name="AddPatronLists_categorycode"-->
+<!--TMPL_LOOP Name="categories"-->{ text: "<!--TMPL_VAR Name="description"-->", url: "/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=<!--TMPL_VAR Name="categorycode"-->" },<!--/TMPL_LOOP-->
+<!--TMPL_ELSE-->
{ text: _("Adult Patron"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=A" },
{ text: _("Child Patron"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=C" },
{ text: _("Professional Patron"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=P" },
{ text: _("Organisation"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=I" },
{ text: _("Staff"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=S" },
{ text: _("Statistical"), url: "/cgi-bin/koha/members/memberentry.pl?op=add&category_type=X" },
+<!--/TMPL_IF-->
]
new YAHOO.widget.Button({
@@ -40,10 +47,6 @@
//]]>
</script>
<ul class="toolbar">
- <li id="newmenuc"><a id="addadult" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=A">Adult</a></li>
-<li><a id="addchild" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=C">Child</a></li>
-<li><a id="addprofessional" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=P">Professional</a></li>
-<li><a id="addorganisation" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=I">Organisation</a></li>
-<li><a id="addstaff" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=S">Staff</a></li>
-<li><a id="addstatistical" href="/cgi-bin/koha/members/memberentry.pl?op=add&category_type=X">Statistical</a></li>
-</ul></div>
+ <li id="newmenuc"></li>
+</ul>
+</div>
diff --git a/kohaversion.pl b/kohaversion.pl
index df4bb19..ccff567 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -10,7 +10,7 @@
use strict;
sub kohaversion {
- our $VERSION = "3.00.00.078";
+ our $VERSION = "3.00.00.079";
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
diff --git a/members/member.pl b/members/member.pl
index dc3da69..1d33191 100755
--- a/members/member.pl
+++ b/members/member.pl
@@ -55,6 +55,16 @@ if($quicksearch){
});
}
my $theme = $input->param('theme') || "default";
+
+
+$template->param(
+ "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
+ );
+if (C4::Context->preference("AddPatronLists")=~/code/){
+ my $categories=GetBorrowercategory();
+ $categories->[0]->{'first'}=1;
+ $template->param(categories=>$categories);
+}
# only used if allowthemeoverride is set
#my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
# FIXME - Error-checking
@@ -62,7 +72,6 @@ my $theme = $input->param('theme') || "default";
# die_on_bad_params => 0,
# loop_context_vars => 1 );
-
my $member=$input->param('member');
my $orderby=$input->param('orderby');
$orderby = "surname,firstname" unless $orderby;
diff --git a/members/memberentry.pl b/members/memberentry.pl
index 5cc8c00..4619fcc 100755
--- a/members/memberentry.pl
+++ b/members/memberentry.pl
@@ -301,14 +301,14 @@ if ($ethnicitycategoriescount>=0) {
}
my @typeloop;
-foreach ( ($new_c_type) ? ($new_c_type) : qw(C A S P I X)){
+foreach ( ($category_type) ? ($category_type) : qw(C A S P I X)){
my $action="WHERE category_type=?";
($categories,$labels)=GetborCatFromCatType($_,$action);
my @categoryloop;
foreach my $cat (@$categories){
push @categoryloop,{'categorycode' => $cat,
'categoryname' => $labels->{$cat},
- 'categorycodeselected' => ($cat eq $borrower_data->{'categorycode'}),
+ 'categorycodeselected' => ($cat eq $borrower_data->{'categorycode'} || $cat eq $categorycode),
};
}
my %typehash;
diff --git a/members/members-home.pl b/members/members-home.pl
index a5f6c8e..212c97b 100755
--- a/members/members-home.pl
+++ b/members/members-home.pl
@@ -20,7 +20,7 @@ use CGI;
use C4::Auth;
use C4::Output;
use C4::Context;
-
+use C4::Members;
my $query = new CGI;
my $quicksearch = $query->param('quicksearch');
@@ -46,5 +46,13 @@ if($quicksearch){
debug => 1,
});
}
+$template->param(
+ "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
+ );
+if (C4::Context->preference("AddPatronLists")=~/code/){
+ my $categories=GetBorrowercategory();
+ $categories->[0]->{'first'}=1;
+ $template->param(categories=>$categories);
+}
output_html_with_http_headers $query, $cookie, $template->output;
--
1.5.4.3
More information about the Koha-patches
mailing list