File: /var/www/html/owlcrm/resources/views/users/reminder/edit.blade.php
@extends('adminlte::page')
@section('title', 'Dashboard')
@section('content_header')
<h1>Reminder</h1>
<small>Manage Reminder</small>
@stop
@section('content')
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title"> Edit Reminder</h3>
</div>
@if (session('error'))
<h6 class="alert alert-danger">
{{ session('error') }}
</h6>
@endif
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form method="POST" id="edit_reminder" role="form" action="{{ route('reminder.update', $reminder->id) }}"
class="jqueryValidation">
@csrf
@method('PATCH')
<div class="card-body">
<div class=" form-group">
<label for="reminder_to">Reminder To</label>
<select class="form-control" name="reminder_to" id="">
<option value="">--Select--</option>
@foreach ($users as $user)
<option value="{{ $user->id }}"{{ $reminder->reminder_to == $user->id ? 'selected' : '' }}>
{{ $user->first_name . $user->last_name }}</option>
@endforeach
</select>
</div>
{{-- created by --}}
<div class="form-group">
<label for="entity_type"> Entity Type </label>
<select name="entity_type" id="entity_type" class="form-control">
<option value="">--Select--</option>
@foreach (App\Models\Reminder::Entity as $key => $entity)
<option value="{{ $key }}"{{ $reminder->entity_type == $key ? 'selected' : '' }}>
{{ $entity }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="entity_id">Entity Id</label>
<select name="entity_id" id="entity_id" class="form-control">
<option value="{{ $reminder->entity_id }}" selected>
{{ $reminder->entity_id }}
</option>
</select>
</div>
<div class="form-group">
<input type="checkbox" id="is_notified" name="is_notified" value="1"
{{ $reminder->is_notified == 1 ? 'checked' : '' }}>
<label for="is_notified">Is Notified</label>
</div>
<div class=" form-group">
<label for="reminder_date">Reminder Date</label>
<x-adminlte-input type="datetime-local" class="form-control" id="reminder_date " name="reminder_date"
placeholder="Enter Reminder Date"
value="{{ old('reminder_date', $reminder->reminder_date ? \Carbon\Carbon::parse($reminder->due_date)->format('Y-m-d\TH:i') : '') }}"
required />
</div>
{{-- email_notification --}}
<div class="form-group">
<input type="checkbox" id="email_notification" name="email_notification" value="1"
{{ $reminder->email_notification == 1 ? 'checked' : '' }}>
<label for="email_notification">Email Notification</label>
</div>
<div class="form-group">
<input type="checkbox" id="is_active" name="is_active" value="1"
{{ $reminder->status == 1 ? 'checked' : '' }}>
<label for="is_active">Is Active</label>
</div>
<div class=" form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description" rows="4" placeholder="Enter Description"
required>{{ old('description', $reminder->description) }}</textarea>
</div>
<div class="card-footer d-flex justify-content-end">
<a href="{{ route('reminder.index') }}" class="btn btn-danger mx-1">Cancel</a>
<button type="submit" class="btn btn-dark mx-1">Submit</button>
</div>
</form>
</div>
@push('js')
<script>
// for Entity_type and entity_id
$(document).ready(function() {
$('#entity_type').on('change', function() {
let entityType = $(this).val();
console.log('Selected entity type:', entityType);
if (entityType) {
$.ajax({
url: '/reminder/create',
type: 'GET',
data: {
entity_type: entityType
},
dataType: 'json',
success: function(response) {
console.log('Response:', response);
let entityIdSelect = $('#entity_id');
entityIdSelect.empty();
entityIdSelect.append('<option value="">Select</option>');
if (response.success) {
$.each(response.entities, function(index, entity) {
entityIdSelect.append('<option value="' + entity
.id + '">' + entity.first_name + entity
.last_name + '</option>');
});
} else {
alert(response.message);
}
},
error: function(xhr, status, error) {
console.error('Error fetching entity IDs:', error);
}
});
} else {
$('#entity_id').empty().append('<option value="">Select Entity Id</option>');
}
});
});
// End Entity_type and entity_id
</script>
@endpush
@stop