/home/mip/mip/app/Modules/Client/Views/questionnaire/question/index.blade.php
@extends('Client::layouts')
@section('page-body')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<i class="fa fa-question-circle-o"></i> Manage Questions
</h1>
<ol class="breadcrumb">
<li><a href="{{ route(config('modules.client').'.questionnaire.index') }}"><i class="fa fa-question-circle-o"></i> Questionnaire</a></li>
<li class="active">Question</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
@include('Client::message')
<div class="row">
<div class="col-sm-3">
@include('Client::questionnaire.nav', array('nav' => 'questions'))
</div>
<div class="col-sm-9">
<div class="box box-default">
<div class="box-header">
<div class="page-header">
<h2>{{ $template->title }}</h2>
</div>
<h3 class="box-title">List of Questions</h3>
@can('create', $permissions)
<span class="pull-right">
<a href="{{ route(config('modules.client').'.questionnaire.question.create', $template->hashid) }}" data-toggle="modal" title="Add Question"><button class="btn btn-primary btn-flat"><i class="fa fa-plus-circle"></i> Add Question</button></a>
</span>
@endcan
</div>
<div class="box-body">
<table class="table table-bordered table-striped table-hover" id="question-table" width="100%">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Question Type</th>
<th>Action</th>
</tr>
</thead>
</table>
</div>
</div>
@include('Client::questionnaire.question.logs')
</div>
</div>
</section>
@include('Client::questionnaire.template.create-modal')
@stop
@section('page-js')
@include('Client::questionnaire.template.js')
<script type="text/javascript">
$(function() {
var questionTable = $('#question-table').DataTable({
dom:"<'row'<'col-sm-6'l><'col-sm-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
processing: true,
serverSide: true,
"pagingType": "input",
rowReorder: true,
filter:false,
paging:false,
scrollY: 200,
scrollCollapse: true,
ajax: {
url:"{!! url(config('modules.client').'/questionnaire/'.$template->hashid.'/get-question-data') !!}",
},
columns: [
{
width:'10px', searchable: false, orderable: false,
render: function (data, type, row, meta) {
var no = meta.row + meta.settings._iDisplayStart + 1;
return 'Q.' + no.toString();
}
},
{ data: 'title', name: 'title', orderable:false, searchable:false},
{ data: 'question_type_name', name: 'question_type', orderable:false,width:'100px', searchable:false},
{ data: 'action', name: 'action', orderable: false, searchable: false, width:'100px', className:'text-center'},
],
fnDrawCallback: function ( oSettings ) {
$('[data-toggle="tooltip"]').tooltip();
@can('update', $permissions)
$('#question-table').tableDnD({
onDrop: function(table, row) {
$.post("{!! route(config('modules.client').'.questionnaire.question.sort', $template->hashid) !!}?", $.tableDnD.serialize(),function(data, status){
questionTable.draw(false);
});
}
});
@endcan
questionTable.$("td").on("click", 'a#copy-question', function() {
var action = $(this).attr('href');
swal({
title: '',
text: "Are you sure you want to make a copy of this question?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes'
}).then(function () {
$.ajax({
type: "POST",
url: action,
dataType: 'json',
success: function(data) {
questionTable.draw();
},
error :function( jqXhr ) {
swal('Unable to copy.', 'Please try again.', 'error')
}
});
});
return false;
});
questionTable.$("td").on("click", 'a#btn-delete', function() {
var action = $(this).data('action');
swal({
title: 'Are you sure you want to delete?',
text: "This question and its answers 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") {
questionTable.draw();
swal(data.message, '', 'success')
}else{
swal(data.message, '', 'error')
}
},
error :function( jqXhr ) {
swal('Unable to delete.', 'Please try again.', 'error')
}
});
})
});
},
"order": [],
});
});
</script>
</script>
@include('Client::notify')
@stop