Skip to content

Commit

Permalink
#1485 (issuing rules improvement) continued
Browse files Browse the repository at this point in the history
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 <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
  • Loading branch information
Paul POULAIN authored and Joshua Ferraro committed Oct 13, 2007
1 parent d9b7ef9 commit 28257e7
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 74 deletions.
13 changes: 9 additions & 4 deletions admin/issuingrules.pl
Expand Up @@ -90,6 +90,10 @@
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;
Expand Down Expand Up @@ -117,18 +121,19 @@
$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,
);
push @cell_loop,\%row;
}
my %row = (categorycode => $$data->{description},
total => ($$data->{itemtype} eq '*'?1:0),
cell =>\@cell_loop
);
push @row_loop, \%row;
Expand Down
3 changes: 1 addition & 2 deletions installer/kohastructure.sql
Expand Up @@ -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;

--
Expand Down
117 changes: 57 additions & 60 deletions koha-tmpl/intranet-tmpl/prog/en/modules/admin/issuingrules.tmpl
Expand Up @@ -9,68 +9,65 @@
<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; Issuing Rules</div>

<div id="doc3" class="yui-t2">

<div id="bd">
<div id="yui-main">
<div class="yui-b">

<h1>Defining <!-- TMPL_IF NAME="branch" -->issuing rules for <!-- TMPL_VAR NAME="branch" --><!-- TMPL_ELSE -->default issuing rules<!-- /TMPL_IF --></h1>
<div class="help">
<h3>HINT for issues</h3>
<p>Each box needs to be filled in with issuelength,maxissues</p>
<p>eq 21,5 enables 5 issues for 21 days</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">

<div class="help">
<h3>Default values</h3>
<p> If a cell is not filled, the 1st of the following value is searched :</p>
<ul>
<li>same library and same patron category, itemtype *</li>
<li>same library and same itemtype, patron category *</li>
<li>same itemtype and patron category, library *</li>
<li>everywhere</li>
<li>If nothing is set, default is 21,5 (hardcoded)</li>
</ul>
</div>
<form method="post" action="/cgi-bin/koha/admin/issuingrules.pl">
<label for="branch">Select a library :</label>
<select id="branch" name="branch">
<option value="">Default</option>
<!-- TMPL_LOOP NAME="branchloop" -->
<!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP --></select>
<input type="submit" value="Select" />
</form>
<form method="post" action="/cgi-bin/koha/admin/issuingrules.pl">
<input type="hidden" name="op" value="save" />
<input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->" />

<table>
<caption>Defining circulation rules for <!-- TMPL_VAR NAME="branch" --></caption>
<tr>
<th>&nbsp;</th><!-- TMPL_LOOP NAME="title" --><th scope="col"><!-- TMPL_VAR NAME="in_title" --></th><!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_LOOP NAME="row" -->
<tr>
<th><!-- TMPL_VAR NAME="categorycode" --></th>
<!-- TMPL_LOOP NAME="cell" -->
<!-- TMPL_IF NAME="toggle" -->
<td class="highlight">
<!-- TMPL_ELSE -->
<td>
<!-- /TMPL_IF -->
<input name="<!-- TMPL_VAR NAME="issuingname" -->" value="<!-- TMPL_VAR NAME="issuingvalue" -->" size="6" maxlength="10" />
</td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>

<input type="submit" value="Save Changes" />
</form>
<h1>Defining <!-- TMPL_IF NAME="branch" -->issuing rules for <!-- TMPL_VAR NAME="branch" --><!-- TMPL_ELSE -->default issuing rules<!-- /TMPL_IF --></h1>
<div class="help">
<h3>HINT for issues</h3>
<p>Each box needs to be filled in with issuelength,maxissues</p>
<p>eq 21,5 enables 5 issues for 21 days</p>
</div>

<div class="help">
<h3>Default values</h3>
<ul>
<li>If a cell is not filled, the value in the default column (top right) is used</li>
<li>If a total is filled (last line), the patron must fit both itemtype and total rule</li>
<li>If a rule is filled for a given branch, it is used, otherwise, it's the rule of the "default" branch</li>
</div>
<form method="post" action="/cgi-bin/koha/admin/issuingrules.pl">
<label for="branch">Select a library :</label>
<select id="branch" name="branch">
<option value="">Default</option>
<!-- TMPL_LOOP NAME="branchloop" -->
<!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<input type="submit" value="Select" />
</form>
<form method="post" action="/cgi-bin/koha/admin/issuingrules.pl">
<input type="hidden" name="op" value="save" />
<input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->" />

<table>
<caption>Defining circulation rules for <!-- TMPL_VAR NAME="branch" --></caption>
<tr>
<th>&nbsp;</th><!-- TMPL_LOOP NAME="title" --><th scope="col"><!-- TMPL_IF EXPR="in_title eq '*'" -->Default<!-- TMPL_ELSE --><!-- TMPL_VAR NAME="in_title" --><!-- /TMPL_IF --></th><!-- /TMPL_LOOP -->
</tr>
<!-- TMPL_LOOP NAME="row" -->
<tr>
<th><!-- TMPL_IF name="total" -->Total <!-- TMPL_ELSE --><!-- TMPL_VAR NAME="categorycode" --><!-- /TMPL_IF --></th>
<!-- TMPL_LOOP NAME="cell" -->
<!-- TMPL_IF NAME="toggle" -->
<td class="highlight">
<!-- TMPL_ELSE -->
<td>
<!-- /TMPL_IF -->
<input name="<!-- TMPL_VAR NAME="issuingname" -->" value="<!-- TMPL_VAR NAME="issuingvalue" -->" size="6" maxlength="10" />
</td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
</table>
<input type="submit" value="Save Changes" />
</form>

</div>
</div>
Expand Down
8 changes: 0 additions & 8 deletions updater/update22to30.pl
Expand Up @@ -1469,14 +1469,6 @@
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',
Expand Down

0 comments on commit 28257e7

Please sign in to comment.