[Koha-patches] [PATCH] Ability to link to items belong to host records from a analytical record

savitra.sirohi at osslabs.biz savitra.sirohi at osslabs.biz
Wed Nov 10 19:22:04 CET 2010


From: Amit Gupta <amit.gupta at osslabs.biz>

---
 cataloguing/linkitem.pl                            |   98 ++++++++++++++++++++
 .../intranet-tmpl/prog/en/includes/cat-toolbar.inc |    1 +
 .../prog/en/modules/cataloguing/linkitem.tmpl      |   57 +++++++++++
 3 files changed, 156 insertions(+), 0 deletions(-)
 create mode 100755 cataloguing/linkitem.pl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl

diff --git a/cataloguing/linkitem.pl b/cataloguing/linkitem.pl
new file mode 100755
index 0000000..bff001e
--- /dev/null
+++ b/cataloguing/linkitem.pl
@@ -0,0 +1,98 @@
+#!/usr/bin/perl
+
+# Move an item from a biblio to another
+#
+# Copyright 2009 BibLibre
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Output;
+use C4::Biblio;
+use C4::Items;
+use C4::Context;
+use C4::Koha;
+use C4::Branch;
+
+
+my $query = CGI->new;
+
+my $biblionumber = $query->param('biblionumber');
+my $barcode	 = $query->param('barcode');
+
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "cataloguing/linkitem.tmpl",
+                 query => $query,
+                 type => "intranet",
+                 authnotrequired => 0,
+                 flagsrequired => {editcatalogue => 'edit_catalogue'},
+                 debug => 1,
+                 });
+
+my $biblio = GetMarcBiblio($biblionumber);
+$template->param(bibliotitle => $biblio->subfield('245','a'));
+$template->param(biblionumber => $biblionumber);
+
+if ($barcode && $biblionumber) { 
+    
+    # We get the host itemnumber
+    my $hostitemnumber = GetItemnumberFromBarcode($barcode);
+
+    if ($hostitemnumber) {
+	my $hostbiblionumber = GetBiblionumberFromItemnumber($hostitemnumber);
+	my $hostrecord = GetMarcBiblio($hostbiblionumber);
+
+	if ($hostbiblionumber) {
+	        my $field = MARC::Field->new(
+			773, '', '',
+			'w' => $hostbiblionumber,
+			'o' => $hostitemnumber,
+               		'a' => $hostrecord->subfield('245','a'),
+	                'x' => $hostrecord->subfield('245','x')
+                );
+		$biblio->append_fields($field);
+
+		my $modresult = ModBiblio($biblio, $biblionumber, ''); 
+		if ($modresult) { 
+			$template->param(success => 1);
+		} else {
+			$template->param(error => 1,
+					 errornomodbiblio => 1); 
+		}
+	} else {
+		$template->param(error => 1,
+	        	             errornohostbiblionumber => 1);
+	}
+    } else {
+	    $template->param(error => 1,
+			     errornohostitemnumber => 1);
+
+    }
+    $template->param(
+			barcode => $barcode,  
+			hostitemnumber => $hostitemnumber,
+		    );
+
+} else {
+    $template->param(missingparameter => 1);
+    if (!$barcode)      { $template->param(missingbarcode      => 1); }
+    if (!$biblionumber) { $template->param(missingbiblionumber => 1); }
+}
+
+
+output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
index 228ebf3..f3776a6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
@@ -85,6 +85,7 @@ function confirm_items_deletion() {
 	        { text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },
 	        { text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
 	        { text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
+                { text: _("Link to Host Item"), url: "/cgi-bin/koha/cataloguing/linkitem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
 	        { text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" },
 			{ text: _("Delete Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> },
             { text: _("Delete all Items"), onclick: {fn: confirm_items_deletion }<!-- TMPL_UNLESS NAME="count" -->,id:'disabled'<!-- /TMPL_UNLESS --> }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl
new file mode 100644
index 0000000..bcddf17
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/linkitem.tmpl
@@ -0,0 +1,57 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Attach item</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE NAME="header.inc" -->
+<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloging/addbooks.pl">Cataloging</a>  &rsaquo; Attach an item to <i><!-- TMPL_VAR NAME="bibliotitle" escape="html" --></i></div>
+<div id="doc3" class="yui-t2">
+
+<!-- TMPL_IF NAME="error" -->
+    <div class="dialog alert">
+	<!-- TMPL_IF NAME="errornomodbiblio" -->ERROR: Unable to modify the bibliographic record.<!-- /TMPL_IF -->
+	<!-- TMPL_IF NAME="errornohostbiblionumber" -->ERROR: Unable to get the biblio number of host item.<!-- /TMPL_IF -->
+	<!-- TMPL_IF NAME="errornohostitemnumber" -->ERROR: Unable to get the item number from this barcode.<!-- /TMPL_IF -->
+    </div>
+    <form action="/cgi-bin/koha/catalogue/MARCdetail.pl" method="post">
+	<input type="submit" value="OK" />
+	<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+    </form>
+<!-- TMPL_ELSE -->
+    <!-- TMPL_IF NAME="success" -->
+	<div class="dialog">The item has successfully been linked to <i><!-- TMPL_VAR NAME="bibliotitle" escape="html" --></i>.</div>    
+	<form action="/cgi-bin/koha/catalogue/MARCdetail.pl" method="post">
+	    <input type="submit" value="OK" />
+	    <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+	</form>
+    <!-- TMPL_ELSE -->
+	<!-- TMPL_IF NAME="missingparameter" -->
+	<form method="post" action="/cgi-bin/koha/cataloguing/linkitem.pl">
+	    <!-- TMPL_IF NAME="missingbiblionumber" -->
+	    <fieldset id="biblionumber_fieldset">
+		<label for="biblionumber_fieldset">Select the biblionumber to link the item to</label>
+		    <div class="hint">Enter biblionumber:</div>
+		    <input type="text" name="biblionumber" id="biblionumber" class="focus" size="14" /> 
+	    </fieldset>
+	    <!-- TMPL_ELSE -->
+	    <input type="hidden" name="biblionumber" id="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+	    <!-- /TMPL_IF -->
+
+    	    <!-- TMPL_IF NAME="missingbarcode" -->
+	    <fieldset id="barcode_fieldset">
+		<label for="barcode_fieldset">Select the item to attach<!-- TMPL_IF NAME="bibliotitle" --> to <i><!-- TMPL_VAR NAME="bibliotitle" escape="html" --></i><!-- /TMPL_IF --></label>
+		    <div class="hint">Enter item barcode:</div>
+		    <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" /> 
+	    </fieldset>
+	    <!-- TMPL_ELSE -->
+	    <input type="hidden" name="barcode" id="barcode" value="<!-- TMPL_VAR NAME="barcode" -->" />
+	    <!-- /TMPL_IF -->
+
+	    <input type="submit" value="Select" />
+
+	</form>
+	<!-- /TMPL_IF -->
+    <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
-- 
1.5.4.5



More information about the Koha-patches mailing list