Bug 13818 - Editing and saving a course reserve displays the add item form
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 10 Mar 2015 18:25:48 +0000 (14:25 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 25 Mar 2015 14:25:26 +0000 (11:25 -0300)
If one chooses to edit an existing course reserve for an item, saving it
should go back to the course details, but instead displays the "add
items: scan barcode" form.

Test Plan:
1) Edit a course reserve
2) Save it
3) Note you get the "add items: scan barcode" form
4) Apply this patch
5) Repeat steps 1 and 2
6) Note you are now redirected back to the course details page

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

course_reserves/add_items.pl
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt
koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt

index 0a96860..ecae625 100755 (executable)
@@ -35,6 +35,7 @@ my $cgi = new CGI;
 my $action    = $cgi->param('action')    || '';
 my $course_id = $cgi->param('course_id') || '';
 my $barcode   = $cgi->param('barcode')   || '';
+my $return    = $cgi->param('return')    || '';
 
 my $item = GetBiblioFromItemNumber( undef, $barcode );
 
@@ -73,6 +74,7 @@ if ( $action eq 'lookup' ) {
         locations => GetAuthorisedValues('LOC'),
         itypes    => GetItemTypes( style => 'array' ),
         branches  => GetBranchesLoop(),
+        return    => $return,
     );
 
 } elsif ( $action eq 'add' ) {
@@ -90,6 +92,11 @@ if ( $action eq 'lookup' ) {
         staff_note  => $cgi->param('staff_note'),
         public_note => $cgi->param('public_note'),
     );
+
+    if ( $return ) {
+        print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=$return");
+        exit;
+    }
 }
 
 output_html_with_http_headers $cgi, $cookie, $template->output;
index 96bf783..2ec285f 100644 (file)
@@ -18,6 +18,7 @@
 
         <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
             <input type="hidden" name="course_id" value="[% course.course_id %]" />
+            <input type="hidden" name="return" value="[% return %]" />
             <input type="hidden" name="action" value="add" />
 
             <fieldset class="rows">
index 2a8dfba..429782a 100644 (file)
                             <td>[% cr.public_note %]</td>
 
                             [% IF CAN_user_coursereserves_add_reserves %]
-                                <td><a href="add_items.pl?course_id=[% course.course_id %]&amp;barcode=[% cr.item.barcode %]&amp;action=lookup">Edit</a></td>
+                                <td><a href="add_items.pl?course_id=[% course.course_id %]&amp;barcode=[% cr.item.barcode %]&amp;action=lookup&amp;return=[% course.course_id %]">Edit</a></td>
                             [% END %]
 
                             [% IF CAN_user_coursereserves_delete_reserves %]