@extends('adminlte::page') @section('title', 'Reason Add') @section('content')

Add {{$type}}

@csrf @php $groupedData = $reasonData->groupBy('type'); @endphp @if($d_id != null) @if($groupedData->has('document')) @foreach($groupedData['document'] as $key => $val) @php $ids = explode(',', $val['document_ids']); $ids = array_values(array_filter($ids)); $add_ids = explode(',', $val['additional_ids']); $add_ids = array_values(array_filter($add_ids)); @endphp
@endforeach @endif @if($groupedData->has('doc_cat')) @foreach($groupedData['doc_cat'] as $key => $val) @php $ids = explode(',', $val['document_ids']); $ids = array_values(array_filter($ids)); $add_ids = explode(',', $val['additional_ids']); $add_ids = array_values(array_filter($add_ids)); @endphp
@php //echo "
"; print_r($reasonDocuments); exit; @endphp
																								
																						
@endforeach @endif @endif @if($groupedData->has('process'))
Processes
@foreach($groupedData['process'] as $key => $val) @php $ids = explode(',', $val['document_ids']); $ids = array_values(array_filter($ids)); @endphp
@endforeach @endif
@if($d_id == null)
@if($type == "document")
@else
@endif
@endif
@if($type != "document")
@endif
@stop @section('css') @stop @section('js') < {{-- function initSelect2Sortable(selectId, hiddenInputId) { // Initialize Select2 $('#' + selectId).select2({ placeholder: "Select documents", width: 'resolve' }); // Wait for Select2 to render setTimeout(function () { const rendered = document.querySelector('#' + selectId + ' + .select2 .select2-selection__rendered'); if (rendered) { Sortable.create(rendered, { animation: 150, ghostClass: 'sortable-ghost', onEnd: function () { let reorderedTitles = []; // Get reordered text labels $('#' + selectId).next('.select2').find('li.select2-selection__choice').each(function () { const title = $(this).attr('title'); if (title) reorderedTitles.push(title.trim()); }); let orderedValues = []; $('#' + selectId + ' option:selected').each(function () { const text = $(this).text().trim(); const value = $(this).val(); if (reorderedTitles.includes(text)) { orderedValues.push({ text, value }); } }); // Match values according to the reordered titles const valuesOnly = reorderedTitles.map(title => { const match = orderedValues.find(item => item.text === title); return match ? match.value : null; }).filter(Boolean); // Set hidden input with the final order $('#' + hiddenInputId).val(valuesOnly.join(',')); } }); } }, 300); }--}} @stop