ultimatepos/Modules/ManagementTools/Resources/views/tools/index.blade.php

103 lines
3.9 KiB
PHP

@extends('layouts.app')
@section('title', __('managementtools::lang.tools'))
@section('content')
@include('managementtools::layouts.nav')
<section class="content no-print mt-page">
<div class="mt-page-header">
<h1><i class="fas fa-toolbox" style="color:#2563eb;margin-left:8px;"></i> @lang('managementtools::lang.tools')</h1>
<button type="button" class="mt-btn-primary btn-modal"
data-href="{{ action([\Modules\ManagementTools\Http\Controllers\ToolController::class, 'create']) }}"
data-container=".mt_tool_modal">
<i class="fa fa-plus"></i> @lang('managementtools::lang.add')
</button>
</div>
<div class="mt-card">
<div class="mt-card-header">
<h3 class="mt-card-title">@lang('managementtools::lang.all_tools')</h3>
</div>
<div class="mt-card-body">
<div class="table-responsive">
<table class="table table-bordered table-striped" id="mt_tools_table" style="width:100%">
<thead>
<tr>
<th>@lang('managementtools::lang.title')</th>
<th>@lang('managementtools::lang.parent')</th>
<th>@lang('managementtools::lang.attributes')</th>
<th>@lang('managementtools::lang.action')</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</section>
<div class="modal fade mt_tool_modal" tabindex="-1" role="dialog"></div>
@endsection
@section('javascript')
<script type="text/javascript">
$(document).ready(function() {
var tools_table = $('#mt_tools_table').DataTable({
processing: true,
serverSide: true,
ajax: '{{ action([\Modules\ManagementTools\Http\Controllers\ToolController::class, "index"]) }}',
columns: [
{ data: 'title', name: 'title' },
{ data: 'parent_name', name: 'parent_name', orderable: false, searchable: false },
{ data: 'attributes_display', name: 'attributes_display', orderable: false, searchable: false },
{ data: 'action', name: 'action', orderable: false, searchable: false }
]
});
$(document).on('click', '.add_mt_attribute_row', function() {
var row = $('.mt_attribute_row:first').clone();
row.find('input').val('');
$('#mt_attributes_wrapper').append(row);
});
$(document).on('click', '.remove_mt_attribute_row', function() {
if ($('.mt_attribute_row').length > 1) {
$(this).closest('.mt_attribute_row').remove();
}
});
$(document).on('submit', 'form#mt_tool_form', function(e) {
e.preventDefault();
var form = $(this);
$.ajax({
method: form.find('input[name="_method"]').val() === 'PUT' ? 'PUT' : 'POST',
url: form.attr('action'),
dataType: 'json',
data: form.serialize(),
success: function(result) {
if (result.success) {
$('.mt_tool_modal').modal('hide');
toastr.success(result.msg);
tools_table.ajax.reload();
} else {
toastr.error(result.msg);
}
}
});
});
$(document).on('click', '.delete_mt_tool', function() {
var url = $(this).data('href');
swal({ title: LANG.sure, icon: 'warning', buttons: true, dangerMode: true }).then(function(willDelete) {
if (willDelete) {
$.ajax({ method: 'DELETE', url: url, dataType: 'json', success: function(result) {
if (result.success) { toastr.success(result.msg); tools_table.ajax.reload(); }
else { toastr.error(result.msg); }
}});
}
});
});
});
</script>
@endsection