Skip to content

Commit

Permalink
Add ability to pass params into the coverflow report
Browse files Browse the repository at this point in the history
For multibranch systems where eachlibrary wants a coverflow of their
own books this allows for reusing a single report

This also allows for multiple coverflow on different sections using a
single report

Basically, it's kinda cool :-) it will need documented but should be
battle tested, kept a little secret for now
  • Loading branch information
kidclamp committed Jan 31, 2018
1 parent 898ffab commit 835b588
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Koha/Plugin/Com/ByWaterSolutions/CoverFlow.pm
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,13 @@ sub get_report {
my $report_id = $params->{'id'};
my $report_name = $params->{'name'};
my $sql_params = $params->{'sql_params'};
my @sql_params;

my $cgi = $params->{'cgi'};
if ($cgi) {
$report_id ||= $cgi->param('id');
$report_name ||= $cgi->param('name');
$sql_params ||= $cgi->param('sql_params');
@sql_params = $cgi->multi_param('sql_params');
}

my $report_rec = get_saved_report(
Expand All @@ -235,8 +236,7 @@ sub get_report {

#die "Sorry this report is not public\n" unless $report_rec->{public};

my @sql_params = $sql_params ? @$sql_params : ();

$sql_params ||= \@sql_params;
my $cache;# = Koha::Caches->get_instance();
my $cache_active;# = $cache->is_cache_active;
my ( $cache_key, $json_text );
Expand All @@ -257,7 +257,7 @@ sub get_report {
$sql =~ s/(<<.*?>>)/\?/g;

my ( $sth, $errors ) =
execute_query( $sql, $offset, $limit, \@sql_params );
execute_query( $sql, $offset, $limit, $sql_params );
if ($sth) {
my $lines;
$lines = $sth->fetchall_arrayref( {} );
Expand Down
2 changes: 1 addition & 1 deletion Koha/Plugin/Com/ByWaterSolutions/CoverFlow/opacuserjs.tt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $(document).ready(function () {
$.getScript("/plugin/Koha/Plugin/Com/ByWaterSolutions/CoverFlow/bower_components/jquery-flipster/dist/jquery.flipster.min.js", function (data, textStatus, jqxhr) {
$("head").append("<link id='flipster-css' href='/plugin/Koha/Plugin/Com/ByWaterSolutions/CoverFlow/bower_components/jquery-flipster/dist/jquery.flipster.min.css' type='text/css' rel='stylesheet' />");
[% FOREACH m IN mapping %]
$('[% m.selector %]').load("/coverflow.pl?id=[% m.id %]", function () {
$('[% m.selector %]').load("/coverflow.pl?id=[% m.id %][% FOREACH param IN m.params %]&sql_params=[% param %][% END %]", function () {
$('.koha-coverflow img').on("load", function(){
if ( this.naturalHeight == 1 ) {
$(this).attr("src", [% IF (custom_image) %]"[% custom_image %]")[% ELSE %]"http://media.bywatersolutions.com/Model/NoImage.png")[% END%];
Expand Down

0 comments on commit 835b588

Please sign in to comment.