+<!-- TMPL_UNLESS NAME="no_add" -->
<div id="toolbar">
<script type="text/javascript">
//<![CDATA[
</li>
</ul>
</div>
+<!-- /TMPL_UNLESS -->
\ No newline at end of file
<!-- 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" -->
<!-- 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">
<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" -->
<!-- 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" -->
<!-- /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" -->
<!-- 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" -->
}
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,
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
if ( $guarantorid ) {
$select_city = getidcity($data{city});
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,
-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")){
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
category_type =>$category_type,
modify => $modify,
nok => $nok,#flag to konw if an error
- CGIbranch => $CGIbranch,
memberofinstution => $member_of_institution,
CGIorganisations => $CGIorganisations,
NoUpdateLogin => $NoUpdateLogin
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 );