Bug 3928: Modification of date for serials.
authorJ. David Bavousett <dbavousett@ptfs.com>
Tue, 11 May 2010 08:10:58 +0000 (20:10 +1200)
committerGalen Charlton <gmcharlt@gmail.com>
Tue, 11 May 2010 11:34:17 +0000 (07:34 -0400)
When a serial status is changed to "Arrived" or "Claimed", the "Expected on"
date is changed to the current date.

A bit of rewriting to get it to apply on master - chris@bigballowax.co.nz

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>

koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tmpl
serials/serials-edit.pl

index 6548174..774247f 100644 (file)
@@ -81,6 +81,10 @@ function HideItems(index,labelindex) {
        label = document.getElementById(labelindex);
        label.style.display='block';    
 }
+function changeDate(adate) {
+    var elem = document.getElementById("expecteddate");
+    elem.value = adate;
+}
 function CloneSubfield(index){
     var original = document.getElementById(index); //original <div>
     var clone = original.cloneNode(true);
@@ -210,7 +214,7 @@ function CloneSubfield(index){
             <input type="text" name="publisheddate" value="<!-- TMPL_VAR name="publisheddate" -->" size="10" maxlength="15" />
         </td>
         <td>
-            <input type="text" name="planneddate" value="<!-- TMPL_VAR name="planneddate" -->" size="10" maxlength="15" />
+            <input type="text" id="expecteddate" name="planneddate" value="<!-- TMPL_VAR name="planneddate" -->" size="10" maxlength="15" />
         </td>
         <td>
             <!--TMPL_IF name="editdisable"-->
@@ -218,9 +222,9 @@ function CloneSubfield(index){
               <select name="status" size="1"  disabled="disabled">
             <!--TMPL_ELSE-->
               <!--TMPL_IF Name="serialsadditems"-->
-              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="serialid" -->" onchange="if (this.value==2){unHideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->', '<!--TMPL_VAR Name="serialid"-->')} else { HideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')}" >
+              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="serialid" -->" onchange="if (this.value==2){unHideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->'); changeDate('<!-- TMPL_VAR NAME="arriveddate" -->')} else if (this.value==7){changeDate('<!-- TMPL_VAR NAME="arriveddate" -->')} else { HideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->'); changeDate('<!-- TMPL_VAR NAME="planneddate" -->')}" >
                <!--TMPL_ELSE -->
-              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="serialid" -->" >
+              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="serialid" -->" onchange="if (this.value==2 || this.value==7){changeDate('<!-- TMPL_VAR NAME="arriveddate" -->')} else {changeDate('<!-- TMPL_VAR NAME="planneddate" -->')}" >
                <!--/TMPL_IF--> 
             <!--/TMPL_IF-->
   <!--TMPL_IF name="status1" -->
index 3e2a852..bd7d420 100755 (executable)
@@ -121,6 +121,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 
 my @serialdatalist;
 my %processedserialid;
+
+my $today = C4::Dates->new();  
 foreach my $tmpserialid (@serialids) {
 
     #filtering serialid for duplication
@@ -132,6 +134,7 @@ foreach my $tmpserialid (@serialids) {
         my $data = GetSerialInformation($tmpserialid);
         $data->{publisheddate} = format_date( $data->{publisheddate} );
         $data->{planneddate}   = format_date( $data->{planneddate} );
+       $data->{arriveddate}=$today->output('us');
         $data->{'editdisable'} = (
             (
                 HasSubscriptionExpired( $data->{subscriptionid} )