[Koha-patches] [biblibre-integration] 1110 : Balance carts and lists, follow-up : Added Opac lists features to admin lists
Henri-Damien LAURENT
henridamien.laurent at biblibre.com
Fri Sep 11 21:56:14 CEST 2009
From: Matthias Meusburger <matthias.meusburger at biblibre.com>
---
koha-tmpl/intranet-tmpl/prog/en/css/print.css | 4 +
.../en/modules/virtualshelves/downloadshelf.tmpl | 33 ++++
.../prog/en/modules/virtualshelves/sendshelf.tmpl | 43 +++++
.../en/modules/virtualshelves/sendshelfform.tmpl | 38 +++++
.../prog/en/modules/virtualshelves/shelves.tmpl | 14 +-
virtualshelves/downloadshelf.pl | 90 ++++++++++
virtualshelves/sendshelf.pl | 173 ++++++++++++++++++++
7 files changed, 390 insertions(+), 5 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tmpl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tmpl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelfform.tmpl
create mode 100755 virtualshelves/downloadshelf.pl
create mode 100755 virtualshelves/sendshelf.pl
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/print.css b/koha-tmpl/intranet-tmpl/prog/en/css/print.css
index 724687b..1699661 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/print.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/print.css
@@ -202,6 +202,10 @@ tr.highlight {
display : none;
}
+input, fieldset.action, .list-actions {
+ display: none;
+}
+
tr.overdue {
font-weight : bold;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tmpl
new file mode 100644
index 0000000..52ae03d
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tmpl
@@ -0,0 +1,33 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Download shelf</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_IF NAME="format" -->
+ Your Download should automatically start
+<!-- TMPL_ELSE -->
+<div id="export" class="detailtagcell"> <form method="post" action="/cgi-bin/koha/virtualshelves/downloadshelf.pl">
+ <fieldset class="row">
+ <legend>Download Shelf</legend>
+ <label for="format">Format : </label>
+ <select name="format" id="format">
+ <option value="">-- Choose Format --</option>
+ <option value="iso2709">iso2709</option>
+ <option value="ris">RIS</option>
+ <option value="bibtex">BibTex</option>
+ <!-- TMPL_LOOP NAME="csv_profiles" -->
+ <option value="<!-- TMPL_VAR NAME="export_format_id" -->">CSV - <!-- TMPL_VAR NAME="profile" --></option>
+ <!-- /TMPL_LOOP -->
+
+ </select>
+ <input type="hidden" name="shelfid" value="<!-- TMPL_VAR NAME="shelfid" -->" />
+ <input type="submit" name="save" value="Go" />
+ </fieldset>
+ </form>
+
+ <p><a class="button" href="#" onclick="javascript:window.close()">Close this window</a></p>
+ </div>
+
+<!-- /TMPL_IF -->
+</body>
+</html>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tmpl
new file mode 100644
index 0000000..3f8502e
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tmpl
@@ -0,0 +1,43 @@
+<SUBJECT>
+Your List : <!-- TMPL_VAR NAME="shelfname" -->
+<END_SUBJECT>
+
+<HEADER>
+Hi,
+
+Here is your list called <!-- TMPL_VAR NAME="shelfname" -->, sent from our online catalog.
+
+Please note that the attached file is a MARC biblographic records file
+which can be imported into a Personal Bibliographic Software like EndNote,
+Reference Manager or ProCite.
+<END_HEADER>
+
+<MESSAGE>
+---------------------------------------------
+<!-- TMPL_IF NAME="comment" -->
+<!-- TMPL_VAR NAME="comment" -->
+<!-- /TMPL_IF -->
+<!-- TMPL_LOOP NAME="BIBLIO_RESULTS" --><!-- TMPL_VAR NAME="title" --><!-- TMPL_IF name="subtitle" --> <!-- TMPL_VAR NAME="subtitle" --><!-- /TMPL_IF --><!-- TMPL_IF name="MARCAUTHORS" -->
+Author(s): <!-- TMPL_LOOP NAME="MARCAUTHORS" --><!-- TMPL_LOOP NAME="MARCAUTHOR_SUBFIELDS_LOOP" --><!-- TMPL_VAR NAME="separator" --><!-- TMPL_VAR NAME="value" --><!-- /TMPL_LOOP --><!-- TMPL_UNLESS NAME="__last__" -->; <!-- TMPL_ELSE -->
+<!-- /TMPL_UNLESS --><!-- /TMPL_LOOP --><!-- /TMPL_IF --><!-- TMPL_IF name="ISBN" -->
+ISBN: <!-- TMPL_VAR NAME="ISBN" --><!-- /TMPL_IF -->
+<!-- TMPL_IF name="publishercode" -->Published by: <!-- TMPL_VAR NAME="publishercode" --><!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> in <!-- /TMPL_IF --><!-- TMPL_VAR NAME="publicationyear" --><!-- TMPL_IF name="pages" -->, <!-- /TMPL_IF --><!-- TMPL_VAR name="pages" --><!-- TMPL_IF name="size" -->, <!-- /TMPL_IF --><!-- TMPL_VAR name="size" --><!-- TMPL_IF name="collection" -->
+Collection: <!-- TMPL_VAR NAME="seriestitle" --><!-- /TMPL_IF --><!-- TMPL_IF name="subject" -->
+Subject: <!-- TMPL_VAR NAME="subject" --><!-- /TMPL_IF --><!-- TMPL_IF name="copyrightdate" -->
+Copyright year: <!-- TMPL_VAR NAME="copyrightdate" --><!-- /TMPL_IF --><!-- TMPL_IF name="notes" -->
+Notes : <!-- TMPL_VAR NAME="notes" --><!-- /TMPL_IF --><!-- TMPL_IF name="unititle" -->
+Unified title: <!-- TMPL_VAR NAME="unititle" --><!-- /TMPL_IF --><!-- TMPL_IF name="serial" -->
+Serial: <!-- TMPL_VAR NAME="serial" --><!-- /TMPL_IF --><!-- TMPL_IF name="dewey" -->
+Dewey: <!-- TMPL_VAR name="dewey" --><!-- /TMPL_IF --><!-- TMPL_IF name="classification" -->
+Classification: <!-- TMPL_VAR name="classification" --><!-- /TMPL_IF --><!-- TMPL_IF name="lccn" -->
+LCCN: <!-- TMPL_VAR name="lccn" --><!-- /TMPL_IF --><!-- TMPL_IF name="url" -->
+URL : <!-- TMPL_VAR NAME="url" --><!-- /TMPL_IF -->
+In the online catalog:
+<!-- TMPL_VAR NAME="OPACBaseURL" -->/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" escape="url" -->
+Items : <!-- TMPL_LOOP NAME="ITEM_RESULTS" -->
+ <!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR NAME="location" --> <!-- TMPL_IF name="itemcallnumber" -->(<!-- TMPL_VAR NAME="itemcallnumber" -->)<!-- /TMPL_IF --> <!-- TMPL_VAR NAME="barcode" --><!-- /TMPL_LOOP -->
+
+---------------------------------------------
+
+<!-- /TMPL_LOOP -->
+<END_MESSAGE>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelfform.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelfform.tmpl
new file mode 100644
index 0000000..41f7d32
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelfform.tmpl
@@ -0,0 +1,38 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha Online<!-- /TMPL_IF --> Catalog › Sending Your List
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body style="padding: 1em;" id="sendbasket">
+<div class="container"><!-- TMPL_IF NAME="email" -->
+
+ <!-- TMPL_IF NAME="SENT" -->
+ <h3>Message Sent</h3>
+ <p>The list was sent to: <!-- TMPL_VAR NAME="email" --></p>
+ <p><a class="close focus" href="#">Close window</a></p>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="error" -->
+ <p>Problem sending the list...</p>
+ <!-- /TMPL_IF -->
+
+<!-- TMPL_ELSE -->
+
+<form action="<!-- TMPL_VAR NAME="url" -->" method="post">
+
+<fieldset class="rows">
+<legend>Sending your list</legend>
+<ol> <li>
+ <label for="email">Email Address:</label>
+ <input type="text" id="email" name="email" size="43" class="focus" />
+ </li>
+ <li>
+ <label for="comment">Comment:</label>
+ <textarea id="comment" name="comment" rows="4" cols="40"></textarea>
+ </li>
+ <li>
+ <input type="hidden" name="shelfid" value="<!-- TMPL_VAR NAME="shelfid" -->" />
+ </li></ol></fieldset>
+ <fieldset class="action"> <input type="submit" value="Send" /> <a class="cancel close" href="#">Cancel</a> </fieldset>
+</form>
+
+<!-- /TMPL_IF --></div>
+</body>
+</html>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
index d4699e3..8e5b4bc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
@@ -125,12 +125,16 @@ function placeHold () {
<input type="hidden" name="modifyshelfcontents" value="1" />
<fieldset>
<legend>Contents of <i><!-- TMPL_VAR NAME="shelfname" --></i></legend>
+ <div id="toolbar" class="list-actions">
<!--TMPL_IF NAME="manageshelf" -->
- <p>
- <span class="checkall"></span>
- <span class="clearall"></span>
- </p>
+ <span class="checkall"></span> |
+ <span class="clearall"></span> |
<!-- /TMPL_IF -->
+ <a class="print" href="shelves.pl" onclick="print(); return false;">Print</a> |
+ <a href="#" class="send tag_hides" onclick="open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=<!-- TMPL_VAR NAME="shelfnumber" -->','win_form','dependant=yes,scrollbars=no,resizable=no,height=300,width=450,top=50,left=100')">Send List</a> |
+ <a href="#" class="download tag_hides" onclick="open(CGIBIN+'virtualshelves/downloadshelf.pl?shelfid=<!-- TMPL_VAR NAME="shelfnumber" -->','win_form','dependant=yes,scrollbars=no,resizable=no,height=300,width=450,top=50,left=100')">Download List</a>
+
+ </div>
<!-- TMPL_VAR name='pagination_bar'-->
<table>
<tr>
@@ -195,7 +199,7 @@ function placeHold () {
<!-- TMPL_IF name="manageshelf" -->
<div class="yui-g">
<form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
- <fieldset class="brief">
+ <fieldset class="brief action">
<legend>Add an item to <i><!-- TMPL_VAR NAME="shelfname" --></i></legend>
<ol>
<li>
diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl
new file mode 100755
index 0000000..03f3a5c
--- /dev/null
+++ b/virtualshelves/downloadshelf.pl
@@ -0,0 +1,90 @@
+#!/usr/bin/perl
+
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use warnings;
+
+use CGI;
+use Encode qw(encode);
+use Switch;
+
+use C4::Auth;
+use C4::Biblio;
+use C4::Items;
+use C4::Output;
+use C4::VirtualShelves;
+use C4::Record;
+use C4::Ris;
+use C4::Csv;
+use utf8;
+use open qw( :std :utf8);
+my $query = new CGI;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
+ {
+ template_name => "virtualshelves/downloadshelf.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ }
+);
+
+my $shelfid = $query->param('shelfid');
+my $format = $query->param('format');
+my $dbh = C4::Context->dbh;
+
+if ($shelfid && $format) {
+
+ my @shelf = GetShelf($shelfid);
+ my ($items, $totitems) = GetShelfContents($shelfid);
+ my $marcflavour = C4::Context->preference('marcflavour');
+ my $output;
+
+ # retrieve biblios from shelf
+ my $firstpass = 1;
+ foreach my $biblio (@$items) {
+ my $biblionumber = $biblio->{biblionumber};
+
+ my $record = GetMarcBiblio($biblionumber);
+
+ switch ($format) {
+ case "iso2709" { $output .= $record->as_usmarc(); }
+ case "ris" { $output .= marc2ris($record); }
+ case "bibtex" { $output .= marc2bibtex($record, $biblionumber); }
+ # We're in the case of a csv profile (firstpass is used for headers printing) :
+ case /^\d+$/ { $output .= marc2csv($record, $format, $firstpass); }
+ }
+ $firstpass = 0;
+ }
+
+ # If it was a CSV export we change the format after the export so the file extension is fine
+ $format = "csv" if ($format =~ m/^\d+$/);
+
+ print $query->header(
+ -type => 'application/octet-stream',
+ -'Content-Transfer-Encoding' => 'binary',
+ -attachment=>"shelf.$format");
+ print $output;
+
+} else {
+ $template->param(csv_profiles => GetCsvProfilesLoop());
+ $template->param(shelfid => $shelfid);
+ output_html_with_http_headers $query, $cookie, $template->output;
+}
diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl
new file mode 100755
index 0000000..f7cafda
--- /dev/null
+++ b/virtualshelves/sendshelf.pl
@@ -0,0 +1,173 @@
+#!/usr/bin/perl
+
+# 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., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use warnings;
+
+use CGI;
+use Encode qw(encode);
+
+use Mail::Sendmail;
+use MIME::QuotedPrint;
+use MIME::Base64;
+use C4::Auth;
+use C4::Biblio;
+use C4::Items;
+use C4::Output;
+use C4::VirtualShelves;
+
+my $query = new CGI;
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
+ {
+ template_name => "virtualshelves/sendshelfform.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ }
+);
+
+my $shelfid = $query->param('shelfid');
+my $email = $query->param('email');
+
+my $dbh = C4::Context->dbh;
+
+if ( $email ) {
+ my $email_from = C4::Context->preference('KohaAdminEmailAddress');
+ my $comment = $query->param('comment');
+
+ my %mail = (
+ To => $email,
+ From => $email_from
+ );
+
+ my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "virtualshelves/sendshelf.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ }
+ );
+
+ my @shelf = GetShelf($shelfid);
+ my ($items, $totitems) = GetShelfContents($shelfid);
+ my $marcflavour = C4::Context->preference('marcflavour');
+ my $iso2709;
+ my @results;
+
+ # retrieve biblios from shelf
+ foreach my $biblio (@$items) {
+ my $biblionumber = $biblio->{biblionumber};
+
+ my $dat = GetBiblioData($biblionumber);
+ my $record = GetMarcBiblio($biblionumber);
+ my $marcnotesarray = GetMarcNotes( $record, $marcflavour );
+ my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
+ my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
+
+ my @items = &GetItemsInfo( $biblionumber, 'opac' );
+
+ $dat->{MARCNOTES} = $marcnotesarray;
+ $dat->{MARCSUBJCTS} = $marcsubjctsarray;
+ $dat->{MARCAUTHORS} = $marcauthorsarray;
+ $dat->{'biblionumber'} = $biblionumber;
+ $dat->{ITEM_RESULTS} = \@items;
+
+ $iso2709 .= $record->as_usmarc();
+
+ push( @results, $dat );
+ }
+
+ $template2->param(
+ BIBLIO_RESULTS => \@results,
+ email_sender => $email_from,
+ comment => $comment,
+ shelfname => $shelf[1],
+ );
+
+ # Getting template result
+ my $template_res = $template2->output();
+ my $body;
+
+ # Analysing information and getting mail properties
+ if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
+ $mail{'subject'} = $1;
+ }
+ else { $mail{'subject'} = "no subject"; }
+
+ my $email_header = "";
+ if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
+ $email_header = $1;
+ }
+
+ my $email_file = "basket.txt";
+ if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
+ $email_file = $1;
+ }
+
+ if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) { $body = encode_qp($1); }
+
+ my $boundary = "====" . time() . "====";
+
+ # We set and put the multipart content
+ $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
+
+ my $isofile = encode_base64(encode("UTF-8", $iso2709));
+ $boundary = '--' . $boundary;
+
+ $mail{body} = <<END_OF_BODY;
+$boundary
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+$email_header
+$body
+$boundary
+Content-Type: application/octet-stream; name="shelf.iso2709"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment; filename="shelf.iso2709"
+
+$isofile
+$boundary--
+END_OF_BODY
+
+ # Sending mail
+ if ( sendmail %mail ) {
+ # do something if it works....
+ $template->param( SENT => "1" );
+ }
+ else {
+ # do something if it doesnt work....
+ warn "Error sending mail: $Mail::Sendmail::error \n";
+ $template->param( error => 1 );
+ }
+
+ $template->param( email => $email );
+ output_html_with_http_headers $query, $cookie, $template->output;
+
+
+}else{
+ $template->param( shelfid => $shelfid,
+ url => "/cgi-bin/koha/virtualshelves/sendshelf.pl",
+ );
+ output_html_with_http_headers $query, $cookie, $template->output;
+}
--
1.6.0.4
More information about the Koha-patches
mailing list