2026-09-25 18:00:58 +05:30

217 lines
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Portal My Home extension -->
<template id="portal_my_home_library" name="Show Library" inherit_id="portal.portal_my_home" priority="40">
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">My Library</t>
<t t-set="url" t-value="'/my/library'"/>
<t t-set="placeholder_count" t-value="'library_issue_count'"/>
</t>
<t t-call="portal.portal_docs_entry">
<t t-set="title">Library Catalog</t>
<t t-set="url" t-value="'/my/library/books'"/>
<t t-set="placeholder_count" t-value="'catalog'"/>
</t>
</xpath>
</template>
<!-- Library Dashboard -->
<template id="portal_my_library" name="My Library Dashboard">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title">Library Dashboard</t>
</t>
<div class="row mt-4">
<div class="col-md-12">
<h3>Currently Issued Books</h3>
<t t-if="not issues">
<p class="text-muted">You have no issued books.</p>
</t>
<t t-if="issues">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>Book</th>
<th>Accession</th>
<th>Issue Date</th>
<th>Due Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<t t-foreach="issues" t-as="issue">
<tr>
<td><span t-field="issue.copy_id.book_id.title"/></td>
<td><span t-field="issue.copy_id.accession_number"/></td>
<td><span t-field="issue.issue_date"/></td>
<td>
<span t-field="issue.due_date" t-att-class="'text-danger font-weight-bold' if issue.status == 'overdue' else ''"/>
</td>
<td><span t-field="issue.status" class="badge badge-info"/></td>
</tr>
</t>
</tbody>
</table>
</t>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<h3>Outstanding Fines</h3>
<t t-if="not fines">
<p class="text-muted">You have no outstanding fines.</p>
</t>
<t t-if="fines">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>Reference</th>
<th>Book</th>
<th>Days Late</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<t t-foreach="fines" t-as="fine">
<tr>
<td><span t-field="fine.name"/></td>
<td><span t-field="fine.issue_id.copy_id.book_id.title"/></td>
<td><span t-field="fine.days_late"/></td>
<td><span t-field="fine.amount" class="text-danger"/></td>
</tr>
</t>
</tbody>
</table>
</t>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<h3>Active Reservations</h3>
<t t-if="not reservations">
<p class="text-muted">You have no active reservations.</p>
</t>
<t t-if="reservations">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>Book</th>
<th>Reservation Date</th>
<th>Expiry Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<t t-foreach="reservations" t-as="res">
<tr>
<td><a t-attf-href="/my/library/book/#{res.book_id.id}"><span t-field="res.book_id.title"/></a></td>
<td><span t-field="res.reservation_date"/></td>
<td><span t-field="res.expiry_date"/></td>
<td><span t-field="res.state" class="badge badge-primary"/></td>
</tr>
</t>
</tbody>
</table>
</t>
</div>
</div>
</t>
</template>
<!-- Books Catalog -->
<template id="portal_library_books" name="Library Catalog">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title">Library Catalog</t>
</t>
<div class="row mt-4">
<t t-if="not books">
<p class="text-muted pl-3">No books found matching your criteria.</p>
</t>
<t t-foreach="books" t-as="book">
<div class="col-md-3 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">
<a t-attf-href="/my/library/book/#{book.id}"><t t-esc="book.title"/></a>
</h5>
<h6 class="card-subtitle mb-2 text-muted"><t t-esc="book.author"/></h6>
<p class="card-text small">
Available: <t t-esc="book.available_copies"/> / <t t-esc="book.total_copies"/>
</p>
</div>
</div>
</div>
</t>
</div>
<div t-if="pager" class="o_portal_pager text-center">
<t t-call="portal.pager"/>
</div>
</t>
</template>
<!-- Book Detail -->
<template id="portal_library_book_detail" name="Book Detail">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title"><t t-esc="book.title"/></t>
</t>
<div class="row mt-4">
<div class="col-md-8">
<h2><t t-esc="book.title"/></h2>
<h4 class="text-muted"><t t-esc="book.subtitle"/></h4>
<hr/>
<div class="row">
<div class="col-md-6">
<strong>Author:</strong> <t t-esc="book.author"/><br/>
<strong>Publisher:</strong> <t t-esc="book.publisher"/><br/>
<strong>Edition:</strong> <t t-esc="book.edition"/><br/>
</div>
<div class="col-md-6">
<strong>ISBN:</strong> <t t-esc="book.isbn"/><br/>
<strong>Language:</strong> <t t-esc="book.language"/><br/>
<strong>Category:</strong> <t t-esc="book.category_id.name"/><br/>
</div>
</div>
<div class="mt-4">
<strong>Description:</strong>
<p><t t-esc="book.description"/></p>
</div>
</div>
<div class="col-md-4">
<div class="card bg-light">
<div class="card-body">
<h4 class="card-title">Availability</h4>
<h1 class="display-4"><t t-esc="book.available_copies"/></h1>
<p class="text-muted">copies available out of <t t-esc="book.total_copies"/></p>
<t t-if="res_enabled and member and book.available_copies == 0">
<t t-if="not has_reservation">
<form t-attf-action="/my/library/book/#{book.id}/reserve" method="post">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<button type="submit" class="btn btn-primary btn-block">Reserve Book</button>
</form>
</t>
<t t-if="has_reservation">
<button class="btn btn-secondary btn-block" disabled="1">Already Reserved</button>
</t>
</t>
</div>
</div>
</div>
</div>
</t>
</template>
</odoo>