2024-04-07 07:28:58 +00:00
|
|
|
@extends('layouts.app')
|
2024-04-05 05:22:15 +00:00
|
|
|
@section('content')
|
2024-04-11 10:59:09 +00:00
|
|
|
<div class="page-content">
|
|
|
|
<div class="container-fluid">
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
<!-- start page title -->
|
|
|
|
@include('layouts.partials.breadcrumb', ['title' => 'Vendor'])
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
<!-- end page title -->
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
<div class="card">
|
|
|
|
<div class="card-header align-items-center d-flex">
|
|
|
|
<h5 class="card-title flex-grow-1 mb-0">Vendor Lists</h5>
|
|
|
|
<div class="flex-shrink-0">
|
|
|
|
<a href="{{ route('vendors.create') }}" class="btn btn-success waves-effect waves-light"><i
|
|
|
|
class="ri-add-fill me-1 align-bottom"></i>Create Vendor</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-07 07:28:58 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
<div class="card-body">
|
|
|
|
<table class="dataTable table" id="tbl_vendors" data-url="{{ route('vendors.sort') }}">
|
|
|
|
<thead class="table-light">
|
|
|
|
<tr>
|
|
|
|
<th class="tb-col"><span class="overline-title">{{ label('Sn.') }}</span></th>
|
|
|
|
<th class="tb-col"><span class="overline-title">{{ label('vendortypes') }}</span></th>
|
|
|
|
<th class="tb-col"><span class="overline-title">{{ label('title') }}</span></th>
|
|
|
|
<th class="tb-col"><span class="overline-title">{{ label('alias') }}</span></th>
|
|
|
|
<th class="tb-col" data-sortable="false"><span class="overline-title">{{ label('Action') }}</span>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach ($data as $index => $item)
|
|
|
|
<tr data-id="{{ $item->vendor_id }}" data-display_order="{{ $item->display_order }}"
|
|
|
|
class="draggable-row <?php echo $item->status == 0 ? 'bg-light bg-danger' : ''; ?>">
|
|
|
|
<td class="tb-col">{{ $index + 1 }}</td>
|
|
|
|
<td class="tb-col">
|
|
|
|
{!! getFieldData('tbl_vendortypes', 'title', 'vendortypes_id', $item->vendortypes_id) !!}
|
|
|
|
</td>
|
|
|
|
<td class="tb-col">{{ $item->title }}</td>
|
|
|
|
<td class="tb-col">
|
|
|
|
<div class="alias-wrapper" data-id="{{ $item->vendor_id }}">
|
|
|
|
<span class="alias">{{ $item->alias }}</span>
|
|
|
|
<input type="text" class="alias-input d-none" value="{{ $item->alias }}"
|
|
|
|
id="alias_{{ $item->vendor_id }}" />
|
|
|
|
</div>
|
|
|
|
<span class="badge badge-soft-primary change-alias-badge">change alias</span>
|
|
|
|
</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('vendors.show', [$item->vendor_id]) }}" class="dropdown-item"><i
|
|
|
|
class="ri-eye-fill text-muted me-2 align-bottom"></i> {{ label('View') }}</a></li>
|
|
|
|
<li><a href="{{ route('vendors.edit', [$item->vendor_id]) }}"
|
|
|
|
class="dropdown-item edit-item-btn"><i
|
|
|
|
class="ri-pencil-fill text-muted me-2 align-bottom"></i> {{ label('Edit') }}</a></li>
|
|
|
|
<li>
|
|
|
|
<a href="{{ route('vendors.toggle', [$item->vendor_id]) }}"
|
|
|
|
class="dropdown-item toggle-item-btn" onclick="confirmToggle(this.href)">
|
|
|
|
<i class="ri-article-fill text-muted me-2 align-bottom"></i>
|
|
|
|
{{ $item->status == 1 ? label('Unpublish') : label('Publish') }}
|
|
|
|
</a>
|
2024-04-07 07:28:58 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="{{ route('vendors.clone', [$item->vendor_id]) }}"
|
|
|
|
class="dropdown-item toggle-item-btn" onclick="confirmClone(this.href)">
|
|
|
|
<i class="ri-file-copy-line text-muted me-2 align-bottom"></i> {{ label('Clone') }}
|
|
|
|
</a>
|
2024-04-07 07:28:58 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="{{ route('vendors.destroy', [$item->vendor_id]) }}"
|
|
|
|
class="dropdown-item remove-item-btn" onclick="confirmDelete(this.href)">
|
|
|
|
<i class="ri-delete-bin-fill text-muted me-2 align-bottom"></i> {{ label('Delete') }}
|
|
|
|
</a>
|
2024-04-07 07:28:58 +00:00
|
|
|
|
2024-04-11 10:59:09 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
@endforeach
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-07 07:28:58 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@push('js')
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(e) {
|
|
|
|
$('.change-alias-badge').on('click', function() {
|
2024-04-05 05:22:15 +00:00
|
|
|
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) {
|
2024-04-07 07:28:58 +00:00
|
|
|
// 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('vendors.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);
|
|
|
|
}
|
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
} else {
|
2024-04-07 07:28:58 +00:00
|
|
|
// Switch to editing state
|
|
|
|
aliasSpan.hide();
|
|
|
|
aliasInput.show().focus();
|
|
|
|
$(this).addClass('editing').text('Save Alias');
|
2024-04-05 05:22:15 +00:00
|
|
|
}
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
|
|
|
var mytable = $(".dataTable").DataTable({
|
2024-04-05 05:22:15 +00:00
|
|
|
ordering: true,
|
|
|
|
rowReorder: {
|
2024-04-07 07:28:58 +00:00
|
|
|
//selector: 'tr'
|
2024-04-05 05:22:15 +00:00
|
|
|
},
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-07 07:28:58 +00:00
|
|
|
var isRowReorderComplete = false;
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-07 07:28:58 +00:00
|
|
|
mytable.on('row-reorder', function(e, diff, edit) {
|
2024-04-05 05:22:15 +00:00
|
|
|
isRowReorderComplete = true;
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-07 07:28:58 +00:00
|
|
|
mytable.on('draw', function() {
|
2024-04-05 05:22:15 +00:00
|
|
|
if (isRowReorderComplete) {
|
2024-04-07 07:28:58 +00:00
|
|
|
var url = mytable.table().node().getAttribute('data-url');
|
|
|
|
var ids = mytable.rows().nodes().map(function(node) {
|
|
|
|
return $(node).data('id');
|
|
|
|
}).toArray();
|
2024-04-05 05:22:15 +00:00
|
|
|
|
2024-04-07 07:28:58 +00:00
|
|
|
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;
|
2024-04-05 05:22:15 +00:00
|
|
|
}
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
});
|
2024-04-07 07:28:58 +00:00
|
|
|
|
|
|
|
function confirmDelete(url) {
|
|
|
|
event.preventDefault();
|
|
|
|
Swal.fire({
|
2024-04-05 05:22:15 +00:00
|
|
|
title: 'Are you sure?',
|
|
|
|
text: 'You will not be able to recover this item!',
|
|
|
|
icon: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: 'Delete',
|
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
reverseButtons: true
|
2024-04-07 07:28:58 +00:00
|
|
|
}).then((result) => {
|
2024-04-05 05:22:15 +00:00
|
|
|
if (result.isConfirmed) {
|
2024-04-07 07:28:58 +00:00
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'GET',
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
}
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function confirmToggle(url) {
|
|
|
|
event.preventDefault();
|
|
|
|
Swal.fire({
|
2024-04-05 05:22:15 +00:00
|
|
|
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
|
2024-04-07 07:28:58 +00:00
|
|
|
}).then((result) => {
|
2024-04-05 05:22:15 +00:00
|
|
|
if (result.isConfirmed) {
|
2024-04-07 07:28:58 +00:00
|
|
|
$.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');
|
|
|
|
}
|
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
}
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function confirmClone(url) {
|
|
|
|
event.preventDefault();
|
|
|
|
Swal.fire({
|
2024-04-05 05:22:15 +00:00
|
|
|
title: 'Are you sure?',
|
|
|
|
text: 'Clonning will create replica of current row. No any linked data will be updated!',
|
|
|
|
icon: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonText: 'Proceed',
|
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
reverseButtons: true
|
2024-04-07 07:28:58 +00:00
|
|
|
}).then((result) => {
|
2024-04-05 05:22:15 +00:00
|
|
|
if (result.isConfirmed) {
|
2024-04-07 07:28:58 +00:00
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: 'GET',
|
|
|
|
headers: {
|
|
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
|
|
},
|
|
|
|
success: function(response) {
|
|
|
|
Swal.fire('Updated!', 'Clonning Completed', 'success');
|
|
|
|
location.reload();
|
|
|
|
},
|
|
|
|
error: function(xhr, status, error) {
|
|
|
|
Swal.fire('Error!', 'An error occurred.', 'error');
|
|
|
|
}
|
|
|
|
});
|
2024-04-05 05:22:15 +00:00
|
|
|
}
|
2024-04-07 07:28:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2024-04-05 05:22:15 +00:00
|
|
|
@endpush
|