2023-02-17 06:17:32 +08:00
|
|
|
/* global I18n DataTableHelpers DataTableCheckboxes animateSpinner HelperModule Promise */
|
2023-06-01 15:52:58 +08:00
|
|
|
/* eslint-disable no-param-reassign */
|
2021-03-17 19:54:25 +08:00
|
|
|
|
2021-04-14 20:40:13 +08:00
|
|
|
(function() {
|
2018-04-18 22:47:52 +08:00
|
|
|
'use strict';
|
|
|
|
|
2021-04-14 20:40:13 +08:00
|
|
|
const RETRY_COUNT = 25;
|
|
|
|
const START_POLLING_INTERVAL = 10000;
|
2021-05-06 20:22:02 +08:00
|
|
|
var REPORTS_TABLE;
|
2023-02-17 06:17:32 +08:00
|
|
|
let CHECKBOX_SELECTOR;
|
2018-04-18 22:47:52 +08:00
|
|
|
|
|
|
|
function renderCheckboxHTML(data) {
|
2020-10-22 22:37:59 +08:00
|
|
|
return `<div class="sci-checkbox-container">
|
2023-02-17 06:17:32 +08:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
class="sci-checkbox report-row-selector"
|
|
|
|
data-action='toggle'
|
|
|
|
data-report-id="${data}"
|
|
|
|
>
|
2020-10-22 22:37:59 +08:00
|
|
|
<span class="sci-checkbox-label"></span>
|
|
|
|
</div>`;
|
2018-04-18 22:47:52 +08:00
|
|
|
}
|
|
|
|
|
2021-03-17 19:54:25 +08:00
|
|
|
function renderDocxFile(data) {
|
|
|
|
if (data.error) {
|
2021-05-11 19:28:28 +08:00
|
|
|
let oldLink = '';
|
|
|
|
if (data.preview_url) {
|
2023-06-21 18:02:18 +08:00
|
|
|
oldLink = `<a href="#" class="file-preview-link flex items-center gap-1 docx hover:no-underline whitespace-nowrap" data-preview-url="${data.preview_url}">
|
2021-05-11 19:28:28 +08:00
|
|
|
(<i class="fas fa-file-docx"></i>
|
|
|
|
${I18n.t('projects.reports.index.previous_docx')})
|
|
|
|
</a>`;
|
|
|
|
}
|
2021-06-14 18:27:25 +08:00
|
|
|
return `<span class="processing-error docx">
|
2021-03-17 19:54:25 +08:00
|
|
|
<i class="fas fa-exclamation-triangle"></i>
|
2021-05-11 19:28:28 +08:00
|
|
|
${I18n.t('projects.reports.index.error')}${oldLink}
|
2021-03-17 19:54:25 +08:00
|
|
|
</span>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.processing) {
|
|
|
|
return `<span class="processing docx">
|
|
|
|
${I18n.t('projects.reports.index.generating')}
|
|
|
|
</span>`;
|
|
|
|
}
|
|
|
|
|
2021-03-23 22:20:40 +08:00
|
|
|
if (data.preview_url) {
|
2023-06-21 18:02:18 +08:00
|
|
|
return `<a href="#" class="file-preview-link flex items-center gap-1 docx hover:no-underline whitespace-nowrap" data-preview-url="${data.preview_url}">
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-file-word"></i>
|
2021-03-17 19:54:25 +08:00
|
|
|
${I18n.t('projects.reports.index.docx')}
|
|
|
|
</a>`;
|
|
|
|
}
|
2021-05-17 18:02:20 +08:00
|
|
|
return `<a href="#" class="generate-docx docx">${I18n.t('projects.reports.index.generate')}</a>`;
|
2021-03-17 19:54:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderPdfFile(data) {
|
|
|
|
if (data.error) {
|
2021-05-11 19:28:28 +08:00
|
|
|
let oldLink = '';
|
|
|
|
if (data.preview_url) {
|
2023-06-21 18:02:18 +08:00
|
|
|
oldLink = `<a href="#" class="file-preview-link flex items-center gap-1 pdf hover:no-underline whitespace-nowrap" data-preview-url="${data.preview_url}">
|
2021-05-11 19:28:28 +08:00
|
|
|
(<i class="fas fa-file-pdf"></i>
|
|
|
|
${I18n.t('projects.reports.index.previous_pdf')})
|
|
|
|
</a>`;
|
|
|
|
}
|
2021-06-17 15:51:25 +08:00
|
|
|
return `<span class="processing-error pdf">
|
2021-03-17 19:54:25 +08:00
|
|
|
<i class="fas fa-exclamation-triangle"></i>
|
2021-05-11 19:28:28 +08:00
|
|
|
${I18n.t('projects.reports.index.error')}${oldLink}
|
2021-03-17 19:54:25 +08:00
|
|
|
</span>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.processing) {
|
|
|
|
return `<span class="processing pdf">
|
|
|
|
${I18n.t('projects.reports.index.generating')}
|
|
|
|
</span>`;
|
|
|
|
}
|
|
|
|
|
2021-03-23 22:20:40 +08:00
|
|
|
if (data.preview_url) {
|
2023-06-21 18:02:18 +08:00
|
|
|
return `<a href="#" class="file-preview-link flex items-center gap-1 pdf hover:no-underline whitespace-nowrap" data-preview-url="${data.preview_url}">
|
2021-03-17 19:54:25 +08:00
|
|
|
<i class="fas fa-file-pdf"></i>
|
|
|
|
${I18n.t('projects.reports.index.pdf')}
|
|
|
|
</a>`;
|
|
|
|
}
|
|
|
|
|
2021-05-27 20:55:27 +08:00
|
|
|
return `<a href="#" class="generate-pdf pdf">${I18n.t('projects.reports.index.generate')}</a>`;
|
2021-03-17 19:54:25 +08:00
|
|
|
}
|
|
|
|
|
2021-04-14 20:40:13 +08:00
|
|
|
function addAttributesToRow(row, data) {
|
2018-04-18 22:47:52 +08:00
|
|
|
$(row).addClass('report-row')
|
2021-04-14 20:40:13 +08:00
|
|
|
.attr('data-edit-path', data.edit)
|
|
|
|
.attr('data-status-path', data.status)
|
2021-04-14 21:45:51 +08:00
|
|
|
.attr('data-generate-pdf-path', data.generate_pdf)
|
|
|
|
.attr('data-generate-docx-path', data.generate_docx)
|
2021-04-14 20:40:13 +08:00
|
|
|
.attr('data-retry-count', 0)
|
2021-04-13 22:36:52 +08:00
|
|
|
.attr('data-save-to-inventory-path', data.save_to_inventory)
|
2023-02-17 06:17:32 +08:00
|
|
|
.attr('data-id', data['0'])
|
|
|
|
.attr('id', data['0']);
|
2021-05-28 22:17:20 +08:00
|
|
|
if (data.archived) {
|
|
|
|
$(row).addClass('archived');
|
|
|
|
}
|
2022-12-02 18:41:32 +08:00
|
|
|
if (data['4'].processing || data['5'].processing) {
|
2021-04-14 20:40:13 +08:00
|
|
|
$(row).addClass('processing');
|
|
|
|
}
|
2018-04-18 22:47:52 +08:00
|
|
|
}
|
|
|
|
|
2024-01-03 23:31:31 +08:00
|
|
|
function initActionButtons() {
|
|
|
|
initUpdatePDFReport();
|
|
|
|
initGenerateDocxReport();
|
|
|
|
initUpdateDocxReport();
|
|
|
|
initEditReport();
|
|
|
|
initSaveReportPDFToInventory();
|
|
|
|
initDeleteReports();
|
|
|
|
}
|
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
function updateButtons() {
|
2023-05-18 04:42:16 +08:00
|
|
|
if (window.actionToolbarComponent) {
|
2024-01-03 23:31:31 +08:00
|
|
|
window.actionToolbarComponent.setActionsLoadedCallback(initActionButtons);
|
2023-05-18 04:42:16 +08:00
|
|
|
window.actionToolbarComponent.fetchActions({ report_ids: CHECKBOX_SELECTOR.selectedRows });
|
2023-05-23 17:15:19 +08:00
|
|
|
$('.dataTables_scrollBody').css('padding-bottom', `${CHECKBOX_SELECTOR.selectedRows.length > 0 ? 68 : 0}px`);
|
2023-05-18 04:42:16 +08:00
|
|
|
}
|
|
|
|
|
2023-02-17 06:17:32 +08:00
|
|
|
const rowsCount = CHECKBOX_SELECTOR.selectedRows.length;
|
|
|
|
if (rowsCount === 0) {
|
2021-03-17 19:54:25 +08:00
|
|
|
$('.single-object-action, .multiple-object-action').addClass('disabled hidden');
|
2023-02-17 06:17:32 +08:00
|
|
|
} else if (rowsCount === 1) {
|
2021-03-17 19:54:25 +08:00
|
|
|
$('.single-object-action, .multiple-object-action').removeClass('disabled hidden');
|
|
|
|
|
2023-02-17 06:17:32 +08:00
|
|
|
let $row = $(`.report-row[data-id=${CHECKBOX_SELECTOR.selectedRows[0]}]`);
|
2021-05-28 22:17:20 +08:00
|
|
|
let archived = $row.hasClass('archived');
|
2021-03-17 19:54:25 +08:00
|
|
|
let pdfProcessing = $row.has('.processing.pdf').length > 0;
|
|
|
|
let docxProcessing = $row.has('.processing.docx').length > 0;
|
|
|
|
let docxGenerate = $row.has('.generate-docx').length > 0;
|
|
|
|
|
|
|
|
if (pdfProcessing) {
|
|
|
|
$('#updatePdf').addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$('#updatePdf').removeClass('disabled');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (docxGenerate) {
|
|
|
|
$('#requestDocx').removeClass('hidden');
|
|
|
|
$('#updateDocx').addClass('hidden');
|
|
|
|
} else {
|
|
|
|
$('#requestDocx').addClass('hidden');
|
|
|
|
$('#updateDocx').removeClass('hidden');
|
|
|
|
|
|
|
|
if (docxProcessing) {
|
|
|
|
$('#updateDocx').addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$('#updateDocx').removeClass('disabled');
|
|
|
|
}
|
|
|
|
}
|
2021-05-20 19:39:27 +08:00
|
|
|
|
2021-05-28 22:17:20 +08:00
|
|
|
if (archived || pdfProcessing || docxProcessing) {
|
2021-05-20 19:39:27 +08:00
|
|
|
$('#edit-report-btn').addClass('disabled');
|
|
|
|
} else {
|
|
|
|
$('#edit-report-btn').removeClass('disabled');
|
|
|
|
}
|
2018-04-18 22:47:52 +08:00
|
|
|
} else {
|
2021-03-17 19:54:25 +08:00
|
|
|
$('.single-object-action').removeClass('hidden').addClass('disabled');
|
|
|
|
$('.multiple-object-action').removeClass('disabled hidden');
|
2018-04-18 22:47:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 20:40:13 +08:00
|
|
|
function checkProcessingStatus(reportId) {
|
|
|
|
let $row = $('#reports-table').find(`tr[data-id="${reportId}"]`);
|
|
|
|
if ($row.length === 0) return;
|
|
|
|
|
|
|
|
$.getJSON($row.data('status-path'), (statusData) => {
|
|
|
|
$row.find('.docx').parent().html(renderDocxFile(statusData.docx));
|
|
|
|
$row.find('.pdf').parent().html(renderPdfFile(statusData.pdf));
|
|
|
|
|
|
|
|
if (statusData.docx.processing || statusData.pdf.processing) {
|
|
|
|
if ($row.data('retry-count') >= RETRY_COUNT) return;
|
|
|
|
|
|
|
|
$row.data('retry-count', $row.data('retry-count') + 1);
|
|
|
|
setTimeout(() => { checkProcessingStatus(reportId); }, START_POLLING_INTERVAL * $row.data('retry-count'));
|
|
|
|
} else {
|
|
|
|
$row.removeClass('processing');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
// INIT
|
|
|
|
|
|
|
|
function initDatatable() {
|
2021-04-14 20:40:13 +08:00
|
|
|
var $table = $('#reports-table');
|
2023-02-17 06:17:32 +08:00
|
|
|
CHECKBOX_SELECTOR = null;
|
2021-05-06 20:22:02 +08:00
|
|
|
REPORTS_TABLE = $table.DataTable({
|
2023-05-23 22:03:10 +08:00
|
|
|
dom: "R<'reports-toolbar'f>t<'pagination-row hidden'<'pagination-info'li><'pagination-actions'p>>",
|
2022-12-02 18:41:32 +08:00
|
|
|
order: [[9, 'desc']],
|
2021-03-16 20:11:15 +08:00
|
|
|
sScrollX: '100%',
|
2023-01-27 21:28:50 +08:00
|
|
|
stateSave: true,
|
2021-03-16 20:11:15 +08:00
|
|
|
sScrollXInner: '100%',
|
|
|
|
processing: true,
|
|
|
|
serverSide: true,
|
|
|
|
ajax: $table.data('source'),
|
|
|
|
pagingType: 'simple_numbers',
|
|
|
|
colReorder: {
|
|
|
|
fixedColumnsLeft: 1000000 // Disable reordering
|
2018-04-18 22:47:52 +08:00
|
|
|
},
|
2021-03-16 20:11:15 +08:00
|
|
|
columnDefs: [{
|
|
|
|
targets: 0,
|
|
|
|
searchable: false,
|
|
|
|
orderable: false,
|
|
|
|
className: 'dt-body-center',
|
|
|
|
sWidth: '1%',
|
|
|
|
render: renderCheckboxHTML
|
2021-03-17 19:54:25 +08:00
|
|
|
},
|
2023-07-10 14:53:01 +08:00
|
|
|
{ targets: 3,
|
|
|
|
width: 50
|
|
|
|
},
|
2021-03-17 19:54:25 +08:00
|
|
|
{
|
2022-12-02 18:41:32 +08:00
|
|
|
targets: 4,
|
2021-03-17 19:54:25 +08:00
|
|
|
searchable: false,
|
|
|
|
sWidth: '60',
|
|
|
|
render: renderPdfFile
|
|
|
|
},
|
|
|
|
{
|
2022-12-02 18:41:32 +08:00
|
|
|
targets: 5,
|
2021-03-17 19:54:25 +08:00
|
|
|
searchable: false,
|
|
|
|
sWidth: '60',
|
|
|
|
render: renderDocxFile
|
2018-04-18 22:47:52 +08:00
|
|
|
}],
|
2021-03-16 20:11:15 +08:00
|
|
|
oLanguage: {
|
|
|
|
sSearch: I18n.t('general.filter')
|
2018-05-08 22:33:42 +08:00
|
|
|
},
|
2021-04-14 20:40:13 +08:00
|
|
|
createdRow: addAttributesToRow,
|
2023-02-17 06:17:32 +08:00
|
|
|
initComplete: function(settings) {
|
2023-05-18 04:42:16 +08:00
|
|
|
initActionToolbar();
|
2023-05-25 19:12:27 +08:00
|
|
|
actionToolbarComponent.setBottomOffset(68);
|
2023-05-18 04:42:16 +08:00
|
|
|
|
2023-02-17 06:17:32 +08:00
|
|
|
const { nTableWrapper: dataTableWrapper } = settings;
|
|
|
|
CHECKBOX_SELECTOR = new DataTableCheckboxes(dataTableWrapper, {
|
|
|
|
checkboxSelector: '.report-row-selector',
|
|
|
|
selectAllSelector: '.dataTables_scrollHead input[name="select_all"]',
|
|
|
|
onChanged: () => updateButtons()
|
|
|
|
});
|
|
|
|
|
2022-02-02 17:41:29 +08:00
|
|
|
DataTableHelpers.initLengthAppearance($table.closest('.dataTables_wrapper'));
|
2023-05-24 17:39:38 +08:00
|
|
|
DataTableHelpers.initSearchField(
|
|
|
|
$table.closest('.dataTables_wrapper'),
|
|
|
|
I18n.t('projects.reports.index.search_reports')
|
|
|
|
);
|
2021-03-16 20:11:15 +08:00
|
|
|
$('.pagination-row').removeClass('hidden');
|
2021-04-14 20:40:13 +08:00
|
|
|
$('.report-row.processing').each(function() {
|
|
|
|
setTimeout(() => { checkProcessingStatus($(this).data('id')); }, START_POLLING_INTERVAL);
|
|
|
|
});
|
2023-05-23 22:03:10 +08:00
|
|
|
|
|
|
|
let topToolbar = $('#toolbarWrapper').detach().html();
|
|
|
|
$('.reports-datatable .reports-toolbar').prepend(topToolbar);
|
2023-02-17 06:17:32 +08:00
|
|
|
},
|
|
|
|
drawCallback: function() {
|
|
|
|
if (CHECKBOX_SELECTOR) CHECKBOX_SELECTOR.checkSelectAllStatus();
|
2023-06-06 16:54:01 +08:00
|
|
|
setTimeout(() => { REPORTS_TABLE.columns.adjust(); }, 0);
|
2023-02-17 06:17:32 +08:00
|
|
|
},
|
|
|
|
rowCallback: function(row) {
|
|
|
|
if (CHECKBOX_SELECTOR) CHECKBOX_SELECTOR.checkRowStatus(row);
|
2023-06-01 15:52:58 +08:00
|
|
|
},
|
|
|
|
stateLoadParams: function(_, state) {
|
|
|
|
state.search.search = '';
|
2021-03-16 20:11:15 +08:00
|
|
|
}
|
2018-04-18 22:47:52 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-14 02:27:09 +08:00
|
|
|
function generateReportRequest(pathAttrName, id) {
|
2023-02-17 06:17:32 +08:00
|
|
|
if (CHECKBOX_SELECTOR.selectedRows.length === 1 || id) {
|
|
|
|
let row = $(".report-row[data-id='" + (id || CHECKBOX_SELECTOR.selectedRows[0]) + "']");
|
2021-04-15 19:12:01 +08:00
|
|
|
animateSpinner();
|
|
|
|
$.post(row.data(pathAttrName), function(response) {
|
|
|
|
animateSpinner(null, false);
|
|
|
|
HelperModule.flashAlertMsg(response.message, 'success');
|
|
|
|
checkProcessingStatus(row.data('id'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function initUpdatePDFReport() {
|
2024-01-03 23:31:31 +08:00
|
|
|
$('#updatePdf').on('click', function(ev) {
|
2021-04-14 21:45:51 +08:00
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
2021-04-15 19:12:01 +08:00
|
|
|
|
|
|
|
new Promise(function(resolve, reject) {
|
|
|
|
$('#regenerate-report-modal').modal('show');
|
|
|
|
$('#regenerate-report-modal .btn-confirm').click(function() {
|
|
|
|
resolve();
|
2021-04-14 21:45:51 +08:00
|
|
|
});
|
2021-04-15 19:12:01 +08:00
|
|
|
$('#regenerate-report-modal').on('hidden.bs.modal', function() {
|
|
|
|
reject();
|
|
|
|
});
|
|
|
|
}).then(function() {
|
|
|
|
$('#regenerate-report-modal').modal('hide');
|
|
|
|
generateReportRequest('generate-pdf-path');
|
|
|
|
}).catch(function() {});
|
2021-04-14 21:45:51 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initGenerateDocxReport() {
|
2024-01-03 23:31:31 +08:00
|
|
|
$('#requestDocx').on('click', function(ev) {
|
2021-04-14 21:45:51 +08:00
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
2021-05-21 20:55:11 +08:00
|
|
|
$(this).closest('.dropdown-menu').dropdown('toggle');
|
2021-04-15 19:12:01 +08:00
|
|
|
generateReportRequest('generate-docx-path');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initUpdateDocxReport() {
|
2024-01-03 23:31:31 +08:00
|
|
|
$('#updateDocx').on('click', function(ev) {
|
2021-04-15 19:12:01 +08:00
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
new Promise(function(resolve, reject) {
|
|
|
|
$('#regenerate-report-modal').modal('show');
|
|
|
|
$('#regenerate-report-modal .btn-confirm').click(function() {
|
|
|
|
resolve();
|
2021-04-14 21:45:51 +08:00
|
|
|
});
|
2021-04-15 19:12:01 +08:00
|
|
|
$('#regenerate-report-modal').on('hidden.bs.modal', function() {
|
|
|
|
reject();
|
|
|
|
});
|
|
|
|
}).then(function() {
|
|
|
|
$('#regenerate-report-modal').modal('hide');
|
|
|
|
generateReportRequest('generate-docx-path');
|
|
|
|
}).catch(function() {});
|
2021-04-14 21:45:51 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
function initEditReport() {
|
|
|
|
$('#edit-report-btn').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
animateSpinner();
|
2023-02-17 06:17:32 +08:00
|
|
|
if (CHECKBOX_SELECTOR.selectedRows.length === 1) {
|
|
|
|
let id = CHECKBOX_SELECTOR.selectedRows[0];
|
2021-04-14 20:40:13 +08:00
|
|
|
let row = $(".report-row[data-id='" + id + "']");
|
|
|
|
let url = row.attr('data-edit-path');
|
2018-04-18 22:47:52 +08:00
|
|
|
$(location).attr('href', url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-13 22:36:52 +08:00
|
|
|
function initSaveReportPDFToInventory() {
|
2024-01-03 23:31:31 +08:00
|
|
|
$('#savePdfToInventoryButton').on('click', function(ev) {
|
2021-04-13 22:36:52 +08:00
|
|
|
ev.preventDefault();
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
2023-02-17 06:17:32 +08:00
|
|
|
let id = CHECKBOX_SELECTOR.selectedRows[0];
|
2021-04-13 22:36:52 +08:00
|
|
|
let row = $(`.report-row[data-id='${id}']`);
|
|
|
|
let url = row.attr('data-save-to-inventory-path');
|
|
|
|
$.get(url, function(result) {
|
|
|
|
let modal = $(result.html);
|
2023-05-29 17:25:54 +08:00
|
|
|
if ($('#content-reports-index').find('#savePDFtoInventory').length === 0) {
|
2023-05-24 02:21:34 +08:00
|
|
|
$('#content-reports-index').append(modal);
|
|
|
|
modal.modal('show');
|
|
|
|
// Remove modal when it gets closed
|
|
|
|
modal.on('hidden.bs.modal', function() {
|
|
|
|
$(this).remove();
|
|
|
|
});
|
|
|
|
}
|
2021-04-13 22:36:52 +08:00
|
|
|
});
|
|
|
|
});
|
2023-05-29 17:25:54 +08:00
|
|
|
}
|
2021-04-13 22:36:52 +08:00
|
|
|
|
2018-04-18 22:47:52 +08:00
|
|
|
function initDeleteReports() {
|
2024-01-03 23:31:31 +08:00
|
|
|
$('#delete-reports-btn').on('click', function() {
|
2023-02-17 06:17:32 +08:00
|
|
|
if (CHECKBOX_SELECTOR.selectedRows.length > 0) {
|
|
|
|
$('#report-ids').attr('value', '[' + CHECKBOX_SELECTOR.selectedRows + ']');
|
2021-04-14 20:40:13 +08:00
|
|
|
$('#delete-reports-modal').modal('show');
|
2018-04-18 22:47:52 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-05-18 04:42:16 +08:00
|
|
|
$(document).on('click', '#confirm-delete-reports-btn', function() {
|
2018-04-18 22:47:52 +08:00
|
|
|
animateLoading();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-14 02:27:09 +08:00
|
|
|
$('.reports-index').on('click', '.generate-docx', function(e) {
|
|
|
|
var reportId = $(this).closest('.report-row').attr('data-id');
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
generateReportRequest('generate-docx-path', reportId);
|
|
|
|
});
|
|
|
|
|
2021-05-27 20:55:27 +08:00
|
|
|
$('.reports-index').on('click', '.generate-pdf', function(e) {
|
|
|
|
var reportId = $(this).closest('.report-row').attr('data-id');
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
generateReportRequest('generate-pdf-path', reportId);
|
|
|
|
});
|
|
|
|
|
2021-05-06 20:00:33 +08:00
|
|
|
$('#show_report_preview').click();
|
|
|
|
|
2018-07-19 23:56:42 +08:00
|
|
|
initDatatable();
|
2021-04-14 20:40:13 +08:00
|
|
|
}());
|