}
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 {
# 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:
$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);
}
# 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;
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);
# 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;
# 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;
# 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;
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'),
'barcode' => $cgi->param('barcode'),
'cardnumber' => $cgi->param('cardnumber'),
}
- );
- }
+ );
+ }
} else {
$result = "Authentication failed."
}