| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- /*************************
- * Case creation section
- *************************/
- /* create the select picker for customer */
- $('#case_customer').selectpicker({
- liveSearch: true,
- title: "Select customer *",
- style: "btn-outline-white",
- size: 8
- });
- $('#case_template_id').selectpicker({
- liveSearch: true,
- title: "Select case template",
- style: "btn-outline-white",
- size: 8
- });
- $('#case_template_id').prepend(new Option('', ''));
- $('#classification_id').selectpicker({
- liveSearch: true,
- title: "Select classification",
- style: "btn-outline-white",
- size: 8
- });
- $('#classification_id').prepend(new Option('', ''));
- /*************************
- * Case list section
- *************************/
- /* case table creation */
- $.each($.find("table"), function(index, element){
- addFilterFields($(element).attr("id"));
- });
- $('#cases_table').dataTable({
- "ajax": {
- "url": `/manage/cases/list${case_param()}`,
- "contentType": "application/json",
- "type": "GET",
- "data": function (d) {
- if (d.status == 'success') {
- return JSON.stringify(d.data);
- } else {
- return [];
- }
- }
- },
- "columns": [
- {
- "render": function (data, type, row) {
- let a_anchor = $('<a>');
- a_anchor.attr('href', 'javascript:void(0);');
- a_anchor.attr('onclick', 'case_detail(\'' + row['case_id'] + '\');');
- a_anchor.text(data);
- return a_anchor[0].outerHTML;
- },
- "data": "case_name"
- },
- {
- "data": "case_description",
- "render": function (data, type, row) {
- if (type === 'display' && data != null) {
- return ret_obj_dt_description(data);
- }
- return data;
- },
- },
- {
- "data": "client_name",
- "render": function (data, type, row, meta) {
- if (type === 'display') { data = sanitizeHTML(data);}
- return data;
- }
- },
- {
- "data": "state_name",
- "render": function (data, type, row, meta) {
- if (type === 'display') { data = sanitizeHTML(data);}
- return data;
- }
- },
- {
- "data": "case_open_date",
- "render": function (data, type, row, meta) {
- if (type === 'display') { data = sanitizeHTML(data);}
- return data;
- },
- "type": "date"
- },
- {
- "data": "case_close_date",
- "type": "date",
- "render": function (data, type, row, meta) {
- if (type === 'display') { data = sanitizeHTML(data);}
- return data;
- }
- },
- {
- "data": "case_soc_id",
- "render": function (data, type, row, meta) {
- if (type === 'display') {
- let span_anchor = $('<span>');
- span_anchor.text(data);
- return span_anchor.html();
- }
- return data;
- }
- },
- {
- "data": "opened_by",
- "render": function (data, type, row, meta) {
- if (type === 'display') { data = sanitizeHTML(data);}
- return data;
- }
- }
- ],
- dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
- filter: true,
- info: true,
- ordering: true,
- processing: true,
- retrieve: true,
- lengthChange: true,
- pageLength: 25,
- select: true,
- sort: true,
- orderCellsTop: true,
- responsive: {
- details: {
- display: $.fn.dataTable.Responsive.display.childRow,
- renderer: $.fn.dataTable.Responsive.renderer.tableAll()
- }
- },
- initComplete: function () {
- tableFiltering(this.api(), 'cases_table');
- }
- }
- );
- $(document).ready(function() {
- if ($('.nav-tabs').length > 0) { // if .nav-tabs exists
- var hashtag = window.location.hash;
- if (hashtag!='') {
- $('.nav-item > a').removeClass('active').removeClass('show');
- $('.nav-item > a[href="'+hashtag+'"]').addClass('active');
- $('.nav-item > a[href="'+hashtag+'"]').addClass('show');
- $('.tab-content > div').removeClass('active');
- $(hashtag).addClass('active'); $(hashtag).addClass('show');
- }
- }
- });
|