Koha/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt
Owen Leonard cde87a34a1 Bug 28958: Use Flatpickr on serials pages
This patch replaces the use of jQueryUI's datepicker on serials pages.

To test, apply the patch and test the following serials pages to confirm
that datepickers work correctly. "Linked" date fields should prevent a
"to" selection which preceeds the selected "from" date.

- Claims -> Choose vendor -> Filter missing issues (linked "from" and
  "to" fields).
- Check expiration -> "Expiring before" field.
- Manage numbering patterns -> New numbering pattern -> "First issue
  publication date" field.
- Serials advanced search -> "Expires before" field.
- Subscription search results -> Check multiple checkboxes -> Edit
  selected serials: "Expiration date" field.
- Subscription details -> Serial collection -> Edit serials ->
  "Published on" and "Expected on" fields.
- Subscription details -> Renew -> "Start date" field in the popup
  window.
- Subscription details -> Edit subscription -> Page 2 -> "First issue
  publication date," "Subscription start date," and "Subscription end
  date" fields.
- Locate a subscription with manual history enabled. From the
  subscription detail page, click the "Planning" tab, then "Edit
  history" -> Linked fields "Subscription start date" and "Subscription
  end date."

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-10-05 10:58:14 +02:00

417 lines
18 KiB
Text

[% USE raw %]
[% USE Asset %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Numbering patterns &rsaquo; Serials &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="ser_subscription_numberpatterns" class="ser">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'serials-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a>
</li>
[% IF ( new ) %]
<li>
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Numbering patterns</a>
</li>
<li>
<a href="#" aria-current="page">
New numbering pattern
</a>
</li>
[% ELSIF ( modify ) %]
<li>
<a href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Numbering patterns</a>
</li>
<li>
<a href="#" aria-current="page">
Modifying numbering pattern '[% label | html %]'
</a>
</li>
[% ELSE %]
<li>
<a href="#" aria-current="page">
Numbering patterns
</a>
</li>
[% END %]
</ol>
</nav>
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% IF (new or modify) %]
[% IF (new) %]
<h1>New numbering pattern</h1>
[% IF (error_existing_numberpattern) %]
<div class="dialog alert">
<p>A pattern with this name already exists.</p>
</div>
[% END %]
[% ELSE %]
<h1>Modify pattern: [% label | html %]</h1>
[% IF (error_existing_numberpattern) %]
<div class="dialog alert">
<p>Another pattern with this name already exists.</p>
</div>
[% END %]
[% END %]
<form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="post">
[% IF (new) %]
<input type="hidden" name="op" value="savenew" />
[% ELSE %]
<input type="hidden" name="op" value="savemod" />
<input type="hidden" name="id" value="[% id | html %]" />
[% END %]
<fieldset class="rows">
<ol>
<li>
<label for="label">Name:</label>
<input type="text" id="label" name="label" value="[% label | html %]" />
</li>
<li>
<label for="description">Description:</label>
<input type="text" id="description" name="description" value="[% description | html %]" size="50" />
</li>
<li>
<label for="numberingmethod">Numbering formula:</label>
<input type="text" id="numberingmethod" name="numberingmethod" value="[% numberingmethod | html %]" />
</li>
<li>
<label for="displayorder">Display order:</label>
<input type="text" id="displayorder" name="displayorder" value="[% displayorder | html %]" />
</li>
</ol>
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>X</th>
<th>Y</th>
<th>Z</th>
</tr>
</thead>
<tbody>
<tr>
<td>Label</td>
<td><input type="text" id="label1" name="label1" value="[% label1 | html %]" /></td>
<td><input type="text" id="label2" name="label2" value="[% label2 | html %]" /></td>
<td><input type="text" id="label3" name="label3" value="[% label3 | html %]" /></td>
</tr>
<tr>
<td>Add</td>
<td><input type="text" id="add1" name="add1" value="[% add1 | html %]" /></td>
<td><input type="text" id="add2" name="add2" value="[% add2 | html %]" /></td>
<td><input type="text" id="add3" name="add3" value="[% add3 | html %]" /></td>
</tr>
<tr>
<td>Every</td>
<td><input type="text" id="every1" name="every1" value="[% every1 | html %]" /></td>
<td><input type="text" id="every2" name="every2" value="[% every2 | html %]" /></td>
<td><input type="text" id="every3" name="every3" value="[% every3 | html %]" /></td>
</tr>
<tr>
<td>Set back to</td>
<td><input type="text" id="setto1" name="setto1" value="[% setto1 | html %]" /></td>
<td><input type="text" id="setto2" name="setto2" value="[% setto2 | html %]" /></td>
<td><input type="text" id="setto3" name="setto3" value="[% setto3 | html %]" /></td>
</tr>
<tr>
<td>When more than</td>
<td><input type="text" id="whenmorethan1" name="whenmorethan1" value="[% whenmorethan1 | html %]" /></td>
<td><input type="text" id="whenmorethan2" name="whenmorethan2" value="[% whenmorethan2 | html %]" /></td>
<td><input type="text" id="whenmorethan3" name="whenmorethan3" value="[% whenmorethan3 | html %]" /></td>
</tr>
<tr>
[% BLOCK numbering_select %]
<select id="[% name | html %]" name="[% name | html %]">
<option value=""></option>
[% IF (value == "dayname") %]
<option selected="selected" value="dayname">Name of day</option>
[% ELSE %]
<option value="dayname">Name of day</option>
[% END %]
[% IF (value == "dayabrv") %]
<option selected="selected" value="dayabrv">Name of day (abbreviated)</option>
[% ELSE %]
<option value="dayabrv">Name of day (abbreviated)</option>
[% END %]
[% IF (value == "monthname") %]
<option selected="selected" value="monthname">Name of month</option>
[% ELSE %]
<option value="monthname">Name of month</option>
[% END %]
[% IF (value == "monthabrv") %]
<option selected="selected" value="monthabrv">Name of month (abbreviated)</option>
[% ELSE %]
<option value="monthabrv">Name of month (abbreviated)</option>
[% END %]
[% IF (value == "season") %]
<option selected="selected" value="season">Name of season</option>
[% ELSE %]
<option value="season">Name of season</option>
[% END %]
[% IF (value == "seasonabrv") %]
<option selected="selected" value="seasonabrv">Name of season (abbreviated)</option>
[% ELSE %]
<option value="seasonabrv">Name of season (abbreviated)</option>
[% END %]
</select>
[% END %]
<td>Formatting</td>
<td>[% PROCESS numbering_select name="numbering1" value=numbering1 %]</td>
<td>[% PROCESS numbering_select name="numbering2" value=numbering2 %]</td>
<td>[% PROCESS numbering_select name="numbering3" value=numbering3 %]</td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset class="action">
<button type="submit" class="btn btn-default">Save</button>
<button type="reset" class="btn btn-default">Reset</button>
<a class="cancel" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl">Cancel</a>
</fieldset>
</form>
<form>
<fieldset class="rows">
<legend>Test prediction pattern</legend>
<ol>
<li>
<label for="frequency">Frequency: </label>
<select id="frequency">
[% FOREACH frequency IN frequencies_loop %]
<option value="[% frequency.id | html %]">[% frequency.description | html %]</option>
[% END %]
</select>
</li>
<li>
<label for="firstacquidate">First issue publication date: </label>
<input type="text" id="firstacquidate" class="flatpickr" size="10" />
</li>
<li>
<label for="sublength">Subscription length:</label>
<select id="subtype">
<option value="issues">issues</option>
<option value="weeks">weeks</option>
<option value="months">months</option>
</select>
<input type="text" id="sublength" size="3" />
</li>
<li>
<label for="locale">Locale: </label>
<select id="locale" name="locale">
<option value=""></option>
[% FOREACH locale IN locales %]
<option value="[% locale.language | html %]">[% locale.description | html %]</option>
[% END %]
</select>
<span class="hint">If empty, English is used</span>
</li>
</ol>
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>X</th>
<th>Y</th>
<th>Z</th>
</tr>
</thead>
<tbody>
<tr>
<td>Begins with</td>
<td><input type="text" id="lastvalue1" name="lastvalue1" value="[% lastvalue1 | html %]" /></td>
<td><input type="text" id="lastvalue2" name="lastvalue2" value="[% lastvalue2 | html %]" /></td>
<td><input type="text" id="lastvalue3" name="lastvalue3" value="[% lastvalue3 | html %]" /></td>
</tr>
<tr>
<td>Inner counter</td>
<td><input type="text" id="innerloop1" name="innerloop1" value="[% innerloop1 | html %]" /></td>
<td><input type="text" id="innerloop2" name="innerloop2" value="[% innerloop2 | html %]" /></td>
<td><input type="text" id="innerloop3" name="innerloop3" value="[% innerloop3 | html %]" /></td>
</tr>
</tbody>
</table>
<fieldset class="action">
<button type="button" id="test_pattern" class="btn btn-default">Test pattern</button>
</fieldset>
<div id="predictionpattern"></div>
</fieldset>
</form>
[% ELSE %]
<h1>Numbering patterns</h1>
[% IF still_used %]
<div class="dialog alert">
<p>
This pattern is still used by [% subscriptions.size | html %]
subscription(s). Do you still want to delete it?
</p>
<p><a href="#" id="show_blocking_subs">Show subscriptions</a></p>
<ul id="blocking_subs" style="display:none">
[% FOREACH sub IN subscriptions %]
<li style="list-style-type:none">
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% sub.subscriptionid | uri %]">[% sub.title | html %]</a>
</li>
[% END %]
</ul>
<form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="get">
<input type="hidden" name="op" value="del" />
<input type="hidden" name="confirm" value="1" />
<input type="hidden" name="id" value="[% id | html %]" />
<button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
</form>
<form action="/cgi-bin/koha/serials/subscription-numberpatterns.pl" method="get">
<button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
</form>
</div>
[% END %]
<div id="toolbar" class="btn-toolbar">
<a class="btn btn-default" id="newnumberpattern" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=new"><i class="fa fa-plus"></i> New numbering pattern</a>
</div>
[% IF (numberpatterns_loop.size) %]
<table id="numberpatternst">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Numbering formula</th>
<th>Display order</th>
<th class="noExport">Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH numberpattern IN numberpatterns_loop %]
<tr>
<td>[% numberpattern.label | html %]</td>
<td>[% numberpattern.description | html %]</td>
<td>[% numberpattern.numberingmethod | html %]</td>
<td>[% numberpattern.displayorder | html %]</td>
<td class="actions">
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=modify&id=[% numberpattern.id | html %]"><i class="fa fa-pencil"></i> Edit</a>
<a class="delete_pattern btn btn-default btn-xs" href="/cgi-bin/koha/serials/subscription-numberpatterns.pl?op=del&id=[% numberpattern.id | html %]"><i class="fa fa-trash"></i> Delete</a>
</td>
</tr>
[% END %]
</tbody>
</table>
[% ELSE %]
<p>There are no existing numbering patterns.</p>
[% END %]
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'serials-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% IF (daily_options) %]
[% Asset.js("js/showpredictionpattern.js") | $raw %]
[% END %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'datatables.inc' %]
<script>
function confirmDelete() {
return confirm(_("Are you sure you want to delete this numbering pattern?"));
}
[% IF (new or modify) %]
function testPattern() {
var frequencyid = $("#frequency").val();
var firstacquidate = $("#firstacquidate").val();
var error = 0;
var error_msg = "";
if(frequencyid == undefined || frequencyid == "") {
error_msg += _("- Frequency is not defined") + "\n";
error ++;
}
if(firstacquidate == undefined || firstacquidate == "") {
error_msg += _("- First publication date is not defined") + "\n";
error ++;
}
if(error){
alert(_("Cannot test prediction pattern for the following reason(s):") + "\n\n"
+ error_msg);
return false;
}
var ajaxData = {
'custompattern': true,
};
var ajaxParams = [
'firstacquidate', 'subtype', 'sublength', 'frequency', 'numberingmethod',
'lastvalue1', 'lastvalue2', 'lastvalue3', 'add1', 'add2', 'add3',
'every1', 'every2', 'every3', 'innerloop1', 'innerloop2', 'innerloop3',
'setto1', 'setto2', 'setto3', 'numbering1', 'numbering2', 'numbering3',
'whenmorethan1', 'whenmorethan2', 'whenmorethan3', 'locale'
];
for(i in ajaxParams) {
var param = ajaxParams[i];
var value = $("#"+param).val();
if(value.length > 0)
ajaxData[param] = value;
}
$.ajax({
url: "/cgi-bin/koha/serials/showpredictionpattern.pl",
data: ajaxData,
async: false,
dataType: "text",
success: function(data) {
$("#predictionpattern").html(data);
}
});
}
[% END %]
function show_blocking_subs() {
$("#blocking_subs").show();
}
$(document).ready(function(){
$("#numberpatternst").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
],
"sPaginationType": "full"
}));
$(".delete_pattern").on("click",function(){
return confirmDelete();
});
$("#show_blocking_subs").on("click",function(e){
e.preventDefault();
$("#blocking_subs").show();
});
$("#test_pattern").on("click",function(){
testPattern();
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]