X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=serials%2Fsubscription-add.pl;h=10bccd187fb64450818954cbed6b779344d31282;hb=fb8aa63f9d9f56bf80ffab7b6e45b8cadb66ddf4;hp=9acee7b56bebe337a99b972d458444be814268a7;hpb=8ae5719d1681ffb5bf3dc803de5b80a39b6f3a68;p=koha_fer diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 9acee7b56b..10bccd187f 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -34,7 +34,7 @@ use Carp; #use Smart::Comments; -my $query = CGI->new; +our $query = CGI->new; my $op = $query->param('op') || ''; my $dbh = C4::Context->dbh; my $sub_length; @@ -63,8 +63,7 @@ my @subscription_types = ( my @sub_type_data; my $subs; -my $firstissuedate; -my $nextexpected; +our $firstissuedate; if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { @@ -75,7 +74,7 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); } - $firstissuedate = $subs->{firstacquidate}; # in iso format. + $firstissuedate = $subs->{firstacquidate} || ''; # in iso format. for (qw(startdate firstacquidate histstartdate enddate histenddate)) { next unless defined $subs->{$_}; # TODO : Handle date formats properly. @@ -89,11 +88,11 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { $subs->{letter}= q{}; } letter_loop($subs->{'letter'}, $template); - $nextexpected = GetNextExpected($subscriptionid); + my $nextexpected = GetNextExpected($subscriptionid); $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate}->output('iso') eq $firstissuedate ; $subs->{nextacquidate} = $nextexpected->{planneddate}->output() if($op eq 'modify'); unless($op eq 'modsubscription') { - foreach my $length_unit qw(numberlength weeklength monthlength){ + foreach my $length_unit (qw(numberlength weeklength monthlength)) { if ($subs->{$length_unit}){ $sub_length=$subs->{$length_unit}; $sub_on=$length_unit; @@ -113,6 +112,12 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { firstacquiyear => substr($firstissuedate,0,4), ); } + + if ( $op eq 'dup' ) { + my $dont_copy_fields = C4::Context->preference('SubscriptionDuplicateDroppedInput'); + my @fields_id = map { fieldid => $_ }, split '\|', $dont_copy_fields; + $template->param( dont_export_field_loop => \@fields_id ); + } } my $onlymine=C4::Context->preference('IndependantBranches') && @@ -134,11 +139,9 @@ for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{b my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'}); $template->param(branchloop => $branchloop, - DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), locations_loop=>$locations_loop, ); # prepare template variables common to all $op conditions: -$template->param( 'dateformat_' . C4::Context->preference('dateformat') => 1 ); if ($op!~/^mod/) { letter_loop(q{}, $template); } @@ -170,6 +173,7 @@ if ($op eq 'addsubscription') { $template->param(bibliotitle => $bib->{title}); } } + $template->param((uc(C4::Context->preference("marcflavour"))) => 1); output_html_with_http_headers $query, $cookie, $template->output; } @@ -326,6 +330,7 @@ sub redirect_mod_subscription { my $opacdisplaycount = $query->param('opacdisplaycount'); my $graceperiod = $query->param('graceperiod') || 0; my $location = $query->param('location'); + my $nextexpected = GetNextExpected($subscriptionid); # 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'));