Hold Slip Formatting for Windsor
authorArt Rhyno <art632000@yahoo.ca>
Wed, 30 Jan 2013 13:34:24 +0000 (08:34 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 19:53:07 +0000 (15:53 -0400)
The Leddy Library used some custom javascript for adding a due date
to the Hold Slip in a previous version of Evergreen. This uses the
far cleaner print_win.js setup to bring this back.

Signed-off-by: Art Rhyno <art632000@yahoo.ca>
Open-ILS/xul/staff_client/chrome/content/util/print_win.js

index 76f53f5..8faadf1 100644 (file)
@@ -9,6 +9,7 @@ function print_init(type) {
     if (typeof print_custom == "function") {
         print_custom(type);
     } else {
+        print_do_hold_dates(5);
         print_do_sums();
         print_check_alt();
         print_check_noprint();
@@ -163,3 +164,27 @@ function print_do_sums() {
         }
     }
 }
+
+/* Hold Date Formating for Leddy
+ * Use example:
+ * <!-- blah blah -->
+ * <!-- Probably as line_item entries: -->
+ * <span hold_date="hold">Due Date: 5 days from Now</span>
+ */
+function print_do_hold_dates(daysToAdd) {
+    var holdDate = new Date();
+    holdDate.setDate(holdDate.getDate() + daysToAdd); 
+    var d = holdDate.getDate();
+    var m = holdDate.getMonth()+1;
+    var y = holdDate.getFullYear();
+
+    var holdDue = 'Due Date: ' + y +'-'+ (m<=9?'0'+m:m) +'-'+ (d<=9?'0'+d:d);
+    var spans = document.getElementsByTagName('span');
+    if(!spans) return;
+    for (var i = 0; i < spans.length; i++) {
+        var dateset = spans[i].getAttribute("hold_date");
+        if(dateset) {
+            spans[i].textContent = holdDue;
+        }//if
+    }//for
+}