Bugzilla – Attachment 152407 Details for
Bug 34030
Print slips in a batch from the preservation module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34030: Add a "print slips" action links to print in batch
Bug-34030-Add-a-print-slips-action-links-to-print-.patch (text/plain), 10.22 KB, created by
Jonathan Druart
on 2023-06-16 12:23:19 UTC
(
hide
)
Description:
Bug 34030: Add a "print slips" action links to print in batch
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-06-16 12:23:19 UTC
Size:
10.22 KB
patch
obsolete
>From fc9cf4f221acbd0b9f1c3dc7833e84f20d445c98 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 16 Jun 2023 12:34:59 +0200 >Subject: [PATCH] Bug 34030: Add a "print slips" action links to print in batch > >Sponsored-by: BULAC - http://www.bulac.fr/ >--- > koha-tmpl/intranet-tmpl/prog/css/print.css | 4 + > .../prog/en/modules/circ/printslip.tt | 12 ++- > .../components/Preservation/TrainsShow.vue | 95 ++++++++++++++++++- > preservation/print_slip.pl | 43 ++++----- > 4 files changed, 122 insertions(+), 32 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/print.css b/koha-tmpl/intranet-tmpl/prog/css/print.css >index b1cbc010b6b..2a914e657f9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/print.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/print.css >@@ -1,3 +1,7 @@ >+@media print { >+ .pagebreak { break-after: page; } >+} >+ > a:link { > color : #000000; > text-decoration: none; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index e75a25b6be8..ab07dbf4a3b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -26,12 +26,18 @@ > <body id="circ_printslip" class="circ"> > <div id="receipt"> > >-[% IF plain %] >+[% UNLESS slips && slips.size %] >+ [% SET slips = [{content => slip, is_html => !plain}] %] >+[% END %] >+[% FOR slip IN slips %] >+[% UNLESS slip.is_html %] > <pre> >-[% IF ( slip ) %][% slip | html %][% ELSE %]No slip template found[% END %] >+[% IF ( slip.content ) %][% slip.content | html %][% ELSE %]No slip template found[% END %] > </pre> > [% ELSE %] >-[% IF ( slip ) %][% slip | $raw %][% ELSE %]No slip template found[% END %] >+[% IF ( slip.content ) %][% slip.content | $raw %][% ELSE %]No slip template found[% END %] >+[% END %] >+[% IF slips.size > 1 && !loop.last%]<div class="pagebreak"></div>[% END %] > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >index 6675ba3e7fd..fe34e4c8452 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >@@ -147,6 +147,27 @@ > </fieldset> > <fieldset v-if="train.items.length" class="rows"> > <legend>{{ $__("Items") }}</legend> >+ <span class="action_links"> >+ <a >+ role="link" >+ @click="selectAll()" >+ :title="$__('Select all')" >+ ><i class="fa fa-check"></i>{{ $__("Select all") }}</a >+ > >+ <a @click="clearAll()" :title="$__('Clear all')" >+ ><i class="fa fa-remove"></i>{{ $__("Clear all") }}</a >+ > >+ {{ $__("Actions: ") }} >+ <a >+ v-if="selected_items.length > 0" >+ @click="printSelected()" >+ :title="$__('Print slip')" >+ ><i class="fa fa-print"></i>{{ $__("Print slip") }}</a >+ > >+ <a v-else class="disabled" :title="$__('Print slip')" >+ ><i class="fa fa-print"></i>{{ $__("Print slip") }}</a >+ > >+ </span> > <table v-if="item_table.display" :id="table_id"></table> > <ol v-else> > <li >@@ -260,6 +281,7 @@ export default { > train_list: [], > train_id_selected_for_copy: null, > train_item_id_to_copy: null, >+ selected_items: [], > av_options: {}, > } > }, >@@ -301,11 +323,21 @@ export default { > this.item_table.data.push(item_row) > }) > this.item_table.columns = [] >- this.item_table.columns.push({ >- name: "", >- title: this.$__("ID"), >- data: "item.user_train_item_id", >- }) >+ this.item_table.columns.push( >+ { >+ name: "checkboxes", >+ className: "checkboxes", >+ width: "5%", >+ render: (data, type, row) => { >+ return "" >+ }, >+ }, >+ { >+ name: "", >+ title: this.$__("ID"), >+ data: "item.user_train_item_id", >+ } >+ ) > train.default_processing.attributes.forEach(a => > this.item_table.columns.push({ > name: a.name, >@@ -468,6 +500,38 @@ export default { > } > ) > }, >+ clearAll() { >+ this.selected_items = [] >+ $("#" + this.table_id) >+ .find("input[name='user_train_item_id'][type='checkbox']") >+ .prop("checked", false) >+ }, >+ selectAll() { >+ $("#" + this.table_id) >+ .find("input[name='user_train_item_id'][type='checkbox']") >+ .each((i, input) => { >+ this.selected_items.push($(input).val()) >+ $(input).prop("checked", true) >+ }) >+ }, >+ printSelected() { >+ window.open( >+ "/cgi-bin/koha/preservation/print_slip.pl?%s_blank".format( >+ this.selected_items >+ .map(id => "train_item_id=" + id) >+ .join("&") >+ ) >+ ) >+ }, >+ updateSelectedItems(checked, train_item_id) { >+ if (checked) { >+ this.selected_items.push(train_item_id) >+ } else { >+ this.selected_items = this.selected_items.filter( >+ id => id != train_item_id >+ ) >+ } >+ }, > build_datatable: function () { > let table_id = this.table_id > let item_table = this.item_table >@@ -476,6 +540,7 @@ export default { > let printSlip = this.printSlip > let selectTrainForCopy = this.selectTrainForCopy > let train = this.train >+ let updateSelectedItems = this.updateSelectedItems > > let table = KohaTable(table_id, { > data: item_table.data, >@@ -484,6 +549,25 @@ export default { > columns: item_table.columns, > drawCallback: function (settings) { > var api = new $.fn.dataTable.Api(settings) >+ $.each($(this).find("td.checkboxes"), function (index, e) { >+ let tr = $(this).parent() >+ let train_item = api.row(tr).data().item >+ let train_item_id = train_item.train_item_id >+ >+ let checkbox = createVNode("input", { >+ type: "checkbox", >+ name: "user_train_item_id", >+ value: train_item_id, >+ onChange: e => { >+ updateSelectedItems( >+ e.target.checked, >+ train_item_id >+ ) >+ }, >+ }) >+ >+ render(checkbox, e) >+ }) > $.each($(this).find("td.actions"), function (index, e) { > let tr = $(this).parent() > let train_item = api.row(tr).data().item >@@ -588,6 +672,7 @@ export default { > .action_links a { > padding-left: 0.2em; > font-size: 11px; >+ cursor: pointer; > } > .attributes_values { > float: left; >diff --git a/preservation/print_slip.pl b/preservation/print_slip.pl >index ec3687ba0f1..67bd6eede04 100755 >--- a/preservation/print_slip.pl >+++ b/preservation/print_slip.pl >@@ -26,7 +26,7 @@ use Koha::Patrons; > use Koha::Preservation::Train::Items; > > my $input = CGI->new; >-my $train_item_id = $input->param('train_item_id'); >+my @train_item_ids = $input->multi_param('train_item_id'); > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -40,32 +40,27 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > my $logged_in_user = Koha::Patrons->find($loggedinuser); > my $branch = C4::Context->userenv->{'branch'}; > >-my $train_item = Koha::Preservation::Train::Items->find($train_item_id); >- >-unless ($train_item){ >- print $input->redirect("/cgi-bin/koha/errors/404.pl"); >- exit; >+my ( @slips, $is_html ); >+for my $train_item_id ( @train_item_ids ) { >+ my $train_item = Koha::Preservation::Train::Items->find($train_item_id); >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'preservation', >+ letter_code => $train_item->processing->letter_code, >+ branchcode => $branch, >+ lang => $logged_in_user->lang, >+ tables => { >+ preservation_train_items => $train_item_id, >+ }, >+ message_transport_type => 'print' >+ ); >+ push @slips, { >+ content => $letter->{content}, >+ is_html => $letter->{is_html}, >+ }; > } > >-my $train = $train_item->train; >- >-my $letter = C4::Letters::GetPreparedLetter( >- module => 'preservation', >- letter_code => $train_item->processing->letter_code, >- branchcode => $branch, >- lang => $logged_in_user->lang, >- tables => { >- preservation_train_items => $train_item_id, >- }, >- message_transport_type => 'print' >-); >- >-my $slip = $letter->{content}; >-my $is_html = $letter->{is_html}; >- > $template->param( >- slip => $slip, >- plain => !$is_html, >+ slips => \@slips, > caller => 'preservation', > stylesheet => C4::Context->preference("SlipCSS"), > ); >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34030
:
152407
|
152408
|
152975
|
152976
|
154208
|
154209
|
156972
|
156973
|
156975
|
156976
|
157591
|
157592