222 lines
6.1 KiB
Twig
222 lines
6.1 KiB
Twig
{% extends 'base.html.twig' %}
|
|
|
|
{% block body %}
|
|
<!-- BEGIN: Subheader -->
|
|
<div class="m-subheader">
|
|
<div class="d-flex align-items-center">
|
|
<div class="mr-auto">
|
|
<h3 class="m-subheader__title">
|
|
Batteries
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END: Subheader -->
|
|
<div class="m-content">
|
|
<!--Begin::Section-->
|
|
<div class="row">
|
|
<div class="col-xl-12">
|
|
<div class="m-portlet m-portlet--mobile">
|
|
<div class="m-portlet__body">
|
|
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
|
|
<div class="row align-items-center">
|
|
<div class="col-xl-8 order-2 order-xl-1">
|
|
<div class="form-group m-form__group row align-items-center">
|
|
<div class="col-md-4">
|
|
<div class="m-input-icon m-input-icon--left">
|
|
<input type="text" class="form-control m-input m-input--solid" placeholder="Search..." id="data-rows-search">
|
|
<span class="m-input-icon__icon m-input-icon__icon--left">
|
|
<span><i class="la la-search"></i></span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-xl-4 order-1 order-xl-2 m--align-right">
|
|
<a href="{{ url('battery_create') }}" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
|
|
<span>
|
|
<i class="fa fa-battery-3"></i>
|
|
<span>New Battery</span>
|
|
</span>
|
|
</a>
|
|
<div class="m-separator m-separator--dashed d-xl-none"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--begin: Datatable -->
|
|
<div id="data-rows"></div>
|
|
<!--end: Datatable -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
$(function() {
|
|
var options = {
|
|
data: {
|
|
type: 'remote',
|
|
source: {
|
|
read: {
|
|
url: '{{ url("battery_rows") }}',
|
|
method: 'POST'
|
|
}
|
|
},
|
|
saveState: {
|
|
cookie: false,
|
|
webstorage: false
|
|
},
|
|
pageSize: 10,
|
|
serverPaging: true,
|
|
serverFiltering: true,
|
|
serverSorting: true
|
|
},
|
|
layout: {
|
|
scroll: true
|
|
},
|
|
columns: [
|
|
{
|
|
field: 'id',
|
|
title: 'ID',
|
|
width: 30
|
|
},
|
|
{
|
|
field: 'image_file',
|
|
title: '',
|
|
sortable: false,
|
|
width: 40,
|
|
template: function (row, index, datatable) {
|
|
var html = '<div class="user-portrait-sm" style="background-image: url(\'' + (row.image_file ? "/uploads/" + row.image_file : "/assets/images/battery.gif") + '\');"></div>';
|
|
|
|
return html;
|
|
}
|
|
},
|
|
/*
|
|
{
|
|
field: 'mfg_name',
|
|
title: 'Manufacturer',
|
|
width: 150
|
|
},
|
|
*/
|
|
{
|
|
field: 'size_name',
|
|
title: 'Size',
|
|
width: 180
|
|
},
|
|
{
|
|
field: 'model_name',
|
|
title: 'Brand',
|
|
width: 120
|
|
},
|
|
{
|
|
field: 'flag_active',
|
|
title: 'Active',
|
|
template: function (row, index, datatable) {
|
|
var tag = '';
|
|
|
|
if (row.flag_active === true) {
|
|
tag = '<span class="m-badge m-badge--success m-badge--wide">Yes</span>';
|
|
} else {
|
|
tag = '<span class="m-badge m-badge--danger m-badge--wide">No</span>';
|
|
}
|
|
|
|
return tag;
|
|
}
|
|
},
|
|
{
|
|
field: 'flag_subscription',
|
|
title: 'Subscription',
|
|
template: function (row, index, datatable) {
|
|
var tag = '';
|
|
|
|
if (row.flag_subscription === true) {
|
|
tag = '<span class="m-badge m-badge--success m-badge--wide">Yes</span>';
|
|
} else {
|
|
tag = '<span class="m-badge m-badge--danger m-badge--wide">No</span>';
|
|
}
|
|
|
|
return tag;
|
|
}
|
|
},
|
|
/*
|
|
{
|
|
field: 'prod_code',
|
|
title: 'Product Code',
|
|
width: 150
|
|
},
|
|
*/
|
|
{
|
|
field: 'warr_private',
|
|
title: 'Private Wty.',
|
|
width: 50
|
|
},
|
|
{
|
|
field: 'warr_commercial',
|
|
title: 'Commercial Wty.',
|
|
width: 50
|
|
},
|
|
{
|
|
field: 'sell_price',
|
|
title: 'Price',
|
|
width: 100
|
|
},
|
|
{
|
|
field: 'Actions',
|
|
width: 110,
|
|
title: 'Actions',
|
|
sortable: false,
|
|
overflow: 'visible',
|
|
template: function (row, index, datatable) {
|
|
var actions = '';
|
|
|
|
if (row.meta.update_url != '') {
|
|
actions += '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" data-id="' + row.prod_code + '" title="Edit"><i class="la la-edit"></i></a>';
|
|
}
|
|
|
|
if (row.meta.delete_url != '') {
|
|
actions += '<a href="' + row.meta.delete_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete" data-id="' + row.prod_code + '" title="Delete"><i class="la la-trash"></i></a>';
|
|
}
|
|
|
|
return actions;
|
|
},
|
|
}
|
|
],
|
|
search: {
|
|
onEnter: false,
|
|
input: $('#data-rows-search'),
|
|
delay: 400
|
|
}
|
|
};
|
|
|
|
var table = $("#data-rows").mDatatable(options);
|
|
|
|
$(document).on('click', '.btn-delete', function(e) {
|
|
var url = $(this).prop('href');
|
|
var id = $(this).data('id');
|
|
var btn = $(this);
|
|
|
|
e.preventDefault();
|
|
|
|
swal({
|
|
title: 'Confirmation',
|
|
html: 'Are you sure you want to delete <strong>' + id + '</strong>?',
|
|
type: 'warning',
|
|
showCancelButton: true
|
|
}).then((result) => {
|
|
if (result.value) {
|
|
$.ajax({
|
|
method: "DELETE",
|
|
url: url
|
|
}).done(function(response) {
|
|
table.row(btn.parents('tr')).remove();
|
|
table.reload();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|