Bug 15099: Move admin/categorie.pl to admin/categories.pl
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 2 Dec 2015 08:49:50 +0000 (08:49 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Wed, 30 Dec 2015 16:36:41 +0000 (16:36 +0000)
This patch fixes the filename categorie.pl correcting it by categories.pl
The plurial is usually used for script names in the admin module.

Test plan:
Navigate to the patron categories page.

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
  No reference to categorie.pl anywhere in the code

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Form/MessagingPreferences.pm
admin/categorie.pl [deleted file]
admin/categories.pl [new file with mode: 0755]
koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt [deleted file]
koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt

index bb981a6..cbee804 100644 (file)
@@ -163,7 +163,7 @@ sub set_form_values {
 
 =head1 SEE ALSO
 
-L<C4::Members::Messaging>, F<admin/categorie.pl>, F<opac/opac-messaging.pl>, F<members/messaging.pl>
+L<C4::Members::Messaging>, F<admin/categories.pl>, F<opac/opac-messaging.pl>, F<members/messaging.pl>
 
 =head1 AUTHOR
 
diff --git a/admin/categorie.pl b/admin/categorie.pl
deleted file mode 100755 (executable)
index cc153bd..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2000-2002 Katipo Communications
-# Copyright 2002 Paul Poulain
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# Koha is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Koha; if not, see <http://www.gnu.org/licenses>.
-
-use Modern::Perl;
-
-use CGI qw ( -utf8 );
-use C4::Context;
-use C4::Auth;
-use C4::Branch;
-use C4::Output;
-use C4::Form::MessagingPreferences;
-use Koha::Borrowers;
-use Koha::Database;
-use Koha::DateUtils;
-use Koha::Patron::Categories;
-
-my $input         = new CGI;
-my $searchfield   = $input->param('description') // q||;
-my $categorycode  = $input->param('categorycode');
-my $op            = $input->param('op') // 'list';
-my @messages;
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
-    {
-        template_name   => "admin/categorie.tt",
-        query           => $input,
-        type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
-        debug           => 1,
-    }
-);
-
-if ( $op eq 'add_form' ) {
-    my ( $category, $selected_branches );
-    if ($categorycode) {
-        $category          = Koha::Patron::Categories->find($categorycode);
-        $selected_branches = $category->branch_limitations;
-    }
-
-    my $branches = GetBranches;
-    my @branches_loop;
-    foreach my $branchcode ( sort { uc( $branches->{$a}->{branchname} ) cmp uc( $branches->{$b}->{branchname} ) } keys %$branches ) {
-        my $selected = ( grep { $_ eq $branchcode } @$selected_branches ) ? 1 : 0;
-        push @branches_loop,
-          { branchcode => $branchcode,
-            branchname => $branches->{$branchcode}->{branchname},
-            selected   => $selected,
-          };
-    }
-
-    $template->param(
-        category => $category,
-        branches_loop       => \@branches_loop,
-    );
-
-    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
-        C4::Form::MessagingPreferences::set_form_values(
-            { categorycode => $categorycode }, $template );
-    }
-}
-elsif ( $op eq 'add_validate' ) {
-
-    my $categorycode = $input->param('categorycode');
-    my $description = $input->param('description');
-    my $enrolmentperiod = $input->param('enrolmentperiod');
-    my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef;
-    my $upperagelimit = $input->param('upperagelimit');
-    my $dateofbirthrequired = $input->param('dateofbirthrequired');
-    my $enrolmentfee = $input->param('enrolmentfee');
-    my $reservefee = $input->param('reservefee');
-    my $hidelostitems = $input->param('hidelostitems');
-    my $overduenoticerequired = $input->param('overduenoticerequired');
-    my $category_type = $input->param('category_type');
-    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
-    my $default_privacy = $input->param('default_privacy');
-    my @branches = grep { $_ ne q{} } $input->param('branches');
-
-    my $is_a_modif = $input->param("is_a_modif");
-
-    if ( $enrolmentperioddate ) {
-        $enrolmentperioddate = output_pref({ dt => dt_from_string($enrolmentperioddate), dateformat => 'iso' });
-    }
-
-    if ($is_a_modif) {
-        my $category = Koha::Patron::Categories->find( $categorycode );
-        $category->categorycode($categorycode);
-        $category->description($description);
-        $category->enrolmentperiod($enrolmentperiod);
-        $category->enrolmentperioddate($enrolmentperioddate);
-        $category->upperagelimit($upperagelimit);
-        $category->dateofbirthrequired($dateofbirthrequired);
-        $category->enrolmentfee($enrolmentfee);
-        $category->reservefee($reservefee);
-        $category->hidelostitems($hidelostitems);
-        $category->overduenoticerequired($overduenoticerequired);
-        $category->category_type($category_type);
-        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
-        $category->default_privacy($default_privacy);
-        eval {
-            $category->store;
-            $category->replace_branch_limitations( \@branches );
-        };
-        if ( $@ ) {
-            push @messages, {type => 'error', code => 'error_on_update' };
-        } else {
-            push @messages, { type => 'message', code => 'success_on_update' };
-        }
-    }
-    else {
-        my $category = Koha::Patron::Category->new({
-            categorycode => $categorycode,
-            description => $description,
-            enrolmentperiod => $enrolmentperiod,
-            enrolmentperioddate => $enrolmentperioddate,
-            upperagelimit => $upperagelimit,
-            dateofbirthrequired => $dateofbirthrequired,
-            enrolmentfee => $enrolmentfee,
-            reservefee => $reservefee,
-            hidelostitems => $hidelostitems,
-            overduenoticerequired => $overduenoticerequired,
-            category_type => $category_type,
-            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
-            default_privacy => $default_privacy,
-        });
-        eval {
-            $category->store;
-            $category->replace_branch_limitations( \@branches );
-        };
-
-        if ( $@ ) {
-            push @messages, { type => 'error', code => 'error_on_insert' };
-        } else {
-            push @messages, { type => 'message', code => 'success_on_insert' };
-        }
-    }
-
-    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
-        C4::Form::MessagingPreferences::handle_form_action( $input,
-            { categorycode => $input->param('categorycode') }, $template );
-    }
-
-    $searchfield = q||;
-    $op = 'list';
-}
-elsif ( $op eq 'delete_confirm' ) {
-
-    my $count = Koha::Borrowers->search({
-        categorycode => $categorycode
-    })->count;
-
-    my $category = Koha::Patron::Categories->find($categorycode);
-
-    $template->param(
-        category => $category,
-        patrons_in_category => $count,
-    );
-
-}
-elsif ( $op eq 'delete_confirmed' ) {
-    my $categorycode = uc( $input->param('categorycode') );
-
-    my $category = Koha::Patron::Categories->find( $categorycode );
-    my $deleted = eval { $category->delete; };
-
-    if ( $@ or not $deleted ) {
-        push @messages, {type => 'error', code => 'error_on_delete' };
-    } else {
-        push @messages, { type => 'message', code => 'success_on_delete' };
-    }
-
-    $op = 'list';
-}
-
-if ( $op eq 'list' ) {
-    my $categories = Koha::Patron::Categories->search(
-        {
-            description => { -like => "$searchfield%" }
-        },
-        {
-            order_by => ['category_type', 'description', 'categorycode' ]
-        }
-    );
-
-    $template->param(
-        categories => $categories,
-    )
-}
-
-$template->param(
-    categorycode => $categorycode,
-    searchfield  => $searchfield,
-    messages     => \@messages,
-    op => $op,
-);
-
-output_html_with_http_headers $input, $cookie, $template->output;
-
-exit 0;
diff --git a/admin/categories.pl b/admin/categories.pl
new file mode 100755 (executable)
index 0000000..1370b58
--- /dev/null
@@ -0,0 +1,216 @@
+#!/usr/bin/perl
+
+# Copyright 2000-2002 Katipo Communications
+# Copyright 2002 Paul Poulain
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+use C4::Context;
+use C4::Auth;
+use C4::Branch;
+use C4::Output;
+use C4::Form::MessagingPreferences;
+use Koha::Borrowers;
+use Koha::Database;
+use Koha::DateUtils;
+use Koha::Patron::Categories;
+
+my $input         = new CGI;
+my $searchfield   = $input->param('description') // q||;
+my $categorycode  = $input->param('categorycode');
+my $op            = $input->param('op') // 'list';
+my @messages;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "admin/categories.tt",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
+        debug           => 1,
+    }
+);
+
+if ( $op eq 'add_form' ) {
+    my ( $category, $selected_branches );
+    if ($categorycode) {
+        $category          = Koha::Patron::Categories->find($categorycode);
+        $selected_branches = $category->branch_limitations;
+    }
+
+    my $branches = GetBranches;
+    my @branches_loop;
+    foreach my $branchcode ( sort { uc( $branches->{$a}->{branchname} ) cmp uc( $branches->{$b}->{branchname} ) } keys %$branches ) {
+        my $selected = ( grep { $_ eq $branchcode } @$selected_branches ) ? 1 : 0;
+        push @branches_loop,
+          { branchcode => $branchcode,
+            branchname => $branches->{$branchcode}->{branchname},
+            selected   => $selected,
+          };
+    }
+
+    $template->param(
+        category => $category,
+        branches_loop       => \@branches_loop,
+    );
+
+    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
+        C4::Form::MessagingPreferences::set_form_values(
+            { categorycode => $categorycode }, $template );
+    }
+}
+elsif ( $op eq 'add_validate' ) {
+
+    my $categorycode = $input->param('categorycode');
+    my $description = $input->param('description');
+    my $enrolmentperiod = $input->param('enrolmentperiod');
+    my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef;
+    my $upperagelimit = $input->param('upperagelimit');
+    my $dateofbirthrequired = $input->param('dateofbirthrequired');
+    my $enrolmentfee = $input->param('enrolmentfee');
+    my $reservefee = $input->param('reservefee');
+    my $hidelostitems = $input->param('hidelostitems');
+    my $overduenoticerequired = $input->param('overduenoticerequired');
+    my $category_type = $input->param('category_type');
+    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
+    my $default_privacy = $input->param('default_privacy');
+    my @branches = grep { $_ ne q{} } $input->param('branches');
+
+    my $is_a_modif = $input->param("is_a_modif");
+
+    if ( $enrolmentperioddate ) {
+        $enrolmentperioddate = output_pref({ dt => dt_from_string($enrolmentperioddate), dateformat => 'iso' });
+    }
+
+    if ($is_a_modif) {
+        my $category = Koha::Patron::Categories->find( $categorycode );
+        $category->categorycode($categorycode);
+        $category->description($description);
+        $category->enrolmentperiod($enrolmentperiod);
+        $category->enrolmentperioddate($enrolmentperioddate);
+        $category->upperagelimit($upperagelimit);
+        $category->dateofbirthrequired($dateofbirthrequired);
+        $category->enrolmentfee($enrolmentfee);
+        $category->reservefee($reservefee);
+        $category->hidelostitems($hidelostitems);
+        $category->overduenoticerequired($overduenoticerequired);
+        $category->category_type($category_type);
+        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
+        $category->default_privacy($default_privacy);
+        eval {
+            $category->store;
+            $category->replace_branch_limitations( \@branches );
+        };
+        if ( $@ ) {
+            push @messages, {type => 'error', code => 'error_on_update' };
+        } else {
+            push @messages, { type => 'message', code => 'success_on_update' };
+        }
+    }
+    else {
+        my $category = Koha::Patron::Category->new({
+            categorycode => $categorycode,
+            description => $description,
+            enrolmentperiod => $enrolmentperiod,
+            enrolmentperioddate => $enrolmentperioddate,
+            upperagelimit => $upperagelimit,
+            dateofbirthrequired => $dateofbirthrequired,
+            enrolmentfee => $enrolmentfee,
+            reservefee => $reservefee,
+            hidelostitems => $hidelostitems,
+            overduenoticerequired => $overduenoticerequired,
+            category_type => $category_type,
+            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
+            default_privacy => $default_privacy,
+        });
+        eval {
+            $category->store;
+            $category->replace_branch_limitations( \@branches );
+        };
+
+        if ( $@ ) {
+            push @messages, { type => 'error', code => 'error_on_insert' };
+        } else {
+            push @messages, { type => 'message', code => 'success_on_insert' };
+        }
+    }
+
+    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
+        C4::Form::MessagingPreferences::handle_form_action( $input,
+            { categorycode => $input->param('categorycode') }, $template );
+    }
+
+    $searchfield = q||;
+    $op = 'list';
+}
+elsif ( $op eq 'delete_confirm' ) {
+
+    my $count = Koha::Borrowers->search({
+        categorycode => $categorycode
+    })->count;
+
+    my $category = Koha::Patron::Categories->find($categorycode);
+
+    $template->param(
+        category => $category,
+        patrons_in_category => $count,
+    );
+
+}
+elsif ( $op eq 'delete_confirmed' ) {
+    my $categorycode = uc( $input->param('categorycode') );
+
+    my $category = Koha::Patron::Categories->find( $categorycode );
+    my $deleted = eval { $category->delete; };
+
+    if ( $@ or not $deleted ) {
+        push @messages, {type => 'error', code => 'error_on_delete' };
+    } else {
+        push @messages, { type => 'message', code => 'success_on_delete' };
+    }
+
+    $op = 'list';
+}
+
+if ( $op eq 'list' ) {
+    my $categories = Koha::Patron::Categories->search(
+        {
+            description => { -like => "$searchfield%" }
+        },
+        {
+            order_by => ['category_type', 'description', 'categorycode' ]
+        }
+    );
+
+    $template->param(
+        categories => $categories,
+    )
+}
+
+$template->param(
+    categorycode => $categorycode,
+    searchfield  => $searchfield,
+    messages     => \@messages,
+    op => $op,
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
+
+exit 0;
index e38b0b4..7a8704f 100644 (file)
@@ -26,7 +26,7 @@
 
 <h5>Patrons and circulation</h5>
 <ul>
-       <li><a href="/cgi-bin/koha/admin/categorie.pl">Patron types and categories</a></li>
+       <li><a href="/cgi-bin/koha/admin/categories.pl">Patron types and categories</a></li>
     <li><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></li>
        <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
        <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
index 885654a..846439d 100644 (file)
@@ -40,7 +40,7 @@
 
 <h3>Patrons and circulation</h3>
 <dl>
-       <dt><a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a></dt>
+       <dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt>
        <dd>Define patron categories.</dd>
 [% IF CAN_user_parameters_manage_circ_rules %]
     <dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt
deleted file mode 100644 (file)
index 8d9e436..0000000
+++ /dev/null
@@ -1,500 +0,0 @@
-[% USE Koha %]
-[% USE KohaDates %]
-[% USE Price %]
-[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF op == 'add_form' %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
-[% IF op == 'delete_confirm' %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
-</title>
-[% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" id="js">
-//<![CDATA[
-    $(document).ready(function() {
-        $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "aoColumnDefs": [
-                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-                { "aTargets": [ 3,4,5 ], "sType": "natural" },
-            ],
-            "aaSorting": [[ 1, "asc" ]],
-            "sPaginationType": "four_button"
-        }));
-
-    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
-
-    if ( $("#branches option:selected").length < 1 ) {
-        $("#branches option:first").attr("selected", "selected");
-    }
-});
-       function isNotNull(f,noalert) {
-               if (f.value.length ==0) {
-   return false;
-               }
-               return true;
-       }
-       //
-       function isNum(v,maybenull) {
-       var n = new Number(v.value);
-       if (isNaN(n)) {
-               return false;
-               }
-       if (maybenull==0 && v.value=='') {
-               return false;
-       }
-       return true;
-       }
-       // to check if the data are correctly entered.
-       function Check(ff) {
-           var ok=0;
-               var _alertString=_("Form not submitted because of the following problem(s)");
-               _alertString +="\n-------------------------------------------------------------------\n\n";
-                ff.categorycode.value = $.trim(ff.categorycode.value);
-                if (ff.categorycode.value.length==0) {
-                   ok=1;
-                   _alertString += _("- categorycode missing") + "\n";
-                }
-                else{
-                   var patt=/^[a-zA-Z0-9\-_]+$/g;
-                   if ( !patt.test(ff.categorycode.value) ) {
-                      ok=1;
-                      _alertString += _("- category code can only contain the following characters: letters, numbers, - and _") + "\n";
-                   }
-                }
-               if (!(ff.category_type.value)){
-                   ok=1;
-                   _alertString += _("- category type missing") + "\n";
-               }
-               if (!(isNotNull(ff.description,1))) {
-                   ok=1;
-                       _alertString += _("- description missing") + "\n";
-               }
-               if (!isNum(ff.upperagelimit,0) && ff.category_type.value=='C') {
-                   ok=1;
-                       _alertString += _("- upperagelimit is not a number") + "\n";
-                               
-               }
-                if(!(ff.enrolmentperioddate.value || ff.enrolmentperiod.value)) {
-                    ok=1;
-                    _alertString += _("- either Enrollment period or Until date must be provided") + "\n";
-                }
-               if(ff.enrolmentperioddate.value && ff.enrolmentperiod.value){
-                       document.getElementById('enrolmentmessage').className = "error";
-                       return false;
-               }
-               
-               if (ok) { // if there is a problem
-                   alert(_alertString);
-                    return false;
-                }
-                // if all is good
-               ff.submit();
-       }
-       //]]>
-</script>
-<style type="text/css">#enrolmentmessage.hint { display : none; }</style>
-</head>
-<body id="admin_categorie" class="admin">
-[% INCLUDE 'header.inc' %]
-[% INCLUDE 'patrons-admin-search.inc' %]
-
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF op == 'add_form' %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
-[% IF op == 'delete_confirm' %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
-[% IF op == 'delete_confirmed' %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
-[% IF op == 'list' %]Patron categories[% END %]</div>
-
-<div id="doc3" class="yui-t2">
-   
-   <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
-
-[% FOR m IN messages %]
-    <div class="dialog [% m.type %]">
-        [% SWITCH m.code %]
-        [% CASE 'error_on_update' %]
-            An error occurred when updating this patron category. Perhaps it already exists.
-        [% CASE 'error_on_insert' %]
-            An error occurred when inserting this patron category. The patron category might already exist.
-        [% CASE 'error_on_delete' %]
-            An error occurred when deleting this patron category. Check the logs.
-        [% CASE 'success_on_update' %]
-            Patron category updated successfully.
-        [% CASE 'success_on_insert' %]
-            Patron category inserted successfully.
-        [% CASE 'success_on_delete' %]
-            Patron category deleted successfully.
-        [% CASE 'already_exists' %]
-            This patron category already exists.
-        [% CASE %]
-            [% m.code %]
-        [% END %]
-    </div>
-[% END %]
-
-[% IF op == 'add_form' %]
-    <form name="Aform" action="/cgi-bin/koha/admin/categorie.pl" method="post">
-        <input type="hidden" name="op" value="add_validate" />
-        <input type="hidden" name="checked" value="0" />
-        [% IF category %]
-            <h1>Modify category [% categorycode |html %]</h1>
-        [% ELSE %]
-            <h1>New category</h1>
-        [% END %]
-        <fieldset class="rows">
-            <ol>
-                [% IF category %]
-                    <li>
-                        <span class="label">Category code: </span>[% categorycode |html %]
-                        <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" /><input type="hidden" name="is_a_modif" value="1" />
-                    </li>
-                [% ELSE %]
-                    <li>
-                        <label for="categorycode" class="required">Category code: </label>
-                        <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" onblur="toUC(this)" />
-                        <span class="required">Required</span>
-                    </li>
-                [% END %]
-                <li>
-                    <label for="description" class="required">Description: </label>
-                    <input type="text" name="description" id="description" size="40" maxlength="80" value="[% category.description |html %]" />
-                    <span class="required">Required</span>
-                </li>
-                <li>
-                    <label for="enrolmentperiod" class="required">Enrollment period: </label>
-                    <fieldset>
-                        <legend>Choose one</legend>
-                        <ol>
-                            <li>
-                                <label for="enrolmentperiod" style="width:6em;">In months: </label>
-                                <input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
-                            </li>
-                            <li>
-                                <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
-                                <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
-                                <div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div>
-                            </li>
-                        </ol>
-                    </fieldset>
-                </li>
-                <li>
-                    <label for="dateofbirthrequired">Age required: </label>
-                    <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% category.dateofbirthrequired %]" size="3" maxlength="3" /> years
-                </li>
-                <li>
-                    <label for="upperagelimit">Upperage limit: </label>
-                    <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% category.upperagelimit %]" /> years
-                </li>
-                <li>
-                    <label for="enrolmentfee">Enrollment fee: </label>
-                    <input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% category.enrolmentfee | $Price on_editing => 1 %]" />
-                </li>
-                <li>
-                    <label for="overduenoticerequired">Overdue notice required: </label>
-                    <select name="overduenoticerequired" id="overduenoticerequired">
-                        [% IF category.overduenoticerequired %]
-                            <option value="0">No</option>
-                            <option value="1" selected="selected">Yes</option>
-                        [% ELSE %]
-                            <option value="0" selected="selected">No</option>
-                            <option value="1">Yes</option>
-                        [% END %]
-                    </select>
-                </li>
-                <li>
-                    <label for="hidelostitems">Lost items in staff client: </label>
-                    <select name="hidelostitems" id="hidelostitems">
-                        [% IF category.hidelostitems %]
-                            <option value="0">Shown</option>
-                            <option value="1" selected="selected">Hidden by default</option>
-                        [% ELSE %]
-                            <option value="0" selected="selected">Shown</option>
-                            <option value="1">Hidden by default</option>
-                        [% END %]
-                    </select>
-                </li>
-                <li>
-                    <label for="reservefee">Hold fee: </label>
-                    <input type="text" name="reservefee" id="reservefee" size="6" value="[% category.reservefee | $Price on_editing => 1 %]" />
-                </li>
-                <li>
-                    <label for="category_type" class="required">Category type: </label>
-                    <select name="category_type" id="category_type">
-                        [% UNLESS category %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %]
-                        [% IF category and category.category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
-                        [% IF category and category.category_type == 'C' %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
-                        [% IF category and category.category_type == 'S' %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
-                        [% IF category and category.category_type == 'I' %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
-                        [% IF category and category.category_type == 'P' %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
-                        [% IF category and category.category_type == 'X' %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
-                    </select>
-                    <span class="required">Required</span>
-                </li>
-                <li><label for="branches">Branches limitation: </label>
-                    <select id="branches" name="branches" multiple size="10">
-                        <option value="">All branches</option>
-                        [% FOREACH branch IN branches_loop %]
-                          [% IF branch.selected %]
-                            <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                          [% ELSE %]
-                            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
-                          [% END %]
-                        [% END %]
-                    </select>
-                    <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
-                    </span>
-                </li>
-                <li><label for="block_expired">Block expired patrons</label>
-                    <select name="BlockExpiredPatronOpacActions" id="block_expired">
-                        [% IF not category or category.BlockExpiredPatronOpacActions == -1%]
-                            <option value="-1" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
-                        [% ELSE %]
-                            <option value="-1"> Follow system preference BlockExpiredPatronOpacActions </option>
-                        [% END %]
-
-                        [% IF category and category.BlockExpiredPatronOpacActions == 1 %]
-                            <option value="1" selected="selected"> Block </option>
-                        [% ELSE %]
-                            <option value="1"> Block </option>
-                        [% END %]
-
-                        [% IF category and category.BlockExpiredPatronOpacActions == 0 %]
-                            <option value="0" selected="selected"> Don't block </option>
-                        [% ELSE %]
-                            <option value="0"> Don't block </option>
-                        [% END %]
-                    </select>
-                    <span>
-                        Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
-                    </span>
-                </li>
-                <li>
-                    <label for="default_privacy">Default privacy: </label>
-                    <select id="default_privacy" name="default_privacy">
-                        [% SET default_privacy = 'default' %]
-                        [% IF category %][% SET default_privacy = category.default_privacy %][% END %]
-                        [% SWITCH default_privacy %]
-                        [% CASE 'forever' %]
-                            <option value="default">Default</option>
-                            <option value="never">Never</option>
-                            <option value="forever" selected="selected">Forever</option>
-                        [% CASE 'never' %]
-                            <option value="default">Default</option>
-                            <option value="never" selected="selected">Never</option>
-                            <option value="forever">Forever</option>
-                        [% CASE %]
-                            <option value="default" selected="selected">Default</option>
-                            <option value="never">Never</option>
-                            <option value="forever">Forever</option>
-                        [% END %]
-                    </select>
-                    <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span>
-                </li>
-            </ol>
-        </fieldset>
-
-        [% IF ( EnhancedMessagingPreferences ) %]
-            <fieldset class="rows">
-                <h4>Default messaging preferences for this patron category</h4>
-                [% INCLUDE 'messaging-preference-form.inc' %]
-            </fieldset>
-        [% END %]
-        <fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
-    </form>
-[% END %]
-
-[% IF op == 'delete_confirm' %]
-    <form action="/cgi-bin/koha/admin/categorie.pl" method="post">
-        <fieldset>
-            <legend>
-                [% IF patrons_in_category > 0 %]
-                    Category [% categorycode |html %] is in use.  Deletion not possible!
-                [% ELSE %]
-                    Confirm deletion of category [% categorycode |html %]
-                [% END %]
-            </legend>
-
-            [% IF patrons_in_category > 0  %]
-                <div class="dialog alert">
-                    <strong>This category is used [% patrons_in_category %] times</strong>. Deletion not possible
-                </div>
-            [% END %]
-            <table>
-                <tr><th scope="row">Category code: </th><td>[% category.categorycode |html %]</td></tr>
-                <tr><th scope="row">Description: </th><td>[% category.description |html %]</td></tr>
-                <tr><th scope="row">Enrollment period: </th>
-                    <td>
-                        [% IF category.enrolmentperiod %]
-                            [% category.enrolmentperiod %] months
-                        [% ELSE %]
-                            until [% category.enrolmentperioddate | $KohaDates %]
-                        [% END %]
-                    </td>
-                </tr>
-                <tr><th scope="row">Age required: </th><td>[% category.dateofbirthrequired %] years</td></tr>
-                <tr><th scope="row">Upperage limit: </th><td>[% category.upperagelimit %] years</td></tr>
-                <tr><th scope="row">Enrollment fee: </th><td>[% category.enrolmentfee | $Price %]</td></tr>
-                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
-                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
-                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
-                <tr>
-                    <th scope="row">Default privacy: </th>
-                    <td>
-                        [% SWITCH category.default_privacy %]
-                        [% CASE 'default' %]
-                            Default
-                        [% CASE 'never' %]
-                            Never
-                        [% CASE 'forever' %]
-                            Forever
-                        [% END %]
-                    </td>
-                </tr>
-            </table>
-            <fieldset class="action">
-                [% IF patrons_in_category > 0 %]
-                    <input type="submit" value="OK" />
-                [% ELSE %]
-                    <input type="hidden" name="op" value="delete_confirmed" />
-                    <input type="hidden" name="categorycode" value="[% categorycode |html %]" />
-                    <input type="submit" value="Delete this category" />
-                    <a class="cancel" href="/cgi-bin/koha/admin/categorie.pl">Cancel</a>
-                [% END %]
-            </fieldset>
-        </fieldset>
-    </form>
-[% END %]
-
-[% IF op == 'list' %]
-
-    <div id="toolbar" class="btn-toolbar">
-        <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/categorie.pl?op=add_form"><i class="fa fa-plus"></i> New category</a>
-    </div>
-
-    <h2>Patron category administration</h2>
-    [% IF searchfield %]
-        You Searched for [% searchfield %]</span>
-    [% END %]
-    [% IF categories%]
-        <table id="table_categorie">
-            <thead>
-                <tr>
-                    <th scope="col">Code</th>
-                    <th scope="col">Category name</th>
-                    <th scope="col">Type</th>
-                    <th scope="col">Enrollment period</th>
-                    <th scope="col">Age required</th>
-                    <th scope="col">Upper age limit</th>
-                    <th scope="col">Enrollment fee</th>
-                    <th scope="col">Overdue</th>
-                    <th scope="col">Lost items</th>
-                    <th scope="col">Hold fee</th>
-                    [% IF ( EnhancedMessagingPreferences ) %]
-                    <th scope="col">Messaging</th>
-                    [% END %]
-                    <th scope="col">Branches limitations</th>
-                    <th scope="col">Default privacy</th>
-                    <th scope="col">&nbsp; </th>
-                    <th scope="col">&nbsp; </th>
-                </tr>
-            </thead>
-            <tbody>
-                [% FOREACH category IN categories %]
-                    <tr>
-                        <td>[% category.categorycode |html %]</td>
-                        <td>
-                            <a href="/cgi-bin/koha/admin/categorie.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">[% category.description |html %]</a>
-                        </td>
-                        <td>
-                            [% SWITCH category.category_type %]
-                                [% CASE 'A' %]Adult
-                                [% CASE 'C' %]Child
-                                [% CASE 'P' %]Prof.
-                                [% CASE 'I' %]Org.
-                                [% CASE 'S' %]Staff
-                                [% CASE 'X' %]Statistical
-                            [% END %]
-                        </td>
-                        <td>
-                            [% IF ( category.enrolmentperiod ) %]
-                                [% category.enrolmentperiod %] months
-                            [% ELSE %]
-                                until [% category.enrolmentperioddate | $KohaDates %]
-                            [% END %]
-                        </td>
-                        <td>[% category.dateofbirthrequired %] years</td>
-                        <td>[% category.upperagelimit %] years</td>
-                        <td>[% category.enrolmentfee | $Price %]</td>
-                        <td>[% IF ( category.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
-                        <td>[% IF ( category.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
-                        <td>[% category.reservefee | $Price %]</td>
-                        [% IF Koha.Preference('EnhancedMessagingPreferences') %]
-                            <td style="white-space: nowrap; font-size:80%;">
-                                [% SET default_messaging = category.default_messaging %]
-                                [% IF default_messaging.size %]
-                                    [% FOREACH prefs IN default_messaging %]
-                                        [% FOREACH transport IN prefs.transports %]
-                                            [% IF ( transport.transport ) %]
-                                                [% IF ( prefs.Item_Due ) %]Item due
-                                                [% ELSIF ( prefs.Advance_Notice ) %]Advance notice
-                                                [% ELSIF ( prefs.Upcoming_Events ) %]Upcoming events
-                                                [% ELSIF ( prefs.Hold_Filled ) %]Hold filled
-                                                [% ELSIF ( prefs.Item_Check_in ) %]Item check-in
-                                                [% ELSIF ( prefs.Item_Checkout ) %]Item checkout
-                                                [% ELSE %]Unknown
-                                                [% END %]:
-                                                <strong>[% transport.transport %]</strong><br />
-                                            [% ELSE %]None<br />[% END %]
-                                        [% END %]
-                                    [% END %]
-                                [% ELSE %]
-                                    None
-                                [% END %]
-                            </td>
-                        [% END %]
-                        <td>
-                            [% SET branch_limitations = category.branch_limitations %]
-                            [% IF branch_limitations.size > 0 %]
-                                [% branches_str = "" %]
-                                [% FOREACH branch IN branch_limitations %]
-                                    [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
-                                [% END %]
-                                <span title="[% branches_str %]">
-                                    [% IF branch_limitations.size > 1 %]
-                                        [% branch_limitations.size %] branches limitations
-                                    [% ELSE %]
-                                        [% branch_limitations.size %] branch limitation
-                                    [% END %]
-                                </span>
-                            [% ELSE %]
-                                No limitation
-                            [% END %]
-                        </td>
-                        <td>
-                            [% SWITCH category.default_privacy %]
-                            [% CASE 'default' %]
-                                Default
-                            [% CASE 'never' %]
-                                Never
-                            [% CASE 'forever' %]
-                                Forever
-                            [% END %]
-                        </td>
-                        <td><a href="/cgi-bin/koha/admin/categorie.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">Edit</a></td>
-                        <td><a href="/cgi-bin/koha/admin/categorie.pl?op=delete_confirm&amp;categorycode=[% category.categorycode |uri %]">Delete</a></td>
-                    </tr>
-                [% END %]
-            </tbody>
-        </table>
-    [% ELSE %]
-        <div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categorie.pl?op=add_form">Create a new category</a>.</div>
-    [% END %]
-[% END %]
-
-</div>
-</div>
-<div class="yui-b">
-[% INCLUDE 'admin-menu.inc' %]
-</div>
-</div>
-[% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
new file mode 100644 (file)
index 0000000..1e74c1b
--- /dev/null
@@ -0,0 +1,500 @@
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Price %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF op == 'add_form' %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
+[% IF op == 'delete_confirm' %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
+</title>
+[% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+[% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" id="js">
+//<![CDATA[
+    $(document).ready(function() {
+        $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
+                { "aTargets": [ 3,4,5 ], "sType": "natural" },
+            ],
+            "aaSorting": [[ 1, "asc" ]],
+            "sPaginationType": "four_button"
+        }));
+
+    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
+
+    if ( $("#branches option:selected").length < 1 ) {
+        $("#branches option:first").attr("selected", "selected");
+    }
+});
+       function isNotNull(f,noalert) {
+               if (f.value.length ==0) {
+   return false;
+               }
+               return true;
+       }
+       //
+       function isNum(v,maybenull) {
+       var n = new Number(v.value);
+       if (isNaN(n)) {
+               return false;
+               }
+       if (maybenull==0 && v.value=='') {
+               return false;
+       }
+       return true;
+       }
+       // to check if the data are correctly entered.
+       function Check(ff) {
+           var ok=0;
+               var _alertString=_("Form not submitted because of the following problem(s)");
+               _alertString +="\n-------------------------------------------------------------------\n\n";
+                ff.categorycode.value = $.trim(ff.categorycode.value);
+                if (ff.categorycode.value.length==0) {
+                   ok=1;
+                   _alertString += _("- categorycode missing") + "\n";
+                }
+                else{
+                   var patt=/^[a-zA-Z0-9\-_]+$/g;
+                   if ( !patt.test(ff.categorycode.value) ) {
+                      ok=1;
+                      _alertString += _("- category code can only contain the following characters: letters, numbers, - and _") + "\n";
+                   }
+                }
+               if (!(ff.category_type.value)){
+                   ok=1;
+                   _alertString += _("- category type missing") + "\n";
+               }
+               if (!(isNotNull(ff.description,1))) {
+                   ok=1;
+                       _alertString += _("- description missing") + "\n";
+               }
+               if (!isNum(ff.upperagelimit,0) && ff.category_type.value=='C') {
+                   ok=1;
+                       _alertString += _("- upperagelimit is not a number") + "\n";
+                               
+               }
+                if(!(ff.enrolmentperioddate.value || ff.enrolmentperiod.value)) {
+                    ok=1;
+                    _alertString += _("- either Enrollment period or Until date must be provided") + "\n";
+                }
+               if(ff.enrolmentperioddate.value && ff.enrolmentperiod.value){
+                       document.getElementById('enrolmentmessage').className = "error";
+                       return false;
+               }
+               
+               if (ok) { // if there is a problem
+                   alert(_alertString);
+                    return false;
+                }
+                // if all is good
+               ff.submit();
+       }
+       //]]>
+</script>
+<style type="text/css">#enrolmentmessage.hint { display : none; }</style>
+</head>
+<body id="admin_categorie" class="admin">
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'patrons-admin-search.inc' %]
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF op == 'add_form' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
+[% IF op == 'delete_confirm' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
+[% IF op == 'delete_confirmed' %] <a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
+[% IF op == 'list' %]Patron categories[% END %]</div>
+
+<div id="doc3" class="yui-t2">
+   
+   <div id="bd">
+       <div id="yui-main">
+       <div class="yui-b">
+
+[% FOR m IN messages %]
+    <div class="dialog [% m.type %]">
+        [% SWITCH m.code %]
+        [% CASE 'error_on_update' %]
+            An error occurred when updating this patron category. Perhaps it already exists.
+        [% CASE 'error_on_insert' %]
+            An error occurred when inserting this patron category. The patron category might already exist.
+        [% CASE 'error_on_delete' %]
+            An error occurred when deleting this patron category. Check the logs.
+        [% CASE 'success_on_update' %]
+            Patron category updated successfully.
+        [% CASE 'success_on_insert' %]
+            Patron category inserted successfully.
+        [% CASE 'success_on_delete' %]
+            Patron category deleted successfully.
+        [% CASE 'already_exists' %]
+            This patron category already exists.
+        [% CASE %]
+            [% m.code %]
+        [% END %]
+    </div>
+[% END %]
+
+[% IF op == 'add_form' %]
+    <form name="Aform" action="/cgi-bin/koha/admin/categories.pl" method="post">
+        <input type="hidden" name="op" value="add_validate" />
+        <input type="hidden" name="checked" value="0" />
+        [% IF category %]
+            <h1>Modify category [% categorycode |html %]</h1>
+        [% ELSE %]
+            <h1>New category</h1>
+        [% END %]
+        <fieldset class="rows">
+            <ol>
+                [% IF category %]
+                    <li>
+                        <span class="label">Category code: </span>[% categorycode |html %]
+                        <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" /><input type="hidden" name="is_a_modif" value="1" />
+                    </li>
+                [% ELSE %]
+                    <li>
+                        <label for="categorycode" class="required">Category code: </label>
+                        <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" onblur="toUC(this)" />
+                        <span class="required">Required</span>
+                    </li>
+                [% END %]
+                <li>
+                    <label for="description" class="required">Description: </label>
+                    <input type="text" name="description" id="description" size="40" maxlength="80" value="[% category.description |html %]" />
+                    <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="enrolmentperiod" class="required">Enrollment period: </label>
+                    <fieldset>
+                        <legend>Choose one</legend>
+                        <ol>
+                            <li>
+                                <label for="enrolmentperiod" style="width:6em;">In months: </label>
+                                <input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
+                            </li>
+                            <li>
+                                <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
+                                <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
+                                <div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div>
+                            </li>
+                        </ol>
+                    </fieldset>
+                </li>
+                <li>
+                    <label for="dateofbirthrequired">Age required: </label>
+                    <input type="text" name="dateofbirthrequired" id="dateofbirthrequired" value="[% category.dateofbirthrequired %]" size="3" maxlength="3" /> years
+                </li>
+                <li>
+                    <label for="upperagelimit">Upperage limit: </label>
+                    <input type="text" name="upperagelimit" id="upperagelimit" size="3" maxlength="3" value="[% category.upperagelimit %]" /> years
+                </li>
+                <li>
+                    <label for="enrolmentfee">Enrollment fee: </label>
+                    <input type="text" name="enrolmentfee" id="enrolmentfee" size="6" value="[% category.enrolmentfee | $Price on_editing => 1 %]" />
+                </li>
+                <li>
+                    <label for="overduenoticerequired">Overdue notice required: </label>
+                    <select name="overduenoticerequired" id="overduenoticerequired">
+                        [% IF category.overduenoticerequired %]
+                            <option value="0">No</option>
+                            <option value="1" selected="selected">Yes</option>
+                        [% ELSE %]
+                            <option value="0" selected="selected">No</option>
+                            <option value="1">Yes</option>
+                        [% END %]
+                    </select>
+                </li>
+                <li>
+                    <label for="hidelostitems">Lost items in staff client: </label>
+                    <select name="hidelostitems" id="hidelostitems">
+                        [% IF category.hidelostitems %]
+                            <option value="0">Shown</option>
+                            <option value="1" selected="selected">Hidden by default</option>
+                        [% ELSE %]
+                            <option value="0" selected="selected">Shown</option>
+                            <option value="1">Hidden by default</option>
+                        [% END %]
+                    </select>
+                </li>
+                <li>
+                    <label for="reservefee">Hold fee: </label>
+                    <input type="text" name="reservefee" id="reservefee" size="6" value="[% category.reservefee | $Price on_editing => 1 %]" />
+                </li>
+                <li>
+                    <label for="category_type" class="required">Category type: </label>
+                    <select name="category_type" id="category_type">
+                        [% UNLESS category %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %]
+                        [% IF category and category.category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %]
+                        [% IF category and category.category_type == 'C' %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %]
+                        [% IF category and category.category_type == 'S' %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %]
+                        [% IF category and category.category_type == 'I' %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %]
+                        [% IF category and category.category_type == 'P' %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
+                        [% IF category and category.category_type == 'X' %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
+                    </select>
+                    <span class="required">Required</span>
+                </li>
+                <li><label for="branches">Branches limitation: </label>
+                    <select id="branches" name="branches" multiple size="10">
+                        <option value="">All branches</option>
+                        [% FOREACH branch IN branches_loop %]
+                          [% IF branch.selected %]
+                            <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
+                          [% ELSE %]
+                            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
+                          [% END %]
+                        [% END %]
+                    </select>
+                    <span>Select <i>All branches</i> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
+                    </span>
+                </li>
+                <li><label for="block_expired">Block expired patrons</label>
+                    <select name="BlockExpiredPatronOpacActions" id="block_expired">
+                        [% IF not category or category.BlockExpiredPatronOpacActions == -1%]
+                            <option value="-1" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
+                        [% ELSE %]
+                            <option value="-1"> Follow system preference BlockExpiredPatronOpacActions </option>
+                        [% END %]
+
+                        [% IF category and category.BlockExpiredPatronOpacActions == 1 %]
+                            <option value="1" selected="selected"> Block </option>
+                        [% ELSE %]
+                            <option value="1"> Block </option>
+                        [% END %]
+
+                        [% IF category and category.BlockExpiredPatronOpacActions == 0 %]
+                            <option value="0" selected="selected"> Don't block </option>
+                        [% ELSE %]
+                            <option value="0"> Don't block </option>
+                        [% END %]
+                    </select>
+                    <span>
+                        Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired.
+                    </span>
+                </li>
+                <li>
+                    <label for="default_privacy">Default privacy: </label>
+                    <select id="default_privacy" name="default_privacy">
+                        [% SET default_privacy = 'default' %]
+                        [% IF category %][% SET default_privacy = category.default_privacy %][% END %]
+                        [% SWITCH default_privacy %]
+                        [% CASE 'forever' %]
+                            <option value="default">Default</option>
+                            <option value="never">Never</option>
+                            <option value="forever" selected="selected">Forever</option>
+                        [% CASE 'never' %]
+                            <option value="default">Default</option>
+                            <option value="never" selected="selected">Never</option>
+                            <option value="forever">Forever</option>
+                        [% CASE %]
+                            <option value="default" selected="selected">Default</option>
+                            <option value="never">Never</option>
+                            <option value="forever">Forever</option>
+                        [% END %]
+                    </select>
+                    <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span>
+                </li>
+            </ol>
+        </fieldset>
+
+        [% IF ( EnhancedMessagingPreferences ) %]
+            <fieldset class="rows">
+                <h4>Default messaging preferences for this patron category</h4>
+                [% INCLUDE 'messaging-preference-form.inc' %]
+            </fieldset>
+        [% END %]
+        <fieldset class="action"><input type="button" value="Save" onclick="Check(this.form);" /> </fieldset>
+    </form>
+[% END %]
+
+[% IF op == 'delete_confirm' %]
+    <form action="/cgi-bin/koha/admin/categories.pl" method="post">
+        <fieldset>
+            <legend>
+                [% IF patrons_in_category > 0 %]
+                    Category [% categorycode |html %] is in use.  Deletion not possible!
+                [% ELSE %]
+                    Confirm deletion of category [% categorycode |html %]
+                [% END %]
+            </legend>
+
+            [% IF patrons_in_category > 0  %]
+                <div class="dialog alert">
+                    <strong>This category is used [% patrons_in_category %] times</strong>. Deletion not possible
+                </div>
+            [% END %]
+            <table>
+                <tr><th scope="row">Category code: </th><td>[% category.categorycode |html %]</td></tr>
+                <tr><th scope="row">Description: </th><td>[% category.description |html %]</td></tr>
+                <tr><th scope="row">Enrollment period: </th>
+                    <td>
+                        [% IF category.enrolmentperiod %]
+                            [% category.enrolmentperiod %] months
+                        [% ELSE %]
+                            until [% category.enrolmentperioddate | $KohaDates %]
+                        [% END %]
+                    </td>
+                </tr>
+                <tr><th scope="row">Age required: </th><td>[% category.dateofbirthrequired %] years</td></tr>
+                <tr><th scope="row">Upperage limit: </th><td>[% category.upperagelimit %] years</td></tr>
+                <tr><th scope="row">Enrollment fee: </th><td>[% category.enrolmentfee | $Price %]</td></tr>
+                <tr><th scope="row">Receives overdue notices: </th><td>[% IF category. overduenoticerequired %]Yes[% ELSE %]No[% END %]</td></tr>
+                <tr><th scope="row">Lost items in staff client</th><td>[% IF category.hidelostitems %]Hidden by default[% ELSE %]Shown[% END %]</td></tr>
+                <tr><th scope="row">Hold fee: </th><td>[% category.reservefee | $Price %]</td></tr>
+                <tr>
+                    <th scope="row">Default privacy: </th>
+                    <td>
+                        [% SWITCH category.default_privacy %]
+                        [% CASE 'default' %]
+                            Default
+                        [% CASE 'never' %]
+                            Never
+                        [% CASE 'forever' %]
+                            Forever
+                        [% END %]
+                    </td>
+                </tr>
+            </table>
+            <fieldset class="action">
+                [% IF patrons_in_category > 0 %]
+                    <input type="submit" value="OK" />
+                [% ELSE %]
+                    <input type="hidden" name="op" value="delete_confirmed" />
+                    <input type="hidden" name="categorycode" value="[% categorycode |html %]" />
+                    <input type="submit" value="Delete this category" />
+                    <a class="cancel" href="/cgi-bin/koha/admin/categories.pl">Cancel</a>
+                [% END %]
+            </fieldset>
+        </fieldset>
+    </form>
+[% END %]
+
+[% IF op == 'list' %]
+
+    <div id="toolbar" class="btn-toolbar">
+        <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/categories.pl?op=add_form"><i class="fa fa-plus"></i> New category</a>
+    </div>
+
+    <h2>Patron category administration</h2>
+    [% IF searchfield %]
+        You Searched for [% searchfield %]</span>
+    [% END %]
+    [% IF categories%]
+        <table id="table_categorie">
+            <thead>
+                <tr>
+                    <th scope="col">Code</th>
+                    <th scope="col">Category name</th>
+                    <th scope="col">Type</th>
+                    <th scope="col">Enrollment period</th>
+                    <th scope="col">Age required</th>
+                    <th scope="col">Upper age limit</th>
+                    <th scope="col">Enrollment fee</th>
+                    <th scope="col">Overdue</th>
+                    <th scope="col">Lost items</th>
+                    <th scope="col">Hold fee</th>
+                    [% IF ( EnhancedMessagingPreferences ) %]
+                    <th scope="col">Messaging</th>
+                    [% END %]
+                    <th scope="col">Branches limitations</th>
+                    <th scope="col">Default privacy</th>
+                    <th scope="col">&nbsp; </th>
+                    <th scope="col">&nbsp; </th>
+                </tr>
+            </thead>
+            <tbody>
+                [% FOREACH category IN categories %]
+                    <tr>
+                        <td>[% category.categorycode |html %]</td>
+                        <td>
+                            <a href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">[% category.description |html %]</a>
+                        </td>
+                        <td>
+                            [% SWITCH category.category_type %]
+                                [% CASE 'A' %]Adult
+                                [% CASE 'C' %]Child
+                                [% CASE 'P' %]Prof.
+                                [% CASE 'I' %]Org.
+                                [% CASE 'S' %]Staff
+                                [% CASE 'X' %]Statistical
+                            [% END %]
+                        </td>
+                        <td>
+                            [% IF ( category.enrolmentperiod ) %]
+                                [% category.enrolmentperiod %] months
+                            [% ELSE %]
+                                until [% category.enrolmentperioddate | $KohaDates %]
+                            [% END %]
+                        </td>
+                        <td>[% category.dateofbirthrequired %] years</td>
+                        <td>[% category.upperagelimit %] years</td>
+                        <td>[% category.enrolmentfee | $Price %]</td>
+                        <td>[% IF ( category.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]</td>
+                        <td>[% IF ( category.hidelostitems ) %]Hidden[% ELSE %]Shown[% END %]</td>
+                        <td>[% category.reservefee | $Price %]</td>
+                        [% IF Koha.Preference('EnhancedMessagingPreferences') %]
+                            <td style="white-space: nowrap; font-size:80%;">
+                                [% SET default_messaging = category.default_messaging %]
+                                [% IF default_messaging.size %]
+                                    [% FOREACH prefs IN default_messaging %]
+                                        [% FOREACH transport IN prefs.transports %]
+                                            [% IF ( transport.transport ) %]
+                                                [% IF ( prefs.Item_Due ) %]Item due
+                                                [% ELSIF ( prefs.Advance_Notice ) %]Advance notice
+                                                [% ELSIF ( prefs.Upcoming_Events ) %]Upcoming events
+                                                [% ELSIF ( prefs.Hold_Filled ) %]Hold filled
+                                                [% ELSIF ( prefs.Item_Check_in ) %]Item check-in
+                                                [% ELSIF ( prefs.Item_Checkout ) %]Item checkout
+                                                [% ELSE %]Unknown
+                                                [% END %]:
+                                                <strong>[% transport.transport %]</strong><br />
+                                            [% ELSE %]None<br />[% END %]
+                                        [% END %]
+                                    [% END %]
+                                [% ELSE %]
+                                    None
+                                [% END %]
+                            </td>
+                        [% END %]
+                        <td>
+                            [% SET branch_limitations = category.branch_limitations %]
+                            [% IF branch_limitations.size > 0 %]
+                                [% branches_str = "" %]
+                                [% FOREACH branch IN branch_limitations %]
+                                    [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
+                                [% END %]
+                                <span title="[% branches_str %]">
+                                    [% IF branch_limitations.size > 1 %]
+                                        [% branch_limitations.size %] branches limitations
+                                    [% ELSE %]
+                                        [% branch_limitations.size %] branch limitation
+                                    [% END %]
+                                </span>
+                            [% ELSE %]
+                                No limitation
+                            [% END %]
+                        </td>
+                        <td>
+                            [% SWITCH category.default_privacy %]
+                            [% CASE 'default' %]
+                                Default
+                            [% CASE 'never' %]
+                                Never
+                            [% CASE 'forever' %]
+                                Forever
+                            [% END %]
+                        </td>
+                        <td><a href="/cgi-bin/koha/admin/categories.pl?op=add_form&amp;categorycode=[% category.categorycode |uri %]">Edit</a></td>
+                        <td><a href="/cgi-bin/koha/admin/categories.pl?op=delete_confirm&amp;categorycode=[% category.categorycode |uri %]">Delete</a></td>
+                    </tr>
+                [% END %]
+            </tbody>
+        </table>
+    [% ELSE %]
+        <div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categories.pl?op=add_form">Create a new category</a>.</div>
+    [% END %]
+[% END %]
+
+</div>
+</div>
+<div class="yui-b">
+[% INCLUDE 'admin-menu.inc' %]
+</div>
+</div>
+[% INCLUDE 'intranet-bottom.inc' %]
index 49971b7..411e8d2 100644 (file)
@@ -321,7 +321,7 @@ function filterByFirstLetterSurname(letter) {
                 <p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>
               [% END %]
               [% IF ( no_categories ) %]
-                <p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>
+                <p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categories.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>
               [% END %]
             </div>
           [% END %]
index 429242c..6b01119 100644 (file)
 
        [% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
             [% IF ( no_branches ) %]<p><strong>There are no libraries defined.</strong> [% IF ( CAN_user_parameters ) %]<a href="/cgi-bin/koha/admin/branches.pl">Please add a library.</a>[% ELSE %]An administrator must define at least one library.[% END %]</p>[% END %]
-            [% IF ( no_categories ) %]<p><strong>There are no patron categories defined.</strong> [% IF ( CAN_user_parameters ) %]<a href="/cgi-bin/koha/admin/categorie.pl">Please add a patron category.</a>[% ELSE %]An administrator must define at least one patron category.</p>[% END %][% END %]</div>[% END %]
+            [% IF ( no_categories ) %]<p><strong>There are no patron categories defined.</strong> [% IF ( CAN_user_parameters ) %]<a href="/cgi-bin/koha/admin/categories.pl">Please add a patron category.</a>[% ELSE %]An administrator must define at least one patron category.</p>[% END %][% END %]</div>[% END %]
 
        [% UNLESS ( no_add ) %]
     <h1>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</h1>
index e561859..ed422c7 100644 (file)
@@ -167,7 +167,7 @@ $(document).ready(function() {
             </form>
             [% ELSE %]
                 <div class="warning">You don't have patron categories defined, or the patron categories are not set to receive overdue notices.</div>
-                <div class="warning">If this is not what you were expecting, go to <a href="../admin/categorie.pl">patron categories</p></div>
+                <div class="warning">If this is not what you were expecting, go to <a href="../admin/categories.pl">patron categories</p></div>
             [% END %]
     </div>
     </div>