my $dbh = C4::Context->dbh;
+my $branchcode = $input->param('branchcode');
+my $branchname = GetBranchName($branchcode);
+
+# Getting the branches for user selection
+my $branches = GetBranches();
+my @branch_loop;
+for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
+ my %row =(value => $thisbranch,
+ branchname => $branches->{$thisbranch}->{'branchname'},
+ );
+ push @branch_loop, \%row;
+}
+
+
# Set the template language for the correct limit type
my $limit_phrase = 'Collection Code';
my $limitType = C4::Context->preference("BranchTransferLimitsType");
## If Form Data Passed, Update the Database
if ( $input->param('updateLimits') ) {
- DeleteBranchTransferLimits();
+ DeleteBranchTransferLimits();
foreach my $code ( @codes ) {
foreach my $toBranch ( @branchcodes ) {
- foreach my $fromBranch ( @branchcodes ) {
- my $isSet = $input->param( $code . "_" . $toBranch . "_" . $fromBranch );
- if ( $isSet ) {
- CreateBranchTransferLimit( $toBranch, $fromBranch, $code );
- }
+ my $isSet = not $input->param( $code . "_" . $toBranch);
+ if ( $isSet ) {
+ CreateBranchTransferLimit( $toBranch, $branchcode, $code );
}
}
}
$row_data{ code } = $code;
$row_data{ to_branch_loop } = \@to_branch_loop;
foreach my $toBranch ( @branchcodes ) {
- my @from_branch_loop;
my %row_data;
- $row_data{ code } = $code;
- $row_data{ toBranch } = $toBranch;
- $row_data{ from_branch_loop } = \@from_branch_loop;
-
- foreach my $fromBranch ( @branchcodes ) {
- my %row_data;
- my $isChecked = ! IsBranchTransferAllowed( $toBranch, $fromBranch, $code );
- $row_data{ code } = $code;
- $row_data{ toBranch } = $toBranch;
- $row_data{ fromBranch } = $fromBranch;
- $row_data{ isChecked } = $isChecked;
-
- push( @from_branch_loop, \%row_data );
- }
-
+ my $isChecked = IsBranchTransferAllowed( $toBranch, $branchcode, $code );
+ $row_data{ code } = $code;
+ $row_data{ toBranch } = $toBranch;
+ $row_data{ isChecked } = $isChecked;
+ $row_data{ toBranchname } = GetBranchName($toBranch);
push( @to_branch_loop, \%row_data );
}
$template->param(
branchcount => $branchcount,
codes_loop => \@codes_loop,
+ branch_loop => \@branch_loop,
branchcode_loop => \@branchcode_loop,
+ branchcode => $branchcode,
+ branchname => $branchname,
limit_phrase => $limit_phrase,
);
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha › Administration › Library Transfer Limits</title>
+<title>Koha › Administration › Library Checkin and Transfer Policy</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript">
$("#SwapAll").click(function(){ $("#transferlimit_tabs").toggleCheckboxes();});
$('#transferlimit_tabs > ul').tabs();
+ $('#branchselect').change(function() {
+ $('#selectlibrary').submit();
+ });
+
+
var checkcolumn = $(".checkcolumn");
var checkrow = $(".checkrow");
var checkall = $(".checkall");
var uncheckall = $(".uncheckall");
- var swapall = $(".swapall");
$(checkcolumn).click(function(){
if(this.checked){ status = "checked" } else { status = "" }
return false;
});
- $(swapall).click(function(){
- var tid = $(this).attr("id");
- tid = tid.replace("SwapAll","");
- $("#"+tid).toggleCheckboxes();
- return false;
- });
});
</script>
<style type="text/css">td { text-align: center; }</style>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Set Library Transfer Limits</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Set Library Checkin and Transfer Policy</div>
<div id="doc3" class="yui-t1">
<div id="yui-main">
<div class="yui-b">
-<h1>Library Transfer Limits</h1>
-<p class="help">Check the boxes for the items that should <strong><em>not</em></strong> be transferable.</p>
-<fieldset>For <strong>all</strong> <!--TMPL_VAR NAME="limit_phrase" -->s: <a id="CheckAll" href="#">Check All</a> | <a id="UncheckAll" href="#">Uncheck All</a> | <a id="SwapAll" href="#">Toggle All</a></fieldset>
+<h1>Library <!-- TMPL_VAR NAME="branchcode" --> - <!-- TMPL_VAR NAME="branchname" --> Checkin and Transfer Policy</h1>
+ <form method="get" action="/cgi-bin/koha/admin/branch_transfer_limits.pl" id="selectlibrary">
+ <label for="branchselect">Select a library :</label>
+ <select name="branchcode" id="branchselect">
+ <!-- TMPL_LOOP NAME="branch_loop" -->
+ <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+ <input type="submit" value="Choose" />
+ </form>
+
+<p class="help">Check the boxes for the libraries you accept to checkin items from.</p>
+<fieldset>For <strong>all</strong> <!--TMPL_VAR NAME="limit_phrase" -->s: <a id="CheckAll" href="#">Check All</a> | <a id="UncheckAll" href="#">Uncheck All</a></fieldset>
<div id="transferlimit_tabs" class="toptabs">
<!-- TMPL_LOOP NAME="codes_loop" -->
<div id="<!-- TMPL_VAR NAME="code" -->set">
- <h4>Limits for <!--TMPL_VAR NAME="limit_phrase" -->: <!-- TMPL_VAR NAME="code" --></h4>
- <p><a id="CheckAll<!-- TMPL_VAR NAME="code" -->table" class="checkall" href="#">Check All</a> | <a id="UncheckAll<!-- TMPL_VAR NAME="code" -->table" class="uncheckall" href="#">Uncheck All</a> | <a id="SwapAll<!-- TMPL_VAR NAME="code" -->table" class="swapall" href="#">Toggle All</a></p>
+ <h4>Policy for <!--TMPL_VAR NAME="limit_phrase" -->: <!-- TMPL_VAR NAME="code" --></h4>
+ <p><a id="CheckAll<!-- TMPL_VAR NAME="code" -->table" class="checkall" href="#">Check All</a> | <a id="UncheckAll<!-- TMPL_VAR NAME="code" -->table" class="uncheckall" href="#">Uncheck All</a></p>
<table id="<!-- TMPL_VAR NAME="code" -->table">
<thead>
<tr>
- <th> </th><th>To:</th>
- <!-- TMPL_LOOP NAME="to_branch_loop" -->
- <th><!-- TMPL_VAR NAME="toBranch" --></th>
- <!-- /TMPL_LOOP -->
- </tr>
- <tr><th colspan="2">From:</th>
- <!-- TMPL_LOOP NAME="to_branch_loop" -->
- <th><input type="checkbox" name="checkcolumn" class="checkcolumn" /></th>
- <!-- /TMPL_LOOP -->
+ <th>Library</th>
+ <th>Allow transfer?</th>
</tr>
</thead>
<!-- TMPL_LOOP NAME="to_branch_loop" -->
<!-- TMPL_UNLESS NAME="__odd__" --><tr class="highlight"><!-- TMPL_ELSE
--><tr><!-- /TMPL_UNLESS -->
- <td><input type="checkbox" name="checkrow" id="<!-- TMPL_VAR NAME="code" --><!-- TMPL_VAR NAME="toBranch" -->row" class="checkrow" /></td>
- <td><label for="<!-- TMPL_VAR NAME="code" --><!-- TMPL_VAR NAME="toBranch" -->row"><!-- TMPL_VAR NAME="toBranch" --></label></td>
- <!-- TMPL_LOOP NAME="from_branch_loop" -->
- <td>
- <!-- TMPL_IF NAME="isChecked" -->
- <input
- name="<!-- TMPL_VAR NAME="code" -->_<!-- TMPL_VAR NAME="toBranch" -->_<!-- TMPL_VAR NAME="fromBranch" -->"
- type="checkbox" value="1" checked="checked" />
- <!-- TMPL_ELSE-->
- <input
- name="<!-- TMPL_VAR NAME="code" -->_<!-- TMPL_VAR NAME="toBranch" -->_<!-- TMPL_VAR NAME="fromBranch" -->"
- type="checkbox" value="1" />
- <!-- TMPL_ELSE-->
- <!-- /TMPL_IF -->
- </td>
- <!-- /TMPL_LOOP -->
+ <td><label style="min-width:400px;" for="<!-- TMPL_VAR NAME="code" --><!-- TMPL_VAR NAME="toBranch" -->row"><!-- TMPL_VAR NAME="toBranch" --> - <!-- TMPL_VAR NAME="toBranchname" --></label></td>
+ <td><input type="checkbox" id="<!-- TMPL_VAR NAME="code" --><!-- TMPL_VAR NAME="toBranch" -->row" name="<!-- TMPL_VAR NAME="code" -->_<!-- TMPL_VAR NAME="toBranch" -->" <!-- TMPL_IF NAME="isChecked" -->checked="checked" <!-- /TMPL_IF --> /></td>
</tr>
<!-- /TMPL_LOOP -->
</tbody>
<!-- /TMPL_LOOP -->
</div>
- <fieldset class="action"><input type="hidden" name="updateLimits" value="1" />
- <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/admin-home.pl">Cancel</a></fieldset>
+ <fieldset class="action">
+ <input type="hidden" name="updateLimits" value="1" />
+ <input type="hidden" name="branchcode" value="<!-- TMPL_VAR NAME="branchcode" -->" />
+ <input type="submit" value="Save" />
+ <a class="cancel" href="/cgi-bin/koha/admin/admin-home.pl">Cancel</a>
+ </fieldset>
</form>
+<!-- /TMPL_UNLESS --> <!-- /defined homebranch -->
</div>
</div>
<div class="yui-b">