From payal.mangyani3 at gmail.com Fri Jul 1 09:37:43 2016 From: payal.mangyani3 at gmail.com (Payal Mangyani) Date: Fri, 1 Jul 2016 13:07:43 +0530 Subject: [Koha-patches] regarding authentication Message-ID: Hello, I am new to perl as well as to koha and I want to modify Koha's code for authentication such that if a user with user name let say admin is logged in and meanwhile someone else wants to login with the same user name that is admin but with different ip address then the koha should restrict this activity. If user logged in has the following details - username-admin ip-192.168.1.129 and if another user try to login with the following - username-admin ip-192.168.1.130 Then that user should not be able to logged in. I have been reading the Auth.pm file, it has code regarding authentication and I am unable to find that where the user is allowed to login after successful authentication as I want to put my code at that place. -------------- next part -------------- An HTML attachment was scrubbed... URL: From srdjan at catalyst.net.nz Mon Jul 4 07:16:58 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 4 Jul 2016 17:16:58 +1200 Subject: [Koha-patches] [PATCH] Bug 15419 SIP: call auth() subs with timeout, and refresh dbh if need be Message-ID: <1467609418-25134-1-git-send-email-srdjan@catalyst.net.nz> --- C4/SIP/ILS/Patron.pm | 11 +++++++++-- C4/SIP/Sip/MsgType.pm | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index 93b6c54..c3d348d 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -14,6 +14,7 @@ use Carp; use Sys::Syslog qw(syslog); use Data::Dumper; +use Time::Out qw(timeout); use C4::Debug; use C4::Context; @@ -199,9 +200,15 @@ sub check_password { # If the record has a NULL password, accept '' as match return $pwd eq q{} unless $self->{password}; - my $dbh = C4::Context->dbh; my $ret = 0; - ($ret) = checkpw( $dbh, $self->{userid}, $pwd, undef, undef, 1 ); # dbh, userid, query, type, no_set_userenv + local $@; + ($ret) = timeout (5 => sub { + # dbh, userid, query, type, no_set_userenv + checkpw( C4::Context->dbh, $self->{userid}, $pwd, undef, undef, 1 ); + }); + if ($@) { + ($ret) = checkpw( C4::Context->new_dbh, $self->{userid}, $pwd, undef, undef, 1 ); + } return $ret; } diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 787449b..e8a4669 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -10,6 +10,7 @@ use strict; use warnings; use Exporter; use Sys::Syslog qw(syslog); +use Time::Out qw(timeout); use C4::SIP::Sip qw(:all); use C4::SIP::Sip::Constants qw(:all); @@ -1607,7 +1608,15 @@ sub api_auth { if ($branch) { $query->param( branch => $branch ); } - my ( $status, $cookie, $sessionID ) = check_api_auth( $query, { circulate => 1 }, 'intranet' ); + + local $@; + my ( $status, $cookie, $sessionID ) = timeout (5 => sub { + check_api_auth( $query, { circulate => 1 }, 'intranet' ); + }); + if ($@) { + C4::Context->new_dbh; + ( $status, $cookie, $sessionID ) = check_api_auth( $query, { circulate => 1 }, 'intranet' ); + } return $status; } -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 6 04:41:21 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 6 Jul 2016 14:41:21 +1200 Subject: [Koha-patches] [PATCH] Bug 16664: fix loaded SQL for strictness Message-ID: <1467772881-19749-1-git-send-email-srdjan@catalyst.net.nz> From: Robin Sheat There were some errors in the SQL structure that MySQL got upset at in strict mode. This lets the file load. Signed-off-by: Srdjan --- installer/data/mysql/kohastructure.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4612a17..867b74e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -69,7 +69,7 @@ CREATE TABLE `auth_subfield_structure` ( `linkid` tinyint(1) NOT NULL default 0, `kohafield` varchar(45) NULL default '', `frameworkcode` varchar(10) NOT NULL default '', - `defaultvalue` TEXT DEFAULT '', + `defaultvalue` TEXT, PRIMARY KEY (`authtypecode`,`tagfield`,`tagsubfield`), KEY `tab` (`authtypecode`,`tab`), CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE @@ -2211,7 +2211,7 @@ CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) `category` varchar(1) default NULL, -- type of list (private [1], public [2]) `sortfield` varchar(16) default 'title', -- the field this list is sorted on `lastmodified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- date and time the list was last modified - `created_on` TIMESTAMP NOT NULL, -- creation time + `created_on` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- creation time `allow_add` tinyint(1) default 0, -- permission for adding entries to list `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 6 04:51:39 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 6 Jul 2016 14:51:39 +1200 Subject: [Koha-patches] [PATCH] Bug 16848: Prevent invalid warning to be carped from output_pref Message-ID: <1467773499-23826-1-git-send-email-srdjan@catalyst.net.nz> From: Jonathan Druart >From Koha::DateUtils::output_pref: $dt = eval { dt_from_string( $str ) } if $str; carp "Invalid date '$str' passed to output_pref\n" if $@; This second line is wrong: if $str does not exist, the first line is not evaluated and $@ could be filled with previous error. To reproduce: Then: prove t/DateUtils.t will display: t/DateUtils.t .. 20/60 Use of uninitialized value $str in concatenation (.) or string at Koha/DateUtils.pm line 217. Invalid date '' passed to output_pref at t/DateUtils.t line 233. t/DateUtils.t .. ok All tests successful. Files=1, Tests=60, 2 wallclock secs ( 0.02 usr 0.00 sys + 1.40 cusr 0.00 csys = 1.42 CPU) Result: PASS Test plan: Without this patch, you should not see the carp Signed-off-by: Srdjan --- Koha/DateUtils.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 6207cc1..51d3d93 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -213,8 +213,11 @@ sub output_pref { and return if $dt and $str; - $dt = eval { dt_from_string( $str ) } if $str; - carp "Invalid date '$str' passed to output_pref\n" if $@; + if ( $str ) { + local $@; + $dt = eval { dt_from_string( $str ) }; + carp "Invalid date '$str' passed to output_pref\n" if $@; + } return unless defined $dt; -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 6 06:11:00 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 6 Jul 2016 16:11:00 +1200 Subject: [Koha-patches] [PATCH] Bug 16855 - Poor performance due to high overhead of SQL call in export.pl Message-ID: <1467778260-18114-1-git-send-email-srdjan@catalyst.net.nz> From: Nick Clemens This patch eliminates all columns retrieved in the biblioitems query except for biblionumber. To test: 1 - Go to tools->Export data 2 - Export using various filters and note you get expected records 3 - Apply patch 4 - Ensure exported results match results before patch Signed-off-by: Srdjan --- tools/export.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/export.pl b/tools/export.pl index 4794d05..373ebfa 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -148,7 +148,7 @@ if ( $op eq "export" ) { ), }; - my $biblioitems = Koha::Biblioitems->search( $conditions, { join => 'items' } ); + my $biblioitems = Koha::Biblioitems->search( $conditions, { join => 'items', columns => 'biblionumber' } ); while ( my $biblioitem = $biblioitems->next ) { push @record_ids, $biblioitem->biblionumber; } -- 2.7.4 From srdjan at catalyst.net.nz Thu Jul 7 05:00:57 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Thu, 7 Jul 2016 15:00:57 +1200 Subject: [Koha-patches] [PATCH] Bug 16859: Fix wrong item field name in export.pl Message-ID: <1467860457-1824-1-git-send-email-srdjan@catalyst.net.nz> From: Marcel de Rooy Field callnumber should be itemcallnumber. For completeness, prefixing the joined fields with items table prefix. Note: You should expect Tools/Export to export only the items within a given itemcallnumber range, but if the biblio has one item in that range, the biblionumber is selected for export with ALL items. The script is designed that way (first select biblio numbers based on criteria, and run export with those biblio numbers). Test plan: [1] Select a biblio N with one item with say itemcallnumber X. [2] Goto Tools/Export. Select biblio range N,N and no itemcallnumber range. The biblio should be exported. [3] Select biblio range N,N and itemcallnumber range A,B. No output. [4] Select biblio range N,N and itemcallnumber range A,. Output. [5] Select biblio range N,N and itemcallnumber range ,X. Output. Signed-off-by: Srdjan --- tools/export.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/export.pl b/tools/export.pl index 4794d05..32077e6 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -122,17 +122,19 @@ if ( $op eq "export" ) { } ) : (), + ( $start_callnumber or $end_callnumber ) ? ( - callnumber => { + 'items.itemcallnumber' => { ( $start_callnumber ? ( '>=' => $start_callnumber ) : () ), ( $end_callnumber ? ( '<=' => $end_callnumber ) : () ), } ) : (), + ( $start_accession or $end_accession ) ? ( - dateaccessioned => { + 'items.dateaccessioned' => { ( $start_accession ? ( '>=' => $start_accession ) : () ), ( $end_accession ? ( '<=' => $end_accession ) : () ), } -- 2.7.4 From srdjan at catalyst.net.nz Thu Jul 7 05:19:17 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Thu, 7 Jul 2016 15:19:17 +1200 Subject: [Koha-patches] [PATCH] Bug 15636 - DataTables Warning: Requested unknown parameter from opac-detail.tt Message-ID: <1467861557-7880-1-git-send-email-srdjan@catalyst.net.nz> From: Bouzid Fergani Signed-off-by: Srdjan --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 10619b0..3440af7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1428,8 +1428,10 @@ $(".holdingst").dataTable($.extend(true, {}, dataTablesDefaults, { "aoColumns": [ [% IF ( item_level_itypes ) %]null,[% END %] - null, - [% IF ( OpacLocationBranchToDisplay == 'both' ) %]null,[% END %] + [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' || singleBranchMode ) %]null,[% END %] + [% UNLESS ( singleBranchMode ) %] + [% IF ( OpacLocationBranchToDisplay == 'home' || OpacLocationBranchToDisplay == 'both' ) %]null,[% END %] + [% END %] [% IF ( itemdata_ccode ) %]null,[% END %] null, [% IF ( itemdata_enumchron ) %]null,[% END %] -- 2.7.4 From srdjan at catalyst.net.nz Thu Jul 7 05:27:40 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Thu, 7 Jul 2016 15:27:40 +1200 Subject: [Koha-patches] [PATCH] Bug 16857 - patron-attr-types.tt: Get rid of warnings "Argument "" isn't numeric" Message-ID: <1467862060-10746-1-git-send-email-srdjan@catalyst.net.nz> From: Marc V?ron To vrify: - Go to Home > Administration > Patron attribute types - Make sure you have some patron attribute types with no branches limitation - For each attribute type you get a warning in intranet-error.log: patron-attr-types.pl: Argument "" isn't numeric in numeric gt (>) at (...)/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt line 284. To test: - Appy patch - Verify that warnings no longer appear in intranet-error.log Signed-off-by: Srdjan --- koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index 3ee2fc5..580f38d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -267,7 +267,7 @@ $(document).ready(function() { [% item.code |html %] [% item.description %] - [% IF item.branches.size > 0 %] + [% IF ( item.branches.size && item.branches.size > 0 ) %] [% branches_str = "" %] [% FOREACH branch IN item.branches %] [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %] -- 2.7.4 From srdjan at catalyst.net.nz Thu Jul 7 05:33:02 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Thu, 7 Jul 2016 15:33:02 +1200 Subject: [Koha-patches] [PATCH] Bug 16823 - Comment out koha-rebuild-zebra in koha-common.cron.d Message-ID: <1467862382-12644-1-git-send-email-srdjan@catalyst.net.nz> From: Magnus Enger Bug 16190 enabled the indexer daemon by default for package installations. This means that it is no longer necessary to set up koha-rebuild-zebra as a cron job. This patch comments it out, so that people who might run into bug 16814 can easily activate the cronjob again after de-activating the indexer daemon. To test: Just read the diff and check that it makes sense. Signed-off-by: Srdjan --- debian/koha-common.cron.d | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/koha-common.cron.d b/debian/koha-common.cron.d index 96ff1b2..149fc47 100644 --- a/debian/koha-common.cron.d +++ b/debian/koha-common.cron.d @@ -6,6 +6,7 @@ SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -# Comment the following line if you want to use the experimental koha-index-daemon integration -*/5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled) +# Uncomment the following line if you do not want to use the koha-index-daemon integration +# */5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra -q $(koha-list --enabled) + */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl -- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 8 04:18:45 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 8 Jul 2016 14:18:45 +1200 Subject: [Koha-patches] [PATCH] Bug 16682: Fix display if Batch patron modification tool does not get any patrons Message-ID: <1467944325-31048-1-git-send-email-srdjan@catalyst.net.nz> From: Marc V?ron To reproduce: - Go to Tools->Batch patron modification - Submit without filling any of "Use a file", "Or use a patron list", "Or list card numbers..." or use a patron lists with zero members Result: Screen without any information To test: - Apply patch - Repeat steps above - Verify that you get a nice message - Verify that the tool works as before - with invalid card numbers only - with valid and invalid card numbers - with valid card numbers only Signed-off-by: Srdjan --- koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index 8d50d70..fd79986 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -172,6 +172,12 @@ [% END %] + [% IF ( op == 'show') && (!borrowers) && (!notfoundcardnumbers) # Alert if no patrons given%] + [% op = 'noshow' # Change op to prevent display in code below %] +

Batch patrons modification

+
No patron card numbers given. Back
+ [% END #Alert if no patrons %] + [% IF ( op == 'show' or op == 'show_results' ) %] [% IF ( op == 'show' ) %]

Batch patrons modification

-- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 8 04:51:08 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 8 Jul 2016 14:51:08 +1200 Subject: [Koha-patches] [PATCH] Bug 16877: Redo GetBorrowercategoryList() to use Koha::Patron::Categories->search() Message-ID: <1467946268-7975-1-git-send-email-srdjan@catalyst.net.nz> --- C4/Members.pm | 27 +++++++++++++-------------- t/db_dependent/Members.t | 6 +++++- tools/modborrowers.pl | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 383799d..68f5f77 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -42,6 +42,7 @@ use Text::Unaccent qw( unac_string ); use Koha::AuthUtils qw(hash_password); use Koha::Database; use Koha::List::Patron; +use Koha::Patron::Categories; our (@ISA, at EXPORT, at EXPORT_OK,$debug); @@ -1510,22 +1511,20 @@ If no category code provided, the function returns all the categories. =cut sub GetBorrowercategoryList { - my $no_branch_limit = @_ ? shift : 0; + my ($no_branch_limit) = @_; + my $branch_limit = $no_branch_limit ? 0 - : C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; - my $dbh = C4::Context->dbh; - my $query = "SELECT categories.* FROM categories"; - $query .= qq{ - LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode - WHERE branchcode = ? OR branchcode IS NULL GROUP BY description - } if $branch_limit; - $query .= " ORDER BY description"; - my $sth = $dbh->prepare( $query ); - $sth->execute( $branch_limit ? $branch_limit : () ); - my $data = $sth->fetchall_arrayref( {} ); - $sth->finish; - return $data; + : C4::Context->userenv && C4::Context->userenv->{"branch"}; + + + my %cond; + my %clause = (distinct => 1, order_by => 'description'); + if ($branch_limit) { + $clause{join} = 'categories_branches'; + $cond{'categories_branches.branchcode'} = [undef, $branch_limit]; + } + return Koha::Patron::Categories->search(\%cond, \%clause)->unblessed; } # sub getborrowercategory =head2 GetAge diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index 797e9bc..21ee209 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 77; +use Test::More tests => 78; use Test::MockModule; use Data::Dumper; use C4::Context; @@ -77,6 +77,10 @@ C4::Context->set_userenv ( @USERENV ); my $userenv = C4::Context->userenv or BAIL_OUT("No userenv"); +# XXX maybe needs a real test +my $categories = GetBorrowercategoryList(); +ok(scalar( @$categories ), "GetBorrowercategoryList()"); + # Make a borrower for testing my %data = ( cardnumber => $CARDNUMBER, diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index c776406..8b6297b 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -104,7 +104,7 @@ if ( $op eq 'show' ) { my @patron_attributes_values; my @patron_attributes_codes; my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all'); - my $patron_categories = C4::Members::GetBorrowercategoryList; + my $patron_categories = C4::Members::GetBorrowercategoryList(); for ( values %$patron_attribute_types ) { my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} ); # TODO Repeatable attributes are not correctly managed and can cause data lost. -- 2.7.4 From srdjan at catalyst.net.nz Tue Jul 12 04:43:51 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Tue, 12 Jul 2016 14:43:51 +1200 Subject: [Koha-patches] [PATCH] Bug 16890: Make TestBuilder generate date for date columns (and not datetime) Message-ID: <1468291431-627-1-git-send-email-srdjan@catalyst.net.nz> From: Jonathan Druart TestBuilder should not generate datetime for date columns, but only for datetime and timestamp columns. Test plan: Make sure the change in t/db_dependent/TestBuilder.t are consistent. Before this patch, 1 of the 2 tests should fail. After this patch applied, they both should pass. Signed-off-by: Srdjan --- t/db_dependent/TestBuilder.t | 13 ++++++++++++- t/lib/TestBuilder.pm | 9 +++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t index 569b6b4..3046ad8 100644 --- a/t/db_dependent/TestBuilder.t +++ b/t/db_dependent/TestBuilder.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Warn; use Data::Dumper qw(Dumper); @@ -321,6 +321,17 @@ subtest 'Auto-increment values tests' => sub { 'Build should not overwrite an auto_incr column'; }; +subtest 'Date handling' => sub { + plan tests => 2; + + $builder = t::lib::TestBuilder->new; + + my $patron = $builder->build( { source => 'Borrower' } ); + is( length( $patron->{updated_on} ), 19, 'A timestamp column value should be YYYY-MM-DD HH:MM:SS' ); + is( length( $patron->{dateofbirth} ), 10, 'A date column value should be YYYY-MM-DD' ); + +}; + $schema->storage->txn_rollback; 1; diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index ed28458..666cc87 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -325,8 +325,8 @@ sub _gen_type { decimal => \&_gen_real, double_precision => \&_gen_real, - timestamp => \&_gen_date, - datetime => \&_gen_date, + timestamp => \&_gen_datetime, + datetime => \&_gen_datetime, date => \&_gen_date, char => \&_gen_text, @@ -380,6 +380,11 @@ sub _gen_real { sub _gen_date { my ($self, $params) = @_; + return $self->schema->storage->datetime_parser->format_date(DateTime->now()) +} + +sub _gen_datetime { + my ($self, $params) = @_; return $self->schema->storage->datetime_parser->format_datetime(DateTime->now()); } -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 02:55:41 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 12:55:41 +1200 Subject: [Koha-patches] [PATCH] Bug 15006 Drop raw connection if login fails Message-ID: <1468371341-32601-1-git-send-email-srdjan@catalyst.net.nz> From: Colin Campbell raw_connection was not behaving correctly if an invalid string was passed or a login failed. It was not checking that the login succeeded ( it checked that account existed not that it contained data and it existed even if login failed) and so failed logins instead of aborting immediately fell through into the sip_protocol_loop, forcing that to timeout invalid connections. It now checks that account has id set and returns if not. The timeout alarm is now set on the while loop, in normal running this should not be triggered as the socket is opened and the first data should be a login message and the while loop should only iterate once, but lets not go into an infinite loop due to unforeseen circumstances. I have reindented the routine as the flow was not clear (the while was not indented at all. Also if using Net::Server::PreFork when a new connection comes in you may be handed the the successful login parameters from a preceding call. Because of this you could successfully transmit transactions and Koha would carry them out without having received a valid login ( and possibly with the wrong account details!) We now delete any existing account for new connections. NB: This patch requires that the patch for bug 13807 has been applied Signed-off-by: Srdjan --- C4/SIP/SIPServer.pm | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index d556845..b3f67d4 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -124,25 +124,38 @@ sub process_request { sub raw_transport { my $self = shift; - my ($input); + my $input; my $service = $self->{service}; + # If using Net::Server::PreFork you may already have account set from a previous session + # Ensure you dont + if ($self->{account}) { + delete $self->{account}; + } + # Timeout the while loop if we get stuck in it + # In practice it should only iterate once but be prepared + local $SIG{ALRM} = sub { die 'raw transport Timed Out!' } + syslog('LOG_DEBUG', "raw_transport: timeout is $service->{timeout}"); + alarm $service->{timeout}; while (!$self->{account}) { - local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; - syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); - $input = read_request(); - if (!$input) { - # EOF on the socket - syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); - return; - } - $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) - last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); + $input = read_request(); + if (!$input) { + # EOF on the socket + syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); + return; + } + $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) + last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); } + alarm 0; syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", - $self->{account}->{id}, - $self->{account}->{institution}); + $self->{account}->{id}, + $self->{account}->{institution}); + if (! $self->{account}->{id}) { + syslog("LOG_ERR","Login failed shutting down"); + return; + } $self->sip_protocol_loop(); syslog("LOG_INFO", "raw_transport: shutting down"); -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 02:56:24 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 12:56:24 +1200 Subject: [Koha-patches] [PATCH] Bug 15006 Remove tabs from sip_protocol_loop Message-ID: <1468371384-407-1-git-send-email-srdjan@catalyst.net.nz> From: Colin Campbell Remove the tabs causing inconsistent indentation of sip_protocol_loop and replace with spaces Reimplements the renaining parts of Marcel de Rooy's original QA patch No logic changes in this patch - layout only Signed-off-by: Srdjan --- C4/SIP/SIPServer.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index b3f67d4..0a76ca8 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -134,7 +134,7 @@ sub raw_transport { # Timeout the while loop if we get stuck in it # In practice it should only iterate once but be prepared - local $SIG{ALRM} = sub { die 'raw transport Timed Out!' } + local $SIG{ALRM} = sub { die 'raw transport Timed Out!' }; syslog('LOG_DEBUG', "raw_transport: timeout is $service->{timeout}"); alarm $service->{timeout}; while (!$self->{account}) { @@ -253,14 +253,14 @@ sub telnet_transport { # telnet transport. From that point on, both the raw and the telnet # processes are the same: sub sip_protocol_loop { - my $self = shift; - my $service = $self->{service}; - my $config = $self->{config}; + my $self = shift; + my $service = $self->{service}; + my $config = $self->{config}; my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; # The spec says the first message will be: - # SIP v1: SC_STATUS - # SIP v2: LOGIN (or SC_STATUS via telnet?) + # SIP v1: SC_STATUS + # SIP v2: LOGIN (or SC_STATUS via telnet?) # But it might be SC_REQUEST_RESEND. As long as we get # SC_REQUEST_RESEND, we keep waiting. @@ -268,9 +268,9 @@ sub sip_protocol_loop { # constraint, so we'll relax about it too. # Using the SIP "raw" login process, rather than telnet, # requires the LOGIN message and forces SIP 2.00. In that - # case, the LOGIN message has already been processed (above). - # - # In short, we'll take any valid message here. + # case, the LOGIN message has already been processed (above). + + # In short, we'll take any valid message here. eval { local $SIG{ALRM} = sub { syslog( 'LOG_DEBUG', 'Inactive: timed out' ); -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 02:57:04 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 12:57:04 +1200 Subject: [Koha-patches] [PATCH] Bug 15006: Introduce client_timeout in SIPconfig.xml Message-ID: <1468371424-695-1-git-send-email-srdjan@catalyst.net.nz> From: Colin Campbell Most selfchecks have persistent connections and send a periodic status request at intervals (approx every 5mins appears the norm) The timeout was dropping connections by default every 30secs which for the client appears as a very flakey network. This patch adds a separate parameter client_timeout that can be used if you do want to force a disconnect if the client sends no requests for a period. The sample config sets it to 600, but you can also define a 0 value meaning no timeout. If the parameter is not defined, it will fallback to service timeout. Signed-off-by: Marcel de Rooy Restored this patch from Colin in order to separate it from the get_timeout patch. Adjusted the commit message slightly. The original value of 600 from Colin's earlier patch may give less discussion than setting to 0 (no timeout) in a later proposal. Signed-off-by: Srdjan --- etc/SIPconfig.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index fc7635e..c61a6c7 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -32,7 +32,15 @@ port="127.0.0.1:6001/tcp" transport="RAW" protocol="SIP/2.00" + client_timeout="600" timeout="60" /> + -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 02:57:46 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 12:57:46 +1200 Subject: [Koha-patches] [PATCH] Bug 15006: Centralize timeout logic and allow zero client timeout Message-ID: <1468371466-1014-1-git-send-email-srdjan@catalyst.net.nz> From: Marcel de Rooy Moving timeout logic to one routine in Sip.pm (with unit test). This further implements two suggestions from Kyle and Larry: [1] You could use a client_timeout of 0 to specify no timeout at all. [2] Have the client_timeout default to the timeout if not defined. Test plan: [1] Run t/SIP_Sip.t [2] Test login timeout for raw and telnet. [3] Check ACS status message for timeout value. Should match policy timeout from institution. [4] Test client timeout (zero and non-zero). [5] Remove client timeout. Test fallback to service. [6] Remove service timeout too. Test fallback to 30 at login. Signed-off-by: Srdjan --- C4/SIP/SIPServer.pm | 12 ++++--- C4/SIP/Sip.pm | 46 +++++++++++++++++++++++++- C4/SIP/Sip/MsgType.pm | 7 +--- t/SIP_Sip.t | 90 +++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 119 insertions(+), 36 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 0a76ca8..e3cab23 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -15,6 +15,7 @@ use C4::SIP::Sip::Constants qw(:all); use C4::SIP::Sip::Configuration; use C4::SIP::Sip::Checksum qw(checksum verify_cksum); use C4::SIP::Sip::MsgType qw( handle login_core ); +use C4::SIP::Sip qw( get_timeout ); use base qw(Net::Server::PreFork); @@ -135,8 +136,9 @@ sub raw_transport { # Timeout the while loop if we get stuck in it # In practice it should only iterate once but be prepared local $SIG{ALRM} = sub { die 'raw transport Timed Out!' }; - syslog('LOG_DEBUG', "raw_transport: timeout is $service->{timeout}"); - alarm $service->{timeout}; + my $timeout = get_timeout( $self, { transport => 1 } ); + syslog('LOG_DEBUG', "raw_transport: timeout is $timeout"); + alarm $timeout; while (!$self->{account}) { $input = read_request(); if (!$input) { @@ -193,8 +195,8 @@ sub telnet_transport { my $account = undef; my $input; my $config = $self->{config}; - my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; - syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout); + my $timeout = get_timeout( $self, { transport => 1 } ); + syslog("LOG_DEBUG", "telnet_transport: timeout is $timeout"); eval { local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; @@ -256,7 +258,7 @@ sub sip_protocol_loop { my $self = shift; my $service = $self->{service}; my $config = $self->{config}; - my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; + my $timeout = get_timeout( $self, { client => 1 } ); # The spec says the first message will be: # SIP v1: SC_STATUS diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index 52eda1f..ec549e6 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -22,17 +22,19 @@ BEGIN { @ISA = qw(Exporter); @EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count - denied sipbool boolspace write_msg + denied sipbool boolspace write_msg get_timeout $error_detection $protocol_version $field_delimiter $last_response); %EXPORT_TAGS = ( all => [qw(y_or_n timestamp add_field maybe_add add_count denied sipbool boolspace write_msg + get_timeout $error_detection $protocol_version $field_delimiter $last_response)]); } + our $error_detection = 0; our $protocol_version = 1; our $field_delimiter = '|'; # Protocol Default @@ -197,4 +199,46 @@ sub write_msg { $last_response = $msg; } +# get_timeout( $server, { $type => 1, fallback => $fallback } ); +# where $type is transport | client | policy +# +# Centralizes all timeout logic. +# Transport refers to login process, client to active connections. +# Policy timeout is transaction timeout (used in ACS status message). +# +# Fallback is optional. If you do not pass transport, client or policy, +# you will get fallback or hardcoded default. + +sub get_timeout { + my ( $server, $params ) = @_; + my $fallback = $params->{fallback} || 30; + my $service = $server->{service} // {}; + my $config = $server->{config} // {}; + + if( $params->{transport} || + ( $params->{client} && !exists $service->{client_timeout} )) { + # We do not allow zero values here. + # Note: config/timeout seems to be deprecated. + return $service->{timeout} || $config->{timeout} || $fallback; + + } elsif( $params->{client} ) { + # We know that client_timeout exists now. + # We do allow zero values here to indicate no timeout. + return 0 if $service->{client_timeout} =~ /^0+$|\D/; + return $service->{client_timeout}; + + } elsif( $params->{policy} ) { + my $policy = $server->{policy} // {}; + my $rv = sprintf( "%03d", $policy->{timeout} // 0 ); + if( length($rv) != 3 ) { + syslog( "LOG_ERR", "Policy timeout has wrong size: '%s'", $rv ); + return '000'; + } + return $rv; + + } else { + return $fallback; + } +} + 1; diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 787449b..8a87f31 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -1505,14 +1505,9 @@ sub send_acs_status { $ACS_renewal_policy = sipbool( $policy->{renewal} ); $status_update_ok = sipbool( $ils->status_update_ok ); $offline_ok = sipbool( $ils->offline_ok ); - $timeout = sprintf( "%03d", $policy->{timeout} ); + $timeout = get_timeout( $server, { policy => 1 } ); $retries = sprintf( "%03d", $policy->{retries} ); - if ( length($timeout) != 3 ) { - syslog( "LOG_ERR", "handle_acs_status: timeout field wrong size: '%s'", $timeout ); - $timeout = '000'; - } - if ( length($retries) != 3 ) { syslog( "LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", $retries ); $retries = '000'; diff --git a/t/SIP_Sip.t b/t/SIP_Sip.t index f670277..2486ddc 100755 --- a/t/SIP_Sip.t +++ b/t/SIP_Sip.t @@ -17,42 +17,84 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 3; use Test::Warn; BEGIN { - use_ok('C4::SIP::Sip'); + use_ok('C4::SIP::Sip', qw|get_timeout| ); } -my $date_time = C4::SIP::Sip::timestamp(); -like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format no param'); +subtest 'Timestamp' => sub { + plan tests => 8; + test_timestamp(); +}; +subtest 'Get_timeout' => sub { + plan tests => 11; + test_get_timeout(); +}; -my $t = time(); +sub test_timestamp { + my $date_time = C4::SIP::Sip::timestamp(); + like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format no param'); -$date_time = C4::SIP::Sip::timestamp($t); -like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format secs'); + my $t = time(); -$date_time = C4::SIP::Sip::timestamp('2011-01-12'); -ok( $date_time eq '20110112 235900', 'Timestamp iso date string'); + $date_time = C4::SIP::Sip::timestamp($t); + like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format secs'); -my $myChecksum = C4::SIP::Sip::Checksum::checksum("12345"); -my $checker = 65281; -my $stringChecksum = C4::SIP::Sip::Checksum::checksum("teststring"); -my $stringChecker = 64425; + $date_time = C4::SIP::Sip::timestamp('2011-01-12'); + ok( $date_time eq '20110112 235900', 'Timestamp iso date string'); -is( $myChecksum, $checker, "Checksum: $myChecksum matches expected output"); -is( $stringChecksum, $stringChecker, "Checksum: $stringChecksum matches expected output"); + my $myChecksum = C4::SIP::Sip::Checksum::checksum("12345"); + my $checker = 65281; + my $stringChecksum = C4::SIP::Sip::Checksum::checksum("teststring"); + my $stringChecker = 64425; -my $testdata = "abcdAZ"; -my $something = C4::SIP::Sip::Checksum::checksum($testdata); + is( $myChecksum, $checker, "Checksum: $myChecksum matches expected output"); + is( $stringChecksum, $stringChecker, "Checksum: $stringChecksum matches expected output"); -$something = sprintf("%4X", $something); -ok( C4::SIP::Sip::Checksum::verify_cksum($testdata.$something), "Checksum: $something is valid."); + my $testdata = "abcdAZ"; + my $something = C4::SIP::Sip::Checksum::checksum($testdata); -my $invalidTest; -warning_is { $invalidTest = C4::SIP::Sip::Checksum::verify_cksum("1234567") } - 'verify_cksum: no sum detected', - 'verify_cksum prints the expected warning for an invalid checksum'; -is($invalidTest, 0, "Checksum: 1234567 is invalid as expected"); + $something = sprintf("%4X", $something); + ok( C4::SIP::Sip::Checksum::verify_cksum($testdata.$something), "Checksum: $something is valid."); + + my $invalidTest; + warning_is { $invalidTest = C4::SIP::Sip::Checksum::verify_cksum("1234567") } + 'verify_cksum: no sum detected', + 'verify_cksum prints the expected warning for an invalid checksum'; + is($invalidTest, 0, "Checksum: 1234567 is invalid as expected"); +} + +sub test_get_timeout { + my $server = { policy => { timeout => 1 }, + config => { timeout => 2 }, + service => { + timeout => 3, + client_timeout => 4, + }, + }; + + is( get_timeout(), 30, "Default fallback" ); + is( get_timeout( undef, { fallback => 25 } ), 25, "Fallback parameter" ); + is( get_timeout( $server, { transport => 1 } ), 3, "Transport value" ); + is( get_timeout( $server, { client => 1 } ), 4, "Client value" ); + is( get_timeout( $server, { policy => 1 } ), '001', "Policy value" ); + + delete $server->{policy}->{timeout}; + is( get_timeout( $server, { policy => 1 } ), '000', "No policy" ); + + $server->{service}->{client_timeout} = '0'; + is( get_timeout( $server, { client => 1 } ), 0, "Client zero" ); + $server->{service}->{client_timeout} = 'no'; + is( get_timeout( $server, { client => 1 } ), 0, "Client no" ); + delete $server->{service}->{client_timeout}; + is( get_timeout( $server, { client => 1 } ), 3, "Fallback to service" ); + + delete $server->{service}->{timeout}; + is( get_timeout( $server, { transport => 1 } ), 2, "Back to old config" ); + delete $server->{config}->{timeout}; + is( get_timeout( $server, { transport => 1 } ), 30, "Fallback again" ); +} 1; -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 02:58:32 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 12:58:32 +1200 Subject: [Koha-patches] [PATCH] Bug 15006 Correct indentation of EXPORTs in Sip.pm Message-ID: <1468371512-1313-1-git-send-email-srdjan@catalyst.net.nz> From: Colin Campbell Removed tabs and used spaces consistently Used 'use base' to remove unnecessary BEGIN sub and explicit setting of ISA at application level Signed-off-by: Srdjan --- C4/SIP/Sip.pm | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm index ec549e6..15bb9a3 100644 --- a/C4/SIP/Sip.pm +++ b/C4/SIP/Sip.pm @@ -16,24 +16,19 @@ use IO::Handle; use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG); use C4::SIP::Sip::Checksum qw(checksum); -use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); - -BEGIN { - @ISA = qw(Exporter); - - @EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count - denied sipbool boolspace write_msg get_timeout - $error_detection $protocol_version $field_delimiter - $last_response); - - %EXPORT_TAGS = ( - all => [qw(y_or_n timestamp add_field maybe_add - add_count denied sipbool boolspace write_msg - get_timeout - $error_detection $protocol_version - $field_delimiter $last_response)]); -} - +use base qw(Exporter); + +our @EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count + denied sipbool boolspace write_msg get_timeout + $error_detection $protocol_version $field_delimiter + $last_response); + +our %EXPORT_TAGS = ( + all => [qw(y_or_n timestamp add_field maybe_add + add_count denied sipbool boolspace write_msg + get_timeout + $error_detection $protocol_version + $field_delimiter $last_response)]); our $error_detection = 0; our $protocol_version = 1; -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 13 03:00:07 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 13 Jul 2016 13:00:07 +1200 Subject: [Koha-patches] [PATCH] Bug 15006: [QA Follow-up] Satisfy qa tools with one tab less Message-ID: <1468371607-1895-1-git-send-email-srdjan@catalyst.net.nz> From: Marcel de Rooy Signed-off-by: Marcel de Rooy Signed-off-by: Srdjan --- C4/SIP/SIPServer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index e3cab23..c674474 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -146,7 +146,7 @@ sub raw_transport { syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); return; } - $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) + $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); } alarm 0; -- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 15 03:54:47 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 15 Jul 2016 13:54:47 +1200 Subject: [Koha-patches] [PATCH] bug 14803: KOHA.Checkouts js object Message-ID: <1468547687-941-1-git-send-email-srdjan@catalyst.net.nz> * Use javascript to: - update fines/checkouts info - show/hide checkouts form and messages * Created svc/patron/fines --- circ/circulation.pl | 14 ----- .../prog/en/includes/blocked-fines.inc | 16 ++--- .../prog/en/includes/checkouts-table.inc | 7 +-- .../prog/en/modules/circ/circulation.tt | 72 ++++++++-------------- .../prog/en/modules/members/moremember.tt | 6 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 39 ++++++++++++ members/moremember.pl | 3 - svc/patron/fines | 40 ++++++++++++ 8 files changed, 116 insertions(+), 81 deletions(-) create mode 100755 svc/patron/fines diff --git a/circ/circulation.pl b/circ/circulation.pl index 38bb40b..86439b8 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -261,7 +261,6 @@ if ($findborrower) { # get the borrower information..... if ($borrowernumber) { $borrower = GetMemberDetails( $borrowernumber, 0 ); - my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber ); # Warningdate is the date that the warning starts appearing my ( $today_year, $today_month, $today_day) = Today(); @@ -291,12 +290,6 @@ if ($borrowernumber) { $template->param("returnbeforeexpiry" => 1); } } - $template->param( - overduecount => $od, - issuecount => $issue, - finetotal => $fines - ); - if ( IsDebarred($borrowernumber) ) { $template->param( 'userdebarred' => $borrower->{debarred}, @@ -411,9 +404,6 @@ if (@$barcodes) { } } - # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue - my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber); - if ($question->{RESERVE_WAITING} or $question->{RESERVED}){ $template->param( reserveborrowernumber => $question->{'resborrowernumber'} @@ -424,10 +414,6 @@ if (@$barcodes) { itembiblionumber => $getmessageiteminfo->{'biblionumber'} ); - - - $template_params->{issuecount} = $issue; - if ( $iteminfo ) { $iteminfo->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($iteminfo->{biblionumber}), GetFrameworkCode($iteminfo->{biblionumber})); $template_params->{item} = $iteminfo; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc index 596c0c7..547fa7f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc @@ -1,14 +1,11 @@ -[% USE Price %] -[% SET NoIssuesCharge = Koha.Preference('noissuescharge') %] - -[% IF NoIssuesCharge && fines > NoIssuesCharge %] -
  • + +
  • -[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index 53ef182..f032c5a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -1,6 +1,6 @@ [% USE Koha %]
    - [% IF ( issuecount ) %] + +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 9e42153..e924fff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -23,6 +23,9 @@ [% INCLUDE 'strings.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] + [% INCLUDE 'timepicker.inc' %] @@ -81,6 +84,10 @@ function toggle_onsite_checkout(){ function Dopop(link) { var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); } + +KOHA.Checkouts.DisallowIssue = [% noissues ? "true" : "false" %]; +KOHA.Checkouts.ForceAllowIssue = [% forceallow ? "true" : "false" %]; +KOHA.Checkouts.ForceOnSiteCheckouts = [% Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ? "true" : "false" %]; $(document).ready(function() { $('#mainform').on('submit',function() { if ($("#barcode") && $("#barcode").val()) { @@ -390,9 +397,7 @@ $(document).ready(function() { [% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %] - [% UNLESS noissues %] - - [% END %] + [% END %] [% END %] @@ -559,7 +564,6 @@ No patron matched [% message %]
    Error: This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.
    [% END %] -[% IF ( !noissues ) || ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') )%]
    @@ -592,7 +596,6 @@ No patron matched [% message %]
    - [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %] [% IF ( SpecifyDueDate ) %]
    Specify due date [% INCLUDE 'date-format.inc' %]:
    @@ -610,10 +613,8 @@ No patron matched [% message %]
    [% END %] - [% END %] - [% UNLESS ( noissues ) %] -
    +
    [% IF NEEDSCONFIRMATION %] [% ELSE %] @@ -640,19 +641,17 @@ No patron matched [% message %]
    [% END %] - [% END %] [% IF Koha.Preference('OnSiteCheckouts') %]
    - [% IF noissues %] -
    +
    - [% ELSE %] +
    - [% END %] +
    [% END %] @@ -674,35 +673,20 @@ No patron matched [% message %] [% END %]
    -[% END %] - -[% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
    - [% ELSE %] -
    - [% END %] -[% ELSE %]
    -[% END %] - - [% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
    - [% ELSE %] +
    +

    Attention:

    +
    + [% IF !( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]

    Checking out to [% INCLUDE 'patron-title.inc' %]

    -
    [% END %] -

    - Cannot check out! - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] - Only on-site checkouts are allowed - [% END %] -

    - [% ELSE %] -
    -

    Attention:

    - [% END %] +

    + Cannot check out! + [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] + Only on-site checkouts are allowed + [% END %] +

    +
      @@ -761,8 +745,8 @@ No patron matched [% message %]
      View restrictions - [% IF (noissues && borrowernumber && CAN_user_circulate_force_checkout) %] - + [% IF (borrowernumber && CAN_user_circulate_force_checkout) %] + Override restriction temporarily [% END %] @@ -861,11 +845,7 @@ No patron matched [% message %]
      • - [% IF ( issuecount ) %] - [% issuecount %] Checkout(s) - [% ELSE %] - 0 Checkouts - [% END %] + 0 Checkout(s)
      • [% IF relatives_issues_count %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 710cb16..5f9d8cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -175,9 +175,7 @@ function validate1(date) { [% ELSE %] [% IF ( was_renewed ) %]
        Patron's account has been renewed until [% dateexpiry | $KohaDates %]
        [% END %] - [% IF fines %] - [% INCLUDE 'blocked-fines.inc' %] - [% END %] + [% INCLUDE 'blocked-fines.inc' %] [% IF ( flagged ) %]
        @@ -467,7 +465,7 @@ function validate1(date) {
          -
        • [% issuecount %] Checkout(s)
        • +
        • 0 Checkout(s)
        • [% IF relatives_issues_count %]
        • Relatives' checkouts
        • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 9643d0e..17a7ca5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,6 +1,43 @@ +if ( KOHA === undefined ) var KOHA = {}; +KOHA.Checkouts = { + NoIssuesCharge: null, + BorrowerNumber: null, + DisallowIssue: false, + ForceAllowIssue: false, + ForceOnSiteCheckouts: false, + ToggleInput: function( allow_issue ) { + if (KOHA.Checkouts.DisallowIssue) allow_issue = false; + if (KOHA.Checkouts.ForceAllowIssue) allow_issue = true; + + $(".issue-allow").toggle(allow_issue); + $(".issue-disallow").toggle(!allow_issue); + $("#mainform").toggle(allow_issue || KOHA.Checkouts.ForceOnSiteCheckouts); + + if (!allow_issue) { + $(".circmessage.attention").removeClass("attention").addClass("warning"); + } + }, + UpdateCheckoutsAndFees: function(checkouts_only=false) { + $.get( "/cgi-bin/koha/svc/patron/fines", {borrowernumber: KOHA.Checkouts.BorrowerNumber}, function( data ) { + $("#issuecount").text(data.issuecount); + var has_checkouts = data.issuecount > 0; + $(".has-checkouts").toggle(has_checkouts); + $(".no-checkouts").toggle(!has_checkouts); + if (checkouts_only) return; + + var noissue = KOHA.Checkouts.NoIssuesCharge && data.owing >= KOHA.Checkouts.NoIssuesCharge; + $("#outstanding-fees").toggle(noissue); + $("#outstanding-fees-amount").text(data.owing_formatted); + KOHA.Checkouts.ToggleInput(!noissue); + } ); + } +} + $(document).ready(function() { $.ajaxSetup ({ cache: false }); + KOHA.Checkouts.UpdateCheckoutsAndFees(); + var barcodefield = $("#barcode"); var issuesTable; @@ -65,6 +102,7 @@ $(document).ready(function() { content = ""; if ( data.returned ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(true); content = CIRCULATION_RETURNED; $(id).parent().parent().addClass('ok'); $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED); @@ -97,6 +135,7 @@ $(document).ready(function() { var content = ""; if ( data.renew_okay ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(); issuesTable.api().ajax.reload(); content = CIRCULATION_RENEWED_DUE + " " + data.date_due; $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); diff --git a/members/moremember.pl b/members/moremember.pl index e7c54f4..c6fe21d 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -115,9 +115,6 @@ my $borrowernumber = $input->param('borrowernumber'); my $error = $input->param('error'); $template->param( error => $error ) if ( $error ); -my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber); -$template->param( issuecount => $issue, fines => $fines ); - my $data = GetMember( 'borrowernumber' => $borrowernumber ); if ( not defined $data ) { diff --git a/svc/patron/fines b/svc/patron/fines new file mode 100755 index 0000000..d61df9c --- /dev/null +++ b/svc/patron/fines @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +# Copyright 2016 CatalystIT +# +# 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 strict; +use warnings; + +use C4::Service; +use C4::Members qw/GetMemberIssuesAndFines/; +use Koha::Number::Price; + +my ( $query, $response ) = C4::Service->init( borrowers => '*' ); + +my $borrowernumber = $query->param('borrowernumber'); + +my ( $od, $issue, $owing ) = GetMemberIssuesAndFines( $borrowernumber ); + +$response->param( + overduecount => $od, + issuecount => $issue, + owing => $owing || 0.00, + owing_formatted => Koha::Number::Price->new( $owing )->format, +); + +C4::Service->return_success( $response ); -- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 15 04:20:54 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 15 Jul 2016 14:20:54 +1200 Subject: [Koha-patches] [PATCH] Bug 16870 - Move and rename class files and unit tests Message-ID: <1468549254-10254-1-git-send-email-srdjan@catalyst.net.nz> From: Kyle M Hall Signed-off-by: Srdjan --- Koha/Issue.pm | 28 ------------------- Koha/Issues.pm | 33 ----------------------- t/db_dependent/Koha/Checkouts.t | 29 +++++++++----------- t/db_dependent/Koha/Issues.t | 60 ----------------------------------------- 4 files changed, 13 insertions(+), 137 deletions(-) delete mode 100644 Koha/Issue.pm delete mode 100644 Koha/Issues.pm delete mode 100644 t/db_dependent/Koha/Issues.t diff --git a/Koha/Issue.pm b/Koha/Issue.pm deleted file mode 100644 index 8b67235..0000000 --- a/Koha/Issue.pm +++ /dev/null @@ -1,28 +0,0 @@ -package Koha::Issue; - -# 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); - -sub _type { - return 'Issue'; -} - -1; diff --git a/Koha/Issues.pm b/Koha/Issues.pm deleted file mode 100644 index f0b2216..0000000 --- a/Koha/Issues.pm +++ /dev/null @@ -1,33 +0,0 @@ -package Koha::Issues; - -# 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::Issue; - -use base qw(Koha::Objects); - -sub _type { - return 'Issue'; -} - -sub object_class { - return 'Koha::Issue'; -} - -1; diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t index e8b1341..30cdf9d 100644 --- a/t/db_dependent/Koha/Checkouts.t +++ b/t/db_dependent/Koha/Checkouts.t @@ -30,33 +30,30 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -my $builder = t::lib::TestBuilder->new; -my $library = $builder->build( { source => 'Branch' } ); -my $patron = $builder->build( { source => 'Borrower', value => { branchcode => $library->{branchcode} } } ); -my $item_1 = $builder->build( { source => 'Item' } ); -my $item_2 = $builder->build( { source => 'Item' } ); -my $nb_of_checkouts = Koha::Checkouts->search->count; -my $new_checkout_1 = Koha::Checkout->new( +my $builder = t::lib::TestBuilder->new; +my $patron = $builder->build( { source => 'Borrower' } ); +my $item_1 = $builder->build( { source => 'Item' } ); +my $item_2 = $builder->build( { source => 'Item' } ); +my $nb_of_issues = Koha::Checkouts->search->count; +my $new_issue_1 = Koha::Checkout->new( { borrowernumber => $patron->{borrowernumber}, itemnumber => $item_1->{itemnumber}, - branchcode => $library->{branchcode}, } )->store; -my $new_checkout_2 = Koha::Checkout->new( +my $new_issue_2 = Koha::Checkout->new( { borrowernumber => $patron->{borrowernumber}, itemnumber => $item_2->{itemnumber}, - branchcode => $library->{branchcode}, } )->store; -like( $new_checkout_1->issue_id, qr|^\d+$|, 'Adding a new checkout should have set the issue_id' ); -is( Koha::Checkouts->search->count, $nb_of_checkouts + 2, 'The 2 checkouts should have been added' ); +like( $new_issue_1->issue_id, qr|^\d+$|, 'Adding a new issue should have set the issue_id' ); +is( Koha::Checkouts->search->count, $nb_of_issues + 2, 'The 2 issues should have been added' ); -my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id ); -is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' ); +my $retrieved_issue_1 = Koha::Checkouts->find( $new_issue_1->issue_id ); +is( $retrieved_issue_1->itemnumber, $new_issue_1->itemnumber, 'Find a issue by id should return the correct issue' ); -$retrieved_checkout_1->delete; -is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); +$retrieved_issue_1->delete; +is( Koha::Checkouts->search->count, $nb_of_issues + 1, 'Delete should delete the issue' ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Issues.t b/t/db_dependent/Koha/Issues.t deleted file mode 100644 index 38023c8..0000000 --- a/t/db_dependent/Koha/Issues.t +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2015 Koha Development team -# -# 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, see . - -use Modern::Perl; - -use Test::More tests => 4; - -use Koha::Issue; -use Koha::Issues; -use Koha::Database; - -use t::lib::TestBuilder; - -my $schema = Koha::Database->new->schema; -$schema->storage->txn_begin; - -my $builder = t::lib::TestBuilder->new; -my $patron = $builder->build( { source => 'Borrower' } ); -my $item_1 = $builder->build( { source => 'Item' } ); -my $item_2 = $builder->build( { source => 'Item' } ); -my $nb_of_issues = Koha::Issues->search->count; -my $new_issue_1 = Koha::Issue->new( - { borrowernumber => $patron->{borrowernumber}, - itemnumber => $item_1->{itemnumber}, - } -)->store; -my $new_issue_2 = Koha::Issue->new( - { borrowernumber => $patron->{borrowernumber}, - itemnumber => $item_2->{itemnumber}, - } -)->store; - -like( $new_issue_1->issue_id, qr|^\d+$|, 'Adding a new issue should have set the issue_id' ); -is( Koha::Issues->search->count, $nb_of_issues + 2, 'The 2 issues should have been added' ); - -my $retrieved_issue_1 = Koha::Issues->find( $new_issue_1->issue_id ); -is( $retrieved_issue_1->itemnumber, $new_issue_1->itemnumber, 'Find a issue by id should return the correct issue' ); - -$retrieved_issue_1->delete; -is( Koha::Issues->search->count, $nb_of_issues + 1, 'Delete should delete the issue' ); - -$schema->storage->txn_rollback; - -1; -- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 15 04:22:26 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 15 Jul 2016 14:22:26 +1200 Subject: [Koha-patches] [PATCH] Bug 16870 - Update Koha::Patron use of the class Message-ID: <1468549346-10828-1-git-send-email-srdjan@catalyst.net.nz> From: Kyle M Hall Test Plan: 1) Apply this patch 2) prove t/db_dependent/Patron/Borrower_PrevCheckout.t 3) prove t/db_dependent/Koha/Checkouts.t Signed-off-by: Srdjan --- Koha/Patron.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 5ba5efc..37a1d85 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -24,7 +24,7 @@ use Carp; use C4::Context; use Koha::Database; -use Koha::Issues; +use Koha::Checkouts; use Koha::OldIssues; use Koha::Patron::Categories; use Koha::Patron::Images; @@ -153,19 +153,19 @@ sub do_check_for_previous_checkout { push @item_nos, $item->itemnumber; } - # Create (old)issues search criteria + # Create (old)checkouts search criteria my $criteria = { borrowernumber => $self->borrowernumber, itemnumber => \@item_nos, }; - # Check current issues table - my $issues = Koha::Issues->search($criteria); - return 1 if $issues->count; # 0 || N + # Check current checkouts table + my $checkouts = Koha::Checkouts->search($criteria); + return 1 if $checkouts->count; # 0 || N - # Check old issues table - my $old_issues = Koha::OldIssues->search($criteria); - return $old_issues->count; # 0 || N + # Check old checkouts table + my $old_checkouts = Koha::OldIssues->search($criteria); + return $old_checkouts->count; # 0 || N } =head3 type -- 2.7.4 From srdjan at catalyst.net.nz Tue Jul 19 02:33:08 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Tue, 19 Jul 2016 12:33:08 +1200 Subject: [Koha-patches] [PATCH] bug 14803: KOHA.Checkouts js object Message-ID: <1468888388-22054-1-git-send-email-srdjan@catalyst.net.nz> * Use javascript to: - update fines/checkouts info - show/hide checkouts form and messages * Created svc/patron/fines --- circ/circulation.pl | 14 ----- .../prog/en/includes/blocked-fines.inc | 18 +++--- .../prog/en/includes/checkouts-table.inc | 7 +-- .../prog/en/modules/circ/circulation.tt | 72 ++++++++-------------- .../prog/en/modules/members/moremember.tt | 6 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 40 ++++++++++++ members/moremember.pl | 3 - svc/patron/fines | 40 ++++++++++++ 8 files changed, 121 insertions(+), 79 deletions(-) create mode 100755 svc/patron/fines diff --git a/circ/circulation.pl b/circ/circulation.pl index ed00e2d..5f179f6 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -261,7 +261,6 @@ if ($findborrower) { # get the borrower information..... if ($borrowernumber) { $borrower = GetMemberDetails( $borrowernumber, 0 ); - my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber ); # Warningdate is the date that the warning starts appearing my ( $today_year, $today_month, $today_day) = Today(); @@ -291,12 +290,6 @@ if ($borrowernumber) { $template->param("returnbeforeexpiry" => 1); } } - $template->param( - overduecount => $od, - issuecount => $issue, - finetotal => $fines - ); - if ( Koha::Patrons->find( $borrowernumber )->is_debarred ) { $template->param( 'userdebarred' => $borrower->{debarred}, @@ -411,9 +404,6 @@ if (@$barcodes) { } } - # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue - my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber); - if ($question->{RESERVE_WAITING} or $question->{RESERVED}){ $template->param( reserveborrowernumber => $question->{'resborrowernumber'} @@ -424,10 +414,6 @@ if (@$barcodes) { itembiblionumber => $getmessageiteminfo->{'biblionumber'} ); - - - $template_params->{issuecount} = $issue; - if ( $iteminfo ) { $iteminfo->{subtitle} = GetRecordValue('subtitle', GetMarcBiblio($iteminfo->{biblionumber}), GetFrameworkCode($iteminfo->{biblionumber})); $template_params->{item} = $iteminfo; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc index 0789789..07b647a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc @@ -1,13 +1,15 @@ -[% USE Price %] -[% SET NoIssuesCharge = Koha.Preference('noissuescharge') %] -[% IF fines > 0 %] -
        • + +
        • -[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index 53ef182..f032c5a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -1,6 +1,6 @@ [% USE Koha %]
          - [% IF ( issuecount ) %] + +
          diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index b02851f..3efe387 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -23,6 +23,9 @@ [% INCLUDE 'strings.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] + [% INCLUDE 'timepicker.inc' %] @@ -81,6 +84,10 @@ function toggle_onsite_checkout(){ function Dopop(link) { var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); } + +KOHA.Checkouts.DisallowIssue = [% noissues ? "true" : "false" %]; +KOHA.Checkouts.ForceAllowIssue = [% forceallow ? "true" : "false" %]; +KOHA.Checkouts.ForceOnSiteCheckouts = [% Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ? "true" : "false" %]; $(document).ready(function() { $('#mainform').on('submit',function() { if ($("#barcode") && $("#barcode").val()) { @@ -390,9 +397,7 @@ $(document).ready(function() { [% IF ( RESERVED || ISSUED_TO_ANOTHER ) && (CAN_user_reserveforothers_place_holds ) %] - [% UNLESS noissues %] - - [% END %] + [% END %]
        [% END %] @@ -559,7 +564,6 @@ No patron matched [% message %]
        Error: This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.
        [% END %] -[% IF ( !noissues ) || ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') )%]
        @@ -592,7 +596,6 @@ No patron matched [% message %]
        - [% UNLESS ( noissues && Koha.Preference('OnSiteCheckoutsForce') ) %] [% IF ( SpecifyDueDate ) %]
        Specify due date [% INCLUDE 'date-format.inc' %]:
        @@ -610,10 +613,8 @@ No patron matched [% message %]
        [% END %] - [% END %] - [% UNLESS ( noissues ) %] -
        +
        [% IF NEEDSCONFIRMATION %] [% ELSE %] @@ -640,19 +641,17 @@ No patron matched [% message %]
        [% END %] - [% END %] [% IF Koha.Preference('OnSiteCheckouts') %]
        - [% IF noissues %] -
        +
        - [% ELSE %] +
        - [% END %] +
        [% END %] @@ -674,35 +673,20 @@ No patron matched [% message %] [% END %]
        -[% END %] - -[% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
        - [% ELSE %] -
        - [% END %] -[% ELSE %]
        -[% END %] - - [% IF ( noissues ) %] - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] -
        - [% ELSE %] +
        +

        Attention:

        +
        + [% IF !( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %]

        Checking out to [% INCLUDE 'patron-title.inc' %]

        -
        [% END %] -

        - Cannot check out! - [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] - Only on-site checkouts are allowed - [% END %] -

        - [% ELSE %] -
        -

        Attention:

        - [% END %] +

        + Cannot check out! + [% IF ( Koha.Preference('OnSiteCheckouts') && Koha.Preference('OnSiteCheckoutsForce') ) %] + Only on-site checkouts are allowed + [% END %] +

        +
          @@ -761,8 +745,8 @@ No patron matched [% message %] [% END %]
          View restrictions - [% IF (noissues && borrowernumber && CAN_user_circulate_force_checkout) %] - + [% IF (borrowernumber && CAN_user_circulate_force_checkout) %] + Override restriction temporarily [% END %] @@ -861,11 +845,7 @@ No patron matched [% message %]
          • - [% IF ( issuecount ) %] - [% issuecount %] Checkout(s) - [% ELSE %] - 0 Checkouts - [% END %] + 0 Checkout(s)
          • [% IF relatives_issues_count %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 65bdb7a..02e3fb6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -175,9 +175,7 @@ function validate1(date) { [% ELSE %] [% IF ( was_renewed ) %]
            Patron's account has been renewed until [% dateexpiry | $KohaDates %]
            [% END %] - [% IF fines %] - [% INCLUDE 'blocked-fines.inc' %] - [% END %] + [% INCLUDE 'blocked-fines.inc' %] [% IF ( flagged ) %]
            @@ -468,7 +466,7 @@ function validate1(date) {
              -
            • [% issuecount %] Checkout(s)
            • +
            • 0 Checkout(s)
            • [% IF relatives_issues_count %]
            • Relatives' checkouts
            • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 9643d0e..51df6b8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,6 +1,44 @@ +if ( KOHA === undefined ) var KOHA = {}; +KOHA.Checkouts = { + NoIssuesCharge: null, + BorrowerNumber: null, + DisallowIssue: false, + ForceAllowIssue: false, + ForceOnSiteCheckouts: false, + ToggleInput: function( allow_issue ) { + if (KOHA.Checkouts.DisallowIssue) allow_issue = false; + if (KOHA.Checkouts.ForceAllowIssue) allow_issue = true; + + $(".issue-allow").toggle(allow_issue); + $(".issue-disallow").toggle(!allow_issue); + $("#mainform").toggle(allow_issue || KOHA.Checkouts.ForceOnSiteCheckouts); + + if (!allow_issue) { + $(".circmessage.attention").removeClass("attention").addClass("warning"); + } + }, + UpdateCheckoutsAndFees: function(checkouts_only=false) { + $.get( "/cgi-bin/koha/svc/patron/fines", {borrowernumber: KOHA.Checkouts.BorrowerNumber}, function( data ) { + $("#issuecount").text(data.issuecount); + var has_checkouts = data.issuecount > 0; + $(".has-checkouts").toggle(has_checkouts); + $(".no-checkouts").toggle(!has_checkouts); + if (checkouts_only) return; + + var noissue = KOHA.Checkouts.NoIssuesCharge !== null && data.owing >= KOHA.Checkouts.NoIssuesCharge; + $("#outstanding-fees").toggle(data.owing > 0); + $("#outstanding-fees-amount").text(data.owing_formatted); + $("#outstanding-fees-over-limit").toggle(noissue); + KOHA.Checkouts.ToggleInput(!noissue); + } ); + } +} + $(document).ready(function() { $.ajaxSetup ({ cache: false }); + KOHA.Checkouts.UpdateCheckoutsAndFees(); + var barcodefield = $("#barcode"); var issuesTable; @@ -65,6 +103,7 @@ $(document).ready(function() { content = ""; if ( data.returned ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(true); content = CIRCULATION_RETURNED; $(id).parent().parent().addClass('ok'); $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED); @@ -97,6 +136,7 @@ $(document).ready(function() { var content = ""; if ( data.renew_okay ) { + KOHA.Checkouts.UpdateCheckoutsAndFees(); issuesTable.api().ajax.reload(); content = CIRCULATION_RENEWED_DUE + " " + data.date_due; $('#date_due_' + data.itemnumber).replaceWith( data.date_due ); diff --git a/members/moremember.pl b/members/moremember.pl index 98286a0..4cf6c57 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -115,9 +115,6 @@ my $borrowernumber = $input->param('borrowernumber'); my $error = $input->param('error'); $template->param( error => $error ) if ( $error ); -my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber); -$template->param( issuecount => $issue, fines => $fines ); - my $data = GetMember( 'borrowernumber' => $borrowernumber ); if ( not defined $data ) { diff --git a/svc/patron/fines b/svc/patron/fines new file mode 100755 index 0000000..d61df9c --- /dev/null +++ b/svc/patron/fines @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +# Copyright 2016 CatalystIT +# +# 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 strict; +use warnings; + +use C4::Service; +use C4::Members qw/GetMemberIssuesAndFines/; +use Koha::Number::Price; + +my ( $query, $response ) = C4::Service->init( borrowers => '*' ); + +my $borrowernumber = $query->param('borrowernumber'); + +my ( $od, $issue, $owing ) = GetMemberIssuesAndFines( $borrowernumber ); + +$response->param( + overduecount => $od, + issuecount => $issue, + owing => $owing || 0.00, + owing_formatted => Koha::Number::Price->new( $owing )->format, +); + +C4::Service->return_success( $response ); -- 2.7.4 From srdjan at catalyst.net.nz Wed Jul 27 05:20:30 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Wed, 27 Jul 2016 15:20:30 +1200 Subject: [Koha-patches] [PATCH] Bug 16986: Added 035 $a tag to search index as OCLC-Number Message-ID: <1469589630-15139-1-git-send-email-srdjan@catalyst.net.nz> --- C4/Search.pm | 2 ++ etc/searchengine/queryparser.yaml | 9 +++++++++ etc/zebradb/ccl.properties | 5 +++++ etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml | 5 +++++ etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl | 9 +++++++++ etc/zebradb/marc_defs/marc21/biblios/record.abs | 2 +- 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/C4/Search.pm b/C4/Search.pm index 36c4cfa..84f70c4 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1179,6 +1179,8 @@ sub getIndexes{ 'notes', 'ns', 'nt', + 'oclc', + 'OCLC-Number', 'pb', 'Personal-name', 'Personal-name-heading', diff --git a/etc/searchengine/queryparser.yaml b/etc/searchengine/queryparser.yaml index d9f637b..da7a6d6 100644 --- a/etc/searchengine/queryparser.yaml +++ b/etc/searchengine/queryparser.yaml @@ -923,6 +923,15 @@ field_mappings: aliases: - notforloan label: Notforloan + oclc: + bib1_mapping: + biblioserver: + 1: 1211 + enabled: 1 + index: oclc + aliases: + - oclc + label: OCLC-Number onloan: bib1_mapping: biblioserver: diff --git a/etc/zebradb/ccl.properties b/etc/zebradb/ccl.properties index 873c749..90dd51f 100644 --- a/etc/zebradb/ccl.properties +++ b/etc/zebradb/ccl.properties @@ -581,6 +581,11 @@ Personal-name-seealso 1=Personal-name-seealso Publisher 1=1018 pb Publisher +#OCLC-Number 1211 A sequential accession number 035$a +# assigned by OCLC +OCLC-Number 1=1211 +oclc OCLC-Number + #Provider 1225 A generic, single index 257$a2 # combining place, publisher, 260$abcdefg3 # and date. To avoid searching 264$abc3 diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml index 35b1c71..cbd95c4 100644 --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml +++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml @@ -180,6 +180,11 @@ Map-scale:w + + + OCLC-Number:w + Identifier-standard:w + Identifier-standard:w diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl index 16b339e..16ae588 100644 --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl +++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl @@ -191,6 +191,15 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + + + diff --git a/etc/zebradb/marc_defs/marc21/biblios/record.abs b/etc/zebradb/marc_defs/marc21/biblios/record.abs index efdcf80..4a25094 100644 --- a/etc/zebradb/marc_defs/marc21/biblios/record.abs +++ b/etc/zebradb/marc_defs/marc21/biblios/record.abs @@ -72,7 +72,7 @@ melm 028 Identifier-publisher-for-music,Identifier-standard melm 030 CODEN,Identifier-standard #melm 033 Date melm 034 Map-scale -#melm 035 Local-number,Identifier-standard +melm 035$a OCLC-Number,Identifier-standard melm 037 Identifier-standard,Stock-number melm 040 Code-institution,Record-source melm 041$a ln,ln-audio:w -- 2.7.4 From srdjan at catalyst.net.nz Fri Jul 29 02:45:13 2016 From: srdjan at catalyst.net.nz (Srdjan) Date: Fri, 29 Jul 2016 12:45:13 +1200 Subject: [Koha-patches] [PATCH] Bug 16034 follow-up: added WebService::ILS to PerlDependencies Message-ID: <1469753113-4147-1-git-send-email-srdjan@catalyst.net.nz> --- C4/Installer/PerlDependencies.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index db9cd7c..2bc7515 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -812,6 +812,11 @@ our $PERL_DEPS = { 'required' => '1', 'min_ver' => '3.0', }, + 'WebService::ILS' => { + 'usage' => 'Interface third party systems', + 'required' => '0', + 'min_ver' => '0.07', + }, }; 1; -- 2.7.4