Bug 32648: Avoid skipping record or hiding item
[srvgit] / offline_circ / download.pl
index 95c2aea..ad120fd 100755 (executable)
@@ -4,31 +4,29 @@
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# 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
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY 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, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
-use CGI;
-use JSON;
-use C4::Auth;
+use CGI qw ( -utf8 );
+use JSON qw( to_json );
+use C4::Auth qw( checkauth );
 use C4::Output;
 use C4::Context;
 use C4::Koha;
 
-my $query = new CGI;
-my ( $template, $loggedinuser, $cookie, $flags ) =
-  checkauth( $query, undef, { circulate => "circulate_remaining_permissions" },
+my $query = CGI->new;
+checkauth( $query, undef, { circulate => "circulate_remaining_permissions" },
     "intranet" );
 
 my $page     = $query->param('page') || 0;
@@ -38,8 +36,9 @@ my $req_data = $query->param('data') || '';
 my $patrons_query = q{SELECT
     borrowers.borrowernumber, cardnumber, surname, firstname, title,
     othernames, initials, streetnumber, streettype, address, address2, city,
-    state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode,
-    categorycode, dateenrolled, dateexpiry, gonenoaddress, lost, debarred,
+    state, zipcode, country, email, phone, mobile, fax, dateofbirth, borrowers.branchcode,
+    categorycode, dateenrolled, dateexpiry, COALESCE(gonenoaddress, 0) AS gonenoaddress,
+    COALESCE(lost, 0) AS lost, debarred,
     debarredcomment, SUM(accountlines.amountoutstanding) AS fine
     FROM borrowers
     LEFT JOIN accountlines ON borrowers.borrowernumber=accountlines.borrowernumber
@@ -67,7 +66,8 @@ my $issues_query = q{SELECT
     items.itemcallnumber AS callnumber,
     issues.date_due AS date_due,
     issues.issuedate AS issuedate,
-    issues.renewals AS renewals,
+    issues.renewals_count AS renewals,
+    issues.unseen_renewals AS unseen_renewals,
     borrowers.cardnumber AS cardnumber,
     CONCAT(borrowers.surname, ', ', borrowers.firstname) AS borrower_name
     FROM issues