@@ -, +, @@ --- C4/Circulation.pm | 55 +++++++++++++++---------------- installer/data/mysql/updatedatabase.pl | 8 ++-- offline_circ/list.pl | 27 +++++++++------ offline_circ/process.pl | 9 +++-- offline_circ/process_koc.pl | 6 ++-- offline_circ/service.pl | 25 ++++++++------ 6 files changed, 70 insertions(+), 60 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -3037,51 +3037,50 @@ sub LostItem{ } sub GetOfflineOperations { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp"); - $sth->execute(C4::Context->userenv->{'branch'}); - my $results = $sth->fetchall_arrayref({}); - $sth->finish; - return $results; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE branchcode=? ORDER BY timestamp"); + $sth->execute(C4::Context->userenv->{'branch'}); + my $results = $sth->fetchall_arrayref({}); + $sth->finish; + return $results; } sub GetOfflineOperation { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?"); - $sth->execute( shift ); - my $result = $sth->fetchrow_hashref; - $sth->finish; - return $result; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM pending_offline_operations WHERE operationid=?"); + $sth->execute( shift ); + my $result = $sth->fetchrow_hashref; + $sth->finish; + return $result; } sub AddOfflineOperation { - my $dbh = C4::Context->dbh; - warn Data::Dumper::Dumper(@_); - my $sth = $dbh->prepare("INSERT INTO pending_offline_operations VALUES('',?,?,?,?,?,?)"); - $sth->execute( @_ ); - return "Added."; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("INSERT INTO pending_offline_operations (userid, branchcode, timestamp, action, barcode, cardnumber) VALUES(?,?,?,?,?,?)"); + $sth->execute( @_ ); + return "Added."; } sub DeleteOfflineOperation { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?"); - $sth->execute( shift ); - return "Deleted."; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("DELETE FROM pending_offline_operations WHERE operationid=?"); + $sth->execute( shift ); + return "Deleted."; } sub ProcessOfflineOperation { - my $operation = shift; + my $operation = shift; my $report; - if ( $operation->{action} eq 'return' ) { + if ( $operation->{action} eq 'return' ) { $report = ProcessOfflineReturn( $operation ); - } elsif ( $operation->{action} eq 'issue' ) { - $report = ProcessOfflineIssue( $operation ); - } + } elsif ( $operation->{action} eq 'issue' ) { + $report = ProcessOfflineIssue( $operation ); + } - DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; + DeleteOfflineOperation( $operation->{operationid} ) if $operation->{operationid}; - return $report; + return $report; } sub ProcessOfflineReturn { --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -15,9 +15,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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. # # Bugs/ToDo: @@ -4714,7 +4714,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { $DBversion = "3.07.00.XXX"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { - $dbh->do("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;"); + $dbh->do("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;"); print "Upgrade to $DBversion done ( adding offline operations table )\n"; SetVersion($DBversion); } --- a/offline_circ/list.pl +++ a/offline_circ/list.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 CGI; use C4::Output; use C4::Auth; @@ -41,14 +44,16 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ my $operations = GetOfflineOperations; for (@$operations) { - my $biblio = GetBiblioFromItemNumber(undef, $_->{'barcode'}); - $_->{'bibliotitle'} = $biblio->{'title'}; - $_->{'biblionumber'} = $biblio->{'biblionumber'}; - my $borrower = GetMemberDetails(undef,$_->{'cardnumber'}); - $_->{'borrowernumber'} = $borrower->{'borrowernumber'}; - $_->{'borrower'} = join(' ', $borrower->{'firstname'}, $borrower->{'surname'}); - $_->{'actionissue'} = $_->{'action'} eq 'issue'; - $_->{'actionreturn'} = $_->{'action'} eq 'return'; + my $biblio = GetBiblioFromItemNumber(undef, $_->{'barcode'}); + $_->{'bibliotitle'} = $biblio->{'title'}; + $_->{'biblionumber'} = $biblio->{'biblionumber'}; + my $borrower = GetMemberDetails(undef,$_->{'cardnumber'}); + if ($borrower) { + $_->{'borrowernumber'} = $borrower->{'borrowernumber'}; + $_->{'borrower'} = ($borrower->{'firstname'}?$borrower->{'firstname'}:'').' '.$borrower->{'surname'}; + } + $_->{'actionissue'} = $_->{'action'} eq 'issue'; + $_->{'actionreturn'} = $_->{'action'} eq 'return'; } $template->param(pending_operations => $operations); --- a/offline_circ/process.pl +++ a/offline_circ/process.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 CGI; use C4::Auth; use C4::Circulation; --- a/offline_circ/process_koc.pl +++ a/offline_circ/process_koc.pl @@ -13,9 +13,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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; --- a/offline_circ/service.pl +++ a/offline_circ/service.pl @@ -13,11 +13,14 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 CGI; use C4::Auth; use C4::Circulation; @@ -30,17 +33,17 @@ my ($status, $cookie, $sessionId) = C4::Auth::check_api_auth($cgi, undef); my $result; if ($status eq 'ok') { # if authentication is ok - if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them - $result = AddOfflineOperation( - $cgi->param('userid') || '', + if ( $cgi->param('pending') eq 'true' ) { # if the 'pending' flag is true, we store the operation in the db instead of directly processing them + $result = AddOfflineOperation( + $cgi->param('userid') || '', $cgi->param('branchcode') || '', $cgi->param('timestamp') || '', $cgi->param('action') || '', $cgi->param('barcode') || '', $cgi->param('cardnumber') || '', - ); - } else { - $result = ProcessOfflineOperation( + ); + } else { + $result = ProcessOfflineOperation( { 'userid' => $cgi->param('userid'), 'branchcode' => $cgi->param('branchcode'), @@ -49,8 +52,8 @@ if ($status eq 'ok') { # if authentication is ok 'barcode' => $cgi->param('barcode'), 'cardnumber' => $cgi->param('cardnumber'), } - ); - } + ); + } } else { $result = "Authentication failed." } --