Rapport-Laravel/resources/views/doctor/list.blade.php

165 lines
8.8 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.shared/title-meta', ['title' => "History"])
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
</head>
<body class="loading">
<div class="account-pages">
<div class="container">
<!-- end page title -->
@if(session()->has('message'))
<div class="alert alert-success">
{{ session()->get('message') }}
</div>
@endif
@if(session()->has('error'))
<div class="alert alert-danger">
{{ session()->get('error') }}
</div>
@endif
<div class="row">
<div class="col-12 p-0">
<div class="card" id="list-wrapper">
<div class="card-body">
<div class="responsive-table-plugin">
<div class="table-rep-plugin">
<div class="table-responsive" data-pattern="priority-columns">
<table id="tech-companies-1" class="table table-striped">
<thead>
<tr>
<th>Actions</th>
@foreach ($fields as $field => $props)
<th>{{ $props['title'] }}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($items as $item)
<tr>
<td>
<button type="button" jsondata="{{json_encode($item)}}" class="btn btn-primary btn-xs edit-button">Edit</button>
</td>
@foreach ($fields as $field => $props)
<td>
{{ isset($item->{$field}) ? $item->{$field} : '' }}
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div> <!-- end .table-responsive -->
</div> <!-- end .table-rep-plugin-->
</div> <!-- end .responsive-table-plugin-->
</div> <!-- end card body-->
</div> <!-- end card -->
<div class="card" id="edit-wrapper">
<form method="post" action="/doctor/submit" id="form-availiblity" enctype="multipart/form-data">
@csrf
<input type="hidden" id="field-id" name="id" value="">
<div class="card-body">
<div class="row">
<div class="col-6 mb-3">
<h4 class="page-title">Edit Doctor</h4>
</div>
<div class="col-6 mb-3">
<div class="float-end">
<button type="button" class="btn btn-dark waves-effect waves-light btn-back">Back</button>
<button type="submit" class="btn btn-success waves-effect waves-light">Submit</button>
</div>
</div>
@foreach($fields as $field => $props)
@if($props['type'] != 'hidden')
<div class="col-md-{{isset($props['fullwidth'])?'12':'6'}} mb-3">
<label for="field-{{$field}}" class="form-label">{{$props['title']}} {!!isset($props['required'])&&$props['required'] ? '<span class="text-danger">*</span>':''!!} </label>
@endif
@switch($props['type'])
@case('hidden')
<input type="{{$props['type']}}" id="field-{{$field}}" name="{{$field}}" value="{{$mode=='edit'?$item->{$field}:''}}">
@break
@case('text')
@case('email')
@case('number')
@case('tel')
<input type="{{$props['type']}}" id="field-{{$field}}" name="{{$field}}" class="form-control" placeholder="Enter {{$props['title']}}" value="" >
@break
@case('date')
<input type="text" id="field-{{$field}}" name="{{$field}}" class="form-control" placeholder="Enter {{$props['title']}}" value="" data-provide="datepicker" data-date-format="mm-dd-yyyy" data-date-autoclose="true">
@break
@case('select')
<select class="form-control" id="field-{{$field}}" name="{{$field}}">
<option value=""> -- Select {{$props['title']}} -- </option>
@foreach($props['values'] as $k => $v)
<option value="{{$k}}">{{$v}}</option>
@endforeach
</select>
@break
@case('checkbox')
@foreach($props['values'] as $k => $v)
<div class="form-check mb-2 form-check-blue">
<input class="form-check-input" type="checkbox" name="{{$field}}[]" value="{{$k}}" id="field-{{$field}}-{{$k}}" {{$mode=='edit' && isset($item->{$field}) && in_array($k, $item->{$field}) ? 'checked':''}}>
<label class="form-check-label" for="field-{{$field}}-{{$k}}">{{$v}}</label>
</div>
@endforeach
@break
@case('image')
<div class="mt-3" id="file_wrapper">
<input type="file" name="{{$field}}" class="dropify" data-default-file="{{isset($item->{$field})?$item->{$field}:''}}" data-allowed-file-extensions="png jpg jpeg gif" />
<p class="text-muted text-center mt-2 mb-0">500MB Max File size</p>
</div>
@break
@endswitch
@if($props['type'] != 'hidden')
</div>
@endif
@endforeach
<div class="col-md-12 mb-3">
<div class="float-end">
<button type="button" class="btn btn-dark waves-effect waves-light btn-back">Back</button>
<button type="submit" class="btn btn-success waves-effect waves-light">Submit</button>
</div>
</div>
</div>
</div> <!-- end card-body -->
</form>
</div> <!-- end card-->
</div><!-- end col-->
</div>
<!-- end row-->
</div> <!-- container -->
</div>
<!-- end page -->
@include('layouts.shared/footer-script')
<script type="text/javascript">
jQuery(document).ready(function($){
$('#edit-wrapper').hide();
$('.edit-button').click(function(){
$('#edit-wrapper').show();
$('#list-wrapper').hide();
let data = JSON.parse($(this).attr('jsondata') )
$('#form-availiblity')[0].reset()
for(let field of Object.keys(data) ) {
$('#field-'+field).val(data[field]).change();
}
console.log(data)
})
$('.btn-back').click(function(){
$('#list-wrapper').show();
$('#edit-wrapper').hide();
})
})
</script>
</body>
</html>