[Koha-patches] [PATCH] Add textarea to display selected irregularity in subscription add.

Ryan Higgins rch at liblime.com
Sun Jul 27 20:26:35 CEST 2008


---
 .../intranet-tmpl/prog/en/css/staff-global.css     |    4 ++
 .../prog/en/modules/serials/subscription-add.tmpl  |   26 ++++------
 serials/subscription-add.pl                        |   53 +++++++++----------
 3 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index e645f57..fa77e7e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -1426,6 +1426,10 @@ a.yuimenuitemlabel:hover {
 	background-color: #CCCCCC;
 }
 
+#irregularity_summary {
+	vertical-align : top;
+}
+
 #toplevelnav {
 	float : left;
 	margin-left : .5em;
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 642385a..c3e60cc 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
@@ -26,7 +26,7 @@ function xmlhttpPost(strURL) {
         self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
     }
     self.xmlHttpReq.open('POST', strURL, true);
-    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
     self.xmlHttpReq.onreadystatechange = function() {
         if (self.xmlHttpReq.readyState == 4) {
             updatepage(self.xmlHttpReq.responseText);
@@ -93,19 +93,7 @@ function IrregularPattern() {
     // init:
 	var irregular = '<!-- TMPL_VAR NAME="irregularity" -->';
     var periodicity = document.f.periodicity.value;
-    var skipped = irregular.split(',');
-    if(skipped.lengh > 0) {
-		// when loading page, irregularity_select doesn't exist.  create it here:
-    	for(j=0;j<skipped.length;j++){
-	//		if(periodicity ==1){  
-				// for daily pubs, make checkboxes.
-    //	    	document.getElementById("irregular"+skipped[j]).checked = true; 
-    //	    } else {
-				document.getElementById("irregularity_select").options[i].selected = true;
-    //	}	
-		}
-		this.update;
-	}
+    this.skipped = irregular.split(',');
 }
 
 IrregularPattern.prototype.update = function() {
@@ -113,12 +101,17 @@ IrregularPattern.prototype.update = function() {
 		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
+		var summary_str = '';
 		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++;
 			}
 		}
+		var summary = document.getElementById("irregularity_summary");
+		summary.value = summary_str;
+		summary.rows= ( cnt > 6 ) ? cnt : 6 ;
 }
 
 IrregularPattern.prototype.irregular = function(index) { 
@@ -135,7 +128,7 @@ function init_pattern() {
 }
 function reset_pattern() {
 	document.getElementById("numberpattern").value = '';
-	document.getElementById("numberpattern").value = '';
+//	document.getElementById("numberpattern").value = '';
 	init_pattern();
 	reset_num_pattern();
 
@@ -642,7 +635,7 @@ function irregularity_check(){
 		}
         errortext +="<select multiple id='irregularity_select' name='irregularity_select' onchange='irregular_issues.update();'>\n"; 
 		errortext +=irregular_options(periodicity);
-		errortext += "</select>";
+		errortext += "</select>\n <textarea rows='6' width='18' id='irregularity_summary' name='irregularity_summary' value='foo' />";
         error=errortext;
     }
     if(toobig){
@@ -654,6 +647,7 @@ function irregularity_check(){
     }
 	display_example(expected);
     document.getElementById("irregularity").innerHTML = error;
+	irregular_issues.update();
 }
 
 function irregular_options(periodicity){
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index 391fb74..e8002aa 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -53,27 +53,6 @@ my ($template, $loggedinuser, $cookie)
 				});
 
 
-my $weekarrayjs='';
-my $count = 0;
-# FIXME - This assumes first pub date of today().
-# You can't enter past-date irregularities.
-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,$i - 1);
-#warn "$y-$m-$d";
-        #BUGFIX padding add_delta_days() date
-        my $output  =  sprintf("%04d-%02d-%02d",$y , $m, $d );
-        $weekarrayjs .= "'Wk $wkno: ". format_date($output) ."',";
-        $wkno++;    
-}
-chop($weekarrayjs);
-# warn $weekarrayjs;
 
 my $sub_on;
 my @subscription_types = (
@@ -110,22 +89,25 @@ for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{b
 $template->param(branchloop => \@branchloop,
     DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
 );
-
+my $subscriptionid;
+my $subs;
+my $firstissuedate;
 if ($op eq 'mod'||$op eq 'dup') {
 
-    my $subscriptionid = $query->param('subscriptionid');
-#     warn "irregularity :$irregularity numberpattern : $numberpattern, callnumber :$callnumber, firstacquidate :$firstacquidate";
-    my $subs = &GetSubscription($subscriptionid);
+    $subscriptionid = $query->param('subscriptionid');
+    $subs = &GetSubscription($subscriptionid);
 ## FIXME : Check rights to edit if mod. Could/Should display an error message.
     if ($subs->{'cannotedit'} && $op eq 'mod'){
       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");
-    }  
-	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->{$_} = ''
     	} else {
-            $subs->{$_} = format_date($subs->{$_});
+            $subs->{$_} = format_date($subs->{$_});  
         }
 	}
     $subs->{'letter'}='' unless($subs->{'letter'});
@@ -167,6 +149,21 @@ if ($op eq 'mod'||$op eq 'dup') {
                 "numberpattern".$subs->{'numberpattern'} => 1,
                 );
 }
+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;
 
 if ($op eq 'addsubscription') {
     my $auser = $query->param('user');
-- 
1.5.5.GIT




More information about the Koha-patches mailing list