<div class="table-responsive">
    <div class="">
    	
        <h5 class="mb-0">Bed Details</h5>
        {{-- <a href="{{ route('ipd-billings.add-more', $ipd_patient_id->patient_id) }}" style="float: right; margin-right: 9px; margin-top: -23px; " class="btn btn-success">Generate</a> --}}
        {{-- <a href="{{ route('ipd-billings.add-more', ['id' => $ipd_patient_id->patient_id, 'ipd_admission_id' => $id]) }}" style="float: right; margin-right: 9px; margin-top: -23px;" class="btn btn-success">Generate</a> --}}
        @if (count($bed_histories)>0 && $bed_historiesData->sale_invoice_batch_id=='')
		<a href="{{ route('ipd-billings.add-more', ['id' => $id, 'ipd_admission_id' => $id, 'bill_type' => 'bed_bill']) }}" style="float: right; margin-right: 9px; margin-top: -23px;" class="btn btn-success"><i class="bi bi-receipt-cutoff"></i> Generate Bill</a>
		@else
		 	@if(isset($ipd_patient_id->sale_invoice_id) && isset($bed_historiesData->sale_invoice_batch_id))
				<a href="{{route('ipd-billings.edit',['id'=>$ipd_patient_id->sale_invoice_id,'batch_id'=>$bed_historiesData->sale_invoice_batch_id])}}?redirect=ipd_billings&&bill_type=bed_bill" style="float: right; margin-right: 9px; margin-top: -23px;" class="btn btn-success"><i class="bi bi-receipt-cutoff"></i> Update Bill</a>
			@endif
		@endif
    <button style="float: right; margin-right: 9px; margin-top: -23px;" type="button" class="btn btn-primary" id="createBed" data-bs-toggle="modal" data-bs-target="#commonModal"><i class="bx bx-plus-circle"></i> Assign Bed To Patient</button>
  	</div>
  	<hr class="mb-2">
  	<table id="beds_table" class="table table-bordered align-middle" style="width:100%">
	    <thead class="table-light">
	      <tr>
	        <th class="thbutton">Sl No</th>
	        <th>Bed No</th>
	        <th>Floor Details</th>
			<th>Days</th>
	        <th>Revert Reason</th>
	        <th>Check IN/OUT Date</th>
	        <th class="thbutton">Bed Status</th>
	        <th class="thbutton">Transfer Bed</th>
			{{--<th class="thbutton">Refresh Billing</th>--}}
			
	        <th class="thbutton">Edit</th>
	        <th class="thbutton">Delete</th>
			
	      </tr>
	    </thead>
	    <tbody>
	      	@if (count($bed_histories)>0)
		        @foreach ($bed_histories as $key => $bed)
		          	<tr>
			            <td class="text-center">{{ $key+1 }}</td>
			            <td style="font-size: medium; font-weight:bold;">{{ $bed->getBed->name ?? 'N/A' }}</td>
			            <td> <b>{{ $bed->getBed->getRoom->getFloor->name ?? ''}}</b> ({{ $bed->getBed->getRoom->getBuilding->name ?? ''}})</td>
						<td>
							@if(isset($bed->full_days) && $bed->full_days!='')
							Full Day:<b>{{ $bed->full_days ?? 'N/A' }} </b>
							@endif
							@if(isset($bed->half_days) && $bed->half_days!='')
							 - Half Day: <b>{{ $bed->half_days ?? 'N/A' }}</b>
							@endif
							 </td>
			            <td>{{ $bed->revert_reason ?? 'N/A' }}</td>
			            <td>IN: {!! $bed->check_in_date_time ? formatedDateTime($bed->check_in_date_time) : 'N/A' !!}<br>
							OUT: {!! $bed->check_out_date_time ? formatedDateTime($bed->check_out_date_time) : 'N/A' !!}
						</td>
                  {{-- <td>
                            <div class="form-check form-check-inline{{ $bed_histories }}">
                                <input class="form-check-input{{ $bed_histories }} btn-lg changeStatusCustom" type="checkbox" id="inlineCheckbox{{ $bed_histories }}" data-url="{{ route('ipd-admissions.bed-allotment.status', ['id' => $bed->id]) }}" data-id="{{$bed->id }}" data-status="{{$bed->allotment_status == '0' ? '1' : '0' }}" {{$bed->allotment_status == '1' ? 'checked' : '' }}>
                            </div>
                        </td> --}}
						<td class="thbutton">
							@if($bed->is_active == '1')
							<span class="badge btn-warning">On Hold</span>
							@else
								<span class="badge btn-success">Released</span>
							@endif
						</td>
						<td class="thbutton">
							<button data-id="{{ $bed->id }}" class="btn btn-md btn-secondary bedTransfer" data-bs-toggle="modal" data-bs-target="#commonModal" data-admission_id="{!! $bed->ipd_admission_id !!}">
								<i class="bi bi-arrow-left-right"></i> Transfer
				            </button>
						</td>
			            {{--<td class="text-center">
			            	@if($bed->sale_invoice_batch_id != '' && $bed->is_updated == 1)
				              <button data-id="{{ $bed->id }}" class="btn btn-md btn-warning refresh">
				                <i class="bi bi-arrow-clockwise"></i> Refresh
				              </button>
			              	@endif
			            </td>--}}
						
			            <td class="text-center">
			              <button data-id="{{ $bed->id }}" class="btn btn-sm btn-outline-secondary editBed" data-bs-toggle="modal" data-bs-target="#commonModal" title="Edit">
			                <i class="bi bi-pencil-square"></i>
			              </button>
			            </td>
			            <td class="text-center">
			              <a data-url="{{route('ipd-admissions-bed-remove')}}" data-id="{{$bed->id}}" class="btn btn-sm btn-danger deleteDataCustomBed" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete">
			                  <i class="bi bi-trash text-white"></i>
			              </a>
			            </td>
		          	</tr>
		        @endforeach
	      	@else
	        <tr>
	          <td colspan="9">No Data Found</td>
	        </tr>
	      	@endif
    	</tbody>
	</table>
</div>
