From 28257e7a98aa0ffe1b192732fc6815c6edb0c97d Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Fri, 12 Oct 2007 17:35:25 -0500 Subject: [PATCH] #1485 (issuing rules improvement) continued IMPORTANT NOTE : all existing test database for 3.0 must manually delete ALL constraints on issuingrules table (the update22to30.pl don't contain the constraints anymore, as kohastructure.sql, so are concerned only the existing 3.0 tests databases) Filling issuingrules table : - the issuingrules table can't have a constraint on categorycode, as we have a '*' categorycode (=default issuingrule) - reintroducing the "default" issuingrule column - changing some text ('*' replaced by something more explanatory) - handling correctly the '0' (that is different from 'undefined' Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- admin/issuingrules.pl | 13 +- installer/kohastructure.sql | 3 +- .../prog/en/modules/admin/issuingrules.tmpl | 117 +++++++++--------- updater/update22to30.pl | 8 -- 4 files changed, 67 insertions(+), 74 deletions(-) diff --git a/admin/issuingrules.pl b/admin/issuingrules.pl index 7167c9af1b..22e7dd02aa 100755 --- a/admin/issuingrules.pl +++ b/admin/issuingrules.pl @@ -90,6 +90,10 @@ while (my $data=$sth->fetchrow_hashref){ push @trow3,$data->{'categorycode'}; } +my %row = (in_title => "*"); +push @title_loop, \%row; +push @trow3,'*'; + $sth->finish; $sth=$dbh->prepare("Select description,itemtype from itemtypes order by description"); $sth->execute; @@ -117,11 +121,11 @@ foreach my $data (@itemtypes) { $sth2->execute($branch,$trow3[$i],$$data->{'itemtype'}); my $dat=$sth2->fetchrow_hashref; $sth2->finish; - my $fine=$dat->{'fine'}+0; - my $maxissueqty = $dat->{'maxissueqty'}+0; - my $issuelength = $dat->{'issuelength'}+0; + my $fine=$dat->{'fine'}; + my $maxissueqty = $dat->{'maxissueqty'}; + my $issuelength = $dat->{'issuelength'}; my $issuingvalue; - $issuingvalue = "$issuelength,$maxissueqty" if $issuelength+$maxissueqty>0; + $issuingvalue = "$issuelength,$maxissueqty" if $maxissueqty ne ''; my %row = (issuingname => "I-$branch-$trow3[$i].$$data->{itemtype}", issuingvalue => $issuingvalue, toggle => $toggle, @@ -129,6 +133,7 @@ foreach my $data (@itemtypes) { push @cell_loop,\%row; } my %row = (categorycode => $$data->{description}, + total => ($$data->{itemtype} eq '*'?1:0), cell =>\@cell_loop ); push @row_loop, \%row; diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index 91f3a2db54..d5ca0c3047 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -844,8 +844,7 @@ CREATE TABLE `issuingrules` ( `branchcode` char(10) NOT NULL default '', PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), KEY `categorycode` (`categorycode`), - KEY `itemtype` (`itemtype`), - CONSTRAINT `issuingrules_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/issuingrules.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/issuingrules.tmpl index 8a38adb394..7b852ffc64 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/issuingrules.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/issuingrules.tmpl @@ -9,68 +9,65 @@
- -
-
-
-

Defining issuing rules for default issuing rules

-
-

HINT for issues

-

Each box needs to be filled in with issuelength,maxissues

-

eq 21,5 enables 5 issues for 21 days

-
+
+
+
-
-

Default values

-

If a cell is not filled, the 1st of the following value is searched :

-
    -
  • same library and same patron category, itemtype *
  • -
  • same library and same itemtype, patron category *
  • -
  • same itemtype and patron category, library *
  • -
  • everywhere
  • -
  • If nothing is set, default is 21,5 (hardcoded)
  • -
-
-
- - - -
-
- - " /> - - - - - - - - - - - - - - - -
Defining circulation rules for
 
- - - - " value="" size="6" maxlength="10" /> -
- - -
+

Defining issuing rules for default issuing rules

+
+

HINT for issues

+

Each box needs to be filled in with issuelength,maxissues

+

eq 21,5 enables 5 issues for 21 days

+
+ +
+

Default values

+
    +
  • If a cell is not filled, the value in the default column (top right) is used
  • +
  • If a total is filled (last line), the patron must fit both itemtype and total rule
  • +
  • If a rule is filled for a given branch, it is used, otherwise, it's the rule of the "default" branch
  • +
+
+ + + +
+
+ + " /> + + + + + + + + + + + + + + + +
Defining circulation rules for
 Default
Total + + + + " value="" size="6" maxlength="10" /> +
+ +
diff --git a/updater/update22to30.pl b/updater/update22to30.pl index 93bb495430..549db4fc0c 100755 --- a/updater/update22to30.pl +++ b/updater/update22to30.pl @@ -1469,14 +1469,6 @@ my $DBversion = "3.00.00.000"; onDelete => 'CASCADE', }, ], - issuingrules => [ - { key => 'categorycode', - foreigntable => 'categories', - foreignkey => 'categorycode', - onUpdate => 'CASCADE', - onDelete => 'CASCADE', - }, - ], issues => [ # constraint is SET NULL : when a borrower or an item is deleted, we keep the issuing record # for stat purposes { key => 'borrowernumber', -- 2.39.5