From a5746c616a1ee15b80614ce0de81d6c415236319 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 4 Dec 2007 17:40:51 -0600 Subject: [PATCH] serials subdir - Dates.pm integration and warnings fixes. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- serials/acqui-search-result.pl | 2 +- serials/acqui-search.pl | 2 +- serials/checkexpiration.pl | 10 ++++----- serials/distributedto.pl | 2 +- serials/reorder_members.pl | 2 +- serials/routing-preview.pl | 2 +- serials/routing.pl | 2 +- serials/serial-issues.pl | 2 +- serials/serials-collection.pl | 2 +- serials/serials-edit.pl | 2 +- serials/serials-recieve.pl | 35 +++++++++++++---------------- serials/statecollection.pl | 2 +- serials/subscription-add.pl | 13 +++++------ serials/subscription-copy.pl | 21 ++++++++--------- serials/subscription-detail.pl | 41 ++++++++++++++-------------------- serials/subscription-renew.pl | 2 +- 16 files changed, 65 insertions(+), 77 deletions(-) diff --git a/serials/acqui-search-result.pl b/serials/acqui-search-result.pl index 09a5d962a8..c943eb9416 100755 --- a/serials/acqui-search-result.pl +++ b/serials/acqui-search-result.pl @@ -47,7 +47,7 @@ use CGI; use C4::Acquisition; -use C4::Date; +use C4::Dates; use C4::Bookseller; my $query=new CGI; diff --git a/serials/acqui-search.pl b/serials/acqui-search.pl index 60a85d18d2..7461a8a139 100755 --- a/serials/acqui-search.pl +++ b/serials/acqui-search.pl @@ -72,7 +72,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { #currencies my @rates = GetCurrencies(); -my $count = scalar @rates; +$count = scalar @rates; my @loop_currency = (); for ( my $i = 0 ; $i < $count ; $i++ ) { diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index aaf4df54e2..374c94b933 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -48,7 +48,7 @@ use C4::Auth; use C4::Serials; # GetExpirationDate use C4::Output; use C4::Context; -use C4::Date; +use C4::Dates; use Date::Calc qw/Today Date_to_Days/; my $query = new CGI; @@ -67,10 +67,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( my $title = $query->param('title'); my $issn = $query->param('issn'); my $date = format_date_in_iso($query->param('date')); -my $today = join "-",&Today; if ($date) { - my @subscriptions = GetSubscriptions( $title, $issn ); my @subscriptions_loop; @@ -79,9 +77,9 @@ if ($date) { my $expirationdate = GetExpirationDate($subscriptionid); $subscription->{expirationdate} = $expirationdate; - next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in good format. + next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format. if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) && - Date_to_Days(split "-",$expirationdate) > Date_to_Days(split "-",$today) ) { + Date_to_Days(split "-",$expirationdate) > Date_to_Days(&Today) ) { $subscription->{expirationdate}=format_date($subscription->{expirationdate}); push @subscriptions_loop,$subscription; } @@ -97,6 +95,6 @@ if ($date) { ); } $template->param ( - DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(), + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/serials/distributedto.pl b/serials/distributedto.pl index d90f80775a..af4088b354 100755 --- a/serials/distributedto.pl +++ b/serials/distributedto.pl @@ -48,7 +48,7 @@ to know what subscription this scrpit have to distribute. use strict; use CGI; -use C4::Date; +use C4::Dates; use C4::Auth; use C4::Context; use C4::Output; diff --git a/serials/reorder_members.pl b/serials/reorder_members.pl index dd083e50ba..d118f94d66 100755 --- a/serials/reorder_members.pl +++ b/serials/reorder_members.pl @@ -10,7 +10,7 @@ use C4::Auth; use C4::Context; use C4::Output; use C4::Koha; -use C4::Date; +use C4::Dates; use C4::Acquisition; use C4::Serials; diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index 06fa34cbad..9f11ec7a1a 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -7,7 +7,7 @@ use strict; use CGI; use C4::Koha; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Output; use C4::Acquisition; use C4::Reserves; diff --git a/serials/routing.pl b/serials/routing.pl index c612a78d93..e739a2d12c 100755 --- a/serials/routing.pl +++ b/serials/routing.pl @@ -29,7 +29,7 @@ use strict; use CGI; use C4::Koha; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Output; use C4::Acquisition; use C4::Output; diff --git a/serials/serial-issues.pl b/serials/serial-issues.pl index 3412d178ef..127d4c55c0 100755 --- a/serials/serial-issues.pl +++ b/serials/serial-issues.pl @@ -45,7 +45,7 @@ use strict; use CGI; use C4::Auth; use C4::Koha; -use C4::Date; +use C4::Dates; use C4::Serials; use C4::Output; use C4::Context; diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index b6a9aec6c7..c24cf9e19f 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -22,7 +22,7 @@ use strict; use CGI; use C4::Auth; use C4::Koha; -use C4::Date; +use C4::Dates; use C4::Serials; use C4::Letters; use C4::Output; diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index b57bc578fc..5bc4f8faf6 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -65,7 +65,7 @@ op can be : use strict; use CGI; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Biblio; use C4::Koha; use C4::Output; diff --git a/serials/serials-recieve.pl b/serials/serials-recieve.pl index b64a6ae5e6..f743e71298 100755 --- a/serials/serials-recieve.pl +++ b/serials/serials-recieve.pl @@ -65,7 +65,7 @@ op can be : use strict; use CGI; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Biblio; use C4::Koha; use C4::Output; @@ -195,8 +195,8 @@ my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId(); $sth->execute($subscriptionid); my $solhistory = $sth->fetchrow_hashref; -my $subs = &GetSubscription($subscriptionid); -my ($totalissues,@serialslist) = GetSerials($subscriptionid); +$subs = &GetSubscription($subscriptionid); +($totalissues,@serialslist) = GetSerials($subscriptionid); if (C4::Context->preference("serialsadditems")){ my $fwk=GetFrameworkCode($subscription->{biblionumber}); @@ -216,13 +216,13 @@ if (C4::Context->preference("serialsadditems")){ } my $itemstatushash = GetItemStatus($fwk); my @itemstatusloop; - my $itemstatusloopcount=0; + my $itemstatusloopcount=0; foreach my $thisitemstatus (keys %$itemstatushash) { my %row =(itemval => $thisitemstatus, itemlib => $itemstatushash->{$thisitemstatus}, ); # warn "".$row{'itemval'}.", ". $row{"itemlib"}; - $itemstatusloopcount++; + $itemstatusloopcount++; push @itemstatusloop, \%row; } my $itemlocationhash = GetItemLocation($fwk); @@ -234,29 +234,26 @@ if (C4::Context->preference("serialsadditems")){ push @itemlocationloop, \%row; } - my $choice = 0; - if($itemstatusloopcount == 1){ $choice = 1;} - foreach my $data (@serialslist){ - if (scalar(@itemstatusloop)){$data->{"itemstatusloop"}=\@itemstatusloop;} - else { $data->{"itemstatusloop"}=[];} - if (scalar(@itemlocationloop)){$data->{"itemlocationloop"}=\@itemlocationloop;} - else {$data->{"itemlocationloop"}=[];} - $data->{"branchloop"}=\@branchloop ; - } + my $choice = ($itemstatusloopcount == 1) ? 1 : 0; + foreach my $data (@serialslist){ + $data->{"itemstatusloop"} = (scalar(@itemstatusloop )) ? \@itemstatusloop : []; + $data->{"itemlocationloop"} = (scalar(@itemlocationloop)) ? \@itemlocationloop : []; + $data->{"branchloop"} = \@branchloop ; + } # warn "Choice: $choice"; $template->param(choice => $choice); $template->param(serialadditems =>C4::Context->preference("serialsadditems"), branchloop => \@branchloop, ) ; - $template->param(itemstatus=>1,itemstatusloop=>\@itemstatusloop) if (scalar(@itemstatusloop)); - $template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop)); -}else{ + $template->param( itemstatus=>1, itemstatusloop=>\@itemstatusloop ) if (scalar(@itemstatusloop )); + $template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop)); +} else { $template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ; } -my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId(); +$sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId(); $sth->execute($subscriptionid); -my $solhistory = $sth->fetchrow_hashref; +$solhistory = $sth->fetchrow_hashref; $template->param( user => $auser, diff --git a/serials/statecollection.pl b/serials/statecollection.pl index fc928eea65..1e26fed341 100755 --- a/serials/statecollection.pl +++ b/serials/statecollection.pl @@ -19,7 +19,7 @@ use strict; use CGI; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Output; use C4::Context; use C4::Serials; diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 2388e97548..7b407e8640 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -20,7 +20,7 @@ use CGI; use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days); use C4::Koha; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Acquisition; use C4::Output; use C4::Context; @@ -53,7 +53,7 @@ my ($template, $loggedinuser, $cookie) my $weekarrayjs=''; my $count = 0; my ($year, $month, $day) = Today; -my $firstday = Day_of_Year($year,$month,$day); +my $firstday = Day_of_Year($year,$month,$day); my ($wkno,$yr) = Week_of_Year($year,$month,$day); # week starting monday my $weekno = $wkno; for(my $i=$firstday;$i<($firstday+365);$i=$i+7){ @@ -101,7 +101,7 @@ foreach my $thisbranch (keys %$branches) { push @branchloop, \%row; } $template->param(branchloop => \@branchloop, - DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(), + DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), ); if ($op eq 'mod'||$op eq 'dup') { @@ -114,10 +114,9 @@ if ($op eq 'mod'||$op eq 'dup') { 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"); } - $subs->{'startdate'}=format_date($subs->{'startdate'}); - $subs->{'firstacquidate'}=format_date($subs->{'firstacquidate'}); - $subs->{'histstartdate'}=format_date($subs->{'histstartdate'}); - $subs->{'enddate'}=format_date($subs->{enddate}); + for (qw(startdate firstacquidate histstartdate enddate)) { + $subs->{$_} = format_date($subs->{$_}); + } $subs->{'letter'}='' unless($subs->{'letter'}); if($subs->{numberlength} > 0){ diff --git a/serials/subscription-copy.pl b/serials/subscription-copy.pl index 83cb26fc68..65aa6165b9 100755 --- a/serials/subscription-copy.pl +++ b/serials/subscription-copy.pl @@ -6,7 +6,7 @@ use CGI; use C4::Koha; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Output; use C4::Acquisition; use C4::Context; @@ -19,14 +19,15 @@ my $dbh = C4::Context->dbh; my $subs = &GetSubscription($subscriptionid); # make newsubscription() -my $subscriptionid = old_newsubscription($subs->{'auser'},$subs->{'aqbooksellerid'},$subs->{'cost'},$subs->{'aqbudgetid'}, - $subs->{'biblionumber'},$subs->{'startdate'},$subs->{'periodicity'},$subs->{'firstacquidate'}, - $subs->{'dow'},$subs->{'irregularity'},$subs->{'numberpattern'},$subs->{'numberlength'}, - $subs->{'weeklength'},$subs->{'monthlength'},$subs->{'add1'},$subs->{'every1'}, - $subs->{'whenmorethan1'},$subs->{'setto1'},$subs->{'lastvalue1'},$subs->{'add2'}, - $subs->{'every2'},$subs->{'whenmorethan2'},$subs->{'setto2'},$subs->{'lastvalue2'},$subs->{'add3'}, - $subs->{'every3'},$subs->{'whenmorethan3'},$subs->{'setto3'},$subs->{'lastvalue3'}, - $subs->{'numberingmethod'},$subs->{'status'},$subs->{'notes'}, - ); +$subscriptionid = old_newsubscription( + $subs->{'auser'},$subs->{'aqbooksellerid'},$subs->{'cost'},$subs->{'aqbudgetid'}, + $subs->{'biblionumber'},$subs->{'startdate'},$subs->{'periodicity'},$subs->{'firstacquidate'}, + $subs->{'dow'},$subs->{'irregularity'},$subs->{'numberpattern'},$subs->{'numberlength'}, + $subs->{'weeklength'},$subs->{'monthlength'},$subs->{'add1'},$subs->{'every1'}, + $subs->{'whenmorethan1'},$subs->{'setto1'},$subs->{'lastvalue1'},$subs->{'add2'}, + $subs->{'every2'},$subs->{'whenmorethan2'},$subs->{'setto2'},$subs->{'lastvalue2'},$subs->{'add3'}, + $subs->{'every3'},$subs->{'whenmorethan3'},$subs->{'setto3'},$subs->{'lastvalue3'}, + $subs->{'numberingmethod'},$subs->{'status'},$subs->{'notes'}, +); print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 7110476b54..c1c465deec 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -19,7 +19,7 @@ use strict; use CGI; use C4::Auth; use C4::Koha; -use C4::Date; +use C4::Dates; use C4::Serials; use C4::Output; use C4::Context; @@ -31,27 +31,19 @@ my $op = $query->param('op'); my $dbh = C4::Context->dbh; my $sth; # my $id; -my ($template, $loggedinuser, $cookie, $subs); -my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity, - $firstacquidate, $dow, $irregularity, $sublength, $subtype, $numberpattern, $numberlength, $weeklength, $monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $biblionumber, $bibliotitle, $callnumber, $notes, $hemisphere,$letter,$manualhistory,$histstartdate,$enddate,$missinglist,$recievedlist,$opacnote,$librariannote); - -$subscriptionid = $query->param('subscriptionid'); +my ($template, $loggedinuser, $cookie, $hemisphere); +my $subscriptionid = $query->param('subscriptionid'); my $subs = &GetSubscription($subscriptionid); $subs->{enddate} = GetExpirationDate($subscriptionid); if ($op eq 'del') { - if ($subs->{'cannotedit'}){ - warn "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; - print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); - } - &DelSubscription($subscriptionid); - print "Content-Type: text/html\n\n"; - exit; - + if ($subs->{'cannotedit'}){ + warn "Attempt to delete subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; + print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); + } + &DelSubscription($subscriptionid); + print "Content-Type: text/html\n\n"; + exit; } my ($routing, @routinglist) = getroutinglist($subscriptionid); my ($totalissues,@serialslist) = GetSerials($subscriptionid); @@ -67,7 +59,8 @@ $totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscript debug => 1, }); -my ($user, $cookie, $sessionID, $flags) +my ($user, $sessionID, $flags); +($user, $cookie, $sessionID, $flags) = checkauth($query, 0, {catalogue => 1}, "intranet"); my $weekarrayjs=''; @@ -89,11 +82,11 @@ chop($weekarrayjs); # COMMENT hdl : IMHO, we should think about passing more and more data hash to template->param rather than duplicating code a new coding Guideline ? -$subs->{startdate}=format_date($subs->{startdate}); -$subs->{firstacquidate}=format_date($subs->{firstacquidate}); -$subs->{histstartdate}=format_date($subs->{histstartdate}); -$subs->{enddate}=format_date($subs->{enddate}); -$subs->{abouttoexpire}=abouttoexpire($subs->{subscriptionid}); +$subs->{startdate} = format_date($subs->{startdate}); +$subs->{firstacquidate} = format_date($subs->{firstacquidate}); +$subs->{histstartdate} = format_date($subs->{histstartdate}); +$subs->{enddate} = format_date($subs->{enddate}); +$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid}); # Done in Serials.pm # $subs->{'donotedit'}=(C4::Context->preference('IndependantBranches') && # C4::Context->userenv && diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl index f83eeba4e9..72b101b76e 100755 --- a/serials/subscription-renew.pl +++ b/serials/subscription-renew.pl @@ -49,7 +49,7 @@ require Exporter; use CGI; use C4::Koha; use C4::Auth; -use C4::Date; +use C4::Dates; use C4::Context; use C4::Auth; -- 2.39.5