From ceb1eafa76b99b9136c7f1a6b617051fa5279195 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Wed, 28 Apr 2010 14:42:25 +0200 Subject: [PATCH] MT3421: Moves subscription history in a separate page --- .../prog/en/includes/serials-menu.inc | 3 + .../en/modules/serials/subscription-add.tmpl | 41 --------- .../modules/serials/subscription-history.tmpl | 73 ++++++++++++++++ serials/subscription-add.pl | 5 -- serials/subscription-history.pl | 84 +++++++++++++++++++ 5 files changed, 160 insertions(+), 46 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tmpl create mode 100755 serials/subscription-history.pl diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc index 88e32e3db2..d347cb8e09 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc @@ -8,6 +8,9 @@
  • &op=new">Create Routing List
  • + +
  • ">Subscription history
  • + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl index 27ce4d7015..46785ddac4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl @@ -1349,47 +1349,6 @@ $(document).ready(function() { - -
    -

    Subscription history

    -
    - - " /> - -

    Hint : you can update the serial history manually. This can be useful for an old subscription or to clean the existing history. Modify these fields with care, as future serial receive will continue to update them automatically.

    -
    -
      -
    1. - - " />
      (start date of the 1st subscription)
      -
    2. -
    3. - - " />
      (if empty, subscription is still active)
      -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. -
    -
    -
    -
    -
    - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tmpl new file mode 100644 index 0000000000..8ab7557a02 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tmpl @@ -0,0 +1,73 @@ + +Koha › Serials › <!-- TMPL_VAR name="bibliotitle" escape="html" --> › Modify subscription history + + + + + + + + + +
    + +
    +
    +
    + + + + +

    The subscription history has been successfully modified.

    + +

    The subscription history could not be modified.

    + + +
    +

    Subscription history

    +
    + + " /> +

    Hint : you can update the serial history manually. This can be useful for an old subscription or to clean the existing history. Modify these fields with care, as future serial receive will continue to update them automatically.

    +
    +
      +
    1. + + " />
      (start date of the 1st subscription)
      +
    2. +
    3. + + " />
      (if empty, subscription is still active)
      +
    4. +
    5. + + +
    6. +
    7. + + +
    8. +
    9. + + +
    10. +
    11. + + +
    12. +
    +
    +
    +
    +
    + +

    Manual history is not enabled for this subscription.

    + +
    +
    + +
    + +
    +
    + diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 57902cab33..d56392f7be 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -278,7 +278,6 @@ if ($op eq 'addsubscription') { my $missinglist = $query->param('missinglist'); my $opacnote = $query->param('opacnote'); my $librariannote = $query->param('librariannote'); - my $history_only = $query->param('history_only'); # If it's a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary. if ( $nextacquidate ne $nextexpected->{planneddate}->output('iso') ) { ModNextExpected($subscriptionid,C4::Dates->new($nextacquidate,'iso')); @@ -286,9 +285,6 @@ if ($op eq 'addsubscription') { $firstissuedate = $nextacquidate if($nextexpected->{isfirstissue}); } - if ($history_only) { - ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote); - } else { &ModSubscription( $auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, $periodicity, $firstissuedate, @@ -302,7 +298,6 @@ if ($op eq 'addsubscription') { $notes, $letter, $hemisphere, $manualhistory,$internalnotes, $serialsadditems, $subscriptionid, ); - } print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); } else { diff --git a/serials/subscription-history.pl b/serials/subscription-history.pl new file mode 100755 index 0000000000..5f3122a6c4 --- /dev/null +++ b/serials/subscription-history.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +# 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 2 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 + +use strict; +use CGI; +use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days); +use C4::Koha; +use C4::Biblio; +use C4::Auth; +use C4::Dates qw/format_date format_date_in_iso/; +use C4::Acquisition; +use C4::Output; +use C4::Context; +use C4::Branch; # GetBranches +use C4::Serials; +use C4::Letters; + +#use Smart::Comments; + +my $query = new CGI; +my $dbh = C4::Context->dbh; + +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "serials/subscription-history.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {serials => 'edit_subscription'}, + debug => 1, + }); + + my $subscriptionid = $query->param('subscriptionid'); + my $modhistory = $query->param('modhistory'); + my $subs = &GetSubscription($subscriptionid); + +## FIXME : Check rights to edit if mod. Could/Should display an error message. + if ($subs->{'cannotedit'}){ + warn "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; + print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); + } + + + for (qw(startdate firstacquidate histstartdate enddate histenddate)) { + # TODO : Handle date formats properly. + if ($subs->{$_} eq '0000-00-00') { + $subs->{$_} = '' + } else { + $subs->{$_} = format_date($subs->{$_}); + } + } + + + $template->param($subs); + $template->param( + history => ($subs->{manualhistory} == 1 ), + ); + + + if ($modhistory) { + my $histstartdate = format_date_in_iso($query->param('histstartdate')); + my $histenddate = format_date_in_iso($query->param('histenddate')); + my $recievedlist = $query->param('recievedlist'); + my $missinglist = $query->param('missinglist'); + my $opacnote = $query->param('opacnote'); + my $librariannote = $query->param('librariannote'); + my $return = ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote); + $template->param(success => 1) if ($return == 1); + } + + output_html_with_http_headers $query, $cookie, $template->output; -- 2.20.1