'LETTER',
3 => 'TABLOID',
5 => 'LEGAL',
8 => 'A3',
9 => 'A4',
11 => 'A5'
));
// Get the Excel paper size constant. If the config setting hasn't been set for some reason choose
// a suitable default. Otherwise if it's one of the predefined strings get its value, or else just
// use the value itself.
if (!isset($excel_default_paper))
{
$excel_paper_size = array_search('A4', EXCEL_PAGE_SIZES);
}
elseif ((in_arrayi($excel_default_paper, EXCEL_PAGE_SIZES)))
{
$excel_paper_size = array_search($excel_default_paper, EXCEL_PAGE_SIZES);
}
else
{
$excel_paper_size = $excel_default_paper;
}
?>
'use strict';
var initCompleteActions = function initCompleteActions(id, settings, json) {
$('.datatable_container').css('visibility', 'visible');
$(id).DataTable().columns.adjust().draw();
}
in the
// of the table
?>
var getTypes = function getTypes(table) {
var type,
types = {},
result = [];
table.find('thead tr:first th').each(function(i) {
var type = $(this).find('span').data('type');
if (type)
{
if (types[type] === undefined)
{
types[type] = [];
}
types[type].push(i);
}
});
for (type in types)
{
if (types.hasOwnProperty(type))
{
result.push({type: type,
targets: types[type]});
}
}
return result;
};
var extractEmailAddresses = function(dt, columnSelector, sort) {
var result = [];
var message;
const scheme = 'mailto:';
$.each(dt.columns(columnSelector).data(), function (i, column) {
$.each(column, function (j, value) {
try {
var valueObject = $(value);
var href = valueObject.find('a').add(valueObject.filter('a')).attr('href');
if ((href !== undefined) && href.startsWith(scheme)) {
var address = href.substring(scheme.length);
if ((address !== '') && !result.includes(address)) {
result.push(address);
}
}
} catch (error) {
}
});
});
if (sort) {
result.sort();
}
navigator.clipboard.writeText(result.join(', '))
.then(() => {
message = '';
message = message.replace('%d', result.length.toString());
})
.catch((err) => {
message = '';
console.error(err);
})
.finally(() => {
dt.buttons.info(
dt.i18n('buttons.copyTitle', 'Copy to clipboard'),
message,
2000
)
});
};
var customizeExcel = function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var pageSetup = sheet.createElement('pageSetup');
sheet.childNodes['0'].appendChild(pageSetup);
var settings = sheet.getElementsByTagName('pageSetup')[0];
settings.setAttribute("r:id", "rId1");
settings.setAttribute('orientation', '');
settings.setAttribute('paperSize', '');
};
function makeDataTable(id, specificOptions, fixedColumnsOptions)
{
var i,
defaultOptions,
mergedOptions,
colVisIncludeCols,
nCols,
table,
dataTable,
fixedColumns;
var buttonCommon = {
exportOptions: {
columns: ':visible',
format: {
body: function (data, row, column, node) {
var div = $(' ' + data + ' ');
s that don't
// have a class of 'normal' (which the CSS makes visible). Note that we cannot
// just remove :hidden elements because that would also remove everything that's
// not on the current page and visible on screen.
// (We can get rid of this step when we move to using orthogonal data.)
?>
div.find('span:not(.normal)').remove();
var result = $.fn.dataTable.Buttons.stripData(div.html());
if (result === '')
{
var value = div.find('input[type="submit"]').attr('value');
if (value !== undefined)
{
result = value;
}
}
return result;
}
}
}
};
table = $(id);
if (table.length === 0)
{
return false;
}
. This is only needed to assist in the formatting
// of the non-datatable version of the table. When we have a datatable,
// the datatable sorts out its own formatting.
?>
table.find('colgroup').remove();
table.attr('width', '100%');
defaultOptions = {
buttons: [{extend: 'colvis',
text: ''}],
deferRender: true,
lengthMenu: [ [10, 25, 50, 100, -1], [10, 25, 50, 100, ''] ],
paging: true,
pageLength: 25,
pagingType: 'full_numbers',
processing: true,
scrollCollapse: true,
stateSave: ,
stateDuration: ,
dom: 'B<"clear">lfrtip',
scrollX: '100%',
colReorder: {}
};
if (specificOptions && specificOptions.buttons)
{
for (i=0; i
if (args.page !== 'pending')
{
defaultOptions.buttons = defaultOptions.buttons.concat(
$.extend(true, {}, buttonCommon, {
extend: 'copy',
text: ''
}),
$.extend(true, {}, buttonCommon, {
extend: 'csv',
text: ''
}),
$.extend(true, {}, buttonCommon, {
extend: 'excel',
text: '',
customize: customizeExcel
}),
$.extend(true, {}, buttonCommon, {
extend: 'pdfHtml5',
text: '',
orientation: '',
pageSize: ''
}),
$.extend(true, {}, buttonCommon, {
extend: 'print',
text: ''
})
);
}
getDatatablesLangPath())
{
// As we're calling url_base() from a script a level down in the hierarchy we need
// to strip off the last directory.
// TODO: a better way of doing this?
$base = rtrim(url_base(), '/');
if (false !== ($pos = strrpos($base, '/')))
{
$base = substr($base, 0, $pos + 1);
}
?>
defaultOptions.language = {url: ''}
if (specificOptions &&
specificOptions.buttons &&
specificOptions.buttons[0] &&
specificOptions.buttons[0].columns)
{
defaultOptions.buttons[0].columns = specificOptions.buttons;
}
else
{
colVisIncludeCols = [];
nCols = table.find('tr:first-child th').length;
for (i=0; i= nCols-fixedColumnsOptions.rightColumns))
{
continue;
}
}
colVisIncludeCols.push(i);
}
defaultOptions.buttons[0].columns = colVisIncludeCols;
}
defaultOptions.initComplete = initCompleteActions;
mergedOptions = $.extend(true, {}, defaultOptions, specificOptions);
// Merge the initComplete properties, if any of them are set. This has to be
// done separately as they are functions.
if (defaultOptions.initComplete || specificOptions.initComplete) {
mergedOptions.initComplete = function (settings, json) {
if (defaultOptions.initComplete) {
defaultOptions.initComplete.call(this, id, settings, json);
}
if (specificOptions.initComplete) {
specificOptions.initComplete.call(this, id, settings, json);
}
};
}
const locales = args.langPrefs;
$.fn.dataTable.ext.order.intl(locales);
console.debug("MRBS language preferences: " + JSON.stringify(locales));
console.debug("MRBS: locales supported by Intl.Collator: " + JSON.stringify(Intl.Collator.supportedLocalesOf(locales)));
if (window.Intl && !Intl.Collator.supportedLocalesOf(locales[0]).length)
{
console.warn("MRBS: Intl.Collator in this browser does not support the '" + locales[0] + "' locale.");
}
dataTable = table.DataTable(mergedOptions);
if (fixedColumnsOptions)
{
fixedColumns = new $.fn.dataTable.FixedColumns(dataTable, fixedColumnsOptions);
}
if (!specificOptions.ajax)
{
}
$(window).on('resize', function () {
dataTable.columns.adjust();
});
return dataTable;
}
|