<input type="hidden" name="recordtype" value="biblio" />
<input type="hidden" name="op" value="list" />
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
- <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' %][% SET batch_biblionumbers = 1 %]
+ <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %][% SET batch_biblionumbers = 1 %]
[% cells.cell | html %][% END %][% END %][% END %]</textarea>
</form>
<input type="hidden" name="recordtype" value="biblio" />
<input type="hidden" name="op" value="list" />
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
- <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' %][% SET batch_biblionumbers = 1 %]
+ <textarea style="display:none" name="recordnumber_list" id="recordnumber_list">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %][% SET batch_biblionumbers = 1 %]
[% cells.cell | html %][% END %][% END %][% END %]</textarea>
</form>
[% FOREACH result IN results %]
[% FOREACH cells IN result.cells %]
[% place = loop.index %]
- [% IF header_row.$place.cell == 'itemnumber' %]
+ [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
[% SET batch_itemnumbers = 1 %]
<input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
[% END %]
[% FOREACH result IN results %]
[% FOREACH cells IN result.cells %]
[% place = loop.index %]
- [% IF header_row.$place.cell == 'itemnumber' %]
+ [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %]
[% SET batch_itemnumbers = 1 %]
<input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]" />
[% END %]
[% FOREACH result IN results %]
[% FOREACH cells IN result.cells %]
[% place = loop.index %]
- [% IF header_row.$place.cell == 'biblionumber' %]
+ [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %]
[% SET batch_biblionumbers = 1 %]
<input type="hidden" class="bib_to_list" name="biblionumber" value="[% cells.cell | html %]" />
[% END %]
<form method="POST" action="/cgi-bin/koha/tools/modborrowers.pl" id="batch_patron_modification">
<input type="hidden" name="op" value="show" />
[% # Preserve the whitespace of the following textarea in order to format the values correctly %]
- <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'cardnumber' %][% SET batch_cardnumbers = 1 %]
+ <textarea style="display:none" name="cardnumberlist" id="cardnumberlist">[% FOREACH result IN results %][% FOREACH cells IN result.cells %][% place = loop.index %][% IF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %][% SET batch_cardnumbers = 1 %]
[% cells.cell | html %][% END %][% END %][% END %]</textarea>
</form>
</button>
<ul class="dropdown-menu" aria-labelledby="batch_mod_menu">
[% FOREACH header_ro IN header_row %]
- [% IF header_ro.cell == 'biblionumber' %]
+ [% IF header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' %]
<li class="dropdown-header">Bibliographic records</li>
<li>
<a href="#" data-submit="batch_record_modification" data-toggle="tooltip" data-placement="right" title="Send visible records to batch record modification" class="batch_op send_to_record_mod">Batch record modification</a>
<a href="#" data-submit="batch_add_to_list" data-toggle="tooltip" data-placement="right" title="Send visible records to a list" class="batch_op send_to_list">Add to list</a>
</li>
[% END %]
- [% IF header_ro.cell == 'itemnumber' %]
+ [% IF header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' %]
[% IF ( batch_biblionumbers ) %]
<li role="separator" class="divider"></li>
[% END %]
<a href="#" data-submit="batch_item_deletion" data-toggle="tooltip" data-placement="right" title="Send visible items to batch item deletion" class="batch_op send_to_item_del">Batch item deletion</a>
</li>
[% END %]
- [% IF header_ro.cell == 'cardnumber' %]
+ [% IF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
[% IF ( batch_biblionumbers || batch_itemnumbers ) %]
<li role="separator" class="divider"></li>
[% END %]
'reports' => $report_id,
);
} else {
- my $sql = get_prepped_report( $sql, \@param_names, \@sql_params);
+ my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params);
+ $template->param(header_types => $header_types);
my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id );
my ($sth2, $errors2) = execute_query($sql);
my $total = nb_rows($sql) || 0;
# pass $sth and sql_params, get back an executable query
sub get_prepped_report {
my ($sql, $param_names, $sql_params ) = @_;
+
+ # First we split out the placeholders
+ my @split = split /\[\[|\]\]/,$sql;
+ my $headers;
+ for(my $i=0;$i<$#split/2;$i++){ #The placeholders are always the odd elements of the array
+ my ($type,$name) = split /\|/,$split[$i*2+1]; # We split them on '|'
+ $headers->{$name} = $type; # Store as a lookup for the template
+ $split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; #Quote any special characters so we can replace the placeholders
+ $sql =~ s/\[\[$split[$i*2+1]\]\]/$type AS $name/; # Remove placeholders from SQL
+ }
+
my %lookup;
@lookup{@$param_names} = @$sql_params;
my @split = split /<<|>>/,$sql;
$quoted = C4::Context->dbh->quote($quoted);
$sql =~ s/<<$split[$i*2+1]>>/$quoted/;
}
- return $sql;
+ return $sql,$headers;
}