&GetLatestSerials &ModSerialStatus &GetNextDate &GetSerials2
&ReNewSubscription &GetLateIssues &GetLateOrMissingIssues
&GetSerialInformation &AddItem2Serial
- &PrepareSerialsData
+ &PrepareSerialsData &GetNextExpected &ModNextExpected
&UpdateClaimdateIssues
&GetSuppliersWithLateIssues &getsupplierbyserialid
as well as the number of issues registered in the database (all types)
this number is used to see if a subscription can be deleted (=it must have only 1 issue)
+FIXME: We should return \@serials.
=back
=cut
}
}
+=head2 GetNextExpected
+
+=over 4
+
+$nextexpected = GetNextExpected($subscriptionid)
+
+Get the planneddate for the current expected issue of the subscription.
+
+returns a hashref:
+
+$nextexepected = {
+ serialid => int
+ planneddate => C4::Dates object
+ }
+
+=back
+
+=cut
+
+sub GetNextExpected($) {
+ my ($subscriptionid) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare('SELECT serialid, planneddate FROM serial WHERE subscriptionid=? AND status=?');
+ # Each subscription has only one 'expected' issue, with serial.status==1.
+ $sth->execute( $subscriptionid, 1 );
+ my ( $nextissue ) = $sth->fetchrow_hashref;
+ $nextissue->{planneddate} = C4::Dates->new($nextissue->{planneddate},'iso');
+ return $nextissue;
+}
+=head2 ModNextExpected
+
+=over 4
+
+ModNextExpected($subscriptionid,$date)
+
+Update the planneddate for the current expected issue of the subscription.
+This will modify all future prediction results.
+
+C<$date> is a C4::Dates object.
+
+=back
+
+=cut
+
+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=?');
+ # Each subscription has only one 'expected' issue, with serial.status==1.
+ $sth->execute( $date->output('iso'),$date->output('iso'), $subscriptionid, 1);
+ return 0;
+
+}
+
=head2 ModSubscription
=over 4
my @resultdate;
# warn "DOW $dayofweek";
- if ( $subscription->{periodicity} % 16 == 0 ) {
+ if ( $subscription->{periodicity} % 16 == 0 ) { # 'without regularity' || 'irregular'
return 0;
}
- if ( $subscription->{periodicity} == 1 ) {
+ # daily : n / week
+ # Since we're interpreting irregularity here as which days of the week to skip an issue,
+ # renaming this pattern from 1/day to " n / week ".
+ if ( $subscription->{periodicity} == 1 ) {
my $dayofweek = eval{Day_of_Week( $year,$month, $day )};
if ($@){warn "year month day : $year $month $day $subscription->{subscriptionid} : $@";}
else {
@resultdate = Add_Delta_Days($year,$month, $day , 1 );
}
}
+ # 1 week
if ( $subscription->{periodicity} == 2 ) {
my ($wkno,$year) = eval {Week_of_Year( $year,$month, $day )};
if ($@){warn "year month day : $year $month $day $subscription->{subscriptionid} : $@";}
else {
for ( my $i = 0 ; $i < @irreg ; $i++ ) {
+ #FIXME: if two consecutive irreg, do we only skip one?
if ( $irreg[$i] == (($wkno!=51)?($wkno +1) % 52 :52)) {
($year,$month,$day) = Add_Delta_Days($year,$month, $day , 7 );
$wkno=(($wkno!=51)?($wkno +1) % 52 :52);
@resultdate = Add_Delta_Days( $year,$month, $day, 7);
}
}
+ # 1 / 2 weeks
if ( $subscription->{periodicity} == 3 ) {
my ($wkno,$year) = eval {Week_of_Year( $year,$month, $day )};
if ($@){warn "year month day : $year $month $day $subscription->{subscriptionid} : $@";}
@resultdate = Add_Delta_Days($year,$month, $day , 14 );
}
}
+ # 1 / 3 weeks
if ( $subscription->{periodicity} == 4 ) {
my ($wkno,$year) = eval {Week_of_Year( $year,$month, $day )};
if ($@){warn "année mois jour : $year $month $day $subscription->{subscriptionid} : $@";}
// the english words used in display purposes
var text = new Array(_("Number"),_("Volume"),_("Issue"),_("Month"),_("Week"),_("Starting with:"),_("Rollover at:"),_("Choose Hemisphere:"),_("Northern"),_("Southern"),
_("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"),_("Season"),_("Year"));
+var weekno_label = _("Week # ");
var is_season = 0;
var is_hemisphere = 1;
var irregular_issues; // will hold irregularity object.
-<!-- TMPL_IF NAME="weekarrayjs" -->
- var weeks = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->);
-<!-- /TMPL_IF -->
-
function formatDate(myDate) {
var d = new Array( myDate.getFullYear(), myDate.getMonth() + 1 ,myDate.getDate());
if(d[1].toString().length == 1) { d[1] = '0'+d[1] };
this.setDate(this.getDate()+days);
}
-function getWeeksArray(startDate) {
-// returns a 52 element array with dates starting with startDate.
+function getWeeksArray(startDate,periodicity) {
+// returns an array of syspref-formatted dates starting at the first day of startDate's year.
+// This prediction method will not accurately predict irregularites beyond the first year.
+// FIXME : Should replace with ajax query to get the first Monday of the year so that week numbers have correct dates.
+ var incr=1;
+ if(periodicity==3) { // 1/2 wks
+ incr=2;
+ } else if(periodicity == 4) { // 1/3 wks
+ incr=3;
+ }
var weeksArray = new Array;
- var myDate = new Date;
+ startDate.setDate(1);
+ startDate.setMonth(0);
for(var i=0;i<52;i++) {
+ weeksArray[i] = formatDate(startDate) + ' ' + weekno_label + (i + 1);
startDate.addDays( 7 );
- weeksArray[i] = formatDate(startDate);
}
return weeksArray;
}
this.months = new Array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
this.seasons = new Array(_("Autumn"),_("Winter"),_("Spring"),_("Summer"),_("Fall"));
this.daynames = new Array(_("Monday"),_("Tuesday"),_("Wednesday"),_("Thursday"),_("Friday"),_("Saturday"),_("Sunday"));
- <!-- TMPL_IF NAME="weekarrayjs" -->
- this.weeks = new Array(<!-- TMPL_VAR NAME="weekarrayjs" -->);
- <!-- /TMPL_IF -->
- this.numskipped = 0;
+ // create weeks irregularity selection array:
+ this.firstissue = new Date();
+ this.firstissue.setDate(1);
+ this.firstissue.setMonth(0);
+ <!-- TMPL_IF NAME='firstacquiyear' --> // it's a mod, we already have a start date.
+ this.firstissue.setFullYear( <!-- TMPL_VAR NAME="firstacquiyear" --> );
+ <!-- /TMPL_IF -->
+ this.weeks = getWeeksArray(this.firstissue);
+
+ this.numskipped = 0;
// init:
var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
- // var periodicity = document.f.periodicity.value;
this.skipped = irregular.split(',');
}
this.skipped= new Array;
var cnt = 0;
// daily periodicity, we interpret irregular array as which days of week to skip.
- // else irregular array is list of issues to skip
+ // else if weekly periodicity, week numbers (starting from 01 Jan) to skip.
+ // else irregular array is list of issues to skip
var summary_str = '';
this.numskipped = 0;
if(document.f.irregularity_select) {
var summary = document.getElementById("irregularity_summary");
if(summary) {
summary.value = summary_str;
- summary.rows= ( cnt > 6 ) ? cnt : 6 ;
+ summary.rows= ( cnt > 6 ) ? cnt : 6 ; // textarea will bre resized, but not more than 6 lines will show.
}
}
}
}
function reset_pattern() {
document.getElementById("numberpattern").value = '';
-// document.getElementById("numberpattern").value = '';
+ document.getElementById("irregularity").innerHTML = '';
init_pattern();
reset_num_pattern();
document.f.setto1.value=0;
document.f.setto2.value='1';
document.f.setto3.value='';
- document.f.lastvalue1temp.value=sYear;
document.f.periodicity.value='8';
document.f.numberingmethod.value=_("{Y} {X}");
moreoptions_seasons(text[15],sYear);
+ document.f.lastvalue1temp.value=document.f.lastvalue1.value=sYear;
display_table(0);
is_season = 1;
break;
document.getElementById("more_options").innerHTML = '';
document.f.irreg_check.value=1;
break;
- case "8":
- var d = new Date(document.f.startdate.value);
+ case "8": // Year/Number
+ var d = (document.f.firstacquidate.value) ? new Date( document.f.firstacquidate.value) : new Date() ;
var sYear = d.getFullYear();
document.f.add1.value=1;
document.f.add2.value=1;
document.f.setto1.value=0;
document.f.setto2.value=1;
document.f.setto3.value='';
- if (document.f.lastvalue1.value==0){document.f.lastvalue1.value=sYear};
- if (document.f.lastvalue2.value==0 ||document.f.lastvalue2.value=='' ){
+ document.f.lastvalue1.value=sYear;
switch (document.f.periodicity.value){
case 1:
var doy = dayofyear(d);
- //var Weeknumber=YWDA[1];
document.f.lastvalue2.value=doy;
+ document.f.whenmorethan2.value=365;
break;
case 12:
var doy = dayofyear(d);
- //var Weeknumber=YWDA[1];
document.f.lastvalue2.value=doy*2;
- break;
- case 13:
- var doy = dayofyear(d);
- //var Weeknumber=YWDA[1];
- document.f.lastvalue2.value=doy/3;
+ document.f.whenmorethan2.value=730;
break;
case 2:
case 3:
case 4:
var YWDa = YMDaToYWDa(d);
- //var Weeknumber=YWDA[1];
document.f.lastvalue2.value=YWDA[1]/(document.f.periodicity.value-1);
break;
case 5:
case 6:
var smonth = d.getMonth();
document.f.lastvalue2.value=smonth/2;
+ document.f.whenmorethan2.value=6;
break;
case 7:
case 8:
var smonth = d.getMonth();
document.f.lastvalue2.value=smonth/3;
+ document.f.whenmorethan2.value=4;
break;
case 9:
var smonth = d.getMonth();
document.f.lastvalue2.value=smonth/6;
+ document.f.whenmorethan2.value=2;
break;
default:
}
- }
- // document.f.lastvalue2.value=document.f.lastvalue2temp.value;
document.f.lastvalue3.value='';
- document.f.numberingmethod.value=_("{X}/{Y}");
+ document.f.numberingmethod.value=_("{X} / {Y}");
moreoptions(text[16],text[0]);
+ // document.f.lastvalue1temp.value=sYear;
+ // document.f.lastvalue2temp.value=document.f.lastvalue2.value;
display_table(0);
break;
default:
}
// a pre check with more options to see if 'number' and '1/day' are chosen
-
+<!--
function moreoptions_daily_check(x) {
var periodicity = document.f.periodicity.value;
var errortext='';
moreoptions(x);
}
}
+-->
// to dispaly the more options section
var textbox = '';
// alert("X: "+x+"Y: "+y+"Z: "+z);
if(x){
- textbox +="<table>\n<tr><th> <\/th><th>"+x+"<\/th>";
+ textbox +="<table id='irregularity_table'>\n<tr><th> <\/th><th>"+x+"<\/th>";
if(y){
textbox +="<th>"+y+"<\/th>";
if(z){
// to display the more options section for seasons
function moreoptions_seasons(x,y){
+// x = 'Season'. y = 'Year'.
document.getElementById("irregularity").innerHTML = '';
document.getElementById("more_options").innerHTML = '';
var textbox = '';
textbox +=">"+text[i+7]+"<\/option>";
}
textbox +="<\/li>\n";
- textbox +="<table><tr><th> <\/th><th>"+x+"<\/th>";
+ textbox +="<table id='seasonal_irregularity'><tr><th> <\/th><th>"+x+"<\/th>";
textbox +="<th>"+text[16]+"<\/th>";
textbox +="<\/tr>\n";
textbox +="<tr><th scope=\"row\">"+text[5]+"<\/th><td><select name='lastvalue2temp' id='lastvalue2temp' id='season1' onchange='moreoptionsupdate(this)'>";
for(var j = 1; j <= 4; j++){
- textbox +="<option value='"+j+"'>"+text[j+10]+"<\/option>";
+ textbox +="<option value='"+j+"'>"+text[j+9]+"<\/option>";
}
- textbox +="<\/select><\/td><td><select name='lastvalue1temp' id='lastvalue1temp' onchange='moreoptionsupdate(this)'>";
- for(var k = parseInt(y); k <= parseInt(y)+15; k++){
- textbox +="<option value='"+k+"'>"+k+"<\/option>";
- }
- textbox +="<\/select><\/td><\/tr>\n";
+ textbox +="<\/select><\/td>";
+ var isyr = irregular_issues.firstissue;
+ textbox += "<td>" + irregular_issues.firstissue.getFullYear() + "<\/td><\/tr>\n";
textbox +="<tr><th scope=\"row\">"+text[6]+"<\/th>";
textbox +="<td><input type='text' name='whenmorethan2temp' id='whenmorethan2temp' size='4' onkeyup='moreoptionsupdate(this,1)'><\/td>\n";
textbox +="<\/tr><\/table>\n";
toobig=1;
}
break;
- case "13":
- if(rollover < 156) expected =156;
- if(rollover > 156) {
- expectedover=156;
- toobig=1;
- }
- break;
case "2":
if(rollover < 52) expected =52;
if(rollover > 52){
error=errortext;
}
if(toobig){
- errortext +=expectedover+_(" issues expected, ")+rollover+_(" were entered.<br \/> You seem to have indicated more issues per year than expected.");
+ errortext +=expectedover+_(" issues expected, ")+rollover+_(" were entered.<p class='warning'> You seem to have indicated more issues per year than expected.</p>");
error=errortext;
}
if(error.length ==0){
var count;
var errortext='';
if(periodicity == 1) {
- expected = 366;
- titles = "Day";
+ expected = 7;
+ titles = irregular_issues.daynames;
count = 1;
}
if(periodicity == 2 || periodicity == 3 || periodicity == 4) {
- expected = 52;
titles = irregular_issues.weeks;
- <!-- TMPL_IF NAME="weekno" -->
- count = 1; // This doesn't make sense given the behavior of the script.
- // we should count from the first serial date, not from this week!
- // <!-- TMPL_VAR NAME="weekno" -->;
- <!-- TMPL_ELSE -->
count = 1;
- <!-- /TMPL_IF -->
+ if(periodicity==3) { // 1/2 wks
+ expected = 26;
+ } else if(periodicity == 4) { // 1/3 wks
+ expected = 17;
+ } else {
+ expected = 52;
+ }
}
if(periodicity == 5 || periodicity == 6 || periodicity == 7 || periodicity == 8 || periodicity == 9) {
- if(periodicity == 8) {
+ if(periodicity == 8 && numberpattern==8) {
is_season = 1; // setting up from edit page
}
if(is_season){
if( !expected) {
return ''; // don't know how to deal with irregularity.
}
- for(var j=1;j<=expected;j++){
+ for(var j=0;j<expected;j++){ // rch - changed frrom (1..expected).
if(isArray(titles)){
if(count>expected){
count = count-expected;
} else if(is_season && is_hemisphere == 2){
errortext +="<option value='"+((count*3)-2)+"'>"+titles[j-1]+"<\/option>\n";
// alert("value: "+((count*3)-2)+" title: "+titles[j-1]);
- } else {
- errortext += "<option value='" + count ;
- if(irregular_issues.irregular(j)) {
+ } else { // all non-seasonal periodicities:
+ var incr=1; // multiplier for ( 1/n weeks) patterns; in this case the irreg calc relies on the week# , not the issue#.
+ if(periodicity==3) { // 1/2 wks
+ incr=2;
+ } else if(periodicity == 4) { // 1/3 wks
+ incr=3;
+ }
+ errortext += "<option value='" + (1+j*incr) ;
+ if(irregular_issues.irregular(1+incr*j)) {
errortext += "' selected='selected" ;
}
- errortext += "'>"+titles[j-1]+"<\/option>\n";
+ errortext += "'>"+titles[incr*j]+"<\/option>\n";
}
count++;
} else {
case "2":
case "4":
case "5":
- case "8":
+ case "8": // Year, Number. -- Why not just use Vol, Number withvol==year??
if (document.f.lastvalue2temp.value>0){document.f.innerloop1.value = document.f.lastvalue2temp.value - 1;}
break;
}
<ol>
<li>
<label for="firstacquidate"> First issue publication date:</label>
-
- <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="button2" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
- <input type="text" name="firstacquidate" value="<!-- TMPL_VAR name="firstacquidate" -->" size="13" maxlength="10" id="acqui_date" style="border-width: 0px;" />
+ <!-- TMPL_UNLESS NAME="mod" --><img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="acqui_button" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" /><!-- /TMPL_UNLESS -->
+ <input type="text" name="firstacquidate" value="<!-- TMPL_VAR name="firstacquidate" -->" size="13" maxlength="10" id="acqui_date" <!-- TMPL_IF NAME="mod" -->disabled="true"<!-- /TMPL_IF --> style="border-width: 0px;" />
+ </li>
+ <!-- TMPL_IF NAME="mod" --><li><label for="nextacquidate"> Next issue publication date:</label>
+ <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="next_acqui_button" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
+ <input type="text" name="nextacquidate" value="<!-- TMPL_VAR name="nextacquidate" -->" size="13" maxlength="10" id="next_acqui_date" style="border-width: 0px;" />
+ </li><!-- /TMPL_IF -->
<!-- both scripts for calendar must follow the input field -->
<script type="text/javascript">
Calendar.setup({
- inputField:"acqui_date",
+ inputField : "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
- button : "button2",
- align : "Tl"
- });
- </script>
- <script type="text/javascript">
+ button : "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_button",
+ align : "Tl",
+ onUpdate : function(cal) { irregular_issues.weeks = getWeeksArray(cal.date);
+ irregular_issues.firstissue = cal.date;
+ if(document.irregularity_summary) {
+ irregular_issues.update();
+ }
+ if(document.getElementById("seasonal_irregularity")) {
+ moreoptions_seasons(text[15]);
+ }
+ }
+ });
Calendar.setup({
- inputField : "acqui_date",
+ inputField : "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
- button : "acqui_date",
+ button : "<!-- TMPL_IF NAME="mod" -->next_<!-- /TMPL_IF -->acqui_date",
align : "Tl",
- onUpdate : function(cal) { weeks = getWeeksArray(cal.date);
+ onUpdate : function(cal) { irregular_issues.weeks = getWeeksArray(cal.date);
+ irregular_issues.firstissue = cal.date;
+ if(document.irregularity_summary) {
+ irregular_issues.update();
+ }
+ if(document.getElementById("seasonal_irregularity")) {
+ moreoptions_seasons(text[15]);
+ }
}
});
</script>
-
- </li>
<li>
<label for="periodicity" class="required">Frequency:</label>
<option value="12">2/day</option>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="periodicity1" -->
- <option value="1" selected="selected">1/day</option>
- <!-- TMPL_ELSE -->
- <option value="1">1/day</option>
- <!-- /TMPL_IF -->
- <!-- TMPL_IF name="periodicity13" -->
- <option value="13" selected="selected">3/week</option>
+ <option value="1" selected="selected">daily (n/week)</option>
<!-- TMPL_ELSE -->
- <option value="13">3/week</option>
+ <option value="1">daily (n/week)</option>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="periodicity2" -->
<option value="2" selected="selected">1/week</option>
<li>
<label for="numberpattern"> Numbering pattern:</label>
- <select name="numbering_pattern" size="1" id="numberpattern" onchange="reset_num_pattern()">
+ <select name="numbering_pattern" size="1" id="numberpattern" >
<option value="" selected="selected">-- please choose --</option>
<!-- TMPL_IF name="numberpattern1" -->
<option value="1" selected="selected">Number</option>
my $subscriptionid;
my $subs;
my $firstissuedate;
-if ($op eq 'mod'||$op eq 'dup') {
+my $nextexpected;
+
+if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') {
$subscriptionid = $query->param('subscriptionid');
$subs = &GetSubscription($subscriptionid);
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");
}
-$firstissuedate = $subs->{firstacquidate}; # in iso format.
-for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
+ $firstissuedate = $subs->{firstacquidate}; # in iso format.
+ for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
# TODO : Handle date formats properly.
if ($subs->{$_} eq '0000-00-00') {
$subs->{$_} = ''
$subs->{'letter'}='' unless($subs->{'letter'});
$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
+ $subs->{nextacquidate} = $nextexpected->{planneddate}->output() if($op eq 'mod');
-
+ unless($op eq 'modsubscription') {
if($subs->{numberlength} > 0){
$sublength = $subs->{numberlength};
$sub_on = $subscription_types[0];
$template->param($subs);
$template->param(
- $op => 1,
- subtype => \@sub_type_data,
- sublength =>$sublength,
- history => ($op eq 'mod' && ($subs->{recievedlist}||$subs->{missinglist}||$subs->{opacnote}||$subs->{librariannote}))
- );
- $template->param(
+ $op => 1,
+ subtype => \@sub_type_data,
+ sublength =>$sublength,
+ history => ($op eq 'mod' && ($subs->{recievedlist}||$subs->{missinglist}||$subs->{opacnote}||$subs->{librariannote})),
"periodicity".$subs->{'periodicity'} => 1,
"dow".$subs->{'dow'} => 1,
"numberpattern".$subs->{'numberpattern'} => 1,
+ firstacquiyear => substr($firstissuedate,0,4),
);
+ }
}
-my $weekarrayjs='';
+
my $count = 0;
-# FIXME:
-my ($year, $month, $day) = ($firstissuedate) ? split(/-/,$firstissuedate) : 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){
- my ($y,$m,$d) = Add_Delta_Days($year,1,1,$i - 1);
- my $output = sprintf("%04d-%02d-%02d",$y , $m, $d );
- $weekarrayjs .= "'Wk $wkno: ". format_date($output) ."',";
- $wkno++;
-}
-chop($weekarrayjs);
-# warn $weekarrayjs;
+# prepare template variables common to all $op conditions:
+$template->param( 'dateformat_' . C4::Context->preference('dateformat') => 1 ,
+ );
if ($op eq 'addsubscription') {
my $auser = $query->param('user');
my $biblionumber = $query->param('biblionumber');
my $aqbudgetid = $query->param('aqbudgetid');
my $startdate = format_date_in_iso($query->param('startdate'));
- my $firstacquidate = format_date_in_iso($query->param('firstacquidate'));
+ my $nextacquidate = format_date_in_iso($query->param('nextacquidate'));
my $periodicity = $query->param('periodicity');
my $dow = $query->param('dow');
my $sublength = $query->param('sublength');
my $opacnote = $query->param('opacnote');
my $librariannote = $query->param('librariannote');
my $history_only = $query->param('history_only');
- # FIXME: If it's a mod, we need to check the current 'expected' issue, and mod it in the serials table if necessary.
- #
+ # 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 ($history_only) {
ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
} else {
&ModSubscription(
$auser, $branchcode, $aqbooksellerid, $cost,
- $aqbudgetid, $startdate, $periodicity, $firstacquidate,
+ $aqbudgetid, $startdate, $periodicity, $firstissuedate,
$dow, join(",",@irregularity), $numberpattern, $numberlength,
$weeklength, $monthlength, $add1, $every1,
$whenmorethan1, $setto1, $lastvalue1, $innerloop1,
push( @sub_type_data, \%row );
}
$template->param(subtype => \@sub_type_data,
- weekarrayjs => $weekarrayjs,
- weekno => $weekno,
);
output_html_with_http_headers $query, $cookie, $template->output;
}