Bugzilla – Attachment 2970 Details for
Bug 3319
Need a nicer error message when attempting to add a patron with no libraries defined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Revised for current HEAD
0001-Fix-for-Bug-3319-Need-error-message-when-adding-patr.patch (text/plain), 11.12 KB, created by
Owen Leonard
on 2011-01-11 13:40:08 UTC
(
hide
)
Description:
Revised for current HEAD
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2011-01-11 13:40:08 UTC
Size:
11.12 KB
patch
obsolete
>From 07e85f306ae9e3520e42c6a131486a717afba772 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 17 Aug 2010 12:58:33 -0400 >Subject: [PATCH] Fix for Bug 3319 - Need error message when adding patron and libraries are defined > >- Hiding patron add toolbar when branches or categories are undefined >- Blocking patron entry form if branches or categories are undefined >- Removing nonfunctional template logic for displaying missing category > error message. >--- > .../prog/en/includes/patron-toolbar.inc | 2 + > .../prog/en/modules/members/member.tmpl | 5 +++ > .../prog/en/modules/members/memberentrygen.tmpl | 12 ++++---- > members/memberentry.pl | 28 +++++++++++++++---- > members/members-home.pl | 27 +++++++++++++++--- > 5 files changed, 57 insertions(+), 17 deletions(-) > >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 c508af0..bc4dbc4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc >@@ -1,3 +1,4 @@ >+<!-- TMPL_UNLESS NAME="no_add" --> > <div id="toolbar"> > <script type="text/javascript"> > //<![CDATA[ >@@ -69,3 +70,4 @@ > </li> > </ul> > </div> >+<!-- /TMPL_UNLESS --> >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl >index fef7b69..50a73da 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl >@@ -17,6 +17,11 @@ > > <!-- TMPL_INCLUDE NAME="patron-toolbar.inc" --> > >+ <!-- TMPL_IF NAME="no_add" --><div class="dialog alert"><h3>Cannot add patron</h3> >+ <!-- TMPL_IF NAME="no_branches" --><p>There are <strong>no libraries defined</strong>. <!-- TMPL_IF NAME="CAN_user_parameters" -->Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.<!-- TMPL_ELSE -->An administrator must define at least one library.<!-- /TMPL_IF --></p><!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="no_categories" --><p>There are <strong>no patron categories defined</strong>. <!-- TMPL_IF NAME="CAN_user_parameters" -->Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.<!-- TMPL_ELSE -->An administrator must define at least one patron category.<!-- /TMPL_IF --></p><!-- /TMPL_IF --></div> >+ <!-- /TMPL_IF --> >+ > <div class="browse"> > Browse by last name: > <!-- TMPL_LOOP name="letters" --> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >index 4ecc0cb..a746307 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl >@@ -1,6 +1,6 @@ > <!-- TMPL_INCLUDE NAME="doc-head-open.inc" --> > <title>Koha › Patrons › >-<!-- TMPL_IF NAME="opadd" --> Add<!-- TMPL_ELSE --> Modify<!--/TMPL_IF--> <!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --><!--TMPL_UNLESS Name="opadd"--> <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--/TMPL_UNLESS--></title> >+<!-- TMPL_IF NAME="opadd" -->Add<!-- TMPL_ELSE --> Modify<!--/TMPL_IF--> <!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --><!--TMPL_UNLESS Name="opadd"--> <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!--/TMPL_UNLESS--></title> > <!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> > <!-- TMPL_INCLUDE NAME="calendar.inc" --> > <script type="text/JavaScript" language="JavaScript"> >@@ -80,7 +80,11 @@ > <div id="yui-main"> > <div class="yui-b"> > >+ <!-- TMPL_IF NAME="no_add" --><div class="dialog alert"><h3>Cannot add patron</h3> >+ <!-- TMPL_IF NAME="no_branches" --><p>There are <strong>no libraries defined</strong>. <!-- TMPL_IF NAME="CAN_user_parameters" -->Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.<!-- TMPL_ELSE -->An administrator must define at least one library.<!-- /TMPL_IF --></p><!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="no_categories" --><p>There are <strong>no patron categories defined</strong>. <!-- TMPL_IF NAME="CAN_user_parameters" -->Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.<!-- TMPL_ELSE -->An administrator must define at least one patron category.</p><!-- /TMPL_IF --><!-- /TMPL_IF --></div><!-- /TMPL_IF --> > >+ <!-- TMPL_UNLESS NAME="no_add" --> > <!-- TMPL_IF NAME="opadd" --> > <h1> > Add<!--TMPL_IF Name="categoryname"--> <!--TMPL_VAR Name="categoryname"--> patron<!-- TMPL_ELSE --><!--TMPL_IF Name="I"--> Organization patron<!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult patron<!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child patron<!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional patron<!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff patron<!--/TMPL_IF --><!--/TMPL_IF --> <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR NAME="surname" --> >@@ -731,7 +735,6 @@ > <!-- TMPL_IF NAME="mandatorybranchcode" --><span class="required">Required</span><!-- /TMPL_IF --> > </li> > <li> >- <!-- TMPL_IF NAME="typeloop" --> > <label for="categorycode">Category: </label> > <select id="categorycode" name="categorycode"> > <!-- TMPL_LOOP NAME="typeloop" --> >@@ -755,10 +758,6 @@ > <!-- /TMPL_LOOP --> > <!-- /TMPL_LOOP --> > </select> >- <!-- TMPL_ELSE --> >- <span class="problem">There is no category type to add <!--TMPL_IF Name="A"-->an Adult<!--/TMPL_IF--><!--TMPL_IF Name="C"-->a Child<!--/TMPL_IF--><!--TMPL_IF Name="I"-->an Institution<!--/TMPL_IF--><!--TMPL_IF Name="P"-->a Professional<!--/TMPL_IF--><!--TMPL_IF Name="S"-->a Staff Member<!--/TMPL_IF-->.</span> >- <a href="/cgi-bin/koha/admin/categorie.pl">Please create one</a> >- <!-- /TMPL_IF --> > </li> > <li> > <!-- TMPL_IF NAME="mandatorysort1" --> >@@ -1070,6 +1069,7 @@ > <!-- TMPL_UNLESS NAME="opadd" --><div class="yui-b"> > <!-- TMPL_INCLUDE NAME="members-menu.inc" --> > </div><!-- /TMPL_UNLESS --> >+<!-- /TMPL_UNLESS --> > </div> > <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" --> > >diff --git a/members/memberentry.pl b/members/memberentry.pl >index fbd8538..c54ad7f 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -415,9 +415,12 @@ if ($ethnicitycategoriescount>=0) { > } > > my @typeloop; >+my $no_categories = 1; >+my $no_add; > foreach (qw(C A S P I X)) { > my $action="WHERE category_type=?"; > ($categories,$labels)=GetborCatFromCatType($_,$action); >+ if(scalar(@$categories) > 0){ $no_categories = 0; } > my @categoryloop; > foreach my $cat (@$categories){ > push @categoryloop,{'categorycode' => $cat, >@@ -434,9 +437,10 @@ foreach (qw(C A S P I X)) { > push @typeloop,{'typename' => $_, > $typedescription => 1, > 'categoryloop' => \@categoryloop}; >-} >-$template->param('typeloop' => \@typeloop); >- >+} >+$template->param('typeloop' => \@typeloop, >+ no_categories => $no_categories); >+if($no_categories){ $no_add = 1; } > # test in city > $select_city=getidcity($data{'city'}) if defined $guarantorid and ($guarantorid ne '0'); > ($default_city=$select_city) if ($step eq 0); >@@ -527,17 +531,18 @@ my $onlymine=(C4::Context->preference('IndependantBranches') && > > my $branches=GetBranches($onlymine); > my $default; >- >+my $CGIbranch; > for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { > push @select_branch,$branch; > $select_branches{$branch} = $branches->{$branch}->{'branchname'}; > $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'}); > } >+if(scalar(@select_branch) > 0){ > # -------------------------------------------------------------------------------------------------------- > #in modify mod :default value from $CGIbranch comes from borrowers table > #in add mod: default value come from branches table (ip correspendence) > $default=$data{'branchcode'} if ($op eq 'modify' || ($op eq 'add' && $category_type eq 'C')); >-my $CGIbranch = CGI::scrolling_list(-id => 'branchcode', >+$CGIbranch = CGI::scrolling_list(-id => 'branchcode', > -name => 'branchcode', > -values => \@select_branch, > -labels => \%select_branches, >@@ -546,6 +551,17 @@ my $CGIbranch = CGI::scrolling_list(-id => 'branchcode', > -multiple =>0, > -default => $default, > ); >+} >+ >+if(!$CGIbranch){ >+ $no_add = 1; >+ $template->param(no_branches => 1); >+} >+if($no_categories){ >+ $no_add = 1; >+ $template->param(no_categories => 1); >+} >+$template->param(no_add => $no_add); > my $CGIorganisations; > my $member_of_institution; > if (C4::Context->preference("memberofinstitution")){ >@@ -636,6 +652,7 @@ $template->param( > check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) > "op$op" => 1); > >+$template->param(CGIbranch=>$CGIbranch) if ($CGIbranch); > $template->param( > nodouble => $nodouble, > borrowernumber => $borrowernumber, #register number >@@ -653,7 +670,6 @@ $template->param( > category_type =>$category_type, > modify => $modify, > nok => $nok,#flag to konw if an error >- CGIbranch => $CGIbranch, > memberofinstution => $member_of_institution, > CGIorganisations => $CGIorganisations, > NoUpdateLogin => $NoUpdateLogin >diff --git a/members/members-home.pl b/members/members-home.pl >index 120e65f..db8be4a 100755 >--- a/members/members-home.pl >+++ b/members/members-home.pl >@@ -63,13 +63,30 @@ foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} > push @branchloop, \%row; > } > >-my @categories=C4::Category->all; >-$template->param( >- branchloop=>\@branchloop, >- categories=>\@categories, >-); >+my @categories; >+my $no_categories; >+my $no_add = 0; >+my $branchloop = (defined $branch?GetBranchesLoop($branch):GetBranchesLoop()); >+if(scalar(@$branchloop) < 1){ >+ $no_add = 1; >+ $template->param(no_branches => 1); >+} else { >+ $template->param(branchloop=>\@$branchloop); >+} >+ >+@categories=C4::Category->all; >+if(scalar(@categories) < 1){ $no_categories = 1; } >+if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){ >+ $no_add = 1; >+ $template->param(no_categories => 1); >+} else { >+ $template->param(categories=>\@categories); >+} >+ >+ > $template->param( > "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", >+ no_add => $no_add, > ); > my @letters = map { {letter => $_} } ( 'A' .. 'Z'); > $template->param( letters => \@letters ); >-- >1.7.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3319
:
2548
| 2970