From 4a7cb5ebe37b29635d8748aed1345982580c0704 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. --- C4/Circulation.pm | 17 ++- installer/data/mysql/kohastructure.sql | 18 +- installer/data/mysql/updatedatabase.pl | 8 + .../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 +++-- koha-tmpl/opac-tmpl/prog/en/modules/opac-auth.tt | 9 + offline_circ/enqueue_koc.pl | 197 ++++++++++++++++++++ offline_circ/list.pl | 1 + 10 files changed, 302 insertions(+), 27 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 c26de76..d3cb650 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3126,9 +3126,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."; } @@ -3147,6 +3148,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}; @@ -3216,6 +3219,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 3137f38..ef11035 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1546,17 +1546,17 @@ CREATE TABLE `patronimage` ( -- 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 dbbdee3..a6c1d07 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5308,6 +5308,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.09.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 (redefine the field branchcode as PRIMARY KEY of branches)\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 8b4ad57..f48f557 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 @@ -51,8 +51,12 @@
Offline circulation
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..1e198a5 --- /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 d22cf5f..042acc7 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 b818039..60a699b 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 @@