Files
books/templates/books_for_loan.html

100 lines
2.8 KiB
HTML

<script>
function ActivateBFLRemSelButton()
{
$('#bfl-remsel-btn').removeClass('disabled')
$('#bfl-remsel-btn').attr('disabled',false)
}
function DeactivateBFLRemSelButton()
{
$('#bfl-remsel-btn').addClass('disabled')
$('#bfl-remsel-btn').attr('disabled',true)
}
function RemoveSelFromLoan()
{
var params=$("#book_table :input").serializeArray()
$.post( "/rem_books_from_loan/" + {{loan_id}}, params, function(data) {
DeactivateBFLRemSelButton()
$('#bfl-existing').load('/books_for_loan/' + {{loan_id}}, { 'InDBox' : 1 } )
} )
}
function ShowDBox()
{
$('#dbox').modal('show')
$.post( "/books_for_loan/" + {{loan_id}}, function(data) {$('#bfl-existing').html(data) } );
}
function FindNewBFL()
{
$.post( "/search",{ 'term': $('#bfl-search-term').val(), 'InDBox': 1 }, function(data) { $('#bfl-new').html(data) ; $('#bfl-addsel-btn').show() } );
}
function ActivateBFLAddSelButton()
{
$('#bfl-addsel-btn').removeClass('disabled')
$('#bfl-addsel-btn').attr('disabled',false)
}
function DeactivateBFLAddSelButton()
{
$('#bfl-addsel-btn').addClass('disabled')
$('#bfl-addsel-btn').attr('disabled',true)
$('#bfl-addsel-btn').attr('style','display:none')
}
function AddSelToLoan()
{
var params=$("#addsel_table :input").serializeArray()
$.post( "/add_books_to_loan/" + {{loan_id}}, params, function(data) {
DeactivateBFLAddSelButton()
DeactivateBFLRemSelButton()
$('#bfl-search-term').val('')
$('#bfl-new').html('')
$('#bfl-existing').load('/books_for_loan/' + {{loan_id}}, { 'InDBox' : 1 } )
} )
}
</script>
{% if not InDBox %}
<h3>Loaned Books</h3>
{% endif %}
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead>
<tr class="thead-light">
<th>Title</th>
<th>Author(s)</th>
<th>Covertype</th>
{% if InDBox %}
<th>Remove?</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for book in books %}
<tr>
{% if book.sub_book_num is defined %}
<td data-sort="{{book.parent_id}}.{{book.sub_book_num}}"><a href="/book/{{book.id}}">&nbsp;&nbsp;&nbsp;&nbsp;{{book.title}}</a></td>
{% else %}
<td data-sort="{{book.id}}"><a href="/book/{{book.id}}">{{book.title}}</a></td>
{% endif %}
<td>
{% for auth in book.author %}
{{ auth['surname'] }}, {{auth['firstnames']}}
{% endfor %}
</td>
<td>{{ GetCovertypeById(book.covertype) }}</td>
{% if InDBox %}
<td><input name="bfl-rem-{{book.id}}" type="checkbox" onClick="ActivateBFLRemSelButton()"></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% if not InDBox %}
<button type="button" class="btn btn-primary" onClick="ShowDBox()">Add/Remove Books in Loan</button>
{% endif %}