classification sources part 1 - system preferences

Database schema definitions and system preferences support
for defining classification sources and filing rules.

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Galen Charlton 2007-10-21 21:23:25 -05:00 committed by Joshua Ferraro
parent c3c520b385
commit 43d3efe391
11 changed files with 1017 additions and 2 deletions

329
C4/ClassSource.pm Normal file
View file

@ -0,0 +1,329 @@
package C4::ClassSource;
# Copyright (C) 2007 LibLime
#
# 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
require Exporter;
use C4::Context;
use C4::Koha;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 3.00;
=head1 NAME
C4::ClassSources - handle classification sources in Koha
=head1 SYNOPSIS
use C4::ClassSource;
=head1 DESCRIPTION
This module deals with manipulating classification
sources and sorting rules.
=head1 FUNCTIONS
=cut
@ISA = qw(Exporter);
@EXPORT = qw(
&GetClassSources
&AddClassSource
&GetClassSource
&ModClassSource
&DelClassSource
&GetClassSortRules
&AddClassSortRule
&GetClassSortRule
&ModClassSortRule
&DelClassSortRule
&GetSourcesForSortRule
);
=head2 GetClassSources
my $sources = GetClassSources();
Returns reference to hash of references to
the class sources, keyed on cn_source.
=head3 Example
my $sources = GetClassSources();
my @sources = ();
foreach my $cn_source (sort keys %$sources) {
my $source = $sources->{$cn_source};
push @sources,
{
code => $source->{'cn_source'},
description => $source->{'description'},
used => $source->{'used'},
sortrule => $source->{'class_sort_rule'}
}
}
=cut
sub GetClassSources {
my %class_sources = ();
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources`");
$sth->execute();
while (my $source = $sth->fetchrow_hashref) {
$class_sources{ $source->{'cn_source'} } = $source;
}
$sth->finish();
return \%class_sources;
}
=head2 AddClassSource
AddClassSource($cn_source, $description, $used, $class_sort_rule);
Adds a class_sources row.
=cut
sub AddClassSource {
my ($cn_source, $description, $used, $class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("INSERT INTO `class_sources`
(`cn_source`, `description`, `used`, `class_sort_rule`)
VALUES (?, ?, ?, ?)");
$sth->execute($cn_source, $description, $used, $class_sort_rule);
$sth->finish();
}
=head2 GetClassSource
my $hashref = GetClassSource($cn_source);
Retrieves a class_sources row by cn_source.
=cut
sub GetClassSource {
my ($cn_source) = (@_);
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources` WHERE cn_source = ?");
$sth->execute($cn_source);
my $row = $sth->fetchrow_hashref();
$sth->finish();
return $row;
}
=head2 ModClassSource
ModClassSource($cn_source, $description, $used, $class_sort_rule);
Updates a class_sources row.
=cut
sub ModClassSource {
my ($cn_source, $description, $used, $class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("UPDATE `class_sources`
SET `description` = ?,
`used` = ?,
`class_sort_rule` = ?
WHERE `cn_source` = ?");
$sth->execute($description, $used, $class_sort_rule, $cn_source);
$sth->finish();
}
=head2 DelClassSource
DelClassSource($cn_source);
Deletes class_sources row.
=cut
sub DelClassSource {
my ($cn_source) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("DELETE FROM `class_sources` WHERE `cn_source` = ?");
$sth->execute($cn_source);
$sth->finish();
}
=head2 GetClassSortRules
my $sort_rules = GetClassSortRules();
Returns reference to hash of references to
the class sorting rules, keyed on class_sort_rule
=head3 Example
my $sort_rules = GetClassSortRules();
my @sort_rules = ();
foreach my $sort_rule (sort keys %$sort_rules) {
my $sort_rule = $sort_rules->{$sort_rule};
push @sort_rules,
{
rule => $sort_rule->{'class_sort_rule'},
description => $sort_rule->{'description'},
sort_routine => $sort_rule->{'sort_routine'}
}
}
=cut
sub GetClassSortRules {
my %class_sort_rules = ();
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules`");
$sth->execute();
while (my $sort_rule = $sth->fetchrow_hashref) {
$class_sort_rules{ $sort_rule->{'class_sort_rule'} } = $sort_rule;
}
$sth->finish();
return \%class_sort_rules;
}
=head2 AddClassSortRule
AddClassSortRule($class_sort_rule, $description, $sort_routine);
Adds a class_sort_rules row.
=cut
sub AddClassSortRule {
my ($class_sort_rule, $description, $sort_routine) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("INSERT INTO `class_sort_rules`
(`class_sort_rule`, `description`, `sort_routine`)
VALUES (?, ?, ?)");
$sth->execute($class_sort_rule, $description, $sort_routine);
$sth->finish();
}
=head2 GetClassSortRule
my $hashref = GetClassSortRule($class_sort_rule);
Retrieves a class_sort_rules row by class_sort_rule.
=cut
sub GetClassSortRule {
my ($class_sort_rule) = (@_);
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
$sth->execute($class_sort_rule);
my $row = $sth->fetchrow_hashref();
$sth->finish();
return $row;
}
=head2 ModClassSortRule
ModClassSortRule($class_sort_rule, $description, $sort_routine);
Updates a class_sort_rules row.
=cut
sub ModClassSortRule {
my ($class_sort_rule, $description, $sort_routine) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("UPDATE `class_sort_rules`
SET `description` = ?,
`sort_routine` = ?
WHERE `class_sort_rule` = ?");
$sth->execute($description, $sort_routine, $class_sort_rule);
$sth->finish();
}
=head2 DelClassSortRule
DelClassSortRule($class_sort_rule);
Deletes class_sort_rules row.
=cut
sub DelClassSortRule {
my ($class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("DELETE FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
$sth->execute($class_sort_rule);
$sth->finish();
}
=head2 GetSourcesForSortRule
my @source = GetSourcesForSortRule($class_sort_rule);
Retrieves an array class_source.cn_rule for each source
that uses the supplied $class_sort_rule.
=cut
sub GetSourcesForSortRule {
my ($class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare_cached("SELECT cn_source FROM class_sources WHERE class_sort_rule = ?");
$sth->execute($class_sort_rule);
my @sources = ();
while (my ($source) = $sth->fetchrow_array()) {
push @sources, $source;
}
$sth->finish();
return @sources;
}
1;
=head1 AUTHOR
Koha Developement team <info@koha.org>
=cut

276
admin/classsources.pl Executable file
View file

@ -0,0 +1,276 @@
#! /usr/bin/perl
#
# Copyright 2007 LibLime
#
# 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
use strict;
use CGI;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Koha;
use C4::ClassSource;
my $script_name = "/cgi-bin/koha/admin/classsources.pl";
my $input = new CGI;
my $op = $input->param('op');
my $source_code = $input->param('class_source');
my $rule_code = $input->param('sort_rule');
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "admin/classsources.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {parameters => 1},
debug => 1,
});
if ($op) {
$template->param(script_name => $script_name, $op => 1);
} else {
$template->param(script_name => $script_name);
}
my $display_lists = 0;
if ($op eq "add_source") {
add_class_source_form($template);
} elsif ($op eq "add_source_confirmed") {
add_class_source($template,
$source_code,
$input->param('description'),
$input->param('used') eq "used" ? 1 : 0,
$rule_code);
$display_lists = 1;
} elsif ($op eq "delete_source") {
delete_class_source_form($template);
} elsif ($op eq "delete_source_confirmed") {
delete_class_source($template, $source_code);
$display_lists = 1;
} elsif ($op eq "edit_source") {
edit_class_source_form($template, $source_code);
} elsif ($op eq "edit_source_confirmed") {
edit_class_source($template,
$source_code,
$input->param('description'),
$input->param('used') eq "used" ? 1 : 0,
$rule_code);
$display_lists = 1;
} elsif ($op eq "add_sort_rule") {
add_class_sort_rule_form($template);
} elsif ($op eq "add_sort_rule_confirmed") {
add_class_sort_rule($template,
$rule_code,
$input->param('description'),
$input->param('sort_routine'));
$display_lists = 1;
} elsif ($op eq "delete_sort_rule") {
delete_sort_rule_form($template, $rule_code);
} elsif ($op eq "delete_sort_rule_confirmed") {
delete_sort_rule($template, $rule_code);
$display_lists = 1;
} elsif ($op eq "edit_sort_rule") {
edit_class_sort_rule_form($template, $rule_code);
} elsif ($op eq "edit_sort_rule_confirmed") {
edit_class_sort_rule($template,
$rule_code,
$input->param('description'),
$input->param('sort_routine'));
$display_lists = 1;
} else {
$display_lists = 1;
}
if ($display_lists) {
$template->param(display_lists => 1);
class_source_list($template);
class_sort_rule_list($template);
}
output_html_with_http_headers $input, $cookie, $template->output;
exit 0;
sub add_class_source_form {
my ($template) = @_;
$template->param(
class_source_form => 1,
confirm_op => "add_source_confirmed",
used => 0
);
get_sort_rule_codes($template, '');
}
sub add_class_source {
my ($template, $source_code, $description, $used, $sort_rule) = @_;
AddClassSource($source_code, $description, $used, $sort_rule);
$template->param(added_source => $source_code);
}
sub edit_class_source_form {
my ($template, $source_code) = @_;
my $source = GetClassSource($source_code);
$template->param(
class_source_form => 1,
edit_class_source => 1,
class_source => $source_code,
confirm_op => "edit_source_confirmed",
description => $source->{'description'},
used => $source->{'used'},
);
get_sort_rule_codes($template, $source->{'rule_code'});
}
sub edit_class_source {
my ($template, $source_code, $description, $used, $sort_rule) = @_;
ModClassSource($source_code, $description, $used, $sort_rule);
$template->param(edited_source => $source_code);
}
sub delete_class_source_form {
my ($template) = @_;
$template->param(
delete_class_source_form => 1,
confirm_op => "delete_source_confirmed",
class_source => $source_code,
);
}
sub delete_class_source {
my ($template, $source_code) = @_;
DelClassSource($source_code);
$template->param(deleted_source => $source_code);
}
sub get_sort_rule_codes {
my ($template, $current_rule) = @_;
my $sort_rules = GetClassSortRules();
my @sort_rules = ();
foreach my $sort_rule (sort keys %$sort_rules) {
my $sort_rule = $sort_rules->{$sort_rule};
push @sort_rules,
{
rule => $sort_rule->{'class_sort_rule'},
description => $sort_rule->{'description'},
selected => $sort_rule->{'class_sort_rule'} eq $current_rule ? 1 : 0
}
}
$template->param(rules_dropdown => \@sort_rules);
}
sub add_class_sort_rule_form {
my ($template) = @_;
$template->param(
sort_rule_form => 1,
confirm_op => "add_sort_rule_confirmed"
);
}
sub add_class_sort_rule {
my ($template, $rule_code, $description, $sort_routine) = @_;
AddClassSortRule($rule_code, $description, $sort_routine);
$template->param(added_rule => $rule_code);
}
sub delete_sort_rule_form {
my ($template, $rule_code) = @_;
my @sources = GetSourcesForSortRule($rule_code);
if ($#sources == -1) {
$template->param(
delete_sort_rule_form => 1,
confirm_op => "delete_sort_rule_confirmed",
sort_rule => $rule_code,
);
} else {
$template->param(
delete_sort_rule_impossible => 1,
sort_rule => $rule_code
);
}
}
sub delete_sort_rule {
my ($template, $rule_code) = @_;
DelClassSortRule($rule_code);
$template->param(deleted_rule => $rule_code);
}
sub edit_class_sort_rule_form {
my ($template, $rule_code) = @_;
my $rule = GetClassSortRule($rule_code);
$template->param(
sort_rule_form => 1,
edit_sort_rule => 1,
confirm_op => "edit_sort_rule_confirmed",
sort_rule => $rule_code,
description => $rule->{'description'},
sort_routine => $rule->{'sort_routine'}
);
}
sub edit_class_sort_rule {
my ($template, $rule_code, $description, $sort_routine) = @_;
ModClassSortRule($rule_code, $description, $sort_routine);
$template->param(edited_rule => $rule_code);
}
sub class_source_list {
my ($template) = @_;
my $sources = GetClassSources();
my @sources = ();
foreach my $cn_source (sort keys %$sources) {
my $source = $sources->{$cn_source};
push @sources,
{
code => $source->{'cn_source'},
description => $source->{'description'},
used => $source->{'used'},
sortrule => $source->{'class_sort_rule'}
}
}
$template->param(class_sources => \@sources);
}
sub class_sort_rule_list {
my ($template) = @_;
my $sort_rules = GetClassSortRules();
my @sort_rules = ();
foreach my $sort_rule (sort keys %$sort_rules) {
my $sort_rule = $sort_rules->{$sort_rule};
push @sort_rules,
{
rule => $sort_rule->{'class_sort_rule'},
description => $sort_rule->{'description'},
sort_routine => $sort_rule->{'sort_routine'}
}
}
$template->param(class_sort_rules => \@sort_rules);
}

View file

@ -46,6 +46,7 @@ use C4::Auth;
use C4::Context;
use C4::Koha;
use C4::Languages;
use C4::ClassSource;
use C4::Output;
use C4::Context;
@ -94,6 +95,7 @@ my %tabsysprefs;
$tabsysprefs{NoZebra}="Catalogue";
$tabsysprefs{NoZebraIndexes}="Catalogue";
$tabsysprefs{ReceiveBackIssues}="Catalogue";
$tabsysprefs{DefaultClassificationSource}="Catalogue";
# Circulation
$tabsysprefs{maxoutstanding}="Circulation";
@ -358,6 +360,20 @@ if ($op eq 'add_form') {
push @options, { option => $theme, counter => $counter };
$counter++;
}
} elsif ($data->{'type'} eq 'ClassSource') {
$template->param('type-choice' => 1);
my $type='';
@options=();
my $sources = GetClassSources();
my $counter=0;
foreach my $cn_source (sort keys %$sources) {
if ($cn_source eq $data->{'value'}) {
push @options, { option => $cn_source, counter => $counter, selected => 1 };
} else {
push @options, { option => $cn_source, counter => $counter };
}
$counter++;
}
} elsif ($data->{'type'} eq 'Languages') {
$template->param('type-choice' => 1);
my $type='';

View file

@ -0,0 +1,35 @@
--
-- Default classification sources and filing rules
-- for Koha.
--
-- Copyright (C) 2007 LiblimeA
--
-- 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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place,
-- Suite 330, Boston, MA 02111-1307 USA
-- class sorting (filing) rules
INSERT INTO `class_sort_rules` (`class_sort_rule`, `description`, `sort_routine`) VALUES
('dewey', 'Default filing rules for DDC', 'Dewey'),
('lcc', 'Default filing rules for LCC', 'LCC'),
('generic', 'Generic call number filing rules', 'Generic');
-- classification schemes or sources
INSERT INTO `class_sources` (`cn_source`, `description`, `used`, `class_sort_rule`) VALUES
('ddc', 'Dewey Decimal Classification', 1, 'dewey'),
('lcc', 'Library of Congress Classification', 1, 'lcc'),
('udc', 'Universal Decimal Classification', 0, 'generic'),
('sudocs', 'SuDoc Classification (U.S. GPO)', 0, 'generic'),
('z', 'Other/Generic Classification Scheme', 0, 'generic');

View file

@ -0,0 +1 @@
Default classification sources and filing rules

View file

@ -39,6 +39,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IssuingInProcess','0','If ON, disables fines if the patron is issuing item that accumulate debt',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('item-level_itypes','1','If ON, enables Item-level Itemtype / Issuing Rules','','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemcallnumber','082ab','The MARC field/subfield that is used to calculate the itemcallnumber (Dewey would be 082ab or 092ab; LOC would be 050ab or 090ab) could be 852hi from an item record',NULL,'free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DefaultClassificationSource','ddc','Default classification scheme used by the collection. E.g., Dewey, LCC, etc.', NULL,'ClassSources');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('KohaAdminEmailAddress','root@localhost','Define the email address where patron modification requests are sent','','free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('kohaspsuggest','','Track search queries, turn on by defining host:dbname:user:pass','','');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('LabelMARCView','standard','Define how a MARC record will display','standard|economical','Choice');

View file

@ -610,6 +610,35 @@ CREATE TABLE `cities` (
PRIMARY KEY (`cityid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `class_sort_rules`
--
DROP TABLE IF EXISTS `class_sort_rules`;
CREATE TABLE `class_sort_rules` (
`class_sort_rule` varchar(10) NOT NULL default '',
`description` mediumtext,
`sort_routine` varchar(30) NOT NULL default '',
PRIMARY KEY (`class_sort_rule`),
UNIQUE KEY `class_sort_rule_idx` (`class_sort_rule`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `class_sources`
--
DROP TABLE IF EXISTS `class_sources`;
CREATE TABLE `class_sources` (
`cn_source` varchar(10) NOT NULL default '',
`description` mediumtext,
`used` tinyint(4) NOT NULL default 0,
`class_sort_rule` varchar(10) NOT NULL default '',
PRIMARY KEY (`cn_source`),
UNIQUE KEY `cn_source_idx` (`cn_source`),
KEY `used_idx` (`used`),
CONSTRAINT `class_source_ibfk_1` FOREIGN KEY (`class_sort_rule`) REFERENCES `class_sort_rules` (`class_sort_rule`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `currency`
--

View file

@ -27,6 +27,7 @@
<li><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></li>
<li><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC Bibliographic framework test</a></li>
<li><a href="/cgi-bin/koha/admin/authtypes.pl">MARC Authorities framework</a></li>
<li><a href="/cgi-bin/koha/admin/classsources.pl">Classification sources</a></li>
</ul>
<h5>Additional parameters</h5>

View file

@ -60,6 +60,8 @@
<dd>Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.</dd>
<dt><a href="/cgi-bin/koha/admin/authtypes.pl">MARC Authorities framework</a></dt>
<dd>Create and manage Authorities frameworks that define the characteristics of your MARC Records (field and subfield definitions).</dd>
<dt><a href="/cgi-bin/koha/admin/classsources.pl">Classification sources</a></dt>
<dd>Define classification sources (i.e., call number schemes) used by your collection. Also define filing rules used for sorting call numbers.</dd>
</dl>
<h3>Additional parameters</h3>

View file

@ -0,0 +1,325 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Administration &rsaquo; Classification Sources
<!-- TMPL_IF name="class_source_form" -->
<!-- TMPL_IF name="edit_class_source" -->
&rsaquo; Modify classification source
<!-- TMPL_ELSE -->
&rsaquo; Add classification source
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="sort_rule_form" -->
<!-- TMPL_IF name="edit_sort_rule" -->
&rsaquo; Modify filing rule
<!-- TMPL_ELSE -->
&rsaquo; Add filing rule
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_class_source_form" -->
&rsaquo; Confirm deletion of classification source <!-- TMPL_VAR name="class_source" -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_form" -->
&rsaquo; Confirm deletion of filing rule <!-- TMPL_VAR name="sort_rule" -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_impossible" -->
&rsaquo; Cannot delete filing rule <!-- TMPL_VAR name="sort_rule" -->
<!-- /TMPL_IF -->
</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript">
//<![CDATA[
function DoCancel(f) {
f.op.value='';
document.Aform.submit();
}
function CheckSourceForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.class_source.value.length==0) {
_alertString += "\n- " + _("Classification source code missing");
}
if (f.sort_rule.value.length==0) {
_alertString += "\n- " + _("Filing rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
function CheckRuleForm(f) {
var ok=1;
var _alertString="";
var alertString2;
if (f.sort_rule.value.length==0) {
_alertString += "\n- " + _("Filing rule code missing");
}
if (f.description.value.length==0) {
_alertString += "\n- " + _("Description missing");
}
if (f.sort_routine.value.length==0) {
_alertString += "\n- " + _("Sort routine missing");
}
if (_alertString.length==0) {
document.Aform.submit();
} else {
alertString2 = _("Form not submitted because of the following problem(s)");
alertString2 += "\n------------------------------------------------------------------------------------\n";
alertString2 += _alertString;
alert(alertString2);
}
}
//]]>
</script>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-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; Classification Sources
<!-- TMPL_IF name="class_source_form" -->
<!-- TMPL_IF name="edit_class_source" -->
&rsaquo; Modify classification source
<!-- TMPL_ELSE -->
&rsaquo; Add classification source
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="sort_rule_form" -->
<!-- TMPL_IF name="edit_sort_rule" -->
&rsaquo; Modify filing rule
<!-- TMPL_ELSE -->
&rsaquo; Add filing rule
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_class_source_form" -->
&rsaquo; Confirm deletion of classification source <!-- TMPL_VAR name="class_source" -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_form" -->
&rsaquo; Confirm deletion of filing rule <!-- TMPL_VAR name="sort_rule" -->
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_impossible" -->
&rsaquo; Cannot delete filing rule <!-- TMPL_VAR name="sort_rule" -->
<!-- /TMPL_IF -->
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<!-- TMPL_IF name="class_source_form" -->
<!-- TMPL_IF name="edit_class_source" -->
<h2>Modify classification source</h2>
<!-- TMPL_ELSE -->
<h2>Add classification source</h2>
<!-- /TMPL_IF -->
<form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="<!-- TMPL_VAR name="confirm_op"-->" />
<fieldset class="rows">
<ol>
<li><span class="label">Classification source code</span>
<!-- TMPL_IF name="edit_class_source" -->
<input type="hidden" name="class_source" value="<!-- TMPL_VAR name="class_source" -->" />
<!-- TMPL_VAR name="class_source" -->
<!-- TMPL_ELSE -->
<input type="text" id="class_source" name="class_source" size="10" maxlength="10" />
<!-- /TMPL_IF -->
</li>
<li><span class="label">Description</span>
<input type="text" id="description" name="description" size="50" maxlength="250"
value="<!-- TMPL_VAR name="description" escape="HTML" -->" />
</li>
<li><span class="label">Source in use?</span>
<input type="checkbox" id="used" name="used" value="used"
<!-- TMPL_IF name="used" -->checked="yes"<!-- /TMPL_IF--> />
</li>
<li><span class="label">Filing Rule</span>
<select id="sort_rule" name="sort_rule">
<!-- TMPL_LOOP name="rules_dropdown" -->
<!-- TMPL_IF name="selected" -->
<option value="<!-- TMPL_VAR name="rule" -->" selected="selected"><!-- TMPL_VAR name="description" --> (<!-- TMPL_VAR name="rule" -->)</option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR name="rule" -->"><!-- TMPL_VAR name="description" --> (<!-- TMPL_VAR name="rule" -->)</option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
</li>
</ol>
</fieldset>
<p id="action">
<input type="button" value="<!-- TMPL_IF name="edit_class_source" -->Save Changes<!-- TMPL_ELSE -->Add Classification Source<!-- /TMPL_IF-->"
onclick="CheckSourceForm(this.form)" />
<input type="button" value="Cancel" onclick="DoCancel(this.form)" />
</p>
</form>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="sort_rule_form" -->
<!-- TMPL_IF name="edit_sort_rule" -->
<h2>Modify filing rule</h2>
<!-- TMPL_ELSE -->
<h2>Add filing rule</h2>
<!-- /TMPL_IF -->
<form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="<!-- TMPL_VAR name="confirm_op"-->" />
<fieldset class="rows">
<ol>
<li><span class="label">Filing rule code</span>
<!-- TMPL_IF name="edit_sort_rule" -->
<input type="hidden" name="sort_rule" value="<!-- TMPL_VAR name="sort_rule" -->" />
<!-- TMPL_VAR name="sort_rule" -->
<!-- TMPL_ELSE -->
<input type="text" id="sort_rule" name="sort_rule" size="10" maxlength="10" />
<!-- /TMPL_IF -->
</li>
<li><span class="label">Description</span>
<input type="text" id="description" name="description" size="50" maxlength="250"
value="<!-- TMPL_VAR name="description" escape="HTML" -->" />
</li>
<li><span class="label">Filing Routine</span>
<input type="text" id="sort_routine" name="sort_routine" size="30" maxlength="30"
value="<!-- TMPL_VAR name="sort_routine" escape="HTML" -->" />
</li>
</ol>
</fieldset>
<p id="action">
<input type="button" value="<!-- TMPL_IF name="edit_sort_rule" -->Save Changes<!-- TMPL_ELSE -->Add Filing Rule<!-- /TMPL_IF-->"
onclick="CheckRuleForm(this.form)" />
<input type="button" value="Cancel" onclick="DoCancel(this.form)" />
</p>
</form>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_class_source_form" -->
<h2>Confirm deletion of classification source <!-- TMPL_VAR name="class_source" -->?</h2>
<form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="<!-- TMPL_VAR name="confirm_op"-->" />
<input type="hidden" name="class_source" value="<!-- TMPL_VAR name="class_source" -->" />
<p id="action">
<input type="submit" value="Delete classification source" />
<input type="button" value="Cancel" onclick="DoCancel(this.form)" />
</p>
</form>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_form" -->
<h2>Confirm deletion of filing rule <!-- TMPL_VAR name="sort_rule" -->?</h2>
<form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="<!-- TMPL_VAR name="confirm_op"-->" />
<input type="hidden" name="sort_rule" value="<!-- TMPL_VAR name="sort_rule" -->" />
<p id="action">
<input type="submit" value="Delete filing rule" />
<input type="button" value="Cancel" onclick="DoCancel(this.form)" />
</p>
</form>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="delete_sort_rule_impossible" -->
<h2>Cannot delete filing rule <!-- TMPL_VAR name="sort_rule" --></h2>
<p>The filing rule <!-- TMPL_VAR name="sort_rule" --> is used by at least one classification source. Please
remove it from all classification source definitions before trying again.
</p>
<form action="<!-- TMPL_VAR name="script_name" -->" name="Aform" method="post">
<input type="hidden" name="op" value="<!-- TMPL_VAR name="else"-->" />
<input type="hidden" name="sort_rule" value="<!-- TMPL_VAR name="sort_rule" -->" />
<p id="action">
<input type="button" value="Go back" onclick="DoCancel(this.form)" />
</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="display_lists" -->
<h2>Classification Sources</h2>
<!-- TMPL_IF name="added_source" -->
<span class="problem">Added classification source <!-- TMPL_VAR name="added_source" --></span>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="edited_source" -->
<span class="problem">Modified classification source <!-- TMPL_VAR name="edited_source" --></span>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="deleted_source" -->
<span class="problem">Deleted classification source <!-- TMPL_VAR name="deleted_source" --></span>
<!-- /TMPL_IF -->
<table>
<tr>
<th>Code</th>
<th>Description</th>
<th>In Use</th>
<th>Filing Rule</th>
<th>Actions</th>
</tr>
<!-- TMPL_LOOP name="class_sources" -->
<tr>
<td><!-- TMPL_VAR name="code" --></td>
<td><!-- TMPL_VAR name="description" --></td>
<td><!-- TMPL_IF name="used" -->Yes<!-- TMPL_ELSE -->No<!-- /TMPL_IF --></td>
<td><!-- TMPL_VAR name="sortrule" --></td>
<td>
<a href="<!-- TMPL_VAR name="script_name" -->?op=edit_source&amp;class_source=<!-- TMPL_VAR name="code" escape="HTML" -->">Edit</a>
<a href="<!-- TMPL_VAR name="script_name" -->?op=delete_source&amp;class_source=<!-- TMPL_VAR name="code" escape="HTML" -->">
Delete</a>
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
<p><a href="<!-- TMPL_VAR name="script_name" -->?op=add_source">Add Classification Source</a></p>
<div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
<h2>Classification Filing Rules</h2>
<!-- TMPL_IF name="added_rule" -->
<span class="problem">Added filing rule <!-- TMPL_VAR name="added_rule" --></span>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="edited_rule" -->
<span class="problem">Modified filing rule <!-- TMPL_VAR name="edited_rule" --></span>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="deleted_rule" -->
<span class="problem">Deleted filing rule <!-- TMPL_VAR name="deleted_rule" --></span>
<!-- /TMPL_IF -->
<table>
<tr>
<th>Code</th>
<th>Description</th>
<th>Sorting Routine</th>
<th>Actions</th>
</tr>
<!-- TMPL_LOOP name="class_sort_rules" -->
<tr>
<td><!-- TMPL_VAR name="rule" --></td>
<td><!-- TMPL_VAR name="description" --></td>
<td><!-- TMPL_VAR name="sort_routine" --></td>
<td>
<a href="<!-- TMPL_VAR name="script_name" -->?op=edit_sort_rule&amp;sort_rule=<!-- TMPL_VAR name="rule" escape="HTML" -->">Edit</a>
<a href="<!-- TMPL_VAR name="script_name" -->?op=delete_sort_rule&amp;sort_rule=<!-- TMPL_VAR name="rule" escape="HTML" -->">
Delete</a>
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
<p><a href="<!-- TMPL_VAR name="script_name" -->?op=add_sort_rule">Add Filing Rule</a></p>
<!-- /TMPL_IF -->
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="admin-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -117,7 +117,7 @@
<h3>Koha internal</h3>
Note: you should have no reasons to modify the following default values
<table>
<tr><td><label for="preftype">Variable type:</label></td><td><input type="text" name="preftype" id="preftype" value="<!--TMPL_VAR NAME="preftype" -->" size="40" maxlength="40"><span class="formfield-notes"> (Choice, YesNo, Integer, Textarea, Float, Themes, or Languages)</td></tr>
<tr><td><label for="preftype">Variable type:</label></td><td><input type="text" name="preftype" id="preftype" value="<!--TMPL_VAR NAME="preftype" -->" size="40" maxlength="40"><span class="formfield-notes"> (Choice, YesNo, Integer, Textarea, Float, Themes, Languages, or ClassSource)</td></tr>
<tr><td><label for="prefoptions">Variable options:</label></td><td><input type="text" name="prefoptions" id="prefoptions" value="<!-- TMPL_VAR NAME="prefoptions" -->" size="60" maxlength="80" />(a choice list for Choice (separated by |) or cols|rows for Texarea)</td></tr>
</table>
</form>