Koha/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt
Jonathan Druart 520bda9a45
Bug 37982: Replace edit form with GET
Caught by tests from bug 37728

 # $VAR3 = 'koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt:158';

We don't really need the form to be POSTed, we should not reach the URL maxlength.
The UI will certainly explode if there are lot of items to edit anyway.
The code is not clear on this page as we are sending several forms using
the items selected from this table. But this one form is used to display
the edit form and so can be GET (and better as the URL can be shared).
The other actions have their own form (in modals mostly).

Test plan:
Create a subscription and go to the serial collection page.
Make sure at least one item is select and click the "Edit" button.
No behaviour change expected here, the edit form should still be
displayed.
Try the other actions on top of the table and confirm they are still
working as before.

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2024-09-30 15:26:22 +01:00

431 lines
27 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE AuthorisedValues %]
[% USE Branches %]
[% USE HtmlTags %]
[% USE KohaDates %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% t("Serial collection information") | html %] &rsaquo;
[% bibliotitle | html %] &rsaquo;
[% t("Serials") | html %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="ser_serials-collection" class="ser">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'serials-search.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a>
[% END %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscriptionid | uri %]"><em>[% bibliotitle | html %]</em></a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Serial collection information</span>
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-md-10 order-md-2 order-sm-1">
<main>
[% INCLUDE 'messages.inc' %]
[% INCLUDE 'modals/serials_multi_receiving.inc' %]
[% INCLUDE 'modals/serials_skip_issues.inc' %]
[% INCLUDE 'modals/generate_next.inc' %]
[% UNLESS ( popup ) %]
[% INCLUDE 'serials-toolbar.inc' %]
<h1>
Serial collection information for <em>[% bibliotitle | html %]</em>
[% IF location %] ([% AuthorisedValues.GetByCode( 'LOC', location ) | html %]) [% END %]
[% IF ( callnumber ) %]callnumber: [% callnumber | html %][% END %]
</h1>
[% END %]
[% IF ( delete ) %]
<div class="alert alert-warning">
<h3>You are about to delete [% serialnumber | html %] serial(s). Do you want to continue?</h3>
<form method="post" action="/cgi-bin/koha/serials/serials-collection.pl">
[% INCLUDE 'csrf-token.inc' %]
[% IF countitems > 0 %]
<h5>Number of items available: [% countitems | html %]</h5>
<p>
<label>Delete associated items? <input type="checkbox" name="delitems" value="Yes" />Yes</label>
</p>
[% END %]
<input type="hidden" name="op" value="cud-delete_confirmed" />
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
<input type="hidden" name="subscriptionid" value="[% subscriptionid | html %]" />
[% FOREACH serialid IN serialsid %]
<input type="hidden" name="serialid" value="[% serialid | html %]" />
[% END %]
<button type="submit" class="btn btn-default approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
</form>
<form method="get" action="/cgi-bin/koha/serials/serials-collection.pl">
<input type="hidden" name="subscriptionid" value="[% subscriptionid | html %]" />
<button type="submit" class="btn btn-default deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
</form>
</div>
[% END # /IF delete %]
[% IF ( error_delitem ) %]
<div class="alert alert-warning">
<p><strong>Error</strong>: one or more associated items could not be deleted at this time.</p>
</div>
[% END %]
[% IF ( subscriptions ) %]
<table>
[% IF ( subscriptions.size == 1 ) %]
<caption> Subscription summary</caption>
[% ELSE %]
<caption> Subscription summaries</caption>
[% END %]
<tr>
<th>Subscription num.</th>
<th>Frequency</th>
<th>Numbering pattern</th>
<th>Library</th>
<th>Call number</th>
<th>Notes</th>
<th>&nbsp;</th>
</tr>
[% FOREACH subscription IN subscriptions %]
<tr>
<td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]"># [% subscription.subscriptionid | html %]</a> </td>
<td>[% subscription.frequency.description | html %]</td>
<td>[% subscription.numberpattern.label | html %]</td>
<td>[% IF subscription.branchcode %][% Branches.GetName( subscription.branchcode ) | html %][% END %]</td>
<td> [% subscription.callnumber | html %]</td>
<td> [% subscription.notes | html | html_line_break %]
[% UNLESS subscription.closed %]
[% IF ( subscription.subscriptionexpired ) %]
<p class="problem"><i class="fa fa-exclamation-circle problem" aria-hidden="true"></i> Subscription expired</p>
[% END %]
[% ELSE %]
<br /> Subscription closed
[% END %]
</td>
[% IF ( subscription.abouttoexpire ) || ( subscription.subscriptionexpired ) %]
<td class="problem actions">
[% ELSE %]
<td class="actions">
[% END %]
[% UNLESS subscription.closed %]
[% IF ( routing && CAN_user_serials_routing ) %]
[% IF ( subscription.hasRouting ) %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit routing list</a>
[% ELSE %]
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | html %]&amp;op=new"><i class="fa fa-plus"></i> Create routing list</a>
[% END %]
[% END %]
[% IF ( subscription.abouttoexpire || subscription.subscriptionexpired) %]
<a class="btn btn-default btn-xs subscription_renew" data-subscriptionid="[% subscription.subscriptionid | html %]" href="/cgi-bin/koha/serials/subscription-renew.pl?op=renew&subscriptionid=[% subscription.subscriptionid | html %]"><i class="fa-solid fa-rotate"></i> Renew</a>
[% END %]
[% ELSE %]
&nbsp;
[% END # /UNLESS subscription.closed %]
</td>
</tr>
[% END # /FOREACH subscription %]
[% IF ( subscr ) %]
[% IF ( subscriptioncount > 1 ) %]
<tr>
<td colspan="8"> <a href="serials-collection.pl?biblionumber=[% biblionumber | uri %]">See any subscription attached to this biblio</a></td>
</tr>
[% END %]
[% END %]
</table>
[% END # /IF subscriptions %]
[% IF ( years ) %]
<form name="edition" action="/cgi-bin/koha/serials/serials-edit.pl" method="get">
[% WRAPPER tabs id= "subscription_years" %]
[% WRAPPER tabs_nav %]
[% FOREACH year IN years %]
[% IF ( loop.first ) %]
[% bt_active = 1 %]
[% ELSE %]
[% bt_active = 0 %]
[% END %]
[% IF ( year.year ) %]
[% IF year.year == 'manage' %]
[% SET tabname = "subscription-year-manage" %]
[% SET tab_text = "Manage" %]
[% ELSE %]
[% SET tabname = "subscription-year-${year.year}" %]
[% SET tab_text = year.year %]
[% END %]
[% WRAPPER tab_item tabname= tabname bt_active= bt_active %] [% tab_text | html %] [% END %]
[% END %]
[% END %]
[% END # /WRAPPER tabs_nav %]
[% WRAPPER tab_panels %]
[% FOREACH year IN years %]
[% IF ( loop.first ) %]
[% SET bt_active = 1 %]
[% ELSE %]
[% SET bt_active = 0 %]
[% END %]
[% WRAPPER tab_panel tabname="subscription-year-${year.year}" bt_active= bt_active %]
[% IF ( CAN_user_serials_receive_serials ) %]
<p>
<div class="btn-group"><input type="submit" value="Edit serials" class="btn btn-primary btn-sm" /></div>
[% UNLESS subscription.closed %]
<div class="btn-group">
<input type="button" value="Generate next" data-subscriptionid="[% subscriptionidlist | html %]" href="#generate_next" class="btn btn-default btn-sm" data-bs-toggle="modal" />
</div>
<div class="btn-group">
<input type="button" value="Skip issues and generate next" data-subscriptionid="[% subscriptionidlist | html %]" href="#skip_issues" class="btn btn-default btn-sm" data-bs-toggle="modal" />
</div>
[% IF ( subscriptions.size == 1 and !serialsadditems ) %]&nbsp;
<div class="btn-group"><input type="button" value="Multi receiving" href="#multi_receiving" class="btn btn-default btn-sm" data-bs-toggle="modal"></div>
[% END %]
[% END %]
<input type="button" value="Delete selected issues" class="delete-issues btn btn-default btn-sm" data-subscriptionids="[% subscriptionidlist | html %]" />
</p>
[% END # /IF CAN_user_serials_receive_serials %]
<span class="checkall">
<a class="CheckAll" href="#" data-year="[% year.year | html %]">Select all</a>
</span> |
<span class="clearall">
<a class="CheckNone" href="#" data-year="[% year.year | html %]">Clear all</a>
</span>
<table class="subscription-year-table">
<thead>
<tr>
[% IF ( CAN_user_serials_receive_serials ) %]
<th>Edit</th>
[% END %]
[% IF ( subscriptions.size > 1 ) %]
<th># Subs</th>
[% END %]
<th>Date published</th>
<th>Date published (text)</th>
<th>Date received</th>
<th>Number</th>
<th>Status</th>
<th>Notes</th>
<th>Library</th>
[% IF ( routing ) %]
<th>Routing</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH serial IN year.serials %]
<tr>
[% IF ( CAN_user_serials_receive_serials ) %]
<td>
[% UNLESS CAN_user_serials_receive_serials %]
disabled
[% ELSE %]
[% IF ( serial.subscriptionexpired ) %]
<input type="checkbox" name="serialid" value="[% serial.serialid | html %]" disabled="disabled" />
[% ELSE %]
[% IF ( delete ) %]
[% IF serialsid.grep("${serial.serialid}").size %]
<input type="checkbox" name="serialid" value="[% serial.serialid | html %]" disabled checked />
[% ELSE %]
<input type="checkbox" name="serialid" value="[% serial.serialid | html %]" disabled />
[% END %]
[% ELSE %]
[% IF serial.checked %]
<input type="checkbox" name="serialid" value="[% serial.serialid | html %]" checked />
[% ELSE %]
<input type="checkbox" name="serialid" value="[% serial.serialid | html %]" />
[% END %]
[% END # /IF delete %]
[% END # /IF serial.subscriptionexpired %]
[% END # /UNLESS CAN_user_serials_receive_serials %]
</td>
[% END # /IF CAN_user_serials_receive_serials %]
[% IF ( subscriptions.size > 1 ) %]
<td><a href="serials-collection.pl?subscriptionid=[% serial.subscriptionid | uri %]">[% serial.subscriptionid | html %]</a></td>
[% END %]
<td data-order="[% serial.publisheddate | html %]">
[% IF serial.publisheddate %]
[% serial.publisheddate | $KohaDates %]
[% ELSE %]
<span>Unknown</span>
[% END %]
</td>
<td data-order="[% serial.publisheddatetext | html %]">
[% IF serial.publisheddatetext %]
[% serial.publisheddatetext | html %]
[% END %]
</td>
<td data-order="[% serial.planneddate | html %]">
[% IF serial.planneddate %]
[% serial.planneddate | $KohaDates %]
[% ELSE %]
<span>Unknown</span>
[% END %]
</td>
<td>
[% IF ( matches = serial.serialseq.match('(.*)Spring(.*)') ) %]
[% matches.0 | html %]Spring[% matches.1 | html %]
[% ELSIF ( matches = serial.serialseq.match('(.*)Summer(.*)') ) %]
[% matches.0 | html %]Summer[% matches.1 | html %]
[% ELSIF ( matches = serial.serialseq.match('(.*)Fall(.*)') ) %]
[% matches.0 | html %]Fall[% matches.1 | html %]
[% ELSIF ( matches = serial.serialseq.match('(.*)Winter(.*)') ) %]
[% matches.0 | html %]Winter[% matches.1 | html %]
[% ELSIF ( matches = prediction.number.match('(.*)Spr(.*)') ) %]
[% matches.0 | html %]Spr[% matches.1 | html %]
[% ELSIF ( matches = prediction.number.match('(.*)Sum(.*)') ) %]
[% matches.0 | html %]Sum[% matches.1 | html %]
[% ELSIF ( matches = prediction.number.match('(.*)Fal(.*)') ) %]
[% matches.0 | html %]Fal[% matches.1 | html %]
[% ELSIF ( matches = prediction.number.match('(.*)Win(.*)') ) %]
[% matches.0 | html %]Win[% matches.1 | html %]
[% ELSE %]
[% serial.serialseq | html %]
[% END %]
</td>
<td>
[% INCLUDE 'serial-status.inc' serial = serial %]
</td>
<td>
[% serial.notes | html %]
</td>
<td>
[% Branches.GetName( serial.branchcode ) | html %]
</td>
[% IF ( routing ) %]
<td class="actions">
<a href="/cgi-bin/koha/serials/routing-preview.pl?op=print&amp;subscriptionid=[% serial.subscriptionid | uri %]&amp;issue=[% serial.serialseq.replace("'", "\\'") | uri %]%20([% serial.publisheddate | $KohaDates %])" class="btn btn-default btn-xs print_list"><i class="fa fa-print"></i> Print list</a>
</td>
[% END %]
</tr>
[% END %]
</tbody>
</table> <!-- /.subscription-year-table -->
[% END # /WRAPPER tab_panel#subscription-year %]
[% END # /FOREACH year %]
[% END # /WRAPPER tab_panels %]
<input type="hidden" name="subscriptionid" value="[% subscriptionidlist | html %]" />
[% END # /WRAPPER tabs#subscription_years %]
</form>
[% END # /IF years %]
</main>
</div> <!-- /.col-md-10.order-md-2 -->
<div class="col-md-2 order-sm-2 order-md-1">
<aside>
[% INCLUDE 'serials-menu.inc' %]
</aside>
</div> <!-- /.col-md-2.order-md-1 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script>
var subscriptionid = "[% subscriptionid | html %]";
</script>
[% Asset.js("js/serials-toolbar.js") | $raw %]
<script>
function deleteIssues(subscriptionid) {
var serialschecked = $("form[name='edition'] input[name='serialid']:checked");
if (serialschecked.length > 0) {
var location = 'serials-collection.pl?subscriptionid='+subscriptionid+'&op=delete_confirm';
for (i=0; i < serialschecked.length; i++) {
location += '&serialid=' + serialschecked[i].value;
}
document.location = location;
} else {
alert(_("No serials selected"));
}
}
$(document).ready(function() {
if( $("#subscription_years .tab-pane.active").length < 1 ){
$("#subscription_years a:first").tab("show");
}
$(".subscription-year-table").dataTable($.extend(true, {}, dataTablesDefaults, {
"columnDefs": [
{ "targets": [ 0,-1 ], "orderable": false, "searchable": false }
],
"order": [[0, 'desc']],
"dom": 't',
"autoWidth": false,
"paginate": false,
"info": false,
"searching": false,
} ));
$(".CheckAll").on("click", function(e){
e.preventDefault();
var years = $(this).data("year");
$("#subscription-year-" + years + "_panel" + " input:checkbox").prop("checked", true );
});
$(".CheckNone").on("click", function(e){
e.preventDefault();
var years = $(this).data("year");
$("#subscription-year-" + years + "_panel" + " input:checkbox").prop("checked", false );
});
$(".generatenext").on("click", function(e){
e.preventDefault();
var subscriptionid = $(this).data("subscriptionid");
generateNext( subscriptionid );
});
$(".subscription_renew").on("click", function(e){
e.preventDefault();
var subscriptionid = $(this).data("subscriptionid");
popup( subscriptionid );
});
$(".print_list").on("click", function(e){
e.preventDefault();
var url = $(this).attr("href");
window.open( url,'PrintSlip','width=500,height=500,toolbar=no,scrollbars=yes');
});
$('#multi_receiving').on('show', function () {
$(this).find(".modal-body").html($(".serials_multi_receiving")[0].outerHTML);
});
$("form[name='edition']").on('submit', function(e){
if ( $(this).find("input[name='serialid']:checked").size() == 0 ) {
e.preventDefault();
alert(_("You must select at least one serial to edit"));
return 0;
}
return 1;
});
$(".delete-issues").on("click", function(e){
e.preventDefault();
deleteIssues("[% subscriptionidlist | html %]");
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]