ed7543287b
Having to write [% KOHA_VERSION %] for each url is bad because: - It's easily forgettable when adding new <script> or <link> - It prevents grep'ing for the full filename - It violates the DRY principle - If at some point we want to change the "force js and css reload" mechanism, it will be tedious This patch: - adds a Template::Toolkit plugin that generates <script> and <link> tags for JS and CSS files, and inserts automatically the Koha version in the filename - use the new plugin to remove all occurences of [% KOHA_VERSION %] - remove the code that was adding KOHA_VERSION as a template variable Test plan: 1. Apply patch 2. Go to several different pages in Koha (opac and intranet) while checking your browser's dev tools (there should be no 404 for JS and CSS files, and the Koha version should appear in filenames) and the server logs (there should be no "File not found") 3. `git grep KOHA_VERSION` should return nothing 4. prove t/db_dependent/Koha/Template/Plugin/Asset.t Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
150 lines
6.1 KiB
Text
150 lines
6.1 KiB
Text
[% USE Asset %]
|
|
[% USE Branches %]
|
|
[% SET footerjs = 1 %]
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
<title>Koha › Administration › Transport cost matrix</title>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
<style type="text/css">
|
|
.disabled-transfer {
|
|
background-color: #FF8888;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body id="admin_transport_cost_matrix" class="admin">
|
|
[% INCLUDE 'header.inc' %]
|
|
[% INCLUDE 'prefs-admin-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> › Transport cost matrix</div>
|
|
|
|
<div id="doc3" class="yui-t1">
|
|
|
|
<div id="bd">
|
|
<div id="yui-main">
|
|
<div class="yui-b">
|
|
<h1 class="parameters">
|
|
Defining transport costs between libraries
|
|
</h1>
|
|
[% IF ( WARNING_transport_cost_matrix_off ) %]
|
|
<div class="dialog message">Because the "UseTransportCostMatrix" system preference is currently not enabled, the transport cost matrix is not being used. Go <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=UseTransportCostMatrix">here</a> if you wish to enable this feature.</div>
|
|
[% END %]
|
|
|
|
[% IF ( errors ) %]<div class="dialog alert">
|
|
<h4>There were problems with your submission</h4>
|
|
<ul>
|
|
[% FOR e IN errors %]
|
|
<li>Invalid value for [% e %]</li>
|
|
[% END %]
|
|
</ul>
|
|
</div>[% END %]
|
|
|
|
<form method="post" action="/cgi-bin/koha/admin/transport-cost-matrix.pl" id="cost_matrix_form">
|
|
<input type="hidden" name="op" value="set-cost-matrix" />
|
|
<fieldset id="transport-cost-matrix">
|
|
<div class="help">
|
|
<p>Costs are decimal values between some arbitrary maximum value (e.g. 1 or 100) and 0 which is the minimum (no) cost.</p>
|
|
<p>Red cells signify no transfer allowed.</p>
|
|
<p>Click on individual cells to edit.</p>
|
|
</div>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>From \ To</th>
|
|
[% FOR b IN Branches.all() %]
|
|
<th>[% b.branchname %]</th>
|
|
[% END %]
|
|
</tr>
|
|
[% FOR bf IN branchfromloop %]
|
|
<tr>
|
|
<th>[% bf.name %]</th>
|
|
[% FOR bt IN bf.branchtoloop %]
|
|
<td>
|
|
[% IF bt.skip %]
|
|
|
|
[% ELSE %]
|
|
[% IF bt.disabled %]
|
|
<div id="celldiv_[% bt.id %]" class="disabled-transfer">
|
|
[% ELSE %]
|
|
<div id="celldiv_[% bt.id %]">
|
|
[% END %]
|
|
<div class="enable_cost_input" data-cost-id="[% bt.id %]">[% bt.disabled ? ' ' : bt.value %]</div>
|
|
<input type="hidden" name="cost_[% bt.id %]" value="[% bt.value %]" />
|
|
[% IF bt.disabled %]
|
|
<input type="hidden" name="disable_[% bt.id %]" value="1" />
|
|
[% END %]
|
|
</div>
|
|
[% END %]
|
|
</td>
|
|
[% END %]
|
|
</tr>
|
|
[% END %]
|
|
</table>
|
|
</fieldset>
|
|
<fieldset class="action">
|
|
<input type="submit" value="Save" class="submit" /> <a href="/cgi-bin/koha/admin/transport-cost-matrix.pl" class="cancel">Cancel</a>
|
|
</fieldset>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="yui-b">
|
|
[% INCLUDE 'admin-menu.inc' %]
|
|
</div>
|
|
</div>
|
|
|
|
[% MACRO jsinclude BLOCK %]
|
|
[% Asset.js("js/admin-menu.js") %]
|
|
<script type="text/javascript">
|
|
function check_transport_cost(e) {
|
|
var val = e.value;
|
|
if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) {
|
|
return;
|
|
}
|
|
alert(_("Cost must be expressed as a decimal number >= 0"));
|
|
}
|
|
function disable_transport_cost_chg(e) {
|
|
var input_name = e.name;
|
|
var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name
|
|
disable_transport_cost(cost_id, e.checked);
|
|
}
|
|
function disable_transport_cost(cost_id, disable) {
|
|
if (disable) {
|
|
$('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer');
|
|
} else {
|
|
$('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer');
|
|
}
|
|
}
|
|
function enable_cost_input(cost_id) {
|
|
var cell = $('#celldiv_'+cost_id);
|
|
var cost = $(cell).text();
|
|
var disabled = $(cell).hasClass('disabled-transfer');
|
|
$(cell).removeClass('disabled-transfer');
|
|
|
|
$('#celldiv_'+cost_id).html(
|
|
'<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+
|
|
'<br/>' + _("Disable ") + '<input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />'
|
|
);
|
|
disable_transport_cost(cost_id, disabled);
|
|
}
|
|
|
|
function form_submit (f) {
|
|
$(f).find('input:disabled').prop('disabled', false);
|
|
return true;
|
|
}
|
|
$(document).ready(function(){
|
|
$(".enable_cost_input").on("click",function(){
|
|
var cost_id = $(this).data("cost-id");
|
|
enable_cost_input( cost_id );
|
|
});
|
|
$("body").on("blur",".cost_input",function(){
|
|
check_transport_cost(this);
|
|
});
|
|
$("body").on("change",".disable_transport_cost",function(){
|
|
disable_transport_cost_chg(this);
|
|
});
|
|
$("#cost_matrix_form").on("submit",function(){
|
|
return form_submit(this);
|
|
});
|
|
});
|
|
</script>
|
|
[% END %]
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|