first commit

This commit is contained in:
2024-04-16 15:43:24 +05:45
commit b49e06fa93
4387 changed files with 543889 additions and 0 deletions

View File

@ -0,0 +1,218 @@
@extends('backend.template')
@section('content')
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">Add Options</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
<li class="breadcrumb-item active">Add Options</li>
</ol>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-3 col-md-4">
<form action="{{ route('options.store') }}" id="storeCustomForm" method="POST">
@csrf
<div class="card">
<div class="card-body">
<div class="form-group">
{{ createCustomSelect('tbl_students', 'name', 'student_id', '', 'Student Name', 'students_id', 'form-control select2', 'status<>-1') }}
</div>
<div class="form-group">
{{ createCustomSelect('tbl_programs', 'title', 'program_id', '', 'Program', 'programs_id', 'form-control select2', 'status<>-1') }}
</div>
<div class="form-group">
{{ createText('advices', 'advice', 'Advice') }}
</div>
<div class="form-group">
{{ createText('descriptions', 'description', 'Description') }}
</div>
<button type="button" id="btn-add-item" class="btn btn-success btn-add-item">
<i class="fas fa-plus"></i> Add More
</button>
</div>
<div class="card-footer">
<div class="col-md-12">
<button type="button" id="btn-submit" class="btn btn-primary btn-store">Submit</button>
<a href="{{ route('options.index') }}" class="btn btn-danger btn-cancel">Cancel</a>
</div>
</div>
<input type="hidden" name="programsData" id="programsData[]" value="-1">
<input type="hidden" name="advicesData" id="advicesData[]" value="-1">
<input type="hidden" name="descriptionsData" id="descriptionsData[]" value="-1">
</form>
</div>
</div>
<div class="col-lg-9 col-md-8">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Added Options</h5>
</div>
<div class="card-body">
<table class="table table-bordered">
<thead>
<tr>
<th>S.N.</th>
<th>Programs</th>
<th>Advice</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody id="addedItemTableBody">
</tbody>
</table>
</div>
</div>
</div>
</div>
w
<script>
document.addEventListener('DOMContentLoaded', function() {
var addButton = document.getElementById('btn-add-item');
var studentsId = document.querySelector('input[name="students_id"]');
var addedItemTableBody = document.querySelector('#addedItemTableBody');
var programsSelect = document.querySelector('select[name="programs_id"]');
var advicesInput = document.querySelector('input[name="advices"]');
var descriptionsInput = document.querySelector('input[name="descriptions"]');
var submitButton = document.getElementById('btn-submit');
// Add hidden fields for JavaScript arrays
var programsDataField = document.getElementById('programsData[]');
var advicesDataField = document.getElementById('advicesData[]');
var descriptionsDataField = document.getElementById('descriptionsData[]');
var programsData = [];
var advicesData = [];
var descriptionsData = [];
addButton.addEventListener('click', function() {
var programsId = programsSelect.value;
var programsTitle = programsSelect.options[programsSelect.selectedIndex].text || "N/A";
var advice = advicesInput.value || "N/A";
var description = descriptionsInput.value || "N/A";
programsData.push(programsId);
advicesData.push(advice);
descriptionsData.push(description);
var newRow = document.createElement('tr');
var serialNumber = addedItemTableBody.querySelectorAll('tr').length + 1;
var serialCell = document.createElement('td');
serialCell.textContent = serialNumber;
newRow.appendChild(serialCell);
var programsCell = document.createElement('td');
programsCell.textContent = programsTitle;
newRow.appendChild(programsCell);
var adviceCell = document.createElement('td');
adviceCell.textContent = advice;
newRow.appendChild(adviceCell);
var descriptionCell = document.createElement('td');
descriptionCell.textContent = description;
newRow.appendChild(descriptionCell);
var deleteButton = document.createElement('a');
deleteButton.innerHTML = '<i class="ri-delete-bin-fill align-bottom text-muted"></i>';
deleteButton.className = 'text-danger d-inline-block remove-item-btn';
var deleteCell = document.createElement('td');
deleteCell.appendChild(deleteButton);
newRow.appendChild(deleteCell);
deleteButton.addEventListener('click', function() {
addedItemTableBody.removeChild(newRow);
var index = programsData.indexOf(programsId);
if (index !== -1) {
programsData.splice(index, 1);
advicesData.splice(index, 1);
descriptionsData.splice(index, 1);
}
programsDataField.value = JSON.stringify(programsData);
advicesDataField.value = JSON.stringify(advicesData);
descriptionsDataField.value = JSON.stringify(descriptionsData);
}, );
addedItemTableBody.appendChild(newRow);
advicesInput.value = '';
descriptionsInput.value = '';
addedItemTableBody.appendChild(newRow);
programsDataField.value = JSON.stringify(programsData);
advicesDataField.value = JSON.stringify(advicesData);
descriptionsDataField.value = JSON.stringify(descriptionsData);
});
submitButton.addEventListener('click', function() {
var formData = new FormData();
// Append each array to the formData
programsData.forEach(function(program) {
formData.append('programs[]', program);
});
advicesData.forEach(function(advice) {
formData.append('advices[]', advice);
});
descriptionsData.forEach(function(description) {
formData.append('descriptions[]', description);
});
// Append the CSRF token if needed
formData.append('_token', '{{ csrf_token() }}');
// Make an AJAX POST request to the server
fetch("{{ route('options.store') }}", {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(responseData => {
if (responseData.status === true) {
alert(responseData.message);
} else {
alert('Error: ' + responseData.message);
}
})
.catch(error => {
console.error(error);
});
// Prevent the form submission
storeCustomForm.submit();
});
});
</script>
@endsection

View File

@ -0,0 +1,234 @@
@extends('backend.template')
@section('content')
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h2>{{ label('Options List') }}</h2>
<a href="{{ route('options.create') }}" class="btn btn-primary"><span>{{ label('Create New') }}</span></a>
</div>
<div class="card-body">
<table class="table dataTable" id="tbl_options" data-url="{{ route('options.sort') }}">
<thead class="table-light">
<tr>
<th class="tb-col text-uppercase"><span class="overline-title">{{ label('Sn.') }}</span></th>
<th class="tb-col text-uppercase text-uppercase"><span class="overline-title">{{ label('students') }}</span></th>
<th class="tb-co text-uppercase"><span class="overline-title">{{ label('programs') }}</span></th>
<th class="tb-col text-uppercase"><span class="overline-title">{{ label('advice') }}</span></th>
<th class="tb-col text-uppercase"><span class="overline-title">{{ label('Description') }}</span></th>
<th class="tb-col text-uppercase" data-sortable="false"><span class="overline-title">{{ label('Action') }}</span>
</th>
</tr>
</thead>
<tbody>
@php
$i = 1;
@endphp
@foreach ($data as $item)
<tr data-id="{{ $item->option_id }}" data-display_order="{{ $item->display_order }}"
class="draggable-row <?php echo $item->status == 0 ? 'bg-light bg-danger' : ''; ?>">
<td class="tb-col">{{ $i++ }}</td>
<td class="tb-col">
@if ($item->students_id)
{!! getFieldData('tbl_students', 'name', 'student_id', $item->students_id) !!}
@endif
</td>
<td class="tb-col">
{!! getFieldData('tbl_programs', 'title', 'program_id', $item->programs_id) !!}
</td>
<td class="tb-col">{{ $item->advice }}</td>
<td class="tb-col">{{ $item->description }}</td>
<td class="tb-col">
<div class="dropdown d-inline-block">
<button class="btn btn-soft-secondary btn-sm dropdown" type="button"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="ri-more-fill align-middle"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a href="{{ route('options.show', [$item->students_id]) }}"
class="dropdown-item"><i
class="ri-eye-fill align-bottom me-2 text-muted"></i>
{{ label('View') }}</a></li>
<li>
<a href="{{ route('options.destroy', [$item->option_id]) }}"
class="dropdown-item remove-item-btn" onclick="confirmDelete(this.href)">
<i class="ri-delete-bin-fill align-bottom me-2 text-muted"></i>
{{ label('Delete') }}
</a>
</li>
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
@push('css')
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/rowreorder/1.4.0/css/rowReorder.dataTables.min.css">
@endpush
@push('js')
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.68/vfs_fonts.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/rowreorder/1.4.0/js/dataTables.rowReorder.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
$(document).ready(function(e) {
$('.change-alias-badge').on('click', function() {
var aliasWrapper = $(this).prev('.alias-wrapper');
var aliasSpan = aliasWrapper.find('.alias');
var aliasInput = aliasWrapper.find('.alias-input');
var isEditing = $(this).hasClass('editing');
aliasInput.toggleClass("d-none");
if (isEditing) {
// Update alias text and switch to non-editing state
var newAlias = aliasInput.val();
aliasSpan.text(newAlias);
aliasSpan.show();
aliasInput.hide();
$(this).removeClass('editing').text('Change Alias');
var articleId = $(aliasWrapper).data('id');
var ajaxUrl = "{{ route('options.updatealias') }}";
var data = {
articleId: articleId,
newAlias: newAlias
};
$.ajax({
url: ajaxUrl,
type: 'POST',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: data,
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.error(error);
}
});
} else {
// Switch to editing state
aliasSpan.hide();
aliasInput.show().focus();
$(this).addClass('editing').text('Save Alias');
}
});
var mytable = $(".dataTable").DataTable({
ordering: true,
rowReorder: {
//selector: 'tr'
},
});
var isRowReorderComplete = false;
mytable.on('row-reorder', function(e, diff, edit) {
isRowReorderComplete = true;
});
mytable.on('draw', function() {
if (isRowReorderComplete) {
var url = mytable.table().node().getAttribute('data-url');
var ids = mytable.rows().nodes().map(function(node) {
return $(node).data('id');
}).toArray();
console.log(ids);
$.ajax({
url: url,
type: "POST",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
},
data: {
id_order: ids
},
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.error(error);
}
});
isRowReorderComplete = false;
}
});
});
function confirmDelete(url) {
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: 'You will not be able to recover this item!',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Delete',
cancelButtonText: 'Cancel',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: url,
type: 'DELETE',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(response) {
Swal.fire('Deleted!', 'The item has been deleted.', 'success');
location.reload();
},
error: function(xhr, status, error) {
Swal.fire('Error!', 'An error occurred while deleting the item.', 'error');
}
});
}
});
}
function confirmToggle(url) {
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: 'Publish Status of Item will be changed!! if Unpublished, links will be dead!',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Proceed',
cancelButtonText: 'Cancel',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: url,
type: 'GET',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(response) {
Swal.fire('Updated!', 'Publishing Status has been updated.', 'success');
location.reload();
},
error: function(xhr, status, error) {
Swal.fire('Error!', 'An error occurred.', 'error');
}
});
}
});
}
</script>
@endpush

View File

@ -0,0 +1,75 @@
@extends('backend.template')
@section('content')
<!-- start page title -->
<div class="row">
<div class="col">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">Issued</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
<li class="breadcrumb-item active">Issued</li>
</ol>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-md-4">
<form action="{{ route('options.store') }}" id="storeCustomForm" method="POST">
@csrf
<div class="card">
<div class="card-body">
<div class="form-group">
{{ createCustomSelect('tbl_students', 'name', 'student_id', '', 'Student Name', 'students_id', 'form-control select2', 'status<>-1') }}
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group">
{{ createCustomSelect('tbl_countries', 'title', 'country_id', '', 'Country', 'countries_id', 'form-control select2', 'status<>-1') }}
</div>
<div class="form-group">
{{ createCustomSelect('tbl_institutions', 'title', 'institution_id', '', 'Institution', 'institutions_id', 'form-control select2', 'status<>-1') }}
</div>
<div class="form-group">
{{ createCustomSelect('tbl_programs', 'title', 'program_id', '', 'Program', 'programs_id', 'form-control select2', 'status<>-1') }}
</div>
<div class="form-group">
{{ createText('advices', 'advice', 'Advice') }}
</div>
</div>
<div class="col-md-8">
<div id="student-details">
<!--For displaying student detail-->
</div>
<div id="program-details">
<!--For displaying program detail-->
</div>
</div>
<div class="card-footer">
<div class="col-md-12">
<button type="button" id="btn-submit" class="btn btn-primary btn-store">Submit</button>
<a href="{{ route('options.index') }}" class="btn btn-danger btn-cancel">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,36 @@
@extends('backend.template')
@section('content')
<div class='card'>
<div class='card-header d-flex justify-content-between align-items-center'>
<h2><?php echo label('View Details'); ?></h2>
<?php createButton('btn-primary btn-cancel', '', 'Back to List', route('options.index')); ?>
</div>
<div class='card-body'>
<p><b>Students Name :&nbsp;&nbsp;&nbsp;&nbsp;</b> <span>{!! getFieldData('tbl_students', 'name', 'student_id', $student_id) !!}</span></p>
</div>
<div class='card-body'>
<table class="table">
<thead>
<tr>
<th style="width: 5%;">S.N.</th>
<th style="width: 20%;">Programs</th>
<th>Advice</th>
<th>Description</th>
<!-- Add more table headers as needed -->
</tr>
</thead>
<tbody>
@php $serialNumber = 1; @endphp
@foreach ($data as $option)
<tr>
<td>{{ $serialNumber++ }}</td>
<td style="width: 30%;">{{ getFieldData('tbl_programs', 'title', 'program_id', $option->programs_id) }}</td>
<td>{{ $option->advice }}</td>
<td>{{ $option->description }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection