From 0c66ac6702e2a8841ffa002ceabef2bca07aaa87 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Mon, 4 Aug 2008 22:50:01 -0500 Subject: [PATCH] Final patch for serials planning bugs This patch resolves bug 1580 and addresses the modification of firstacquidate as per hdl's comments. I have also removed some useless javascript from subscription-detail, and just reported the number of irregular issues there (previously was reporting nothing since the js was broken). Signed-off-by: Joshua Ferraro --- C4/Serials.pm | 2 - .../en/modules/serials/subscription-add.tmpl | 2 +- .../modules/serials/subscription-detail.tmpl | 63 +------------------ serials/subscription-add.pl | 9 +-- serials/subscription-detail.pl | 31 ++------- 5 files changed, 13 insertions(+), 94 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 8e17b73095..7e6147bbe2 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1262,8 +1262,6 @@ C<$date> is a C4::Dates object. sub ModNextExpected($$) { my ($subscriptionid,$date) = @_; - warn $subscriptionid; - warn $date->output('iso'); my $dbh = C4::Context->dbh; #FIXME: Would expect to only set planneddate, but we set both on new issue creation, so updating it here my $sth = $dbh->prepare('UPDATE serial SET planneddate=?,publisheddate=? WHERE subscriptionid=? AND status=?'); 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 2274624629..25e2f99393 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 @@ -892,6 +892,7 @@ function Check(f) { } $(document).ready(function() { +init_pattern(); set_num_pattern_from_template_vars(); @@ -902,7 +903,6 @@ $(document).ready(function() { irregularity_check(); -init_pattern(); $('#numberpattern').change( function() { reset_num_pattern(); }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl index 25241c4228..e9418cdca4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl @@ -24,61 +24,6 @@ var textbox = ''; } } -function irregularity(){ - var periodicity = ''; - switch(periodicity){ - case "1": - var names = new Array(_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday"),_("Sunday")); - break; - case "2": - - var names = new Array(); - - break; - case "3": - - var names = new Array(); - - break; - case "4": - - var names = new Array(); - - break; - case "5": - var names = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December")); - break; - case "6": - var names = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December")); - break; - case "7": - var names = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December")); - break; - case "8": - var names = new Array(_("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall")); - break; - case "9": - var names = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December")); - break; - case "10": - expected =1; - break; - default: - break; - } - - - var irregular = ''; - var irregarray = irregular.split('|'); - var irregtext = '

'; - for(var i=0;i -} - function confirm_deletion() { var is_confirmed = confirm(_("Are you sure you want to delete this subscription?")); if (is_confirmed) { @@ -241,13 +186,11 @@ function popup(subscriptionid) { - -

-

+ +

issues

-

- +

diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 7853f9d7af..b2cf3a8f2a 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -116,10 +116,8 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { $irregularity = $subs->{'irregularity'}; $numberpattern = $subs->{'numberpattern'}; $nextexpected = GetNextExpected($subscriptionid); - $nextexpected->{ isfirstissue => ($nextexpected->{planneddate}->output('iso') eq $firstissuedate)}; - # firstacquidate is taken to be the upcoming issue's planned date if we're modifying the sub + $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate}->output('iso') eq $firstissuedate ; $subs->{nextacquidate} = $nextexpected->{planneddate}->output() if($op eq 'mod'); - unless($op eq 'modsubscription') { if($subs->{numberlength} > 0){ $sublength = $subs->{numberlength}; @@ -287,11 +285,10 @@ if ($op eq 'addsubscription') { 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. - # Here firstacquidate is interpreted as nextacquidate. - if ( $nextacquidate ne $nextexpected->{planneddate}->output('iso') ) { ModNextExpected($subscriptionid,C4::Dates->new($nextacquidate,'iso')); - $firstissuedate = $nextexpected->{planneddate}->output('iso') if($nextexpected->{isfirstissue}); + # if we have not received any issues yet, then we also must change the firstacquidate for the subs. + $firstissuedate = $nextacquidate if($nextexpected->{isfirstissue}); } if ($history_only) { diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 6d4d202030..4ab552194c 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -64,24 +64,6 @@ my ($user, $sessionID, $flags); ($user, $cookie, $sessionID, $flags) = checkauth($query, 0, {catalogue => 1}, "intranet"); -my $weekarrayjs=''; -my $count = 0; -my ($year, $month, $day) = Today; -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){ - $count = $i; - if($wkno > 52){$year++; $wkno=1;} - if($count>365){$count=$i-365;} - my ($y,$m,$d) = Add_Delta_Days($year,1,1, $count - 1);#Date_NthDayOfYear($year,$count); - # padding Add_Delta_Days; - my $output = sprintf("%04d-%02d-%02d",$y , $m, $d ); - $weekarrayjs .= "'Wk $wkno: ".format_date($output)."',"; - $wkno++; - } -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}); @@ -110,13 +92,12 @@ $template->param( C4::Context->userenv->{flags} !=1 && C4::Context->userenv->{branch} && $subs->{branchcode} && (C4::Context->userenv->{branch} ne $subs->{branchcode})), + "periodicity".($subs->{periodicity}?$subs->{periodicity}:'0') => 1, + "arrival".$subs->{dow} => 1, + "numberpattern".$subs->{numberpattern} => 1, + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + irregular_issues => scalar(split(/,/,$subs->{irregularity})), ); -$template->param( - "periodicity".($subs->{periodicity}?$subs->{periodicity}:'0') => 1, - "arrival".$subs->{dow} => 1, - "numberpattern".$subs->{numberpattern} => 1, - intranetstylesheet => C4::Context->preference("intranetstylesheet"), - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), - ); output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5