[Koha-patches] [PATCH] Final patch for serials planning bugs

Ryan Higgins rch at liblime.com
Tue Aug 5 05:50:01 CEST 2008


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).
---
 C4/Serials.pm                                      |    2 -
 .../prog/en/modules/serials/subscription-add.tmpl  |    2 +-
 .../en/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 8e17b73..7e6147b 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 2274624..25e2f99 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();
 <!-- TMPL_IF name="mod" -->
     set_num_pattern_from_template_vars();
     <!-- TMPL_IF name="hemisphere" -->
@@ -902,7 +903,6 @@ $(document).ready(function() {
 <!-- TMPL_IF name="irregularity" -->
     irregularity_check();
 <!-- /TMPL_IF -->
-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 25241c4..e9418cd 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 = '<!-- TMPL_VAR NAME="periodicity"-->';
-    switch(periodicity){
-    case "1":
-        var names = new Array(_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday"),_("Sunday"));
-        break;
-    case "2":
-        <!-- TMPL_IF NAME="weekarrayjs" -->
-        var names = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->); 
-        <!-- /TMPL_IF -->
-        break;
-    case "3":
-        <!-- TMPL_IF NAME="weekarrayjs" -->
-        var names = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->); 
-        <!-- /TMPL_IF -->
-        break;
-    case "4":
-        <!-- TMPL_IF NAME="weekarrayjs" -->
-        var names = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->); 
-        <!-- /TMPL_IF -->
-        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;
-    }
-
-    <!-- TMPL_IF NAME="irregularity" -->
-    var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
-    var irregarray = irregular.split('|');
-    var irregtext = '<p>';
-    for(var i=0;i<irregarray.length;i++){
-        irregtext += names[i]+' &nbsp;';
-    }
-    irregtext += '</p>';
-    document.getElementById("irreg").innerHTML = irregtext;
-    <!-- /TMPL_IF -->
-}
-
 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) {
             <!--/TMPL_IF-->
             </tr>
             </table>
-            <!-- TMPL_IF NAME="irregularity" -->
-            <p><label>Irregularity:</label>
-                <div id="irreg"></div>
+            <!-- TMPL_IF NAME="irregular_issues" -->
+            <p><label>Irregularity:</label> <!-- TMPL_VAR name="irregular_issues" --> issues
             </p>
             <!-- /TMPL_IF -->
-            <p><label>First arrival:</label>
-                <!--TMPL_VAR name="firstacquidate" -->
+            <p><label>First arrival:</label> <!--TMPL_VAR name="firstacquidate" -->
             </p>
         <!-- TMPL_IF name="numberlength" --><p><label>Number of issues:</label> <!-- TMPL_VAR name="numberlength" --></p><!-- /TMPL_IF -->
         <!-- TMPL_IF name="weeklength" --><p><label>Number of weeks:</label> <!-- TMPL_VAR name="weeklength" --></p><!-- /TMPL_IF -->
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index 7853f9d..b2cf3a8 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 6d4d202..4ab5521 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;
-- 
1.5.5.GIT




More information about the Koha-patches mailing list