removing useless line (use Data::Dumper)
[koha.git] / circ / branchoverdues.pl
index 2503283..a09f5d3 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 #
 # This file is part of Koha.
 #
 use strict;
 use C4::Context;
 use CGI;
-use C4::Interface::CGI::Output;
+use C4::Output;
 use C4::Auth;
-use C4::Date;
-use C4::Circulation::Circ2;    # AddNotifyLine
-use C4::Koha;                  # GetDepartment...
-use Mail::Sendmail;
-use Getopt::Long;
-use Date::Calc qw/Today Today_and_Now Now/;
+use C4::Dates qw/format_date/;
+use C4::Overdues;    # AddNotifyLine
+use C4::Biblio;
+use C4::Koha;
+use C4::Debug;
 
 =head1 branchoverdues.pl
 
  this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
- this interface is filtered by branches (automaticly), and by department (optional) ....
+ this interface is filtered by branches (automatically), and by location (optional) ....
  all informations are stocked in the notifys BDD
 
  FIXME for this time, we have only four methods to notify :
@@ -55,6 +53,8 @@ use Date::Calc qw/Today Today_and_Now Now/;
 =cut
 
 my $input       = new CGI;
+my $dbh = C4::Context->dbh;
+
 my $theme = $input->param('theme');    # only used if allowthemeoverride is set
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -63,24 +63,20 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { circulate => 1 },
+        flagsrequired   => { circulate => "circulate_remaining_permissions" },
         debug           => 1,
     }
 );
 
 my $default = C4::Context->userenv->{'branch'};
 
-# Initate localtime
-my ( $year, $month, $day ) = &Today;
-my $todaysdate = join "-", ( $year, $month, $day );
-
 # Deal with the vars recept from the template
 my $borrowernumber = $input->param('borrowernumber');
 my $itemnumber     = $input->param('itemnumber');
 my $method         = $input->param('method');
 my $overduelevel   = $input->param('overduelevel');
 my $notifyId       = $input->param('notifyId');
-my $department = $input->param('department');
+my $location       = $input->param('location');
 
 # now create the line in bdd (notifys)
 if ( $input->param('action') eq 'add' ) {
@@ -88,9 +84,7 @@ if ( $input->param('action') eq 'add' ) {
       AddNotifyLine( $borrowernumber, $itemnumber, $overduelevel, $method,
         $notifyId );
 }
-
-#  possibility to remove notify line
-if ( $input->param('action') eq 'remove' ) {
+elsif ( $input->param('action') eq 'remove' ) {
     my $notify_date  = $input->param('notify_date');
     my $removenotify =
       RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );
@@ -100,30 +94,16 @@ my @overduesloop;
 my @todayoverduesloop;
 my $counter = 0;
 
-my @getoverdues = GetOverduesForBranch( $default, $department );
-
-# filter by department
-if ($department) {
-    my ( $departmentlib, $departmentValue ) = GetDepartmentLib($department);
-    $template->param(
-        department      => $departmentlib,
-        departmentValue => $departmentValue,
-    );
+my @getoverdues = GetOverduesForBranch( $default, $location );
+use Data::Dumper;
+$debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
+# search for location authorised value
+my ($tag,$subfield) = GetMarcFromKohaField('items.location','');
+my $tagslib = &GetMarcStructure(1,'');
+if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
+    my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
+    $template->param(locationsloop => $values);
 }
-else {
-
-    # initiate the selector of departments .....
-    my @getdepartments = GetDepartments();
-    my @departmentsloop;
-    foreach my $dpt (@getdepartments) {
-        my %department;
-        $department{'authorised_value'} = $dpt->{'authorised_value'};
-        $department{'lib'}              = $dpt->{'lib'};
-        push( @departmentsloop, \%department );
-    }
-    $template->param( departmentsloop => \@departmentsloop, );
-}
-
 # now display infos
 foreach my $num (@getoverdues) {
 
@@ -164,7 +144,8 @@ foreach my $num (@getoverdues) {
 # initiate the templates for the overdueloop
 $template->param(
     overduesloop => \@overduesloop,
-    show_date    => format_date($todaysdate),
+    show_date    => format_date(C4::Dates->today('iso')),
+    location     => $location,
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;