From 1148d5cefba2fc90348f289dcf97afb20dcf8856 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 --- C4/Circulation.pm | 17 +- installer/data/mysql/kohastructure.sql | 18 +- installer/data/mysql/updatedatabase.pl | 11 +- .../prog/en/modules/circ/circulation-home.tt | 8 +- .../prog/en/modules/offline_circ/enqueue_koc.tt | 31 +++ .../prog/en/modules/offline_circ/list.tt | 6 +- .../prog/en/modules/offline_circ/process_koc.tt | 34 ++-- offline_circ/enqueue_koc.pl | 197 ++++++++++++++++++++ offline_circ/list.pl | 1 + 9 files changed, 294 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 f1c8662..02b973d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3328,9 +3328,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."; } @@ -3349,6 +3350,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}; @@ -3418,6 +3421,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 221c4e4..51ad18e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1573,17 +1573,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 317680a..0a0e8c3 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 '';"); @@ -6505,6 +6503,15 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } + +$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); +} + =head1 FUNCTIONS =head2 TableExists($table) 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 cb0662a..f5e82b4 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 0000000..8c836e3 --- /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 8e14d07..eb19589 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 0aae78b..5c9da7e 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 @@