Bug 5877 QA follow-up
authorPaul Poulain <paul.poulain@biblibre.com>
Wed, 22 Feb 2012 17:12:04 +0000 (18:12 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 2 Mar 2012 16:53:00 +0000 (17:53 +0100)
* removing tabs as indenter
* adding fieldnames in INSERT clause
* updating FSF address
* removing ` in SQL table creation (mysql-ism)
* use strict & use warning added & no error in logs checked

Note that process_koc.pl and updatedatabase are not related to this bug, but the FSF address was wrong, I fixed it as well

C4/Circulation.pm
installer/data/mysql/updatedatabase.pl
offline_circ/list.pl
offline_circ/process.pl
offline_circ/process_koc.pl
offline_circ/service.pl

index d44e862..1a156d9 100644 (file)
@@ -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 {
index cd1aa15..1fb812d 100755 (executable)
@@ -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:
@@ -4721,7 +4721,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);
 }
index 72d6dae..de129ff 100755 (executable)
 # 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);
 
index d814f74..86b5fda 100755 (executable)
 # 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;
index 6c48ffb..736d918 100755 (executable)
@@ -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;
index 8d1dd5f..ce0ab4a 100755 (executable)
 # 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."
 }