(bug #4319) allow reserves on waiting items
[koha.git] / catalogue / recentacquisitions.pl
1 #!/usr/bin/perl
2
3 #attention fichier pour notices MARC21
4
5 use strict;
6 use warnings;
7
8 use C4::Context;
9 use C4::Search;
10 use MARC::File::XML;
11 #use XML::LibXML;
12 #use XML::LibXSLT;
13 use CGI;
14 use C4::Dates;
15 use Date::Calc;
16 use C4::Auth;
17 use C4::Output;
18 use C4::Koha;
19
20 my $query= new CGI;
21 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
22     {
23         template_name   => "catalogue/recentacquisitions.tmpl",
24         query           => $query,
25         type            => "intranet",
26         authnotrequired => 0,
27         flagsrequired   => {catalogue => 1},
28         debug           => 1,
29     }
30 );
31
32 my $op = $query->param('op') || '';
33 if ($op eq "show_list"){
34
35     my $datebegin           = C4::Dates->new($query->param('datebegin'));
36     my $dateend             = C4::Dates->new($query->param('dateend')) if ($query->param('dateend'));
37
38     my $orderby             = $query->param('orderby') if ($query->param('orderby'));
39     my $criteria            = $query->param('criteria');
40     my @itemtypes           = $query->param('itemtypes');
41     
42     
43     my $loopacquisitions = SearchAcquisitions($datebegin, $dateend, \@itemtypes,
44                                                 $criteria, $orderby);
45     
46     $template->param(loopacquisitions=>$loopacquisitions,
47                      show_list=>1);
48 } else {
49     my $period      = C4::Context->preference("recentacquisitionregularPeriod")||30;
50     my $dateend     = C4::Dates->new();
51     #warn " dateend :".$dateend->output("syspref");
52     my @dateend     = Date::Calc::Today;
53     my @datebegin   = Date::Calc::Add_Delta_Days(@dateend,-$period) if ($period);
54     my $datebegin   = C4::Dates->new(sprintf("%04d-%02d-%02d",@datebegin[0..2]),'iso');
55     #warn 'datebegin :'.$datebegin->output("syspref")." dateend :".$dateend->output("syspref");
56     my $itemtypes   = GetItemTypes;
57     
58     my @itemtypesloop;
59     my $selected=1;
60     my $cnt;
61     my $imgdir = getitemtypeimagesrc();
62     
63     foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
64         my %row =(  number=>$cnt++,
65                     imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"",
66                     code => $thisitemtype,
67                     selected => $selected,
68                     description => $itemtypes->{$thisitemtype}->{'description'},
69                     count5 => $cnt % 4,
70                 );
71         $selected = 0 if ($selected) ;
72         push @itemtypesloop, \%row;
73     }
74     
75     $template->param(datebegin  => $datebegin->output("syspref"),
76                      dateend    => $dateend->output("syspref"),);
77     $template->param(period                   => $period,
78                      itemtypeloop             => \@itemtypesloop,
79                      DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),        
80                     );
81           
82 }
83 output_html_with_http_headers $query, $cookie, $template->output;
84