From 7224e47dfe433d94f19b14eade1abee5f5d5c964 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Sat, 9 Jun 2012 11:07:39 -0400 Subject: [PATCH] Bug 8220 - Allow koc uploads to go to process queue instead of being applied directly. The primary advantage to the Firefox offline cirulation plugin when compared to the offline circulation desktop application, is the ability to add offline circulation actions to a queue so that multiple machines running offline circ can have their circ actions combined and ordered chronologically before being executed. This commit adds the ability to put actions from uploaded KOC files into this queue. In this way, both the FF plugina and the desktop application can be run side by side with no ill effects. Signed-off-by: Bob Birchall Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- C4/Circulation.pm | 17 +- installer/data/mysql/kohastructure.sql | 18 +- installer/data/mysql/updatedatabase.pl | 9 +- .../prog/en/modules/circ/circulation-home.tt | 8 +- .../en/modules/offline_circ/enqueue_koc.tt | 31 +++ .../prog/en/modules/offline_circ/list.tt | 6 +- .../en/modules/offline_circ/process_koc.tt | 34 +-- offline_circ/enqueue_koc.pl | 197 ++++++++++++++++++ offline_circ/list.pl | 1 + 9 files changed, 292 insertions(+), 29 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/enqueue_koc.tt create mode 100755 offline_circ/enqueue_koc.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b5a5172de1..bb5b718233 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3336,9 +3336,10 @@ sub GetOfflineOperation { } sub AddOfflineOperation { + my ( $userid, $branchcode, $timestamp, $action, $barcode, $cardnumber, $amount ) = @_; my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("INSERT INTO pending_offline_operations (userid, branchcode, timestamp, action, barcode, cardnumber) VALUES(?,?,?,?,?,?)"); - $sth->execute( @_ ); + my $sth = $dbh->prepare("INSERT INTO pending_offline_operations (userid, branchcode, timestamp, action, barcode, cardnumber, amount) VALUES(?,?,?,?,?,?,?)"); + $sth->execute( $userid, $branchcode, $timestamp, $action, $barcode, $cardnumber, $amount ); return "Added."; } @@ -3357,6 +3358,8 @@ sub ProcessOfflineOperation { $report = ProcessOfflineReturn( $operation ); } elsif ( $operation->{action} eq 'issue' ) { $report = ProcessOfflineIssue( $operation ); + } elsif ( $operation->{action} eq 'payment' ) { + $report = ProcessOfflinePayment( $operation ); } DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; @@ -3426,6 +3429,16 @@ sub ProcessOfflineIssue { } } +sub ProcessOfflinePayment { + my $operation = shift; + + my $borrower = C4::Members::GetMemberDetails( undef, $operation->{cardnumber} ); # Get borrower from operation cardnumber + my $amount = $operation->{amount}; + + recordpayment( $borrower->{borrowernumber}, $amount ); + + return "Success." +} =head2 TransferSlip diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index c74c39bbc5..15eb4d7f1b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1559,17 +1559,17 @@ CREATE TABLE `patronimage` ( -- information related to patron images -- so MyISAM is better in this case DROP TABLE IF EXISTS `pending_offline_operations`; -CREATE TABLE `pending_offline_operations` ( - `operationid` int(11) NOT NULL AUTO_INCREMENT, - `userid` varchar(30) NOT NULL, - `branchcode` varchar(10) NOT NULL, +CREATE TABLE pending_offline_operations ( + operationid int(11) NOT NULL AUTO_INCREMENT, + userid varchar(30) NOT NULL, + branchcode varchar(10) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `action` varchar(10) NOT NULL, - `barcode` varchar(20) NOT NULL, - `cardnumber` varchar(16) DEFAULT NULL, - PRIMARY KEY (`operationid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - + barcode varchar(20) DEFAULT NULL, + cardnumber varchar(16) DEFAULT NULL, + amount decimal(28,6) DEFAULT NULL, + PRIMARY KEY (operationid) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8a6a5b8e2b..8cb05398ff 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5828,8 +5828,6 @@ if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } - - $DBversion = "3.09.00.050"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("ALTER TABLE authorised_values MODIFY category varchar(16) NOT NULL DEFAULT '';"); @@ -6528,6 +6526,13 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.11.00.100"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { print "Upgrade to $DBversion done (3.12-alpha release)\n"; +} + +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER TABLE `pending_offline_operations` CHANGE `barcode` `barcode` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"); + $dbh->do("ALTER TABLE `pending_offline_operations` ADD `amount` DECIMAL( 28, 6 ) NULL DEFAULT NULL"); + print "Upgrade to $DBversion done (Bug 8220 - Allow koc uploads to go to process queue)\n"; SetVersion ($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt index cb0662a2de..f5e82b4a83 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt @@ -53,8 +53,12 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/enqueue_koc.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/enqueue_koc.tt new file mode 100644 index 0000000000..8c836e3d65 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/enqueue_koc.tt @@ -0,0 +1,31 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Add offline circulations to queue +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'circ-search.inc' %] + + + +
+ +
+ +

Koha offline circulation

+

Your file was processed.

+ +[% FOREACH message IN messages %] + [% IF ( message.message ) %] + [% IF ( message.ERROR_file_version ) %] +

Warning: This file is version [% message.upload_version %], but I only know how to import version [% message.current_version %]. I'll try my best.

+ [% END %] + [% END %] +[% END %] + +

Upload another KOC file

+ +

View pending offline circulation actions

+ +
+[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/list.tt index 8e14d0765d..eb19589646 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/list.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/list.tt @@ -78,7 +78,8 @@ Date Action Barcode - Card number + Card number + Amount @@ -95,7 +96,7 @@ [% END %] - [% IF ( operation.actionissue ) %] + [% IF ( operation.actionissue || operation.actionpayment) %] [% IF ( operation.borrowernumber ) %] [% operation.cardnumber %] [% ELSE %] @@ -103,6 +104,7 @@ [% END %] [% END %] + [% operation.amount %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt index 0aae78b83a..5c9da7ef9b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt @@ -6,22 +6,25 @@