[Koha-patches] [PATCH] Bug 5782: Add warning when ordering a duplicate record from external source

Marcel de Rooy M.de.Rooy at rijksmuseum.nl
Mon Feb 21 14:29:31 CET 2011


Enhancement for Acquisitions/ordering from external source.
Koha already checked for duplicates, but this patch warns the user. Offers the choice to use existing record, use new record or return without making an order.
The new template is added for this interaction with the user.
---
 acqui/neworderempty.pl                             |   33 ++++++++++++++-
 .../en/modules/acqui/neworderempty_duplicate.tmpl  |   43 ++++++++++++++++++++
 2 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tmpl

diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 84fc81e..6af057d 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -134,7 +134,14 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){
 
     my $duplicatetitle;
 #look for duplicates
-    if (! (($biblionumber,$duplicatetitle) = FindDuplicate($marcrecord))){
+    ($biblionumber,$duplicatetitle) = FindDuplicate($marcrecord);
+    if($biblionumber && !$input->param('use_external_source')) {
+	#if duplicate record found and user did not decide yet, first warn user
+	#and let him choose between using new record or existing record
+	Load_Duplicate($duplicatetitle);
+	exit;
+    }
+    #from this point: add a new record
         if (C4::Context->preference("BiblioAddsAuthorities")){
             my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $params->{'frameworkcode'});
         }
@@ -163,7 +170,6 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){
             }
         }
         SetImportRecordStatus($params->{'breedingid'}, 'imported');
-    }
 }
 
 
@@ -471,3 +477,26 @@ sub MARCfindbreeding {
     return -1;
 }
 
+sub Load_Duplicate {
+  my ($duplicatetitle)= @_;
+  ($template, $loggedinuser, $cookie) = get_template_and_user(
+    {
+        template_name   => "acqui/neworderempty_duplicate.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { acquisition => 'order_manage' },
+#        debug           => 1,
+    }
+  );
+
+  $template->param(
+    biblionumber        => $biblionumber,
+    basketno            => $basketno,
+    booksellerid        => $basket->{'booksellerid'},
+    breedingid          => $params->{'breedingid'},
+    duplicatetitle      => $duplicatetitle,
+  );
+
+  output_html_with_http_headers $input, $cookie, $template->output;
+}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tmpl
new file mode 100644
index 0000000..c85f40f
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty_duplicate.tmpl
@@ -0,0 +1,43 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha &rsaquo; Acquisitions &rsaquo; Basket <!-- TMPL_VAR NAME="basketno" --> &rsaquo; Duplicate warning</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
+<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/additem.js"></script>
+<script type="text/javascript">
+</script>
+</head>
+<body>
+
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="acquisitions-search.inc" -->
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->">Basket <!-- TMPL_VAR NAME="basketno" --></a> &rsaquo; Duplicate warning</div>
+
+<div id="doc3" class="yui-t2">
+
+<div id="bd">
+    <div id="yui-main">
+    <div class="yui-b">
+
+<h2>Duplicate warning</h2>
+
+<p>You selected a record from an external source that matches an existing record in your catalog!</p>
+<p>Click Use Existing if you do not want to create a duplicate record, but you want to add an order from the existing record in your catalog. Click Create New if you still want to create a new record by importing the external (duplicate) record. Click Cancel to return to the basket without making a new order.</p>
+<p>The existing catalog record can be viewed in a new window by clicking <a target="_blank" href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="duplicatetitle" --></a>
+
+<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
+    <fieldset class="action">
+        <input type="button" value="Use Existing" onclick="window.location='/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->&basketno=<!-- TMPL_VAR NAME="basketno" -->&biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->'" />
+        <input type="button" value="Create New" onclick="window.location='/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!-- TMPL_VAR NAME="booksellerid" -->&basketno=<!-- TMPL_VAR NAME="basketno" -->&breedingid=<!-- TMPL_VAR NAME="breedingid" -->&use_external_source=1'" />
+        <input type="button" value="Cancel" onclick="window.location='/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->'" />
+    </fieldset>
+</form>
+
+</div>
+</div>
+<div class="yui-b">
+<!-- TMPL_INCLUDE NAME="acquisitions-menu.inc" -->
+</div>
+</div>
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
-- 
1.6.0.6



More information about the Koha-patches mailing list