From: Ryan Higgins Date: Mon, 4 Aug 2008 01:10:15 +0000 (-0500) Subject: Update serials planning javascript to properly deal with 3-level periodicity. ( Seria... X-Git-Tag: v3.00.00~86 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=db87e7d738a4f1f73eeafe963129289c41b56f98;p=koha.git Update serials planning javascript to properly deal with 3-level periodicity. ( Serials patch 2/3 ) Minor changes to dom object names and id's to allow for proper calculation of the base planning table from the simplified table. Prior to this patch, the base table was populated with the incorrect value, so patterns like Vol{X} No{Y} Issue{Z} incremented the Vol value incorrectly. Signed-off-by: Joshua Ferraro --- 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 c0f3c21ef0..f9573585c6 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 @@ -88,19 +88,21 @@ IrregularPattern.prototype.update = function() { // else irregular array is list of issues to skip var summary_str = ''; this.numskipped = 0; - for( var i in document.f.irregularity_select.options ) { - if( document.f.irregularity_select.options[i].selected ) { - this.skipped[cnt] = document.f.irregularity_select.options[i].value ; - summary_str += document.f.irregularity_select.options[i].text + "\n" ; - cnt++; - this.numskipped++; - } - } - var summary = document.getElementById("irregularity_summary"); - if(summary) { - summary.value = summary_str; - summary.rows= ( cnt > 6 ) ? cnt : 6 ; - } + if(document.f.irregularity_select) { + for( var i in document.f.irregularity_select.options ) { + if( document.f.irregularity_select.options[i].selected ) { + this.skipped[cnt] = document.f.irregularity_select.options[i].value ; + summary_str += document.f.irregularity_select.options[i].text + "\n" ; + cnt++; + this.numskipped++; + } + } + var summary = document.getElementById("irregularity_summary"); + if(summary) { + summary.value = summary_str; + summary.rows= ( cnt > 6 ) ? cnt : 6 ; + } + } } IrregularPattern.prototype.irregular = function(index) { @@ -223,7 +225,7 @@ var patternchoice = document.getElementById("numberpattern").value; document.f.setto1.value=0; document.f.setto2.value='1'; document.f.setto3.value=''; - document.f.lastvaluetemp1.value=sYear; + document.f.lastvalue1temp.value=sYear; document.f.periodicity.value='8'; document.f.numberingmethod.value=_("{Y} {X}"); moreoptions_seasons(text[15],sYear); @@ -295,7 +297,7 @@ var patternchoice = document.getElementById("numberpattern").value; default: } } - // document.f.lastvalue2.value=document.f.lastvaluetemp2.value; + // document.f.lastvalue2.value=document.f.lastvalue2temp.value; document.f.lastvalue3.value=''; document.f.numberingmethod.value=_("{X}/{Y}"); moreoptions(text[16],text[0]); @@ -371,14 +373,14 @@ function set_num_pattern_from_template_vars() { more_strZ="Z"; } - document.f.lastvaluetemp1.value=''; + document.f.lastvalue1temp.value=''; if(more_strY){ - document.f.lastvaluetemp2.value=''; - document.f.whenmorethantemp2.value=''; + document.f.lastvalue2temp.value=''; + document.f.whenmorethan2temp.value=''; } if(more_strZ){ - document.f.lastvaluetemp3.value=''; - document.f.whenmorethantemp3.value=''; + document.f.lastvalue3temp.value=''; + document.f.whenmorethan3temp.value=''; } } @@ -419,24 +421,24 @@ var textbox = ''; } } textbox +="<\/tr>\n"; - textbox +=""+text[5]+"<\/td><\/td>\n"; + textbox +=""+text[5]+"<\/td><\/td>\n"; if(y){ - textbox +="<\/td>\n"; + textbox +="<\/td>\n"; if(z){ - textbox +="<\/td>\n"; + textbox +="<\/td>\n"; } } textbox +="<\/tr>\n"; if(y){ textbox +=""+text[6]+"<\/th>"; textbox +=" <\/td>\n"; - textbox +="<\/td>\n"; + textbox +="<\/td>\n"; if(z){ - textbox +="<\/td>\n"; + textbox +="<\/td>\n"; } textbox +="<\/tr>"; } else { - textbox +=" "+_("issues expected")+""; + textbox +=" "+_("issues expected")+""; } textbox +="<\/table>\n"; } @@ -489,17 +491,17 @@ var textbox = ''; textbox +=" - - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
 <\/th>"+x+"<\/th>"; textbox +=""+text[16]+"<\/th>"; textbox +="<\/tr>\n"; - textbox +="
"+text[5]+"<\/th>
"+text[5]+"<\/th>
"+text[6]+"<\/th>"; - textbox +="<\/td>\n"; + textbox +="<\/td>\n"; textbox +="<\/tr><\/table>\n"; } @@ -514,11 +516,12 @@ function irregularity_check(){ rollover = document.f.whenmorethan2.value; } if((document.f.whenmorethan3) && document.f.whenmorethan3.value > 0 ){ - // FIXME: This assumes that whenmorethan3 issues are published in one year. - // the other option is that whenmorethan3 * whenmorethan2 issues are published, - // e.g. where there are two volumes of six issues each in one year. + // FIXME: Irregularity check assumes that the full prediction pattern repeats each year. + // In cases where the outermost periodicity is > 1 year, + // e.g. where a volume spans two years, the irregularity check will be incorrect, + // but you can safely ignore the check, submit the form, and the prediction pattern should be correct. // a way to distinguish between these two cases is needed. - rollover = document.f.whenmorethan3.value; + rollover = document.f.whenmorethan3.value * document.f.whenmorethan2.value; } var error=''; var toobig; @@ -787,28 +790,35 @@ else return true; } -function moreoptionsupdate(fieldnames,rollover){ - fieldname = fieldnames; - fld = fieldname.length; - fld = fld-1; - fieldnametempnumber = fieldname.substr(fld); - //alert(fieldnametempnumber); - fieldnametemp = fieldname.slice(0,-1)+"temp"+fieldnametempnumber; - // alert(fieldnametemp); - eval("document.f."+fieldname+".value = document.f."+fieldnametemp+".value"); -// alert (fieldname+" : "+eval("document.f."+fieldname+".value") +' '+fieldnametemp+' : ' +eval("document.f."+fieldnametemp+".value")); +function moreoptionsupdate(inputfield,rollover){ + fieldname = inputfield.name; + // find parent element in base table by stripping 'temp' from element name. + basefield = document.getElementById(fieldname.slice(0,-4)); + var fieldnumber = fieldname.slice(-5,-4); + +// fieldnametemp = fieldname.slice(0,-1)+"temp"+fieldnametempnumber; +// eval("document.f."+fieldname+".value = document.f."+fieldnametemp+".value"); + basefield.value = inputfield.value; var patternchoice = document.getElementById("numberpattern").value; switch(patternchoice){ case "2": case "4": case "5": case "8": - if (document.f.lastvaluetemp2.value>0){document.f.innerloop1.value = document.f.lastvaluetemp2.value - 1;} + if (document.f.lastvalue2temp.value>0){document.f.innerloop1.value = document.f.lastvalue2temp.value - 1;} break; } if(rollover){ - eval("document.f.every"+(fieldnametempnumber-1)+".value = document.f."+fieldnametemp+".value"); - } +// eval("document.f.every"+(fieldnametempnumber-1)+".value = document.f."+fieldnametemp+".value"); + // calculate rollover for higher level of periodicity. + // FIXME: This calculation only works if addN = 1 , that is, the X,Y,and Z each only increment by zero or one on each issue. + + // if there are two levels of periodicity, (e.g. vol{X},num{Y},issue{Z}, then every1=every2*whenmorethan2 + // otherwise, every2 == 1. + var addN = (document.getElementById('add'+fieldnumber)) ? document.getElementById('add'+fieldnumber).value : 1 ; + var everyN = (document.getElementById('every'+fieldnumber)) ? document.getElementById('every'+fieldnumber).value : 1 ; + document.getElementById('every'+(fieldnumber-1)).value = basefield.value * everyN / addN ; + } } @@ -913,7 +923,7 @@ $('#numberpattern').change( function() { " /> - +
@@ -1239,38 +1249,38 @@ $('#numberpattern').change( function() {
Add - " /> + " /> - " /> + " /> - " /> + " />
once every" />" />" />" />" />" />
When more than" />" />" />" />" />" />
inner counter" />" />" />" />" />" />
Set back to" />" />" />" />" />" />
@@ -1280,9 +1290,9 @@ $('#numberpattern').change( function() { Begins with " />" />" />" />" />" />