/home/mip/mip/app/Modules/Client/Views/questionnaire/template/index.blade.php
@extends('Client::layouts')
@section('page-body')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<i class="fa fa-{{$pageIcon ? $pageIcon : 'angle-double-right'}}" aria-hidden="true"></i> {{$pageTitle}}
<br>
<small>{{$pageDescription}}</small>
</h1>
<ol class="breadcrumb">
<li class="active"><i class="fa fa-{{$pageIcon ? $pageIcon : 'angle-double-right'}}"></i> {{$pageTitle}}</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
@include('Client::message')
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">List of Questionnaire Template</h3>
@can('create', $permissions)
<span class="pull-right">
<a href="#add-questionnaire-template-modal" data-toggle="modal" title="Add Questionnaire Template"><button class="btn btn-primary btn-flat"><i class="fa fa-plus-circle"></i> Add {{$pageModuleName}}</button></a>
</span>
@endcan
</div>
<div class="box-body">
<table class="table table-bordered table-striped table-hover" id="questionnaire-table" width="100%">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Created At</th>
<th>Action</th>
</tr>
</thead>
</table>
</div>
</div>
@include('Client::logs')
</section>
@include('Client::questionnaire.template.create-modal')
@stop
@section('page-js')
@include('Client::questionnaire.template.js')
<script type="text/javascript">
$(function() {
var questionnaireTable = $('#questionnaire-table').DataTable({
processing: true,
serverSide: true,
"pagingType": "input",
rowReorder: true,
ajax: {
url:'{!! url(config('modules.client').'/questionnaire/get-template-data') !!}',
},
columns: [
{
width:'10px', searchable: false, orderable: false,
render: function (data, type, row, meta) {
return meta.row + meta.settings._iDisplayStart + 1;
}
},
{ data: 'description', name: 'description', orderable: false, searchable: false},
{ data: 'created_at', name: 'created_at', width:'100px', className:'text-center'},
{ data: 'action', name: 'action', orderable: false, searchable: false, width:'100px', className:'text-center'},
],
fnDrawCallback: function ( oSettings ) {
$('[data-toggle="tooltip"]').tooltip();
questionnaireTable.$("td").on("click", 'a#btn-delete', function() {
var action = $(this).data('action');
swal({
title: 'Are you sure you want to delete?',
text: "This will be permanently deleted.",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes'
}).then(function () {
$.ajax({
type: "DELETE",
url: action,
dataType: 'json',
success: function(data) {
if(data.type == "success") {
questionnaireTable.draw();
swal(data.message, '', 'success')
}else{
swal(data.message, '', 'error')
}
},
error :function( jqXhr ) {
swal('Unable to delete.', 'Please try again.', 'error')
}
});
})
});
questionnaireTable.$("td").on("click", 'a#copy-template', function() {
var action = $(this).attr('href');
swal({
title: '',
text: "Are you sure you want to make a copy of this template?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes'
}).then(function () {
$.ajax({
type: "POST",
url: action,
dataType: 'json',
success: function(data) {
questionnaireTable.draw();
},
error :function( jqXhr ) {
swal('Unable to copy.', 'Please try again.', 'error')
}
});
});
return false;
});
},
"order": [[2, "desc"]],
});
});
</script>
@include('Client::notify')
@stop