From: Art Rhyno Date: Tue, 12 Feb 2013 16:25:08 +0000 (-0500) Subject: Make Date Addition for Hold Receipt Configurable on Client X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fa0e99d4743c10d95c9174c3fae24c0709e79fe3;p=contrib%2FConifer.git Make Date Addition for Hold Receipt Configurable on Client As per Dan Scott's suggestion, this changes the print_win.js function for formatting the holds date receipt to allow the number of days to be specified with the "add_days" attribute. Signed-off-by: Art Rhyno --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print_win.js b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js index 8faadf1146..035692becd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print_win.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print_win.js @@ -9,7 +9,7 @@ function print_init(type) { if (typeof print_custom == "function") { print_custom(type); } else { - print_do_hold_dates(5); + print_do_hold_dates(); print_do_sums(); print_check_alt(); print_check_noprint(); @@ -169,22 +169,26 @@ function print_do_sums() { * Use example: * * - * Due Date: 5 days from Now + * Due Date: 5 days from Now */ -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); +function print_do_hold_dates() { 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; + var hold_date = spans[i].getAttribute("hold_date"); + var add_days = spans[i].getAttribute("add_days"); + if(hold_date && add_days) { + var daysToAdd = parseInt(add_days); + if (daysToAdd > 0 && daysToAdd < 365) { + 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); + spans[i].textContent = holdDue; + }//if daysToAdd }//if }//for }