Bugzilla – Attachment 193331 Details for
Bug 41865
Add percent spent bar graph to acquisitions home page for budgets.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Code for percentage of funds available
acq_funds_percent_avail.txt (text/plain), 3.81 KB, created by
Barbara Johnson
on 2026-02-17 20:07:04 UTC
(
hide
)
Description:
Code for percentage of funds available
Filename:
MIME Type:
Creator:
Barbara Johnson
Created:
2026-02-17 20:07:04 UTC
Size:
3.81 KB
patch
obsolete
> /* BEGIN - Append percentage of funds remaining/available to acquisitions funds tables > > * David Green - Carnegie-Stout Library > * 2018-03-22 > * Koha Version: 17.05, 17.11 > */ > /*Acquisitions budget table */ > /* Wait for the data table to initialize. */ > $('#budgeth').on('init.dt', function () { > console.log("IntranetUserJS: Acquisitions Table Percentage"); > /* On each row of the table: */ > $('#budgeth').DataTable().rows().nodes().toArray().forEach( function (row) { > /* Get the Allocated Funds by: getting the text from column 2, removing commas, and converting to a number. */ > var allocated = parseFloat( row.children[2].textContent.trim().replace(",", "") ); > /* Get the Remaining Funds from column 8 in the same way. */ > var remaining = parseFloat( row.children[8].textContent.trim().replace(",", "") ); > /* Calculate and append the percentage of funds remaining to the 8th column. */ > var percent = Math.floor(remaining / allocated * 100); > row.children[8].innerHTML += ` <span style="width: 3.5em; display: inline-block;">(${percent}%)</span>`; > percent = Math.max(-100, Math.min(100, percent)); > row.children[8].style = `background: linear-gradient(to right, #DFD 0%, #9F9 ${percent}%, #FFF ${percent}%, #FFF ${percent + 100}%, #FAA ${percent + 100}%, #FCC 100%);`; > } ); > /* Make numbers in the table black. */ > $("#budgeth .total_amount, #budgeth .child_fund_amount").css("color", ""); > /* Redraw the table. */ > $('#budgeth').DataTable().rows().invalidate().draw(); > } ); > >/* END - Append percentage of funds remaining to acquisitions budget table */ > > > /*Acquisitions home */ > /* Wait for the data table to initialize. */ > $('#accounts').on('init.dt', function () { > console.log("IntranetUserJS: Acquisitions Table Percentage"); > /* On each row of the table: */ > $('#accounts').DataTable().rows().nodes().toArray().forEach( function (row) { > /* Get the Allocated Funds by: getting the text from column 4, removing commas, and converting to a number. */ > var allocated = parseFloat( row.children[4].textContent.trim().replace(",", "") ); > /* Get the Remaining Funds from column 7 in the same way. */ > var remaining = parseFloat( row.children[7].textContent.trim().replace(",", "") ); > /* Calculate and append the percentage of funds remaining to the 8th column. */ > var percent = Math.floor(remaining / allocated * 100); > row.children[7].innerHTML += ` <span style="width: 3.5em; display: inline-block;">(${percent}%)</span>`; > percent = Math.max(-100, Math.min(100, percent)); > row.children[7].style = `background: linear-gradient(to right, #DFD 0%, #9F9 ${percent}%, #FFF ${percent}%, #FFF ${percent + 100}%, #FAA ${percent + 100}%, #FCC 100%);`; > } ); > /* Make numbers in the table black. */ > $("#accounts .total_amount, #accounts .child_fund_amount").css("color", ""); > /* Redraw the table. */ > $('#accounts').DataTable().rows().invalidate().draw(); > } ); > >/* END - Append percentage of funds remaining to acquisitions home. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 41865
:
193329
| 193331 |
193332