3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
20 use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days);
24 use C4::Dates qw/format_date format_date_in_iso/;
28 use C4::Branch; # GetBranches
35 my $dbh = C4::Context->dbh;
37 my ($template, $loggedinuser, $cookie)
38 = get_template_and_user({template_name => "serials/subscription-history.tmpl",
42 flagsrequired => {serials => 'edit_subscription'},
46 my $subscriptionid = $query->param('subscriptionid');
47 my $modhistory = $query->param('modhistory');
48 my $subs = &GetSubscription($subscriptionid);
50 ## FIXME : Check rights to edit if mod. Could/Should display an error message.
51 if ($subs->{'cannotedit'}){
52 warn "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
53 print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
56 # Modifications has been sent
58 my $histstartdate = format_date_in_iso($query->param('histstartdate'));
59 my $histenddate = format_date_in_iso($query->param('histenddate'));
60 my $recievedlist = $query->param('recievedlist');
61 my $missinglist = $query->param('missinglist');
62 my $opacnote = $query->param('opacnote');
63 my $librariannote = $query->param('librariannote');
64 my $return = ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
65 $template->param(success => 1) if ($return == 1);
67 # Getting modified data
68 $subs = &GetSubscription($subscriptionid);
72 for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
73 # TODO : Handle date formats properly.
74 if ($subs->{$_} eq '0000-00-00') {
77 $subs->{$_} = format_date($subs->{$_});
81 $template->param($subs);
82 $template->param(history => ($subs->{manualhistory} == 1 ));
85 output_html_with_http_headers $query, $cookie, $template->output;