From f2026cc8fbe61cd4db78defc828dd00709046fc0 Mon Sep 17 00:00:00 2001
From: Elliott Davis <elliott@bywatersolions.com>
Date: Tue, 29 Jan 2013 02:32:18 -0500
Subject: [PATCH] Added the ability to save and continue editing in cataloging.

This patch adds the ability for catalogers to save and continue editing when adding new biblios.
This is helpful in the event of a power failure or perhaps in the event you step away for a sandwich and your co-worker closes your tab to look at cats.

To Test:

Select an existing item or create a new item in cataloging using your favorite framework.
Edit the item
From the save menu in the dropdown, select the new option of "Save and continue editing"
If you are missing requited fields you should still be prompted to fill them in before saving
Once all required fields are in place you should be allowed to save and should be on the same page
(You're fresh bib record should also be saved)

http://bugs.koha-community.org/show_bug.cgi?id=7883
Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>
---
 cataloguing/addbiblio.pl                           |    7 +++++--
 .../prog/en/modules/cataloguing/addbiblio.tt       |    9 +++++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index 51b3c7a..e646942 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -871,7 +871,7 @@ if ( $op eq "addbiblio" ) {
         else {
             ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
         }
-        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view")){
+        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
 	    if ($frameworkcode eq 'FA'){
 		print $input->redirect(
             '/cgi-bin/koha/cataloguing/additem.pl?'
@@ -892,7 +892,7 @@ if ( $op eq "addbiblio" ) {
 		exit;
 	    }
         }
-	elsif($is_a_modif || $redirect eq "view"){
+	elsif(($is_a_modif || $redirect eq "view") && $redirect ne "just_save"){
             my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
             my $views = { C4::Search::enabled_staff_search_views };
             if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
@@ -907,6 +907,9 @@ if ( $op eq "addbiblio" ) {
             exit;
 
 	}
+	elsif ($redirect eq "just_save"){
+	    print $input->redirect("/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber&framework=$frameworkcode");
+	}
 	else {
           $template->param(
             biblionumber => $biblionumber,
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
index 415c65f..335da69 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
@@ -292,14 +292,14 @@ function Changefwk(FwkList) {
                     <div class="dialog alert">
                         <h4>Duplicate record suspected</h4>
                         <p>Is this a duplicate of <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% duplicatebiblionumber %]" onclick="openWindow('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% duplicatebiblionumber %]&amp;popup=1', 'Duplicate biblio','800','600'); return false;">[% duplicatetitle %]</a>?</p>
-                        [% IF ( CAN_user_editcatalogue_edit_items ) %]<form action="/cgi-bin/koha/cataloguing/additem.pl" method="get">
+                        [% IF ( CAN_user_editcatalogue_edit_items ) %]<form action="/cgi-bin/koha/cataloguing/additemelliott.pl" method="get">
                                                     <input type="hidden" name="biblionumber" value="[% duplicatebiblionumber %]" />
                                                     <input type="submit" class="edit" value="Yes: Edit existing items" />
-                                                </form>[% ELSE %]<form action="/cgi-bin/koha/catalogue/detail.pl" method="get">
+                                                </form>[% ELSE %]<form action="/cgi-bin/koha/catalogue/detailelliott.pl" method="get">
                                                     <input type="hidden" name="biblionumber" value="[% duplicatebiblionumber %]" />
                                                     <input type="submit" value="Yes: View existing items" />
                                                 </form>[% END %]
-                        <form action="/cgi-bin/koha/cataloguing/addbiblio.pl" method="get">
+                        <form action="/cgi-bin/koha/cataloguing/addbibliolasers.pl" method="get">
                         [% IF ( CAN_user_editcatalogue_edit_items ) %]<input type="button" class="save" onclick="confirmnotdup('items'); return false;" value="No: Save as new record" />[% ELSE %]<input type="button" class="save" onclick="confirmnotdup('view'); return false;" value="No: Save as new record" />[% END %]
                         </form>
                     </div>
@@ -351,7 +351,8 @@ function Changefwk(FwkList) {
 
     var savemenu = [
         { text: _("Save and view record"), value: 1, onclick: {fn:function(){redirect("view");}} },
-        { text: _("Save and edit items"), value: 2, onclick: {fn:function(){redirect("items");}} }
+        { text: _("Save and edit items"), value: 2, onclick: {fn:function(){redirect("items");}} },
+        { text: _("Save and continue editing"), value: 3, onclick: {fn:function(){redirect("just_save");}} }
     ];
 [% END %]
 
-- 
1.7.2.5