Bugzilla – Attachment 167246 Details for
Bug 36789
Transform a booking into checkout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36789: Transform a booking into checkout
Bug-36789-Transform-a-booking-into-checkout.patch (text/plain), 7.12 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-05-29 14:10:12 UTC
(
hide
)
Description:
Bug 36789: Transform a booking into checkout
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-05-29 14:10:12 UTC
Size:
7.12 KB
patch
obsolete
>From d2cdf6ec344f707b860e40dff54c99c7cbcfdcf3 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Mon, 6 May 2024 12:50:01 +0200 >Subject: [PATCH] Bug 36789: Transform a booking into checkout >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Directly from the bookings list, you can perform a checkout with booked >item. > >Test plan: > >1) Got an item booked :) >2) Click on transform to checkout >3) Normally you will be redirected to circulation.pl checkout view with > form infos from booking (due date is calculated from today + booking >length period - new circulation rule - see bug 36271) >4) If issue is confirmed, the booking will be deleted. > >Sponsored by: Association de Gestion des Ã…uvres Sociales d'Inria (AGOS) >--- > bookings/list.pl | 32 +++++++++++++++++-- > circ/circulation.pl | 7 ++++ > .../prog/en/modules/bookings/list.tt | 6 ++++ > .../prog/en/modules/circ/circulation.tt | 5 ++- > 4 files changed, 47 insertions(+), 3 deletions(-) > >diff --git a/bookings/list.pl b/bookings/list.pl >index 6333287e041..38585b2b6e6 100755 >--- a/bookings/list.pl >+++ b/bookings/list.pl >@@ -21,8 +21,14 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >+use Koha::Biblios; >+use Koha::Bookings; >+use Koha::Patrons; >+use Koha::Items; >+use Koha::CirculationRules; >+ > use C4::Output qw( output_html_with_http_headers ); >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user ); > > my $input = CGI->new; > my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( >@@ -35,7 +41,29 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( > ); > > my $biblionumber = $input->param('biblionumber'); >-my $biblio = Koha::Biblios->find($biblionumber); >+my $biblio = Koha::Biblios->find( { biblionumber => $biblionumber } ); >+my $booking = Koha::Bookings->find( { biblio_id => $biblionumber } ); >+if ($booking) { >+ >+ my $patron = Koha::Patrons->find( { borrowernumber => $booking->patron_id } ); >+ my $item = Koha::Items->find( { itemnumber => $booking->item_id } ); >+ >+ my $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ categorycode => $patron->categorycode, >+ itemtype => $item->effective_itemtype, >+ branchcode => $item->homebranch, >+ rule_name => 'bookings_period_length', >+ >+ } >+ ); >+ >+ my $bookings_period_length = $rule ? $rule->rule_value : 0; >+ >+ $template->param( >+ bookings_period_length => $bookings_period_length, >+ ); >+} > > $template->param( > biblionumber => $biblionumber, >diff --git a/circ/circulation.pl b/circ/circulation.pl >index d1c2b3b0cfb..6958c507278 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -56,6 +56,7 @@ use Koha::SearchEngine; > use Koha::SearchEngine::Search; > use Koha::Patron::Modifications; > use Koha::Token; >+use Koha::Bookings; > > use List::MoreUtils qw( uniq ); > >@@ -321,11 +322,13 @@ if ($patron) { > # > if (@$barcodes && $op eq 'cud-checkout') { > my $checkout_infos; >+ my $from_booking = $query->param('booking_id') ? '1' : '0'; > for my $barcode ( @$barcodes ) { > > my $template_params = { > barcode => $barcode, > onsite_checkout => $onsite_checkout, >+ from_booking => $from_booking, > }; > > # always check for blockers on issuing >@@ -553,6 +556,10 @@ if (@$barcodes && $op eq 'cud-checkout') { > confirmation_needed => $confirmation_needed, > ); > } >+ if($from_booking){ >+ my $booking = Koha::Bookings->find( $query->param('booking_id') ); >+ $booking->delete; >+ } > } > > ################################################################################## >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >index 47740506f89..4abb9e0ac64 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >@@ -73,6 +73,7 @@ > var update_success = 0; > var bookings_table; > var timeline; >+ var bookings_period_length = "[% bookings_period_length | html %]"; > $(document).ready(function(){ > > var items = $.ajax({ >@@ -273,9 +274,14 @@ > "orderable": false, > "render": function(data, type, row, meta) { > let result = ""; >+ let today = new Date(); >+ let due_date = new Date(); >+ due_date.setDate(today.getDate() + parseInt(bookings_period_length)); >+ let formatted_date = `${due_date.getFullYear()}-${String(due_date.getMonth() + 1).padStart(2, '0')}-${String(due_date.getDate()).padStart(2, '0')} ${String(due_date.getHours()).padStart(2, '0')}:${String(due_date.getMinutes()).padStart(2, '0')}`; > [% IF CAN_user_circulate_manage_bookings %] > result += '<button type="button" class="btn btn-default btn-xs edit-action" data-toggle="modal" data-target="#placeBookingModal" data-booking="'+row.booking_id+'" data-biblionumber="[% biblionumber | uri %]" data-itemnumber="'+row.item_id+'" data-patron="'+row.patron_id+'" data-pickup_library="'+row.pickup_library_id+'" data-start_date="'+row.start_date+'" data-end_date="'+row.end_date+'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</button>'; > result += '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>'; >+ result += `<form name="checkout-transform" method="post" action="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${row.patron_id}"><input type="hidden" name="op" value="cud-checkout"/><input type="hidden" name="borrowernumber" value="${row.patron_id}"/><input type="hidden" name="barcode" value="${row.item.external_id}"/><input type="hidden" name="duedatespec" value="${formatted_date}"/><input type="hidden" name="booking_id" value="${row.booking_id}"/><button id="checkout_action" class="btn btn-default btn-xs" type="submit">${_("Transform to checkout")}</button></form>`; > [% END %] > return result; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index d6ebd2a0cfb..cf4611939d4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -1049,7 +1049,10 @@ > if ( $("#onsite_checkout").prop('checked') ) { > duedatespec_fp.setDate("[% today_due_date_and_time | $KohaDates dateformat => 'iso', with_hours => 1 %]"); > } else { >- duedatespec_fp.setDate(""); >+ var from_booking = [% from_booking | html %]; >+ if (!from_booking) { >+ duedatespec_fp.setDate(""); >+ } > } > } > } >-- >2.30.2
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 36789
:
166213
|
167191
|
167242
|
167246
|
167268
|
167307
|
167309
|
167311
|
167368
|
167369
|
167602
|
167906
|
167907
|
170198
|
171553
|
171554
|
171555
|
172058
|
172059
|
172060
|
176452
|
176453
|
176489