--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Tools › Inventory</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
+<script type="text/JavaScript" language="JavaScript">
+//<![CDATA[
+ $(document).ready(function() {
+ $("#itemst").tablesorter();
+ });
+//]]>
+</script>
+<!-- TMPL_INCLUDE NAME="calendar.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> ›
+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
+ <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Delete batches of notices</a>
+</div>
+
+<div id="doc3" class="yui-t2">
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+ show : <!-- TMPL_VAR NAME="show" --> <br />
+ action : <!-- TMPL_VAR NAME="action" --><br />
+ results : <!-- TMPL_VAR NAME="results" --><br />
+ nextop : <!-- TMPL_VAR NAME="op" -->
+ <h1>Batch deletion</h1>
+ <!-- TMPL_IF NAME="barcode_not_unique" --><div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="no_next_barcode" --><div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF -->
+
+<!-- TMPL_IF name="item_loop" -->
+ <!-- TMPL_UNLESS name="action" -->
+ <form name="f" action="batchMod.pl" method="post">
+ <div id="cataloguing_additem_itemlist">
+ <div style="overflow:auto">
+ <table id="itemst">
+ <thead>
+ <tr>
+ <th> </th>
+ <!-- TMPL_LOOP NAME="item_header_loop" -->
+ <th> <!-- TMPL_VAR NAME="header_value" --> </th>
+ <!-- /TMPL_LOOP -->
+ </tr>
+ </thead>
+ <tbody>
+ <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF-->
+ <!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td>
+ <!-- /TMPL_LOOP --> </tr>
+ <!-- /TMPL_LOOP -->
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <!-- TMPL_IF name="show" -->
+ <div id="cataloguing_additem_newitem">
+ <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" />
+ <p>This will delete the selected items.</p>
+ <input type="hidden" name="del" value="1" />
+ <fieldset class="action">
+ <input type="submit" name="submit" value="Go" />
+ </fieldset>
+ </div>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_UNLESS -->
+<!-- TMPL_ELSE -->
+ <p>No item found</p>
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF name="action" -->
+ <p><!-- TMPL_VAR NAME="deleted_items" --> item(s) deleted.</p>
+ <!-- TMPL_IF NAME="not_deleted_items" --><p><!-- TMPL_VAR NAME="not_deleted_items" --> item(s) could not be deleted : <!-- TMPL_LOOP NAME="not_deleted_itemnumbers" --><!-- TMPL_VAR NAME="itemnumber" --></p>
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+ <div class="yui-b">
+ <!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
+ </div>
+ </div>
+</div>
+</body>
+</html>
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Tools › Inventory</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
+<script type="text/JavaScript" language="JavaScript">
+//<![CDATA[
+ $(document).ready(function() {
+ $("#itemst").tablesorter();
+ });
+//]]>
+</script>
+<!-- TMPL_INCLUDE NAME="calendar.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> ›
+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
+ <!-- TMPL_IF name="del" -->
+ <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Delete batches of notices</a>
+ <!-- TMPL_ELSE -->
+ <a href="/cgi-bin/koha/tools/batchMod.pl">Modify batches of notices</a>
+ <!-- /TMPL_IF -->
+</div>
+
+<div id="doc3" class="yui-t2">
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+ <h1>Batch <!-- TMPL_IF name="del" -->deletion<!-- TMPL_ELSE -->modification<!-- /TMPL_IF --></h1>
+ <!-- TMPL_UNLESS name="op" -->
+ <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batchMod.pl">
+ <fieldset class="rows">
+ <legend>Use a file</legend>
+ <ol>
+ <li>
+ <label for="barcode_file">Barcodes file</label><input type="radio" name="filecontent" value="barcode_file" id="barcode_file" checked="checked" /><br />
+ <label for="itemid_file">Item Id's file</label><input type="radio" name="filecontent" value="itemid_file" id="itemid_file" />
+ </li>
+ <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile"></input></li>
+ </ol>
+ </fieldset>
+ <fieldset class="rows">
+ <legend>Or scan items one-by-one</legend>
+ <ol>
+ <li>
+ <label for="barcodelist">Barcodes list (one barcode per line): </label>
+ <textarea rows="10" cols="30" id="barcodelist" name="barcodelist"></textarea>
+ </li>
+ </ol>
+ </fieldset>
+ <input type="hidden" name="op" value="show" />
+ <!-- TMPL_IF name="del" --><input type="hidden" name="del" value="1" /><!-- /TMPL_IF -->
+ <fieldset class="action">
+ <input type="submit" value="Continue" class="button" />
+ </fieldset>
+ </form>
+ </div>
+ <!-- /TMPL_UNLESS -->
+<!-- TMPL_IF NAME="barcode_not_unique" --><div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="no_next_barcode" --><div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF -->
+
+<!-- TMPL_IF name="item_loop" -->
+<form name="f" action="batchMod.pl" method="post">
+<div id="cataloguing_additem_itemlist">
+ <div style="overflow:auto">
+ <table id="itemst">
+ <thead>
+ <tr>
+ <th> </th>
+ <!-- TMPL_LOOP NAME="item_header_loop" -->
+ <th> <!-- TMPL_VAR NAME="header_value" --> </th>
+ <!-- /TMPL_LOOP -->
+ </tr>
+ </thead>
+ <tbody>
+ <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF-->
+ <!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td>
+ <!-- /TMPL_LOOP --> </tr>
+ <!-- /TMPL_LOOP -->
+ </tbody>
+ </table>
+ </div>
+</div>
+<!-- TMPL_IF name="show" -->
+<div id="cataloguing_additem_newitem">
+ <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" />
+ <!-- TMPL_IF name="del" -->
+ <p>This will delete the selected items.</p>
+ <input type="hidden" name="del" value="1" />
+ <!-- TMPL_ELSE -->
+ <h2>Edit Items</h2>
+ <fieldset class="rows">
+ <ol>
+ <!-- TMPL_LOOP NAME="item" -->
+ <li><div class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+ <label><!-- TMPL_VAR NAME="subfield" --> -
+ <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF -->
+ <!-- TMPL_VAR NAME="marc_lib" -->
+ <!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF -->
+ </label>
+ <!-- TMPL_VAR NAME="marc_value" -->
+ <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
+ <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
+ <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
+ <!-- TMPL_IF NAME="repeatable" -->
+ <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
+ <!-- /TMPL_IF -->
+
+ </div></li>
+ <!-- /TMPL_LOOP -->
+ </ol>
+ </fieldset>
+ <!-- /TMPL_IF -->
+<fieldset class="action">
+ <input type="submit" name="submit" value="Go" />
+</fieldset>
+</div>
+<!-- TMPL_ELSE --> <!-- // ACTION -->
+ <!-- TMPL_IF NAME="del" -->
+ <p><!-- TMPL_VAR NAME="deleted_items" --> item(s) deleted.</p>
+ <!-- TMPL_IF NAME="not_deleted_items" --><p><!-- TMPL_VAR NAME="not_deleted_items" --> item(s) could not be deleted.<p>
+ <!-- TMPL_ELSE -->
+ <h3>No results!</h3>
+ <a href="javascript:window.history.back()">Go back</a>
+ <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+
+</div>
+</div>
+ <div class="yui-b">
+ <!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
+ </div>
+ </div>
+</div>
+</body>
+</html>
<div id="yui-main">
<div class="yui-b">
<h1>Batch <!-- TMPL_IF name="del" -->deletion<!-- TMPL_ELSE -->modification<!-- /TMPL_IF --></h1>
- <!-- TMPL_UNLESS name="op" -->
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batchMod.pl">
<fieldset class="rows">
<legend>Use a file</legend>
</fieldset>
</form>
</div>
- <!-- /TMPL_UNLESS -->
-<!-- TMPL_IF NAME="barcode_not_unique" --><div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div><!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="no_next_barcode" --><div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div><!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF -->
-<!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF -->
-
-<!-- TMPL_IF name="item_loop" -->
-<form name="f" action="batchMod.pl" method="post">
-<div id="cataloguing_additem_itemlist">
- <div style="overflow:auto">
- <table id="itemst">
- <thead>
- <tr>
- <th> </th>
- <!-- TMPL_LOOP NAME="item_header_loop" -->
- <th> <!-- TMPL_VAR NAME="header_value" --> </th>
- <!-- /TMPL_LOOP -->
- </tr>
- </thead>
- <tbody>
- <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF-->
- <!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td>
- <!-- /TMPL_LOOP --> </tr>
- <!-- /TMPL_LOOP -->
- </tbody>
- </table>
- </div>
-</div>
-<!-- TMPL_IF name="show" -->
-<div id="cataloguing_additem_newitem">
- <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" />
- <!-- TMPL_IF name="del" -->
- <p>This will delete the selected items.</p>
- <input type="hidden" name="del" value="1" />
- <!-- TMPL_ELSE -->
- <h2>Edit Items</h2>
- <fieldset class="rows">
- <ol>
- <!-- TMPL_LOOP NAME="item" -->
- <li><div class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
- <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
- <!-- TMPL_VAR NAME="marc_value" -->
- <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
- <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
- <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
- <!-- TMPL_IF NAME="repeatable" -->
- <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
- <!-- /TMPL_IF -->
-
- </div></li>
- <!-- /TMPL_LOOP -->
- </ol>
- </fieldset>
- <!-- /TMPL_IF -->
-<fieldset class="action">
- <input type="submit" name="submit" value="Go" />
-</fieldset>
-</div>
- <!-- TMPL_ELSE -->
- <h3>No results!</h3>
- <a href="javascript:window.history.back()">Go back</a>
- <!-- /TMPL_IF -->
-
-</div>
-</div>
- <div class="yui-b">
+ </div>
+ <div class="yui-b">
<!-- TMPL_INCLUDE NAME="tools-menu.inc" -->
</div>
</div>
use Switch;
use MARC::File::XML;
-sub find_value {
- my ($tagfield,$insubfield,$record) = @_;
- my $result;
- my $indicator;
- foreach my $field ($record->field($tagfield)) {
- my @subfields = $field->subfields();
- foreach my $subfield (@subfields) {
- if (@$subfield[0] eq $insubfield) {
- $result .= @$subfield[1];
- $indicator = $field->indicator(1).$field->indicator(2);
- }
- }
- }
- return($indicator,$result);
-}
-
-
my $input = new CGI;
my $dbh = C4::Context->dbh;
my $error = $input->param('error');
my $op = $input->param('op');
my $del = $input->param('del');
+my $template_name;
+if (!defined $op) {
+ $template_name = "tools/batchMod.tmpl";
+} else {
+ $template_name = ($del) ? "tools/batchMod-del.tmpl" : "tools/batchMod-edit.tmpl";
+}
+
+
my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "tools/batchMod.tmpl",
+ = get_template_and_user({template_name => $template_name,
query => $input,
type => "intranet",
authnotrequired => 0,
my $frameworkcode="";
my $tagslib = &GetMarcStructure(1,$frameworkcode);
+my $deleted_items = 0; # Numbers of deleted items
+my $not_deleted_items = 0; # Numbers of items that could not be deleted
+my @not_deleted; # List of the itemnumbers that could not be deleted
+
#--- ----------------------------------------------------------------------------
if ($op eq "action") {
#-------------------------------------------------------------------------------
my $marcitem = MARC::Record::new_from_xml($xml, 'UTF-8');
my $localitem = TransformMarcToKoha( $dbh, $marcitem, "", 'items' );
-# my @params=$input->param();
-# warn @params;
-# my $marcitem = TransformHtmlToMarc(\@params,$input);
- foreach my $itemnumber(@itemnumbers){
- my $itemdata=GetItem($itemnumber);
- if ($input->param("del")){
- DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'})
- } else {
- my $localmarcitem=Item2Marc($itemdata);
- UpdateMarcWith($marcitem,$localmarcitem);
- eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)};
- # eval{ModItem($localitem,$itemdata->{biblionumber},$itemnumber)};
- }
- }
- $items_display_hashref=BuildItemsData(@itemnumbers);
- $nextop="action";
+ foreach my $itemnumber(@itemnumbers){
+ my $itemdata=GetItem($itemnumber);
+ if ($input->param("del")){
+ my $return = DelItemCheck(C4::Context->dbh, $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'});
+ if ($return == 1) {
+ $deleted_items++;
+ } else {
+ $not_deleted_items++;
+ push @not_deleted, $itemdata->{'itemnumber'};
+ }
+ } else {
+ my $localmarcitem=Item2Marc($itemdata);
+ UpdateMarcWith($marcitem,$localmarcitem);
+ eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)};
+ }
+ }
+ $items_display_hashref=BuildItemsData(@itemnumbers);
}
#
my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later.
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
+
foreach my $tag (sort keys %{$tagslib}) {
-# loop through each subfield
- foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
- next if subfield_is_koha_internal_p($subfield);
- next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
- my %subfield_data;
+ # loop through each subfield
+ foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
+ next if subfield_is_koha_internal_p($subfield);
+ next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
+ my %subfield_data;
- my $index_subfield = int(rand(1000000));
- if ($subfield eq '@'){
- $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield;
- } else {
- $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield;
- }
- $subfield_data{tag} = $tag;
- $subfield_data{subfield} = $subfield;
- $subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms?
-# $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib};
- $subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
- $subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory};
- $subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
- my ($x,$value);
- $value =~ s/"/"/g;
- unless ($value) {
- $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
- # get today date & replace YYYY, MM, DD if provided in the default value
- my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas!
- $value =~ s/YYYY/$year/g;
- $value =~ s/MM/$month/g;
- $value =~ s/DD/$day/g;
- }
- $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
- # testing branch value if IndependantBranches.
-
- my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
- my $attributes = qq($attributes_no_value value="$value" );
- if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
- my @authorised_values;
- my %authorised_lib;
- # builds list, depending on authorised value...
+ my $index_subfield = int(rand(1000000));
+ if ($subfield eq '@'){
+ $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield;
+ } else {
+ $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield;
+ }
+ $subfield_data{tag} = $tag;
+ $subfield_data{subfield} = $subfield;
+ $subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms?
+ # $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib};
+ $subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
+ $subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory};
+ $subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
+ my ($x,$value);
+ $value =~ s/"/"/g;
+ unless ($value) {
+ $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
+ # get today date & replace YYYY, MM, DD if provided in the default value
+ my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas!
+ $value =~ s/YYYY/$year/g;
+ $value =~ s/MM/$month/g;
+ $value =~ s/DD/$day/g;
+ }
+ $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
+ # testing branch value if IndependantBranches.
+
+ my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
+ my $attributes = qq($attributes_no_value value="$value" );
+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
+ my @authorised_values;
+ my %authorised_lib;
+ # builds list, depending on authorised value...
- if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
- foreach my $thisbranch (@$branches) {
- push @authorised_values, $thisbranch->{value};
- $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
- $value = $thisbranch->{value} if $thisbranch->{selected};
- }
- }
- elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
- push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
- my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description");
- $sth->execute;
- while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
- push @authorised_values, $itemtype;
- $authorised_lib{$itemtype} = $description;
- }
+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
+ foreach my $thisbranch (@$branches) {
+ push @authorised_values, $thisbranch->{value};
+ $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
+ $value = $thisbranch->{value} if $thisbranch->{selected};
+ }
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
+ push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
+ my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description");
+ $sth->execute;
+ while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
+ push @authorised_values, $itemtype;
+ $authorised_lib{$itemtype} = $description;
+ }
#---- class_sources
}
push (@loop_data, \%subfield_data);
$i++
}
-}
+} # -- End foreach tag
+
+
+ # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
+ $template->param(item => \@loop_data);
+ $nextop="action"
+} # -- End action="show"
-# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
-$template->param(
- item => \@loop_data,
-);
-$nextop="action"
-}
$template->param(%$items_display_hashref) if $items_display_hashref;
$template->param(
op => $nextop,
$op => 1,
- opisadd => ($nextop eq "saveitem") ? 0 : 1,
);
+
+if ($op eq "action") {
+
+ my @not_deleted_loop = map{{itemnumber=>$_}}@not_deleted;
+
+ $template->param(
+ not_deleted_items => $not_deleted_items,
+ deleted_items => $deleted_items,
+ not_deleted_itemnumbers => \@not_deleted_loop
+ );
+}
+
foreach my $error (@errors) {
$template->param($error => 1);
}
output_html_with_http_headers $input, $cookie, $template->output;
exit;
+
+# ---------------- Functions
+
sub BuildItemsData{
my @itemnumbers=@_;
# now, build existiing item list
my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted;
return { item_loop => \@item_value_loop, item_header_loop => \@header_loop };
}
+
#BE WARN : it is not the general case
# This function can be OK in the item marc record special case
# Where subfield is not repeated
}
#warn "TO edited:",$marcto->as_formatted;
}
+
+sub find_value {
+ my ($tagfield,$insubfield,$record) = @_;
+ my $result;
+ my $indicator;
+ foreach my $field ($record->field($tagfield)) {
+ my @subfields = $field->subfields();
+ foreach my $subfield (@subfields) {
+ if (@$subfield[0] eq $insubfield) {
+ $result .= @$subfield[1];
+ $indicator = $field->indicator(1).$field->indicator(2);
+ }
+ }
+ }
+ return($indicator,$result);
+}
+
+
+