@if(!$bill->is_cancelled)
	<div <?= $bill->is_flagged_by_administrator && !$bill->is_administrator_flag_cleared ? 'class="alert alert-danger p-1 rounded-0" style="min-width: 380px;"' : '' ?>>
	<?php #dump($bill); ?>
	@if($pro->pro_type === 'ADMIN')
		@if($bill->is_flagged_by_administrator && !$bill->is_administrator_flag_cleared)
			<div class="d-flex flex-column">
				<div class="d-flex align-items-center flex-wrap">
					<span class="mr-2"><b>Flagged At:</b> {{ friendly_date_time($bill->flagged_administrator_at) }}</span>
					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByProAdmin->displayName() }}</small>
				</div>
				
				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $bill->administrator_flag_memo }}</small>
			</div>

			@if($bill->is_administrator_flag_acknowledged && $bill->administrator_flag_acknowledged_at > $bill->flagged_administrator_at)
				<!-- This is resolved -->
				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
					<div class="d-flex flex-column">
						<div class="d-flex align-items-center flex-wrap">
							<span class="mr-2"><b>Ack. At:</b> {{ friendly_date_time($bill->administrator_flag_acknowledged_at) }}</span>
							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByPro->displayName() }}</small>
						</div>
						
						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $bill->administrator_flag_acknowledgement_memo }}</small>
					</div>
				</div>
			@endif
				<!-- Flagged by admin, pending ack. by pro -->
				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
					<div class="d-flex">
						@if($bill->is_administrator_flag_acknowledged)
							<div moe>
								<a start show class="text-success"><i class="fas fa-flag  on-hover-opaque"></i> Clear Flag</a>
								<form url="/api/bill/clearFlag" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control"></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-success mr-1">Clear Flag</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
						@else
							<div moe>
								<a start show class="text-success"><i class="fas fa-flag  on-hover-opaque"></i> Unflag Bill</a>
								<form url="/api/bill/undoFlagAsAdministrator" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control"></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-success mr-1">Unflag Bill</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
						@endif
						<span class="mx-1 text-muted">|</span>
						@if($bill->is_administrator_flag_acknowledged)
							<div moe>
								<a start show class="text-danger"><i class="fas fa-flag  on-hover-opaque"></i> Flag Bill Again</a>
								<form url="/api/bill/flagAsAdministrator" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control" required></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-danger mr-1">Flag Bill</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
						@else
							<div moe>
								<a start show class="text-primary">Update Memo</a>
								<form url="/api/bill/updateFlagMemo" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control"><?= $bill->administrator_flag_memo ?></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-primary mr-1">Update</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
						@endif
						<span class="ml-1 text-muted">|</span>
						@include('app.patient.note.partials.bill-flags-history')
					</div>
				</div>
			
		@else
			<!-- Not flagged, show flag popup -->
			<!-- //api/bill//flagAsAdministrator -->
			<div class="d-flex align-items-center">
				<div moe>
					<a start show class="text-danger"><i class="fas fa-flag  on-hover-opaque"></i> Flag Bill</a>
					<form url="/api/bill/flagAsAdministrator" class="mcp-theme-1">
						<input type="hidden" name="uid" value="{{$bill->uid}}">
						<div class="form-group">
							<label>Memo:</label>
							<textarea name="memo" rows="2" class="form-control" required></textarea>
						</div>
						<div>
							<button submit class="btn btn-sm btn-danger mr-1">Flag Bill</button>
							<button cancel class="btn btn-sm btn-default border">Cancel</button>
						</div>
					</form>
				</div>
				@include('app.patient.note.partials.bill-flags-history')
			</div>
			
		@endif

	@else
	<!-- HCP -->
		@if($bill->is_flagged_by_administrator && !$bill->is_administrator_flag_cleared)
			<div class="d-flex flex-column">
				<div class="d-flex align-items-center flex-wrap">
					<span class="mr-2"><b>Flagged At:</b> {{ friendly_date_time($bill->flagged_administrator_at) }}</span>
					<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByProAdmin->displayName() }}</small>
				</div>			
				<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque text-primary"></i></b> {{ $bill->administrator_flag_memo }}</small>
			</div>

			@if($bill->is_administrator_flag_acknowledged && $bill->administrator_flag_acknowledged_at > $bill->flagged_administrator_at)
				<!-- hcp has ack. -->
				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
					<div class="d-flex flex-column">
						<div class="d-flex align-items-center flex-wrap">
							<span class="mr-2"><b>Ack. At:</b> {{ friendly_date_time($bill->administrator_flag_acknowledged_at) }}</span>
							<small class="text-sm">By: <i class="fas fa-user"></i> {{ $bill->billFlagAcknowledgedByPro->displayName() }}</small>
						</div>
						
						<small class="text-muted"><b><i class="fas fa-comment on-hover-opaque"></i></b> {{ $bill->administrator_flag_acknowledgement_memo }}</small>
						
						<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
							<div moe>
								<a start show class="text-danger"><i class="fas fa-undo fa-fw  on-hover-opaque"></i> Undo Ack.</a>
								<form url="/api/bill/undoAcknowledgeAdministratorFlag" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control"></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-danger mr-1">Undo Ack.</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
							<span class="mx-1 text-muted">|</span>
							<div moe>
								<a start show class="text-primary">Update Memo</a>
								<form url="/api/bill/updateAcknowledgementMemo" class="mcp-theme-1">
									<input type="hidden" name="uid" value="{{$bill->uid}}">
									<div class="form-group">
										<label>Memo:</label>
										<textarea name="memo" rows="2" class="form-control"><?= $bill->administrator_flag_acknowledgement_memo ?></textarea>
									</div>
									<div>
										<button submit class="btn btn-sm btn-primary mr-1">Update</button>
										<button cancel class="btn btn-sm btn-default border">Cancel</button>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			
			@else
				<!-- Needs hcp ack. -->
				<div class="border-top mt-1 pt-1" style="border-color: #f3bcc1!important;">
				<div moe>
					<a start show class="text-primary"><i class="fa fa-check text-sm on-hover-opaque"></i> Ack.</a>
					<form url="/api/bill/acknowledgeAdministratorFlag" class="mcp-theme-1">
						<input type="hidden" name="uid" value="{{$bill->uid}}">
						<div class="form-group">
							<label>Memo:</label>
							<textarea name="memo" rows="2" class="form-control" required></textarea>
						</div>
						<div>
							<button submit class="btn btn-sm btn-primary mr-1">Ack. Flag</button>
							<button cancel class="btn btn-sm btn-default border">Cancel</button>
						</div>
					</form>
				</div>
				</div>

			@endif
		@endif
	@endif
	</div>
@endif