@@ -, +, @@ --- Koha/Schema/Result/SavedSql.pm | 21 +- Koha/Schema/Result/Sign.pm | 132 ++++++++ Koha/Schema/Result/SignStream.pm | 105 +++++++ Koha/Schema/Result/SignsToStream.pm | 114 +++++++ Koha/Sign.pm | 40 +++ Koha/SignStream.pm | 40 +++ Koha/SignStreams.pm | 59 ++++ Koha/Signs.pm | 343 +++------------------ Koha/SignsToStream.pm | 40 +++ Koha/SignsToStreams.pm | 59 ++++ .../mysql/atomicupdate/bug_8628-digital-signs.sql | 2 +- installer/data/mysql/kohastructure.sql | 45 +++ .../intranet-tmpl/prog/en/includes/tools-menu.inc | 3 + .../intranet-tmpl/prog/en/modules/tools/signs.tt | 149 ++++----- opac/opac-signs.pl | 72 ++++- tools/signs.pl | 126 +++++--- 16 files changed, 922 insertions(+), 428 deletions(-) create mode 100644 Koha/Schema/Result/Sign.pm create mode 100644 Koha/Schema/Result/SignStream.pm create mode 100644 Koha/Schema/Result/SignsToStream.pm create mode 100644 Koha/Sign.pm create mode 100644 Koha/SignStream.pm create mode 100644 Koha/SignStreams.pm create mode 100644 Koha/SignsToStream.pm create mode 100644 Koha/SignsToStreams.pm --- a/Koha/Schema/Result/SavedSql.pm +++ a/Koha/Schema/Result/SavedSql.pm @@ -162,9 +162,26 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("id"); +=head1 RELATIONS -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-24 09:58:16 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eGWRRzpe1+EBialePAIhMQ +=head2 sign_streams + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "sign_streams", + "Koha::Schema::Result::SignStream", + { "foreign.saved_sql_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:f9cgj30zP/aIRPhEmZNT6g # You can replace this text with custom content, and it will be preserved on regeneration --- a/Koha/Schema/Result/Sign.pm +++ a/Koha/Schema/Result/Sign.pm @@ -0,0 +1,132 @@ +use utf8; +package Koha::Schema::Result::Sign; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::Sign + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("signs"); + +=head1 ACCESSORS + +=head2 sign_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 name + + data_type: 'varchar' + is_nullable: 1 + size: 64 + +=head2 webapp + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +=head2 transition + + data_type: 'char' + default_value: 'none' + is_nullable: 0 + size: 16 + +=head2 swatch + + data_type: 'char' + default_value: (empty string) + is_nullable: 0 + size: 1 + +=head2 idleafter + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +=head2 pagedelay + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +=head2 reloadafter + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "sign_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 1, size => 64 }, + "webapp", + { data_type => "integer", default_value => 0, is_nullable => 0 }, + "transition", + { data_type => "char", default_value => "none", is_nullable => 0, size => 16 }, + "swatch", + { data_type => "char", default_value => "", is_nullable => 0, size => 1 }, + "idleafter", + { data_type => "integer", default_value => 0, is_nullable => 0 }, + "pagedelay", + { data_type => "integer", default_value => 0, is_nullable => 0 }, + "reloadafter", + { data_type => "integer", default_value => 0, is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("sign_id"); + +=head1 RELATIONS + +=head2 signs_to_streams + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "signs_to_streams", + "Koha::Schema::Result::SignsToStream", + { "foreign.sign_id" => "self.sign_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OWtbToVshm6D/q7jMbhAEA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; --- a/Koha/Schema/Result/SignStream.pm +++ a/Koha/Schema/Result/SignStream.pm @@ -0,0 +1,105 @@ +use utf8; +package Koha::Schema::Result::SignStream; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::SignStream + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("sign_streams"); + +=head1 ACCESSORS + +=head2 sign_stream_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 saved_sql_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 name + + data_type: 'varchar' + is_nullable: 1 + size: 64 + +=cut + +__PACKAGE__->add_columns( + "sign_stream_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "saved_sql_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "name", + { data_type => "varchar", is_nullable => 1, size => 64 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("sign_stream_id"); + +=head1 RELATIONS + +=head2 saved_sql + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "saved_sql", + "Koha::Schema::Result::SavedSql", + { id => "saved_sql_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + +=head2 signs_to_streams + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "signs_to_streams", + "Koha::Schema::Result::SignsToStream", + { "foreign.sign_stream_id" => "self.sign_stream_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+QnTPOZSc8xl1o2qI0YB8A + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; --- a/Koha/Schema/Result/SignsToStream.pm +++ a/Koha/Schema/Result/SignsToStream.pm @@ -0,0 +1,114 @@ +use utf8; +package Koha::Schema::Result::SignsToStream; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::SignsToStream + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("signs_to_streams"); + +=head1 ACCESSORS + +=head2 sign_to_stream_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 sign_stream_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 sign_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 params + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 255 + +=cut + +__PACKAGE__->add_columns( + "sign_to_stream_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "sign_stream_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "sign_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "params", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("sign_to_stream_id"); + +=head1 RELATIONS + +=head2 sign + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "sign", + "Koha::Schema::Result::Sign", + { sign_id => "sign_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + +=head2 sign_stream + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "sign_stream", + "Koha::Schema::Result::SignStream", + { sign_stream_id => "sign_stream_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-21 22:48:12 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fAi1KA4VmwQM96sQoI5DMQ + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; --- a/Koha/Sign.pm +++ a/Koha/Sign.pm @@ -0,0 +1,40 @@ +package Koha::Sign; + +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Database; + +use base qw( Koha::Object ); + +=head1 NAME + +Koha::Sign - Koha Sign object class + +=head1 API + +=head2 Class Methods + +=cut + +sub _type { + return 'Sign'; +} + +1; --- a/Koha/SignStream.pm +++ a/Koha/SignStream.pm @@ -0,0 +1,40 @@ +package Koha::SignStream; + +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Database; + +use base qw( Koha::Object ); + +=head1 NAME + +Koha::SignStream - Koha SignStream object class + +=head1 API + +=head2 Class Methods + +=cut + +sub _type { + return 'SignStream'; +} + +1; --- a/Koha/SignStreams.pm +++ a/Koha/SignStreams.pm @@ -0,0 +1,59 @@ +package Koha::SignStreams; + +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Database; +use Koha::SignStream; + +use base qw( Koha::Objects ); + +=head1 NAME + +Koha::SignStreams - Koha SignStream object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'SignStream'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::SignStream'; +} + +=head1 AUTHOR + +Aleisha Amohia + +=cut + +1; --- a/Koha/Signs.pm +++ a/Koha/Signs.pm @@ -1,330 +1,59 @@ package Koha::Signs; -use C4::Context; -use C4::Biblio; -use C4::Koha; -use C4::Items; -use Modern::Perl; - -use base qw( Exporter ); - -# set the version for version checking -our @EXPORT = qw( - - AddSignStream - ModSignStream - GetSignStream - GetSignStreams - DelSignStream - - GetSignStreamRecords - - AddSign - ModSign - GetSign - GetSigns - DelSign - - AttachSignStreamToSign - DetachSignStreamFromSign - GetSignStreamsAttachedToSign - GetSignStreamsAttachedToSignWithRecords - - ModSignStreamParams - GetSignStreamParams -); - -my $dbh = C4::Context->dbh; - -# Streams - -# Returns id of new sign_stream -sub AddSignStream { - - my ( $name, $report ) = @_; - - my $sth=$dbh->prepare("INSERT INTO sign_streams SET name = ?, saved_sql_id = ?"); - $sth->execute( $name, $report ); - return $dbh->last_insert_id( undef, undef, 'sign_streams', 'sign_stream_id' ); - -} - -sub ModSignStream { - - my ( $name, $report, $sign_stream_id ) = @_; - - my $sth = $dbh->prepare("UPDATE sign_streams SET name = ?, saved_sql_id = ? WHERE sign_stream_id = ?"); - return $sth->execute( $name, $report, $sign_stream_id ); - -} - -sub GetSignStream { - - my ( $sign_id ) = @_; - - return unless $sign_id; - - my $query = "SELECT s.*, sq.report_name, sq.savedsql - FROM sign_streams AS s, saved_sql AS sq - WHERE s.saved_sql_id = sq.id - AND s.sign_stream_id = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($sign_id); - return $sth->fetchrow_hashref(); - -} - -sub GetSignStreams { - - my $query = "SELECT s.*, sq.report_name, sq.savedsql - FROM sign_streams AS s, saved_sql AS sq - WHERE s.saved_sql_id = sq.id - ORDER BY s.name"; - my $sth = $dbh->prepare($query); - $sth->execute(); - return $sth->fetchall_arrayref({}); - -} - -sub DelSignStream { - - my ( $sign_stream_id ) = @_; - - return unless $sign_stream_id; - - my $sth = $dbh->prepare('DELETE FROM sign_streams WHERE sign_stream_id = ?'); - return $sth->execute($sign_stream_id); - -} - -sub GetSignStreamRecords { - my ( $stream, $sign_to_stream_id) = @_; - my $sql = $stream->{'savedsql'}; - - if ( defined $sign_to_stream_id ) { - my $params = GetSignStreamParams( $sign_to_stream_id ); - $sql = ReplaceParamsInSQL( $sql, $params ); - return undef if ( $sql =~ m/< RunSQL( $sql ), sql => $sql }; -} - -# Signs - -# Returns id of new sign -sub AddSign { - - my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ) = @_; - - my $sth=$dbh->prepare("INSERT INTO signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ?"); - $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter ); - return $dbh->last_insert_id( undef, undef, 'signs', 'sign_id' ); - -} - -sub ModSign { - - my ( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ) = @_; - - my $sth = $dbh->prepare("UPDATE signs SET name = ?, webapp = ?, swatch = ?, transition = ?, idleafter = ?, pagedelay = ?, reloadafter = ? WHERE sign_id = ?"); - return $sth->execute( $name, $webapp, $swatch, $transition, $idleafter, $pagedelay, $reloadafter, $sign_id ); - -} - -sub GetSign { - - my ( $sign_id ) = @_; - - return unless $sign_id; - - my $query = "SELECT * - FROM signs - WHERE sign_id = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($sign_id); - return $sth->fetchrow_hashref(); +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -} - -sub GetSigns { - - my $query = "SELECT * - FROM signs - ORDER BY name"; - my $sth = $dbh->prepare($query); - $sth->execute(); - return $sth->fetchall_arrayref({}); - -} - -sub DelSign { - - my ( $sign_id ) = @_; - - return unless $sign_id; - - my $sth = $dbh->prepare('DELETE FROM signs WHERE sign_id = ?'); - return $sth->execute($sign_id); - -} - -# Streams attached to signs - -# Returns the ID of the connection between sign and stream -sub AttachSignStreamToSign { - - my ( $sign_stream_id, $sign_id ) = @_; - - return unless $sign_stream_id || $sign_id; - - my $sth = $dbh->prepare( 'INSERT INTO signs_to_streams SET sign_stream_id = ?, sign_id = ?' ); - $sth->execute( $sign_stream_id, $sign_id ); - return $dbh->last_insert_id( undef, undef, 'signs_to_streams', 'sign_to_stream_id' ); - -} - -sub ModSignStreamParams { - - my ( $sign_to_stream_id, $params ) = @_; - return unless $sign_to_stream_id; - my $sth = $dbh->prepare( 'UPDATE signs_to_streams SET params = ? WHERE sign_to_stream_id = ?' ); - return $sth->execute( $params, $sign_to_stream_id ); - -} - -# Returns the string of params for a given stream-attached-to-sign -sub GetSignStreamParams { - - my ( $sign_to_stream_id ) = @_; - - return unless $sign_to_stream_id; - - my $query = 'SELECT params FROM signs_to_streams WHERE sign_to_stream_id = ?'; - my $sth = $dbh->prepare( $query ); - $sth->execute( $sign_to_stream_id ); - return $sth->fetchrow_array(); - -} - -sub ReplaceParamsInSQL { - - my ( $sql, $params ) = @_; - - return unless $sql || $params; - return $sql unless $sql =~ m/<>/$value/g; - } - return $sql; - -} - -sub GetSignStreamsAttachedToSign { - - my ( $sign_id ) = @_; - - return unless $sign_id; - - my $query = 'SELECT s.*, sts.sign_to_stream_id, sts.params, sq.report_name, sq.savedsql - FROM sign_streams AS s, signs_to_streams AS sts, saved_sql AS sq - WHERE s.sign_stream_id = sts.sign_stream_id - AND s.saved_sql_id = sq.id - AND sts.sign_id = ? - ORDER BY s.name'; - my $sth = $dbh->prepare( $query ); - $sth->execute( $sign_id ); - return $sth->fetchall_arrayref({}); - -} - -sub GetSignStreamsAttachedToSignWithRecords { - - my ( $sign_id, $include_marc ) = @_; - - return unless $sign_id; - - my $streams = GetSignStreamsAttachedToSign( $sign_id ); - my @changedstreams; - my %record_cache = (); - - # Add records to the streams - foreach my $stream ( @{$streams} ) { - - my $records = RunSQL( ReplaceParamsInSQL( $stream->{'savedsql'}, $stream->{'params'} ) ); - - if ( $include_marc ) { - - my @processed_records; - foreach my $rec ( @{$records} ) { - unless(defined $record_cache{$rec->{'biblionumber'}}) { - my $marc = GetMarcBiblio( $rec->{'biblionumber'} ); - if ( ! $marc ) { - next; - } - - my $isbn = GetNormalizedISBN( undef, $marc, C4::Context->preference("marcflavor") ) || ''; - $rec->{'isbn'} = $isbn; +use Modern::Perl; - my $dat = GetBiblioData($rec->{'biblionumber'}); - my @items = GetItemsInfo($rec->{'biblionumber'}); - foreach my $item ( @items ) { - my $shelflocations = GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac'); - if ( defined $item->{'location'} ) { - $item->{'location_description'} = $shelflocations->{ $item->{'location'} }; - } - } - $rec->{'items'} = \@items; - foreach ( keys %{$dat} ) { - $rec->{"$_"} = defined $dat->{$_} ? $dat->{$_} : ''; - } +use Koha::Database; +use Koha::Sign; - $rec->{'marc'} = $marc; +use base qw( Koha::Objects ); - $record_cache{$rec->{'biblionumber'}} = $rec; - } - push @processed_records, $record_cache{$rec->{'biblionumber'}}; - } - $stream->{'records'} = \@processed_records; +=head1 NAME - } else { +Koha::Signs - Koha Sign object set class - $stream->{'records'} = $records; +=head1 API - } +=head2 Class Methods - push @changedstreams, $stream; +=cut - } +=head3 type - return \@changedstreams; +=cut +sub _type { + return 'Sign'; } -sub DetachSignStreamFromSign { - - my ( $sign_to_stream_id ) = @_; - - return unless $sign_to_stream_id; +=head3 object_class - my $sth = $dbh->prepare( 'DELETE FROM signs_to_streams WHERE sign_to_stream_id = ?' ); - return $sth->execute( $sign_to_stream_id ); +=cut +sub object_class { + return 'Koha::Sign'; } -sub RunSQL { +=head1 AUTHOR - my ( $query ) = @_; +Aleisha Amohia - return unless $query; - - my $sth = $dbh->prepare($query); - $sth->execute(); - return $sth->fetchall_arrayref({}); - -} +=cut 1; --- a/Koha/SignsToStream.pm +++ a/Koha/SignsToStream.pm @@ -0,0 +1,40 @@ +package Koha::SignsToStream; + +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Database; + +use base qw( Koha::Object ); + +=head1 NAME + +Koha::SignsToStream - SignsToStream object class + +=head1 API + +=head2 Class Methods + +=cut + +sub _type { + return 'SignsToStream'; +} + +1; --- a/Koha/SignsToStreams.pm +++ a/Koha/SignsToStreams.pm @@ -0,0 +1,59 @@ +package Koha::SignsToStreams; + +# Copyright 2016 Aleisha Amohia +# +# 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 3 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Koha::Database; +use Koha::SignsToStream; + +use base qw( Koha::Objects ); + +=head1 NAME + +Koha::SignsToStreams - Koha SignsToStream object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'SignsToStream'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::SignsToStream'; +} + +=head1 AUTHOR + +Aleisha Amohia + +=cut + +1; --- a/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql +++ a/installer/data/mysql/atomicupdate/bug_8628-digital-signs.sql @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS signs_to_streams; DROP TABLE IF EXISTS sign_streams; CREATE TABLE sign_streams ( sign_stream_id int(11) NOT NULL auto_increment, -- primary key, used to identify streams @@ -19,6 +18,7 @@ CREATE TABLE signs ( reloadafter int(11) NOT NULL default 0, -- seconds to wait before reloading all the pages PRIMARY KEY (sign_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS signs_to_streams; CREATE TABLE signs_to_streams ( sign_to_stream_id int(11) NOT NULL auto_increment, -- primary key, used to identify connections between signs and streams (the same stream can be attached to a sign more than once, with different parameters) sign_stream_id int(11) NOT NULL, -- foreign key from the decks sign_streams table --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -4099,6 +4099,51 @@ CREATE TABLE IF NOT EXISTS club_fields ( CONSTRAINT club_fields_ibfk_4 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +-- +-- Table structure for table 'sign_streams' +-- + +DROP TABLE IF EXISTS sign_streams; +CREATE TABLE sign_streams ( + `sign_stream_id` int(11) NOT NULL auto_increment, -- primary key, used to identify streams + `saved_sql_id` int(11) NOT NULL, -- foreign key from the saved_sql table + `name` varchar(64), -- name/title of the sign + PRIMARY KEY (`sign_stream_id`), + CONSTRAINT `sign_streams_ibfk_1` FOREIGN KEY (`saved_sql_id`) REFERENCES `saved_sql` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Table structure for table 'signs' +-- + +DROP TABLE IF EXISTS signs; +CREATE TABLE signs ( + `sign_id` int(11) NOT NULL auto_increment, -- primary key, used to identify signs + `name` varchar(64), -- name/title of the deck + `webapp` int(1) NOT NULL DEFAULT 0, -- display as web app or normal page + `transition` char(16) NOT NULL DEFAULT 'none', -- transition to use between pages, must be one of the transitions defined by jQuery Mobile (see their docs) + `swatch` char(1) NOT NULL DEFAULT '', -- swatches determine the colors of page elements + `idleafter` int(11) NOT NULL default 0, -- seconds to wait before automatic page turning clicks in + `pagedelay` int(11) NOT NULL default 0, -- seconds to wait before turning to a new page/record + `reloadafter` int(11) NOT NULL default 0, -- seconds to wait before reloading all the pages + PRIMARY KEY (`sign_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Table structure for table 'signs_to_streams' +-- + +DROP TABLE IF EXISTS signs_to_streams; +CREATE TABLE signs_to_streams ( + `sign_to_stream_id` int(11) NOT NULL auto_increment, -- primary key, used to identify connections between signs and streams (the same stream can be attached to a sign more than once, with different parameters) + `sign_stream_id` int(11) NOT NULL, -- foreign key from the decks sign_streams table + `sign_id` int(11) NOT NULL, -- foreign key from the signs table + `params` varchar(255) NOT NULL DEFAULT '', -- list of parameters for the SQL associated with the sign_stream + PRIMARY KEY (`sign_to_stream_id`), + CONSTRAINT `signs_to_streams_ibfk_1` FOREIGN KEY (`sign_stream_id`) REFERENCES `sign_streams` (`sign_stream_id`) ON DELETE CASCADE, + CONSTRAINT `signs_to_streams_ibfk_2` FOREIGN KEY (`sign_id`) REFERENCES `signs` (`sign_id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -119,6 +119,9 @@ [% IF ( CAN_user_tools_edit_quotes ) %]
  • Quote editor
  • [% END %] + [% IF ( CAN_user_tools_edit_digital_signs ) %] +
  • Digital signs
  • + [% END %] [% IF ( UseKohaPlugins && CAN_user_plugins_tool ) %]
  • Tool plugins
  • [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/signs.tt @@ -6,35 +6,25 @@ [% INCLUDE 'datatables.inc' %] @@ -80,26 +70,21 @@
    - -
    -
    -
    +
    +
    +
    [% UNLESS Koha.Preference( 'OPACDigitalSigns' ) %]
    -

    - Digital signs are not enabled. Please enable - OPACDigitalSigns - for OPAC digital signs to work. -

    +

    Digital signs are not enabled. Please enable OPACDigitalSigns for OPAC digital signs to work.

    [% END %] [% IF ( else ) %] [% END %] @@ -127,8 +112,8 @@
    1. -
    2. - [% UNLESS ( stream.sign_stream_id ) %] [% END %] @@ -140,6 +125,7 @@ [% END %] [% END %] + Required
    @@ -223,24 +209,28 @@

    Edit streams attached to [% sign.name %]

    Streams already attached to this sign

    - [% IF ( attached.size ) %] + [% IF ( sts ) %] - + + + + + - [% FOREACH s IN attached %] + [% FOREACH s IN sts %] - - - - + + + + [% END %]
    NameParametersEdit parametersDetach
    NameParameters 
    [% s.name %][% s.params %][% IF s.savedsql.match('<<') %]Edit parameters[% ELSE %]No parameters[% END %]Detach[% s.sign_stream.name %][% IF ( s.params ) %][% s.params %][% ELSE %]None[% END %][% IF ( s.params ) %][% ELSE %][% END %] Detach
    [% ELSE %] -

    There are no streams attached to this sign, yet.

    +

    There are no streams attached to this sign.

    [% END %]

    Attach a new stream to this sign

    @@ -264,7 +254,7 @@ [% ELSIF op == 'get_params' %]

    Parameters for [% stream.name %]

    -

    Based on report: [% stream.report_name %] | Edit this report

    +

    Based on report: [% sql.report_name %] | Edit this report

    @@ -272,14 +262,14 @@
    - [% IF ( params ) %] + [% IF ( params.params ) %] Edit parameters [% ELSE %] Add parameters [% END %]
    1. - +
    @@ -287,7 +277,7 @@

    Raw SQL

    -
    [% stream.savedsql | html %]
    +
    [% sql.savedsql | html %]

    SQL with current parameters replaced

    [% newsql | html %]
    @@ -305,10 +295,11 @@
    -
    + +
    - +
    @@ -328,10 +319,11 @@
    -
    + +
    - +
    @@ -351,7 +343,7 @@ [% IF ( streams ) %] [% FOREACH stream IN streams %] -

    [% stream.name %]

    +

    [% stream.sign_stream.name %]

      [% FOREACH record IN stream.records %]
    • [% record.title %]
    • @@ -365,12 +357,12 @@ [% ELSIF op == 'view_stream' %]

      [% stream.name %]

      -

      Based on report: [% stream.report_name %] | Edit this report

      +

      Based on report: [% stream.saved_sql_id.report_name %] | Edit this report

      SQL

      -
      [% stream.savedsql | html %]
      +
      [% stream.saved_sql_id.savedsql | html %]

      Records

      [% IF ( has_params ) %] -

      Sorry, the report this stream is based on has parameters and displaying it only makes sense after it has been attached to a sign and parameters have been added.

      +

      Unable to display records. Check that this stream has been attached to a sign and any parameters have been filled appropriately.

      [% ELSE %] [% INCLUDE display_records %] [% END %] @@ -379,8 +371,14 @@

      Digital signs

      + [% IF ( error_on_insert_stream ) %] +
      Failed to create a new stream.
      + [% ELSIF ( success_on_insert_stream ) %] +
      New stream added.
      + [% END %] + +

      Signs

      [% IF signs %] -

      Signs

      @@ -391,10 +389,7 @@ - - - - + @@ -407,43 +402,51 @@ - - - - + [% END %]
      Idle after Page delay Reload afterEditEdit streamsDeleteView sign 
      [% s.idleafter %] [% s.pagedelay %] [% s.reloadafter %]EditEdit streamsDelete[% IF ( OPACBaseURL ) %]View sign[% END %] + +
      [% UNLESS ( OPACBaseURL ) %]

      Please note: Links to view signs in the OPAC will only be displayed if you fill in the OPACBaseURL system preference.

      [% END %] [% ELSE %] -

      No signs defined!

      +
      No signs defined. Create a new sign.
      [% END %] +

      Streams

      [% IF streams %] -

      Streams

      - - + [% FOREACH s IN streams %] - - - + + [% END %]
      Name ReportEditDeleteActions
      [% s.name %][% s.report_name %]EditDelete[% FOREACH r IN reports %][% IF r.id == s.saved_sql_id %][% r.report_name %][% END %][% END %] + Edit + Delete +
      [% ELSE %] -

      No streams defined!

      +
      No streams defined. Create a new stream.
      [% END %] [% END %] --- a/opac/opac-signs.pl +++ a/opac/opac-signs.pl @@ -20,7 +20,15 @@ use CGI; use C4::Auth; use C4::Output; +use C4::Biblio; +use C4::Reports::Guided; +use C4::Context; +use C4::Koha; +use C4::Items; +use Koha::AuthorisedValues; use Koha::Signs; +use Koha::SignStreams; +use Koha::SignsToStreams; use Modern::Perl; binmode STDOUT, ':encoding(UTF-8)'; # FIXME Non-ASCII is broken without this @@ -38,11 +46,65 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user({ if ( C4::Context->preference('OPACDigitalSigns') ) { if ( $sign_id ne '' ) { # Display a sign with streams - $template->{VARS}->{'sign'} = GetSign( $sign_id ); - $template->{VARS}->{'streams'} = GetSignStreamsAttachedToSignWithRecords( $sign_id, 1 ); - } - else { # Display a list of all available signs - $template->{VARS}->{'signs'} = GetSigns(); + $template->{VARS}->{'sign'} = Koha::Signs->find( $sign_id ); + + # Getting sign streams attached to sign with records + my $schema = Koha::Database->new()->schema(); + my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); + my @changedstreams; + my %record_cache = (); + foreach my $s ( @signstostreams ) { + my $stream = Koha::SignStreams->find( $s->sign_stream_id ); + my $sql = get_saved_report($stream->saved_sql_id); + my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $s->sign_to_stream_id }); + + # Generate SQL with added params + my $newsql = $sql->{'savedsql'}; + foreach my $param ( split /&/, $params->params ) { + my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself + $newsql =~ s/$key/$value/g; + } + + # Run query with new sql + my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); + if ( ! $error ) { + $records = $records->fetchall_arrayref({}); + } + # Include marc + my @processed_records; + foreach my $rec ( @{$records} ) { + unless (defined $record_cache{$rec->{'biblionumber'}}) { + my $marc = GetMarcBiblio( $rec->{'biblionumber'} ); + if ( ! $marc ) { + next; + } + + my $isbn = GetNormalizedISBN( undef, $marc, C4::Context->preference("marcflavor") ) || ''; + $rec->{'isbn'} = $isbn; + + my $dat = GetBiblioData($rec->{'biblionumber'}); + my @items = GetItemsInfo($rec->{'biblionumber'}); + foreach my $item ( @items ) { + my $shelflocations = { map { $_->authorised_value => $_->opac_description } Koha::AuthorisedValues->search_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) }; + if ( defined $item->{'location'} ) { + $item->{'location_description'} = $shelflocations->{ $item->{'location'} }; + } + } + $rec->{'items'} = \@items; + foreach ( keys %{$dat} ) { + $rec->{"$_"} = defined $dat->{$_} ? $dat->{$_} : ''; + } + $rec->{'marc'} = $marc; + $record_cache{$rec->{'biblionumber'}} = $rec; + } + push @processed_records, $record_cache{$rec->{'biblionumber'}}; + } + $s->{'records'} = \@processed_records; + push @changedstreams, $s; + } + $template->{VARS}->{'streams'} = \@changedstreams; + } else { # Display a list of all available signs + $template->{VARS}->{'signs'} = Koha::Signs->search({}); } } --- a/tools/signs.pl +++ a/tools/signs.pl @@ -16,9 +16,6 @@ # You should have received a copy of the GNU General Public License along # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# -# =head1 NAME @@ -34,7 +31,12 @@ Allows authorized users to create and manage digital signs for the OPAC. =cut +use Koha::Sign; use Koha::Signs; +use Koha::SignStream; +use Koha::SignStreams; +use Koha::SignsToStreams; + use CGI; use C4::Auth; use C4::Context; @@ -73,7 +75,7 @@ if ( $op eq 'add_stream' ) { } elsif ( $op eq 'edit_stream' && $sign_stream_id ne '') { - my $stream = GetSignStream( $sign_stream_id ); + my $stream = Koha::SignStreams->find( $sign_stream_id ); $template->param( 'op' => 'stream_form', @@ -84,22 +86,25 @@ if ( $op eq 'add_stream' ) { } elsif ( $op eq 'save_stream' ) { + my $name = $cgi->param('name'); + my $report = $cgi->param('report'); if ( $sign_stream_id ne '' ) { - ModSignStream( $cgi->param('name'), $cgi->param('report'), $cgi->param('sign_stream_id') ); + Koha::SignStreams->find( $sign_stream_id )->set({ name => $name, saved_sql_id => $report })->store; # modify } else { - AddSignStream( $cgi->param('name'), $cgi->param('report'), ); + Koha::SignStream->new({ name => $name, saved_sql_id => $report })->store; # add new } print $cgi->redirect($script_name); } elsif ( $op eq 'view_stream' && $sign_stream_id ne '' ) { - - my $stream = GetSignStream( $sign_stream_id ); - - if ( $stream->{'savedsql'} =~ m/<param( 'has_params' => 1 ); + my $stream = Koha::SignStreams->find( $sign_stream_id ); + my $report = get_saved_report($stream->saved_sql_id); + my $sql = $report->{'savedsql'}; + my ( $records, $error ) = execute_query( $sql, 0, 999999 ); + if ( $records && not $error ) { + $records = $records->fetchall_arrayref({}); + $template->param( 'records' => $records ); } else { - my $records = GetSignStreamRecords( $stream ); - $template->param( 'records' => $records->{result} ); + $template->param( 'has_params' => 1 ); } $template->param( @@ -110,7 +115,7 @@ if ( $op eq 'add_stream' ) { } elsif ( $op eq 'del_stream' ) { - my $stream = GetSignStream( $sign_stream_id ); + my $stream = Koha::SignStreams->find( $sign_stream_id ); $template->param( 'op' => 'del_stream', @@ -119,8 +124,7 @@ if ( $op eq 'add_stream' ) { ); } elsif ( $op eq 'del_stream_ok' ) { - - DelSignStream( $sign_stream_id ); + Koha::SignStreams->find( $sign_stream_id )->delete; $template->param( 'op' => 'del_stream_ok', @@ -139,25 +143,48 @@ if ( $op eq 'add_stream' ) { $template->param( 'op' => 'sign_form', - 'sign' => GetSign( $sign_id ), + 'sign' => Koha::Signs->find( $sign_id ), 'script_name' => $script_name, ); } elsif ( $op eq 'save_sign' ) { if ($cgi->param('sign_id')) { - ModSign( $cgi->param('name'), $cgi->param('webapp'), $cgi->param('swatch'), $cgi->param('transition'), $cgi->param('idleafter'), $cgi->param('pagedelay'), $cgi->param('reloadafter'), $cgi->param('sign_id') ); + Koha::Signs->find( $cgi->param('sign_id') )->set({ name => $cgi->param('name'), webapp => $cgi->param('webapp'), swatch => $cgi->param('swatch'), transition => $cgi->param('transition'), idleafter => $cgi->param('idleafter'), pagedelay => $cgi->param('pagedelay'), reloadafter => $cgi->param('reloadafter') })->store; # modify } else { - AddSign( $cgi->param('name'), $cgi->param('webapp'), $cgi->param('swatch'), $cgi->param('transition'), $cgi->param('idleafter'), $cgi->param('pagedelay'), $cgi->param('reloadafter') ); + Koha::Sign->new({ name => $cgi->param('name'), webapp => $cgi->param('webapp'), swatch => $cgi->param('swatch'), transition => $cgi->param('transition'), idleafter => $cgi->param('idleafter'), pagedelay => $cgi->param('pagedelay'), reloadafter => $cgi->param('reloadafter') })->store; # add new } print $cgi->redirect($script_name); } elsif ( $op eq 'view_sign' && $sign_id ne '' ) { + # Getting sign streams attached to sign with records + my $schema = Koha::Database->new()->schema(); + my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); + my @changedstreams; + + foreach my $s ( @signstostreams ) { + my $stream = Koha::SignStreams->find( $s->sign_stream_id ); + my $sql = get_saved_report($stream->saved_sql_id); + my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $s->sign_to_stream_id }); + # Generate SQL with added params + my $newsql = $sql->{'savedsql'}; + foreach my $param ( split /&/, $params->params ) { + my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself + $newsql =~ s/$key/$value/g; + } + # Run query with new sql + my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); + if ( $records && not $error ) { + $s->{'records'} = $records->fetchall_arrayref({}); + push @changedstreams, $s; + } + } + $template->param( 'op' => 'view_sign', - 'sign' => GetSign( $sign_id ), - 'streams' => GetSignStreamsAttachedToSignWithRecords( $sign_id, 0 ), + 'sign' => Koha::Signs->find( $sign_id ), + 'streams' => \@changedstreams, 'script_name' => $script_name, ); @@ -165,13 +192,13 @@ if ( $op eq 'add_stream' ) { $template->param( 'op' => 'del_sign', - 'sign' => GetSign( $sign_id ), + 'sign' => Koha::Signs->find( $sign_id ), 'script_name' => $script_name, ); } elsif ( $op eq 'del_sign_ok' ) { - DelSign( $sign_id ); + Koha::Signs->find( $sign_id )->delete; $template->param( 'op' => 'del_sign_ok', @@ -182,22 +209,29 @@ if ( $op eq 'add_stream' ) { } elsif ( $op eq 'edit_streams' && $sign_id ne '') { + my $sign = Koha::Signs->find( $sign_id ); + my $streams = Koha::SignStreams->search({}); + + my $schema = Koha::Database->new()->schema(); + my @signstostreams = $schema->resultset('SignsToStream')->search({ 'me.sign_id' => $sign_id }, { prefetch => 'sign_stream' }); + $template->param( 'op' => 'edit_streams', - 'sign' => GetSign( $sign_id ), + 'sign' => $sign, 'sign_id' => $sign_id, - 'streams' => GetSignStreams(), - 'attached' => GetSignStreamsAttachedToSign( $sign_id ), + 'streams' => $streams, + 'sts' => \@signstostreams, 'script_name' => $script_name ); } elsif ( $op eq 'attach_stream_to_sign' && $sign_stream_id ne '' && $sign_id ne '' ) { - my $sign_to_stream_id = AttachSignStreamToSign( $sign_stream_id, $sign_id ); + Koha::SignsToStream->new({ sign_stream_id => $sign_stream_id, sign_id => $sign_id })->store; # Check if the SQL associated with the stream needs parameters - my $stream = GetSignStream( $sign_stream_id ); - if ( $stream->{'savedsql'} =~ m/<find( $sign_stream_id ); + my $sql = get_saved_report($stream->saved_sql_id); + if ( $sql->{'savedsql'} =~ m/WHERE/ ) { print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id ); } else { print $cgi->redirect( $script_name . '?op=edit_streams&sign_id=' . $sign_id ); @@ -205,10 +239,19 @@ if ( $op eq 'add_stream' ) { } elsif ( $op eq 'get_params' && $sign_to_stream_id ne '' && $sign_stream_id ne '' && $sign_id ne '' ) { - my $stream = GetSignStream( $sign_stream_id ); - my $records = GetSignStreamRecords($stream, $sign_to_stream_id); - if ( $records ) { - $template->param( 'records' => $records->{result} ); + my $stream = Koha::SignStreams->find( $sign_stream_id ); + my $sql = get_saved_report($stream->saved_sql_id); + my $params = Koha::SignsToStreams->find({ sign_to_stream_id => $sign_to_stream_id }); + # Generate SQL with added params + my $newsql = $sql->{'savedsql'}; + foreach my $param ( split /&/, $params->params ) { + my ( $key, $value ) = split /=|<|>/, $param; # The < and > in the split are just to prevent software errors, the sign in the query must be changed in the report itself + $newsql =~ s/$key/$value/g; + } + # Run query with new sql + my ( $records, $error ) = execute_query( $newsql, 0, 999999 ); + if ( $records && not $error) { + $template->param( 'records' => $records->fetchall_arrayref({}) ); } else { $template->param( 'has_params' => 1 ); } @@ -219,28 +262,31 @@ if ( $op eq 'add_stream' ) { 'sign_id' => $sign_id, 'sign_stream_id' => $sign_stream_id, 'sign_to_stream_id' => $sign_to_stream_id, - 'params' => GetSignStreamParams( $sign_to_stream_id ), - 'newsql' => $records->{sql}, + 'params' => $params, + 'sql' => $sql, + 'newsql' => $newsql, 'script_name' => $script_name, ); } elsif ( $op eq 'save_params' && $sign_to_stream_id ne '' && $sign_id ne '' ) { - ModSignStreamParams( $sign_to_stream_id, $parameters ); + Koha::SignsToStreams->find( $sign_to_stream_id )->set({ params => $parameters })->store; print $cgi->redirect( $script_name . '?op=get_params&sign_to_stream_id=' . $sign_to_stream_id . '&sign_stream_id=' . $sign_stream_id . '&sign_id=' . $sign_id ); } elsif ( $op eq 'detach_stream_from_sign' && $sign_to_stream_id ne '' ) { - DetachSignStreamFromSign( $sign_to_stream_id ); + Koha::SignsToStreams->find( $sign_to_stream_id )->delete; print $cgi->redirect($script_name . '?op=edit_streams&sign_id=' . $sign_id); } else { - # TODO Check the setting of OPACDigitalSigns, give a warning if it is off + my $streams = Koha::SignStreams->search({}); + my $signs = Koha::Signs->search({}); $template->param( - 'streams' => GetSignStreams(), - 'signs' => GetSigns(), + 'streams' => $streams, + 'signs' => $signs, + 'reports' => get_saved_reports( { group => 'SIG' } ), 'OPACBaseURL' => C4::Context->preference( 'OPACBaseURL' ) || '', 'else' => 1 ); --