bug 4036: do not count item overdue if it is due today
[koha_fer] / reports / issues_stats.pl
index 11ecc77..d1c0a04 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; FIXME - Bug 2505
 
 use CGI;
 use Date::Manip;
@@ -66,7 +67,7 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({
        query => $input,
        type => "intranet",
        authnotrequired => 0,
-       flagsrequired => {reports => 1},
+       flagsrequired => {reports => '*'},
        debug => 0,
 });
 our $sep     = $input->param("sep");
@@ -137,19 +138,6 @@ for my $itype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{des
        push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{description} } ;
 }
 
-my $branches=GetBranches();
-my @branchloop;
-foreach (sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches) {
-       my $thisbranch = ''; # FIXME 
-       my %row = (
-               branchcode => $_,
-               selected => ($thisbranch eq $_ ? 1 : 0),
-               code => $branches->{$_}->{'branchcode'},
-               description => $branches->{$_}->{'branchname'},
-       );
-       push @branchloop, \%row;
-}
-
     # location list
 my @locations;
 foreach (sort keys %$locations) {
@@ -178,7 +166,7 @@ $template->param(
        itemtypeloop => \@itemtypeloop,
        locationloop => \@locations,
           ccodeloop => \@ccodes,
-         branchloop => \@branchloop,
+         branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}),
        hassort1=> $hassort1,
        hassort2=> $hassort2,
        Bsort1 => $Bsort1,
@@ -350,8 +338,8 @@ sub calculate {
        } else {
                $colfield = $column;
        }
-       $colorder = ($colfield =~ /dayname/) ? "weekday($line)" :
-                               ($colfield =~ /^month/ ) ? "  month($line)" : $colfield;
+       $colorder = ($colfield =~ /dayname/) ? "weekday($column)" :
+                               ($colfield =~ /^month/ ) ? "  month($column)" : $colfield;
        my $strsth2 = "SELECT distinctrow $colfield FROM statistics, ";
        # get stats on items if ccode or location, otherwise borrowers.
        $strsth2 .= ($colsource eq 'items' ) ?