{% extends 'base.html.twig' %}

{% block body %}
	{{ block('nav', 'internal/libs/nav.html.twig') }}

	<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">
		{{ block('topnav', 'internal/libs/top-nav.html.twig') }}

		<div class="container-fluid py-2">
			<div class="row">
				<div class="col-12">
					<div class="card my-4">
						<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
							<div class="d-flex justify-content-between bg-gradient-dark shadow-dark border-radius-lg pt-4 pb-3 ps-3 p-2">
								<div>
									<h6 class="text-white text-capitalize ps-3">Referral Note List</h6>
								</div>
								<div>
									<button type="button" class="btn btn-block btn-light mb-3" onclick="window.open('/index.php/add-note/'+document.getElementById('referralList').value, '_self')">Add Note</button>
								</div>
							</div>
						</div>
						<div class="card-body px-0 pb-2">
							<div>
								Filter:&nbsp;&nbsp;
								<select id='referralList'>
									<option value=''>-- Select Referral --</option>

									{% for c in cases %}
										<optgroup label='{{ c.memberCase.caseName }}'>
											<option value='case-{{ c.memberCase.id }}' {% if case and case.id == c.memberCase.id %} selected='selected' {% endif %}>{{ c.memberCase.caseName }} All Referrals</option>
											{% for r in c.memberCase.referrals %}
												<option value='{{ r.id }}'>
													{{ c.memberCase.caseName }}
													/
													{{ r.referralId }}
													/
													{{ r.serviceCode.value }}
												</option>
											{% endfor %}
										</optgroup>
									{% endfor %}
								</select>&nbsp;&nbsp;
								<input type='date' id='startDate' title='Start Date'/>&nbsp;&nbsp;
								<input type='date' id='endDate' title='End Date'/>&nbsp;&nbsp;
								<button name='filter-notes' id='filter-notes'>Filter Notes</button>
							</div>
							<div class="table-responsive p-0">
								<table class="table align-items-center mb-0">
									<thead>
										<tr>
											<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">DOS</th>
											<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Location</th>
											<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Method</th>
											<th class='text-right text-uppercase text-secondary text-xxs font-weight-bolder opacity-7'>Members Present</th>
											<th class="text-secondary opacity-7"></th>
										</tr>
									</thead>
									<tbody id='note-list'>
										{% if caseNotes %}
											{% for n in caseNotes %}
												<tr>
													<td>{{ n.date|date("F j, Y", company_timezone) }}<br/>
														{{ n.startTime|date("g:i a", company_timezone) }}-{{ n.endTime|date("g:i a", company_timezone) }} ({{ n.calcTimeUsed() }})</td>
													<td class='text-center'>{{ n.location.value }}</td>
													<td class='text-center'>{{ n.method.name|lower|replace({"_": " "})|capitalize }}</td>
													<td></td>
													<td style='text-align: right;'>
														<a href='/edit-note/{{ n.id }}' class='text-secondary' title='Edit Note'>
															<i class="material-symbols-rounded opacity-5">edit</i>
														</a>
													</td>
												</tr>
											{% endfor %}
										{% endif %}
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</main>
{% endblock %}

{% block page_js %}
	<script type='module'>
		import $ from "{{ asset('vendor/jquery/jquery.index.js') }}";
import {filterNotes} from "{{ asset('js/app/notes.js') }}";
window.$ = $;

$(function () {
$('#filter-notes').click(filterNotes);
});
	</script>
{% endblock %}
