Bugzilla – Attachment 4735 Details for
Bug 5725
Batch modifications for Biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
proposed patch (updated again)
0001-Bug-5725-Batch-Modifications-for-Biblios.patch (text/plain), 41.69 KB, created by
Paul Poulain
on 2011-07-25 08:53:44 UTC
(
hide
)
Description:
proposed patch (updated again)
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2011-07-25 08:53:44 UTC
Size:
41.69 KB
patch
obsolete
>From 49ea61995f26d4ea6f9524fdd79ef5cdbc0dfb15 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Mon, 25 Jul 2011 10:52:30 +0200 >Subject: [PATCH] Bug 5725 : Batch Modifications for Biblios > >Squashed commit of the following: > >commit 66282fed94564969f0368e27c7231116a2d1c0fe >Author: Chris Cormack <chrisc@catalyst.net.nz> >Date: Tue Feb 22 08:43:24 2011 +1300 > > Bug 5725 : Follow up fixing permissions thanks to Paul Poulain > >commit 4d0241aea5be13b00abbc6100dc98ec87f816081 >Author: Paul Poulain <paul.poulain@biblibre.com> >Date: Mon Jan 10 17:22:31 2011 +0100 > > Bug 5725 follow up > > Owen noticed the batchedit was not working. This was because we made a patch months ago to change the GetBiblio API > (the 1st returned arg is useless) > This patch is not in main trunk, resulting in the error owen has noticed. > > This patch goes back to official API (even if it is clumsy : the patch we did does not apply anymore) > >commit 19b3e0ecc57af1c2151340328bf06e26882b7863 >Author: Paul Poulain <paul.poulain@biblibre.com> >Date: Wed Dec 15 20:47:21 2010 +0100 > > Bug 5725 : MT #2991 (Feature) Batch biblio modifications > > This patch add a new feature of batch biblio modifications, > it permit to select biblios from basket, and modify fields of them setting > > Rebased to fix whitespace issues. >--- > C4/Biblio.pm | 90 +++++ > installer/data/mysql/updatedatabase.pl | 10 +- > koha-tmpl/intranet-tmpl/prog/en/js/basket.js | 6 + > .../prog/en/modules/basket/basket.tmpl | 366 ++++++++++++++++++++ > .../intranet-tmpl/prog/en/modules/basket/basket.tt | 7 + > .../prog/en/modules/tools/batchedit.tt | 227 ++++++++++++ > kohaversion.pl | 2 +- > tools/batchedit.pl | 222 ++++++++++++ > 8 files changed, 928 insertions(+), 2 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt > create mode 100755 tools/batchedit.pl > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index a91562c..d445224 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -128,6 +128,7 @@ BEGIN { > &TransformHtmlToXml > &PrepareItemrecordDisplay > &GetNoZebraIndexes >+ &BatchModField > ); > } > >@@ -3681,6 +3682,95 @@ sub get_biblio_authorised_values { > return $authorised_values; > } > >+=head3 BatchModField >+ >+ Mod subfields in field record >+ >+ returns 1,$record if succeed >+ returns 0,$record if Action was not processed >+ returns -1 if no record >+ returns -2 if no action done on record >+ >+=cut >+ >+sub BatchModField { >+ my ( $record, $field, $subfield, $action, $condval, $nocond, $repval ) = @_; >+ >+ return -1 unless $record; >+ $condval=NormalizeString($condval); >+ my $condition=qr/$condval/; >+ >+ if($action eq "add"){ >+ for my $rfield ($record->field($field)){ >+ $rfield->add_subfields( $subfield => $repval ); >+ } >+ return 1; >+ }elsif($action eq "addfield"){ >+ my $new_field = MARC::Field->new($field,'','', >+ $subfield => $repval); >+ $record->insert_fields_ordered($new_field); >+ return 1; >+ } else { >+ my $done=0; >+ for my $rfield ($record->field($field)) { >+ if ($subfield && $subfield ne "@"){ >+ my @subfields = $rfield->subfields(); >+ my @subfields_to_add; >+ foreach my $subf (@subfields) { >+ if ($subf->[0] eq $subfield){ >+ $subf->[1]=NormalizeString($subf->[1]); >+ if ( $action eq "mod" ) { >+ if ( $nocond ne "true" && $subf->[1] =~ s/$condition/$repval/) { >+ $done=1; >+ } >+ if ($nocond eq "true"){ >+ $subf->[1] = $repval; >+ $done=1; >+ } >+ } elsif ( $action eq "del" ) { >+ if ( $subf->[1] =~ m/$condition/ || $nocond eq "true" ) { >+ $done=1; >+ next; >+ } >+ } >+ } >+ push @subfields_to_add,@$subf; >+ } >+ if ($done){ >+ if (@subfields_to_add){ >+ $rfield->replace_with(MARC::Field->new($rfield->tag,$rfield->indicator(1),$rfield->indicator(2),@subfields_to_add)); >+ } >+ else { >+ my $count= $record->delete_field($rfield); >+ } >+ } >+ } >+ else { >+ if ($action eq "del"){ >+ my $count=$record->delete_field($rfield); >+ $done=1; >+ } >+ else { >+ if ($field < 10){ >+ my $value=$record->field($field)->data(); >+ if ($value=~ s/$condition/$repval/){ >+ $record->field($field)->update($value); >+ $done=1; >+ >+ } >+ if ( $nocond eq 'true'){ >+ $record->field($field)->update($repval); >+ $done=1; >+ } >+ } >+ } >+ } >+ } >+ return ($done,$record); >+ } >+ return -2; >+} >+ > 1; > > __END__ >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 9cbc8db..c78820d 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4365,11 +4365,19 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > > $DBversion = "3.05.00.004"; > if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >- $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ShowReviewerPhoto',1,'If ON, photo of reviewer will be shown beside comments in OPAC',NULL,'YesNo');"); >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ShowReviewerPhoto',1,'If ON, photo of reviewer will be shown beside comments in OPAC',NULL,'YesNo')"); > print "Upgrade to $DBversion done (Add syspref ShowReviewerPhoto)\n"; > SetVersion($DBversion); > } > >+$DBversion = "3.05.00.005"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES ( 13, 'batchedit', 'Batch editing biblios')"); >+ print "Upgrade to $DBversion done (batch edit permission)\n"; >+ SetVersion($DBversion); >+} >+ >+ > =head1 FUNCTIONS > > =head2 DropAllForeignKeys($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/basket.js b/koha-tmpl/intranet-tmpl/prog/en/js/basket.js >index 9946cf7..03dc306 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/basket.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/basket.js >@@ -433,4 +433,10 @@ $(document).ready(function(){ > if(basketcount){ updateBasket(basketcount); } > }); > >+function batchEdit(){ >+ var valCookie = readCookie(nameCookie); >+ var strCookie = nameParam + "=" + valCookie; > >+ var loc = CGIBIN + "tools/batchedit.pl?" + strCookie; >+ window.opener.location = loc; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl >new file mode 100644 >index 0000000..6699bde >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tmpl >@@ -0,0 +1,366 @@ >+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --> >+<title><!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha Online<!-- /TMPL_IF --> Catalog › Your Cart</title> >+ <!-- TMPL_IF NAME="print_basket" --> >+ >+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+<link rel="shortcut icon" href="<!-- TMPL_VAR NAME="themelang" -->/includes/favicon.ico" type="image/x-icon" /> >+<meta http-equiv="Content-Language" content="en-us" /> >+<style type="text/css"> >+ @import url(<!-- TMPL_VAR NAME="themelang" -->/css/print.css); >+</style> >+ <!-- TMPL_ELSE --><!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> >+ <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+ <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ >+$(document).ready(function() >+ { >+ $("#itemst").tablesorter({ >+ headers: { 0: { sorter: false }} >+ }); >+ } >+); >+ >+ >+function placeHold () { >+ var checkedItems = $("input:checkbox:checked"); >+ if ($(checkedItems).size() == 0) { >+ alert(MSG_NO_RECORD_SELECTED); >+ return false; >+ } >+ var bibs = ""; >+ var badBibs = false; >+ $(checkedItems).each(function() { >+ var bib = $(this).val(); >+ bibs += bib + "/"; >+ }); >+ >+ var newloc = "/cgi-bin/koha/reserve/request.pl?biblionumbers=" + bibs; >+ if ($(checkedItems).size() > 1) { newloc += "&multi_hold=1"; } >+ window.opener.location = newloc; >+ window.close(); >+} >+ >+ >+ >+ $(document).ready(function(){ >+ $("#CheckAll").click(function(){ >+ var checked = []; >+ $("#bookbag_form").checkCheckboxes("*", true).each( >+ function() { >+ selRecord(this.value,true); >+ } >+ ); >+ return false; >+ }); >+ $("#CheckNone").click(function(){ >+ var checked = []; >+ $("#bookbag_form").unCheckCheckboxes("*",true).each( >+ function() { >+ selRecord(this.value,false); >+ } >+ ); >+ return false; >+ }); >+ $(".holdsep").text("| "); >+ $(".hold").text(_("Place Hold")); >+ }); >+ >+ >+ //]]> >+ </script> >+ <!-- /TMPL_IF --> >+</head> >+<!-- TMPL_IF NAME="print_basket" --><body id="basket" onload="print();history.back();"><!-- TMPL_ELSE --><body id="basket"><!-- /TMPL_IF --> >+ >+<div id="doc" class="yui-t7"> >+<div class="container"> >+<!-- TMPL_UNLESS NAME="print_basket" --> >+<h1>Your Cart</h1> >+ >+<div id="toolbar"> >+<ul class="toolbar"> >+ <li> >+ <span id="addchild" class="yui-button yui-link-button"><span class="first-child"> >+ <!-- TMPL_IF NAME="verbose" --><a href="basket.pl" class="brief" onclick="showLess(); return false;">Brief Display</a><!-- TMPL_ELSE --><a href="basket.pl" class="detail" onclick="showMore(); return false;">More Details</a><!-- /TMPL_IF --> >+ </span></span> >+ </li> >+ <li> >+ <span id="batchedit" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="batchedit" href="basket.pl" onclick="batchEdit(); return false;">Batch Edit</a> >+ </span></span> >+ </li> >+ <li> >+ <span id="receive" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="send" href="basket.pl" onclick="sendBasket(); return false;">Send</a> >+ </span></span> >+ </li> >+ <li> >+ <span id="savemenuc" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="download" href="basket.pl" onclick="downloadBasket(); return false;">Download</a> >+ </span></span> >+ </li> >+ <li> >+ <span id="printmenuc" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="print" href="basket.pl" onclick="printBasket(); return false;">Print</a> >+ </span></span> >+ </li> >+ <li> >+ <span id="delete" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="empty" href="basket.pl" onclick="delBasket(); return false;">Empty and Close</a> >+ </span></span> >+ </li> >+ <li> >+ <span id="hide" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="hide" href="basket.pl" onclick="quit(); return false;">Hide Window</a> >+ </span></span> >+ </li> >+</ul> >+</div> >+ <!-- /TMPL_UNLESS --> >+ >+<!-- TMPL_IF NAME="verbose" --> >+ <!-- TMPL_UNLESS NAME="print_basket" --><p style="padding: 7px 0; border-top : 1px solid #E8E8E8;"><a id="CheckAll" href="#">Select All</a> <a id="CheckNone" href="#">Clear All</a> | <b>Selected items :</b> >+ >+ <a href="#" onclick="delSelRecords(); return false;">Remove</a> >+ >+<!-- TMPL_IF NAME="loggedinusername" --> >+ | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a> >+<!-- /TMPL_IF --> >+ >+<!-- TMPL_IF NAME="CAN_user_reserveforothers" --> >+ | <a href="#" onclick="placeHold(); return false;">Place Hold</a> >+<!-- /TMPL_IF --> >+ >+</p><!-- /TMPL_UNLESS --> >+ <form action="basket.pl" method="get" name="bookbag_form" id="bookbag_form"> >+ <!-- TMPL_LOOP NAME="BIBLIO_RESULTS" --> >+ <h3> >+ <!-- TMPL_IF NAME="print_basket" --> >+ <!-- TMPL_VAR NAME="title" ESCAPE="html" --> >+ <!-- TMPL_IF name="subtitle" --> <!-- TMPL_VAR NAME="subtitle" --><!-- /TMPL_IF --> >+ <!-- TMPL_IF name="author" --> <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF --> >+ <!-- TMPL_ELSE --> >+ <input type="checkbox" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="bib<!-- TMPL_VAR NAME="biblionumber" -->" id="bib<!-- TMPL_VAR NAME="biblionumber" -->" onclick="selRecord(value,checked)" /> >+ <!-- TMPL_VAR NAME="title" escape="html" --> >+ <!-- TMPL_IF name="subtitle" --> <!-- TMPL_VAR NAME="subtitle" --><!-- /TMPL_IF --> >+ <!-- TMPL_IF name="author" --> <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF --> >+ <!-- /TMPL_IF --> >+ </h3> >+ <!-- COinS / OpenURL --> >+ <span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.au=<!-- TMPL_VAR NAME="author" -->&rft.btitle=<!-- TMPL_VAR NAME="title" ESCAPE="url" -->&rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&rft.tpages=<!-- TMPL_VAR NAME="size" -->&rft.isbn=<!-- TMPL_VAR NAME="isbn" ESCAPE="url" -->&rft.aucorp=&rft.place=<!-- TMPL_VAR NAME="place" -->&rft.pub=<!-- TMPL_VAR NAME="publisher" ESCAPE="url" -->&rft.edition=<!-- TMPL_VAR NAME="edition" -->&rft.series=<!-- TMPL_VAR NAME="series" -->&rft.genre="></span> >+ <table> >+ <!-- TMPL_IF name="isbn" --> >+ <tr> >+ <th scope="row">ISBN</th> >+ <td><!-- TMPL_VAR NAME="isbn" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF "HASAUTHORS" --> >+ <tr> >+ <th scope="row">Author(s)</th> >+ <td> >+ <!-- TMPL_IF NAME="author" --> >+ <p><!-- TMPL_VAR NAME="author" --></p> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="MARCAUTHORS" --> >+ <!-- TMPL_LOOP NAME="MARCAUTHORS" --> >+ <p> <!-- TMPL_LOOP NAME="MARCAUTHOR_SUBFIELDS_LOOP" --> >+ <!-- TMPL_VAR NAME="separator" --> >+ <!-- TMPL_VAR NAME="value" --> >+ <!-- /TMPL_LOOP --> >+ </p> >+ <!-- /TMPL_LOOP --> >+ <!-- /TMPL_IF --> >+ </td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF NAME="publishercode" --> >+ <tr> >+ <th scope="row">Publisher</th> >+ <td><!-- TMPL_VAR NAME="place" --> <!-- TMPL_VAR NAME="publishercode" --> <!-- TMPL_VAR NAME="publicationyear" --> >+ </td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF NAME="pages" --> >+ <tr> >+ <th scope="row">Details</th> >+ <td><!-- TMPL_VAR NAME="pages" --> <!-- TMPL_VAR NAME="illus" --> <!-- TMPL_VAR NAME="size" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF name="seriestitle" --> >+ <tr> >+ <th scope="row">Collection</th> >+ <td> <!-- TMPL_VAR NAME="seriestitle" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF name="MARCSUBJCTS" --> >+ <tr> >+ <th scope="row">Subject(s)</th> >+ <td><!-- TMPL_LOOP NAME="MARCSUBJCTS" --> >+ <p> <!-- TMPL_LOOP NAME="MARCSUBJECT_SUBFIELDS_LOOP" --> >+ <!-- TMPL_VAR NAME="separator" --><!-- TMPL_VAR NAME="value" --><!-- /TMPL_LOOP --> >+ </p> >+ <!-- /TMPL_LOOP --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF name="copyrightdate" --> >+ <tr><th scope="row">Copyright</th> >+ <td> <!-- TMPL_VAR NAME="copyrightdate" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF name="MARCNOTES" --> >+ <tr> >+ <th scope="row">Notes</th> >+ <td> >+ <!-- TMPL_LOOP NAME="MARCNOTES" --> >+ <p>- <!-- TMPL_VAR NAME="marcnote" --></p> >+ <!-- /TMPL_LOOP --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF name="unititle" --> >+ <tr> >+ <th scope="row">Unified title</th> >+ <td> <!-- TMPL_VAR NAME="unititle" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF name="serial" --> >+ <tr> >+ <th scope="row">Serial</th> >+ <td><!-- TMPL_VAR NAME="serial" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF name="dewey" --> >+ <tr> >+ <th scope="row">Dewey</th> >+ <td><!-- TMPL_VAR name="dewey" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF name="classification" --> >+ <tr> >+ <th scope="row">Classification</th> >+ <td> <!-- TMPL_VAR name="classification" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_IF name="lccn" --> >+ <tr> >+ <th scope="row">LCCN</th> >+ <td> <!-- TMPL_VAR name="lccn" --></td> >+ </tr> >+ <!-- /TMPL_IF --> >+ >+ <!-- TMPL_IF name="MARCURLS" --> >+ <tr> >+ <th scope="row">URL(s)</th> >+ <td> >+ <!-- TMPL_LOOP name="MARCURLS" --> >+ <p><!-- TMPL_IF NAME="part" --><!-- TMPL_VAR NAME="part" --> >+ <br /><!-- /TMPL_IF --> >+ >+ <!-- TMPL_VAR NAME="MARCURL" --> >+ <!-- TMPL_IF NAME="notes" --><!-- TMPL_LOOP NAME="notes" --><!-- TMPL_VAR NAME="note" --><br /><!-- /TMPL_LOOP --><!-- /TMPL_IF --> >+ <!-- /TMPL_LOOP --></p></td> >+ </tr><!-- /TMPL_IF --> >+ >+ <tr> >+ <th scope="row">Location(s)</th> >+ <td><!-- TMPL_IF NAME="ITEM_RESULTS" --><!-- TMPL_LOOP NAME="ITEM_RESULTS" --> >+ <p> >+ <!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR NAME="location_description" --> >+ <!-- TMPL_IF name="itemcallnumber" --> >+ (<!-- TMPL_VAR NAME="itemcallnumber" -->) >+ <!-- /TMPL_IF --> >+ </p> >+ <!-- /TMPL_LOOP --><!-- TMPL_ELSE -->This record has no items.<!-- /TMPL_IF --></td> >+ </tr> >+ </table> >+ <!-- /TMPL_LOOP --> >+ </form> >+ >+<!-- TMPL_ELSE --> >+<!-- TMPL_UNLESS NAME="print_basket" --> >+<p style="border-top : 1px solid #E8E8E8;"> >+ <form action="/cgi-bin/koha/basket/basket.pl" method="get" name="bookbag_form" id="bookbag_form"> >+ <a id="CheckAll" href="#">Select All</a> >+ <a id="CheckNone" href="#">Clear All</a> >+ | <b>Selected items :</b> >+<a href="#" onclick="delSelRecords(); return false;">Remove</a> >+ >+<!-- TMPL_IF NAME="loggedinusername" --> >+ | <a href="#" onclick="addSelToShelf(); return false;">Add to a list</a> >+<!-- /TMPL_IF --> >+ >+<!-- TMPL_IF NAME="CAN_user_reserveforothers" --> >+ | <a href="#" onclick="placeHold(); return false;">Place Hold</a> >+<!-- /TMPL_IF --> >+ >+ >+<!-- /TMPL_UNLESS --> >+</p> >+ <table id="itemst"> >+ <thead><tr> >+ <th> </th> >+ <th>Title</th> >+ <th>Item Type</th> >+ <th>Location</th> >+ </tr></thead> >+ >+ <!-- TMPL_LOOP NAME="BIBLIO_RESULTS" --> >+ <!-- TMPL_IF NAME="even" --> >+ <tr class="highlight"> >+ <!-- TMPL_ELSE --> >+ <tr> >+ <!-- /TMPL_IF --> >+ <!-- TMPL_UNLESS NAME="print_basket" --><td> >+ <input type="checkbox" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="bib<!-- TMPL_VAR NAME="biblionumber" -->" id="bib<!-- TMPL_VAR NAME="biblionumber" -->" onclick="selRecord(value,checked);" /> >+ >+ </td> <!-- /TMPL_UNLESS --> >+ <td><a href="#" onclick="openBiblio('<!-- TMPL_VAR name="dest" -->',<!-- TMPL_VAR name="biblionumber" -->)"> >+ <!-- TMPL_VAR NAME="title" escape="html" --> >+ </a> >+ <!-- TMPL_VAR NAME="author" --> >+ <p><!-- TMPL_IF name="publishercode" -->- <!-- TMPL_VAR name="publishercode" --> >+ <!-- TMPL_IF name="place" --> <!-- TMPL_VAR name="place" --><!-- /TMPL_IF --><!-- /TMPL_IF --> >+ <!-- TMPL_IF name="pages" --> - <!-- TMPL_VAR name="pages" --><!-- TMPL_IF name="size" --> <!-- TMPL_VAR name="size" --> >+ <!-- /TMPL_IF --> >+ <!-- /TMPL_IF --></p> >+ <!-- TMPL_IF name="notes" --> >+ <p><!-- TMPL_VAR name="notes" --></p> >+ <!-- /TMPL_IF --> >+ <!-- COinS / OpenURL --> >+ <span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.au=<!-- TMPL_VAR NAME="author" -->&rft.btitle=<!-- TMPL_VAR NAME="title" ESCAPE="url" -->&rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&rft.tpages=<!-- TMPL_VAR NAME="size" -->&rft.isbn=<!-- TMPL_VAR NAME="isbn" ESCAPE="url" -->&rft.aucorp=&rft.place=<!-- TMPL_VAR NAME="place" -->&rft.pub=<!-- TMPL_VAR NAME="publisher" ESCAPE="url" -->&rft.edition=<!-- TMPL_VAR NAME="edition" -->&rft.series=<!-- TMPL_VAR NAME="series" -->&rft.genre="></span> >+ >+ </td> >+ <td><!-- TMPL_VAR name="description" --></td> >+ <td><!-- TMPL_IF NAME="ITEM_RESULTS" --><!-- TMPL_LOOP NAME="ITEM_RESULTS" --> >+ <p> >+ <!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR NAME="location_description" --> >+ <!-- TMPL_IF name="itemcallnumber" --> >+ (<!-- TMPL_VAR NAME="itemcallnumber" -->) >+ <!-- /TMPL_IF --> >+ </p> >+ <!-- /TMPL_LOOP --><!-- TMPL_ELSE -->This record has no items.<!-- /TMPL_IF --></td> >+ </tr> >+ <!-- /TMPL_LOOP --> >+ </table></form> >+<!-- /TMPL_IF --> >+ >+<!-- TMPL_IF NAME="print_basket" --> >+<a href="#back" class="screen"><< Back to Cart</a> >+<!-- TMPL_ELSE --> >+<form name="myform" action="basket/basket.pl" method="get"> >+ <input type="hidden" name="records" id="records" /> >+</form> >+<!-- /TMPL_IF --> >+ >+</div> >+</div> >+</body> >+</html> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >index 38b25e2..05a8acc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >@@ -86,6 +86,13 @@ function placeHold () { > [% IF ( verbose ) %]<a href="basket.pl" class="brief" onclick="showLess(); return false;">Brief Display</a>[% ELSE %]<a href="basket.pl" class="detail" onclick="showMore(); return false;">More Details</a>[% END %] > </span></span> > </li> >+ [% IF ( CAN_user_tools_batchedit ) %] >+ <li> >+ <span id="batchedit" class="yui-button yui-link-button"><span class="first-child"> >+ <a class="batchedit" href="basket.pl" onclick="batchEdit(); return false;">Batch Edit</a> >+ </span></span> >+ </li> >+ [% END %] > <li> > <span id="receive" class="yui-button yui-link-button"><span class="first-child"> > <a class="send" href="basket.pl" onclick="sendBasket(); return false;">Send</a> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt >new file mode 100644 >index 0000000..981e995 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchedit.tt >@@ -0,0 +1,227 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools › Batch Deletion of Items</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+[% UNLESS ( modsuccess ) %] >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >+<script type="text/JavaScript" language="JavaScript"> >+//<![CDATA[ >+ var CGIBIN = "/cgi-bin/koha/"; >+ >+ function fieldChanged(){ >+ var field = $('#fieldchoice').val(); >+ $.ajax({ >+ url: CGIBIN + 'tools/batchedit.pl?field=' + field, >+ dataType: 'json', >+ success: function(data){ >+ $("#subfieldchoice option").remove(); >+ >+ var subfield = $('#subfieldchoice'); >+ $("<option>").attr("value", "@") >+ .text( _('Whole field')) >+ .appendTo('#subfieldchoice'); >+ for( var i=0; i < data.length ; i++){ >+ $("<option>").attr("value", data[i].subfield) >+ .text(data[i].subfield) >+ .appendTo('#subfieldchoice'); >+ } >+ subfieldChanged(); >+ } >+ }); >+ } >+ >+ function subfieldChanged(){ >+ var field = $('#fieldchoice').val(); >+ var subfield = $('#subfieldchoice').val(); >+ $.ajax({ >+ url: CGIBIN + 'tools/batchedit.pl?field=' + field + '&subfield=' + subfield, >+ dataType: 'json', >+ success: function(data){ >+ >+ if( data.length > 0) { >+ $("#condvaltd").html('<select name="condvalchoice" id="condvalchoice" />'); >+ $("<option>").attr("value", "") >+ .text("") >+ .appendTo('#condvalchoice'); >+ $("#repvaltd" ).html('<select name="repvalchoice" id="repvalchoice" />' ); >+ $("<option>").attr("value", "") >+ .text("") >+ .appendTo('#repvalchoice'); >+ >+ for( var i=0; i < data.length ; i++){ >+ $("<option>").attr("value", data[i].code) >+ .text(data[i].value) >+ .appendTo('#repvalchoice'); >+ $("<option>").attr("value", data[i].code) >+ .text(data[i].value) >+ .appendTo('#condvalchoice'); >+ } >+ }else{ >+ $("#condvaltd").html('<input type="text" name="condvalchoice" id="condvalchoice" />'); >+ $("#repvaltd").html('<input type="text" name="repvalchoice" id="repvalchoice" />'); >+ } >+ $('<input type="checkbox" id="nocond" name="nocond" value="nocond" onClick="$(\'#condvalchoice\').attr(\'disabled\', ! $(\'#condvalchoice\').attr(\'disabled\') ) ">All</input>').appendTo("#condvaltd"); >+ } >+ }); >+ >+ } >+ >+ function addRule(){ >+ var actionlabel = { >+ mod: _('Modify'), >+ del: _('Delete'), >+ add: _('Create') >+ }; >+ var repvallabel = $('#repvalchoice :selected').text() || $("#repvalchoice").val(); >+ >+ var field = $('#fieldchoice').val(); >+ var subfield = $('#subfieldchoice').val(); >+ var action = $('#actionchoice').val(); >+ var nocond = $('#nocond').attr('checked')||(! $('#condvalchoice').val().length); >+ >+ if( ! nocond ) { >+ var condval = $('#condvalchoice').val(); >+ var condvallabel = $('#condvalchoice :selected').text() || $("#condvalchoice").val(); >+ }else{ >+ var condvallabel = _("No condition"); >+ } >+ var repval = $('#repvalchoice').val(); >+ >+ var tmpl = "<tr>" >+ + '<td><input type="hidden" name="field" value="' + field + '" />' + field + '</td>' >+ + '<td><input type="hidden" name="subfield" value="' + subfield + '" />' + subfield + '</td>' >+ + '<td><input type="hidden" name="action" value="' + action + '" />' + actionlabel[action] + '</td>' >+ + '<td><input type="hidden" name="condval" value="' + condval + '" />' >+ + condvallabel >+ + '<input type="hidden" name="nocondval" value="' + nocond + '" />' >+ + '</td>' >+ >+ + '<td><input type="hidden" name="repval" value="' + repval + '" />' + repvallabel + '</td>' >+ + '<td><input type="button" value="Delete" onclick="deleteRule(this)" /></td>' >+ + '</tr>'; >+ $('#rulestable').append(tmpl); >+ >+ } >+ >+ function deleteRule(button){ >+ $(button).parent().parent().remove(); >+ return false; >+ } >+ >+ >+//]]> >+</script> >+[% END %] >+</head> >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+<div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ >+<form method="post" enctype="multipart/form-data"> >+[% IF ( inputform ) %] >+ <h2>Batch records modification</h2> >+ <fieldset class="rows"> >+ <legend>Use a file</legend> >+ <ol> >+ <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>Or enter records one by one</legend> >+ <ol> >+ <li> >+ <label for="recordslist">Records numbers list (one number per line): </label> >+ <textarea rows="10" cols="30" id="recordslist" name="recordslist"></textarea> >+ </li> >+ </ol> >+ </fieldset> >+[% ELSE %] >+ <h2>List of records:</h2> >+ <table id="bibliolist"> >+ <thead> >+ <tr> >+ <th>Biblionumber</th><th>Title</th><th>Author</th>[% IF ( moddone ) %] <th>Status</th>[% END %] >+ </tr> >+ </thead> >+ [% FOREACH biblioinfo IN biblioinfos %] >+ <tr> >+ <td>[% biblioinfo.biblionumber %]</td> >+ <td>[% biblioinfo.title %]</td> >+ <td>[% biblioinfo.author %]</td> >+ [% IF ( biblioinfo.moddone ) %] >+ [% IF ( biblioinfo.OK ) %] >+ <td> >+ [% ELSE %] >+ <td class="problem"> >+ [% END %] >+ [% IF ( biblioinfo.OK ) %]OK[% END %] >+ [% IF ( No_Actions ) %]Nothing done[% END %] >+ [% IF ( biblioinfo.Actions_Failed ) %]Some Actions failed. List Follow : <ul>[% FOREACH failed_action IN biblioinfo.failed_actions %]<li>[% failed_action.action %]</li>[% END %]</ul>[% END %] >+ </td> >+ [% END %] >+ </tr> >+ [% END %] >+ </table> >+[% END %] >+ >+[% IF ( moddone ) %] >+ <div class="dialog alert">All operations processed</div> >+[% ELSE %] >+ <fieldset class="rows"> >+ <h2>Modification rules:</h2> >+ <input type="submit" value="Submit" /> >+ <input type="hidden" name="op" value="do" /> >+ <input type="hidden" name="bib_list" value="[% bib_list %]" /> >+ <table id="rulestable"> >+ <thead> >+ <tr> >+ <th>Field</th><th>Subfield</th><th>Action</th><th>Condition Value</th><th>Value</th><th> </th> >+ </tr> >+ </thead> >+ <tr> >+ <td> >+ <select name="fieldchoice" id="fieldchoice" onchange="fieldChanged();"> >+ [% FOREACH marcfield IN marcfields %] >+ <option value="[% marcfield.tag %]">[% marcfield.tag %]</option> >+ [% END %] >+ </select> >+ </td> >+ <td> >+ <select name="subfieldchoice" id="subfieldchoice" onchange="subfieldChanged();"> >+ >+ </select> >+ </td> >+ <td> >+ <select name="actionchoice" id="actionchoice"> >+ <option value="mod">Modify subfield</option> >+ <option value="add">Create subfield</option> >+ <option value="addfield">Create field and subfield</option> >+ <option value="del">Delete subfield</option> >+ </select> >+ </td> >+ <td id="condvaltd"> >+ <input type="text" name="condvalchoice" id="condvalchoice" /> >+ <input type="checkbox" id="nocond" name="nocond" value="nocond" onClick="$('#condvalchoice').attr('disabled', ! $('#condvalchoice').attr('disabled') ) ">All</input> >+ </td> >+ <td id="repvaltd"> >+ <input type="text" name="repvalchoice" id="repvalchoice" /> >+ </td> >+ <td><input type="button" value="Add" onclick="addRule();" /></td> >+ </tr> >+ </thead> >+ >+ </table> >+ <input type="submit" value="Submit" /> >+ </fieldset> >+ </form> >+[% END %] >+ </div> >+ </div> >+ </div> >+</div> >+</body> >+</html> >diff --git a/kohaversion.pl b/kohaversion.pl >index 00bdbec..9021eb0 100644 >--- a/kohaversion.pl >+++ b/kohaversion.pl >@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : > use strict; > > sub kohaversion { >- our $VERSION = '3.05.00.004'; >+ our $VERSION = '3.05.00.005'; > # version needs to be set this way > # so that it can be picked up by Makefile.PL > # during install >diff --git a/tools/batchedit.pl b/tools/batchedit.pl >new file mode 100755 >index 0000000..0f666b1 >--- /dev/null >+++ b/tools/batchedit.pl >@@ -0,0 +1,222 @@ >+#!/usr/bin/perl >+ >+ >+# Copyright 2010 SARL 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 CGI; >+use strict; >+use C4::Output; >+use C4::Auth; >+use C4::Branch; >+use C4::Koha; >+use C4::Biblio; >+use C4::Context; >+use C4::Debug; >+use JSON; >+ >+my $input = new CGI; >+my $dbh = C4::Context->dbh; >+ >+my $filefh = $input->param('uploadfile'); >+my $recordslist = $input->param('recordslist'); >+my $bib_list = $input->param('bib_list'); >+my @biblionumbers; >+ >+if ($filefh) { >+ while ( my $biblionumber = <$filefh> ) { >+ $biblionumber =~ s/[\r\n]*$//g; >+ push @biblionumbers, $biblionumber if $biblionumber; >+ } >+} elsif ($recordslist) { >+ push @biblionumbers, split( /\s\n/, $recordslist ); >+} elsif ($bib_list) { >+ push @biblionumbers, split('/', $bib_list); >+} >+ >+my $op = $input->param('op'); >+my ($template, $loggedinuser, $cookie); >+ >+my $frameworkcode=""; >+my $tagslib = &GetMarcStructure(1,$frameworkcode); >+my %report_actions; >+ >+if($input->param('field') and not defined $op){ >+ ($template, $loggedinuser, $cookie) >+ = get_template_and_user({template_name => "acqui/ajax.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => "batchedit" }, >+ }); >+ >+ >+ my $tag = $input->param('field'); >+ my $subfield = $input->param('subfield'); >+ >+ if($input->param('subfield')){ >+ my $branches = GetBranchesLoop(); >+ >+ my @authorised_values; >+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) { >+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) { >+ foreach my $thisbranch (@$branches) { >+ push @authorised_values, { >+ code => $thisbranch->{value}, >+ value => $thisbranch->{branchname}, >+ }; >+ # $value = $thisbranch->{value} if $thisbranch->{selected}; >+ } >+ }elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { >+ my $sth = $dbh->prepare("SELECT itemtype,description FROM itemtypes ORDER BY description"); >+ $sth->execute(); >+ while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) { >+ push @authorised_values, { >+ code => $itemtype, >+ value => $description, >+ }; >+ } >+ >+ }else { >+ # Getting the fields where the item location is >+ my ($location_field, $location_subfield) = GetMarcFromKohaField('items.location', $frameworkcode); >+ >+ # Getting the name of the authorised values' category for item location >+ my $item_location_category = $tagslib->{$location_field}->{$location_subfield}->{'authorised_value'}; >+ # Are we dealing with item location ? >+ my $item_location = ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) ? 1 : 0; >+ >+ # If so, we sort by authorised_value, else by libelle >+ my $orderby = $item_location ? 'authorised_value' : 'lib'; >+ >+ my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY $orderby"); >+ >+ $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value}); >+ >+ >+ while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { >+ push @authorised_values, { >+ code => $value, >+ value => ($item_location) ? $value . " - " . $lib : $lib, >+ }; >+ >+ } >+ } >+ } >+ $template->param('return' => to_json(\@authorised_values)); >+ }else{ >+ my @modifiablesubf; >+ >+ foreach my $subfield (sort keys %{$tagslib->{$tag}}) { >+ next if subfield_is_koha_internal_p($subfield); >+ next if $subfield eq "@"; >+ next if ($tagslib->{$tag}->{$subfield}->{'tab'} eq "10"); >+ my %subfield_data; >+ $subfield_data{subfield} = $subfield; >+ push @modifiablesubf, \%subfield_data; >+ } >+ $template->param('return' => to_json(\@modifiablesubf)); >+ } >+ >+ >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+}else{ >+ ($template, $loggedinuser, $cookie) >+ = get_template_and_user({template_name => "tools/batchedit.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => "batchedit" }, >+ }); >+ >+ $template->param( inputform => 1, ) unless @biblionumbers; >+ >+ if(!defined $op) { >+ my @modifiablefields; >+ >+ foreach my $tag (sort keys %{$tagslib}) { >+ my %subfield_data; >+ foreach my $subfield (sort keys %{$tagslib->{$tag}}) { >+ next if $subfield_data{tag}; >+ next if subfield_is_koha_internal_p($subfield); >+ next if ($tagslib->{$tag}->{$subfield}->{'tab'} eq "10"); >+ >+ $subfield_data{tag} = $tag; >+ >+ push @modifiablefields, \%subfield_data; >+ } >+ } >+ >+ $template->param( marcfields => \@modifiablefields, >+ bib_list => $input->param('bib_list'), >+ ); >+ >+ }else{ >+ my @fields = $input->param('field'); >+ my @subfields = $input->param('subfield'); >+ my @actions = $input->param('action'); >+ my @condvals = $input->param('condval'); >+ my @nocondvals = $input->param('nocondval'); >+ my @repvals = $input->param('repval'); >+ foreach my $biblionumber ( @biblionumbers ){ >+ my $record = GetMarcBiblio($biblionumber); >+ my ($count, $biblio) = GetBiblio($biblionumber); >+ my $report = 0; >+ my @failed_actions; >+ for(my $i = 0 ; $i < scalar(@fields) ; $i++ ){ >+ my $field = $fields[$i]; >+ my $subfield = $subfields[$i]; >+ my $action = $actions[$i]; >+ my $condval = $condvals[$i]; >+ my $nocond = $nocondvals[$i]; >+ my $repval = $repvals[$i]; >+ >+ my ($result,$record) = BatchModField($record, $field, $subfield, $action, $condval, $nocond, $repval); >+ push @failed_actions, {action=>"$field $subfield $action ".($nocond eq "true"?"all":$condval)." $repval"} if ($result<=0); >+ } >+ if (@failed_actions == scalar(@fields)){ >+ $report_actions{$biblionumber}->{status}="No_Actions"; >+ } >+ elsif (@failed_actions>0 and @failed_actions < scalar(@fields)){ >+ $report_actions{$biblionumber}->{status}="Actions_Failed"; >+ $report_actions{$biblionumber}->{failed_actions}=\@failed_actions; >+ } >+ elsif (@failed_actions == 0){ >+ $report_actions{$biblionumber}->{status}="OK"; >+ } >+ ModBiblio($record, $biblionumber, $biblio->{frameworkcode}) unless ($report); >+ } >+ $template->param('moddone' => 1); >+ } >+ >+} >+ >+my @biblioinfos; >+ >+for my $biblionumber (@biblionumbers){ >+ my ($count,$biblio) = GetBiblio($biblionumber); >+ if (defined $op){ >+ $biblio->{$report_actions{$biblionumber}->{status}}=1; >+ $biblio->{failed_actions}=$report_actions{$biblionumber}->{failed_actions}; >+ } >+ push @biblioinfos, $biblio; >+} >+ >+$template->param(biblioinfos => \@biblioinfos); >+output_html_with_http_headers $input, $cookie, $template->output; >+exit; >-- >1.7.4.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5725
:
3105
|
3108
|
3191
|
3193
|
3234
|
3356
|
4734
|
4735
|
4736
|
4863
|
4864
|
4897
|
4898
|
4899
|
5404
|
5405
|
5684
|
5685
|
5697
|
5959
|
5960
|
5980
|
5981
|
5982
|
10610
|
10611
|
10612
|
11731
|
11732
|
11733