Bugzilla – Attachment 167368 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), 11.98 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-06-04 07:55:26 UTC
(
hide
)
Description:
Bug 36789: Transform a booking into checkout
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-06-04 07:55:26 UTC
Size:
11.98 KB
patch
obsolete
>From 8527c4571d6e0dc90e9ad3c5da79e927097712d5 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. >4) If issue is confirmed, the booking will be deleted. > >Sponsored by: Association de Gestion des Ã…uvres Sociales d'Inria (AGOS) >--- > C4/Circulation.pm | 6 ++++ > Koha/Booking.pm | 33 ++++++++++--------- > bookings/list.pl | 10 ++++-- > circ/circulation.pl | 5 ++- > .../prog/en/modules/bookings/list.tt | 1 + > .../prog/en/modules/circ/circulation.tt | 11 ++++++- > 6 files changed, 47 insertions(+), 19 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index bff0b1e2f56..ebdc4334d70 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -63,6 +63,7 @@ use Koha::Exceptions::Checkout; > use Koha::Plugins; > use Koha::Recalls; > use Koha::Library::Hours; >+use Koha::Bookings; > use Carp qw( carp ); > use List::MoreUtils qw( any ); > use Scalar::Util qw( looks_like_number blessed ); >@@ -1546,6 +1547,7 @@ sub AddIssue { > my $auto_renew = $params && $params->{auto_renew}; > my $cancel_recall = $params && $params->{cancel_recall}; > my $recall_id = $params && $params->{recall_id}; >+ my $booking_id = $params && $params->{booking_id}; > my $dbh = C4::Context->dbh; > my $barcodecheck = CheckValidBarcode($barcode); > >@@ -1727,6 +1729,10 @@ sub AddIssue { > q{DELETE tmp_holdsqueue, hold_fill_targets FROM tmp_holdsqueue LEFT JOIN hold_fill_targets USING ( itemnumber ) WHERE itemnumber = ?}, > undef, $item_object->id > ); >+ >+ if ($booking_id) { >+ Koha::Bookings->find( { booking_id => $booking_id } )->delete({ 'transform_to_checkout' => 1 }); >+ } > } > $issue->discard_changes; > $patron->update_lastseen('check_out'); >diff --git a/Koha/Booking.pm b/Koha/Booking.pm >index f4cbccb3ae1..edfd10cd502 100644 >--- a/Koha/Booking.pm >+++ b/Koha/Booking.pm >@@ -351,28 +351,29 @@ $booking->delete(); > =cut > > sub delete { >- my ( $self ) = @_; >+ my ( $self, $params ) = @_; > > my $deleted = $self->SUPER::delete($self); > my $patron = Koha::Patrons->find( $self->patron_id ); > my $item = Koha::Items->find( $self->item_id ); > my $library = Koha::Libraries->find( $self->pickup_library_id ); > >+ if ( not defined( $params->{'transform_to_checkout'} ) ) { > my $letter = C4::Letters::GetPreparedLetter( >- module => 'bookings', >- letter_code => 'BOOKING_CANCELLATION', >- message_transport_type => 'email', >- branchcode => $patron->branchcode, >- lang => $patron->lang, >- tables => { >- branches => $library->branchcode, >- borrowers => $patron->borrowernumber, >- items => $item->itemnumber, >- biblio => $item->biblionumber, >- biblioitems => $item->biblionumber, >- bookings => $self->unblessed, >- } >- ); >+ module => 'bookings', >+ letter_code => 'BOOKING_CANCELLATION', >+ message_transport_type => 'email', >+ branchcode => $patron->branchcode, >+ lang => $patron->lang, >+ tables => { >+ branches => $library->branchcode, >+ borrowers => $patron->borrowernumber, >+ items => $item->itemnumber, >+ biblio => $item->biblionumber, >+ biblioitems => $item->biblionumber, >+ bookings => $self->unblessed, >+ } >+ ); > > if ($letter) { > C4::Letters::EnqueueLetter( >@@ -383,6 +384,8 @@ sub delete { > } > ); > } >+ } >+ > return $deleted; > } > >diff --git a/bookings/list.pl b/bookings/list.pl >index 6333287e041..dcf12bbcfb7 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,7 @@ 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 } ); > > $template->param( > biblionumber => $biblionumber, >diff --git a/circ/circulation.pl b/circ/circulation.pl >index d1c2b3b0cfb..c67569f647d 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 ); > >@@ -67,6 +68,7 @@ my $query = CGI->new; > my $borrowernumber = $query->param('borrowernumber'); > my $barcodes = []; > my $barcode = $query->param('barcode'); >+my $booking_id = $query->param('booking_id'); > > > # Barcode given by user could be '0' >@@ -514,7 +516,7 @@ if (@$barcodes && $op eq 'cud-checkout') { > { > onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew'), > switch_onsite_checkout => $switch_onsite_checkout, cancel_recall => $cancel_recall, >- recall_id => $recall_id, >+ recall_id => $recall_id, booking_id => $booking_id > } > ); > $template_params->{issue} = $issue; >@@ -763,6 +765,7 @@ $template->param( > nopermission => scalar $query->param('nopermission'), > autoswitched => $autoswitched, > logged_in_user => $logged_in_user, >+ booking_id => $booking_id || '', > ); > > output_html_with_http_headers $query, $cookie, $template->output; >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 f1c299a40c0..c0fbf8ee0fb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >@@ -277,6 +277,7 @@ > [% 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="${row.end_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 3c9c6cfcb98..1004161e6b7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -9,6 +9,7 @@ > [% USE ItemTypes %] > [% USE Price %] > [% USE AuthorisedValues %] >+[% USE JSON.Escape %] > [% PROCESS 'i18n.inc' %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -282,6 +283,7 @@ > <fieldset> > <input type="hidden" name="restoreduedatespec" /> > <input type="hidden" name="op" value="cud-checkout" /> >+ <input type="hidden" name="booking_id" value="[% booking_id | html %]"/> > > [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %] > >@@ -390,6 +392,7 @@ > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="op" value="cud-checkout" /> > <input type="hidden" name="restoreduedatespec" /> >+ <input type="hidden" name="booking_id" value="[% booking_id | html %]"/> > > [% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %] > >@@ -423,6 +426,7 @@ > <input type="hidden" name="hold_borrower" value="[% resborrowernumber | html %]" /> > <input type="hidden" name="hold_itemnumber" value="[% item.itemnumber | html %]" /> > <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" /> >+ <input type="hidden" name="booking_id" value="[% booking_id | html %]"/> > <button class="print" type="submit" onclick="Dopop('hold-transfer-slip.pl?reserve_id=[% reserve_id | uri %]&itemnumber=[% item.id | html %]');this.form.submit();"><i class="fa fa-print"></i> Don't check out, confirm hold, and print slip (P)</button> > </form> > [% END %] >@@ -439,6 +443,7 @@ > <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" /> > <input type="hidden" name="restoreduedatespec" /> > <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" /> >+ <input type="hidden" name="booking_id" value="[% booking_id | html %]"/> > [% IF CAN_user_circulate_force_checkout or HIGHHOLDS or ADDITIONAL_MATERIALS %] > [% IF ( RENEW_ISSUE ) %] > <button type="submit" class="deny" accesskey="n"><i class="fa fa-times"></i> No, don't renew (N)</button> >@@ -1049,7 +1054,11 @@ > if ( $("#onsite_checkout").prop('checked') ) { > duedatespec_fp.setDate("[% today_due_date_and_time | $KohaDates dateformat => 'iso', with_hours => 1 %]"); > } else { >- duedatespec_fp.setDate(""); >+ var booking_id = [% booking_id.json %]; >+ console.log(booking_id); >+ if (!booking_id) { >+ 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