|
|
@@ -196,6 +196,11 @@ class TableAjax extends ViewAjax {
|
|
|
return $rowFunctions;
|
|
|
}
|
|
|
|
|
|
+ private function _showExportFieldsJson() {
|
|
|
+ $exportFields = $this->_acl->getExportFieldList();
|
|
|
+ return $exportFields;
|
|
|
+ }
|
|
|
+
|
|
|
private function getProcesInitSelected() {
|
|
|
$userAcl = User::getAcl();
|
|
|
return $userAcl->getPermsProcesId();
|
|
|
@@ -549,6 +554,7 @@ class TableAjax extends ViewAjax {
|
|
|
filtersClean: false,
|
|
|
router: false,
|
|
|
longDesc: false,
|
|
|
+ exportFields: [],
|
|
|
mapEditor: false, // mapEditor visible or not
|
|
|
mapEditorContainer: 'window' // 'window' or 'dock'
|
|
|
};
|
|
|
@@ -583,6 +589,7 @@ class TableAjax extends ViewAjax {
|
|
|
var _uniqueCol; // reference to column with the unique property
|
|
|
var _uniqueCols = {}; // array with checked rows
|
|
|
var _checkToggleChecked = false; // check-all toggle state
|
|
|
+ var _exportFieldsSelect = {};
|
|
|
|
|
|
var _tableWidth;
|
|
|
|
|
|
@@ -609,6 +616,10 @@ class TableAjax extends ViewAjax {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ $.each(priv.options.exportFields, function(ind, col) {
|
|
|
+ _exportFieldsSelect[col] = true;
|
|
|
+ });
|
|
|
+
|
|
|
//try call webservice for data
|
|
|
priv.update(priv.options.router);
|
|
|
|
|
|
@@ -1289,6 +1300,29 @@ class TableAjax extends ViewAjax {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //create export dropdown
|
|
|
+ if (priv.options.exportFields.length) {
|
|
|
+ var div = $('<div class="btn-group dropup pagesize"></div>').appendTo(footToolbar);
|
|
|
+ var btn = $('<button class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">Export </button>').appendTo(div);
|
|
|
+ var span = $('<span class="caret"></span>').appendTo(btn);
|
|
|
+ var ul = $('<ul class="dropdown-menu">').appendTo(div);
|
|
|
+
|
|
|
+ $.each(_data.cols, function (col, props) {
|
|
|
+ if (-1 !== priv.options.exportFields.indexOf(col)) {
|
|
|
+ var li = $('<li></li>').appendTo(ul);
|
|
|
+ $('<input {0} type="checkbox" title="{1}" value="{1}" > {2}</input>'.f((_exportFieldsSelect[col])? 'checked' : '', col, props.friendly || col)).appendTo(li);
|
|
|
+ li.on('click', 'input', priv.exportFieldChanged);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var li = $('<li></li>').appendTo(ul);
|
|
|
+ $('<a href="index.php" target="_blank" class=""><i class="icon-share"></i>Export do HTML</a>').appendTo(li);
|
|
|
+ li.on('click', 'a', priv.exportToHTML);
|
|
|
+ var li = $('<li></li>').appendTo(ul);
|
|
|
+ $('<a href="index.php" target="_blank" class=""><i class="icon-share"></i>Export do CSV</a>').appendTo(li);
|
|
|
+ li.on('click', 'a', priv.exportToCSV);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var stickyCol1Width = 55;
|
|
|
@@ -1375,6 +1409,76 @@ class TableAjax extends ViewAjax {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ priv.exportFieldChanged = function (e) {
|
|
|
+
|
|
|
+ e.stopPropagation();
|
|
|
+
|
|
|
+ var column = $(this).val();
|
|
|
+
|
|
|
+ _exportFieldsSelect[column] = !_exportFieldsSelect[column];
|
|
|
+ };
|
|
|
+
|
|
|
+ priv.exportToHTML = function (e) {
|
|
|
+ priv.exportData('html', $(this), e);
|
|
|
+ };
|
|
|
+ priv.exportToCSV = function (e) {
|
|
|
+ priv.exportData('csv', $(this), e);
|
|
|
+ };
|
|
|
+ priv.exportData = function (format, node, e) {
|
|
|
+ var exportFields = [];
|
|
|
+ $.each(_exportFieldsSelect, function (col, selected) {
|
|
|
+ if (selected) {
|
|
|
+ exportFields.push(col);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!exportFields.length) {
|
|
|
+ alert('Nie wybrano żadnych pól do eksportu.');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var limit = 1000;
|
|
|
+ if (!_data.total || _data.total <= 0) {
|
|
|
+ alert('Brak rekordów do eksportu.');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (_data.total > limit) {
|
|
|
+ if (!confirm('Za dużo rekordów. Wyeksportowane zostaną tylko pierwsze ' + limit + ' z ' + _data.total + ' rekordów.')) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var exportUrl = 'index.php?MENU_INIT=VIEWTABLE_AJAX_EXPORT&ZASOB_ID=<?php echo $this->_zasobID; ?>';
|
|
|
+ if ('csv' == format) exportUrl += '&HEADER_NOT_INIT=YES';
|
|
|
+ exportUrl += '&format=' + format;
|
|
|
+ exportUrl += '&flds=' + exportFields.join(',');
|
|
|
+ exportUrl += '&sortCol=' + (_currSortCol || '');
|
|
|
+ exportUrl += '&sortDir=' + (_currSortFlip ? "desc" : "asc");
|
|
|
+
|
|
|
+ if (Object.keys(_filterCols).length > 0) {
|
|
|
+ $.each(_filterCols, function (col, colProps) {
|
|
|
+ if (colProps.filter && colProps.filter.length > 0) {
|
|
|
+ exportUrl += '&f_' + col + '=' + colProps.filter;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // specialFilters
|
|
|
+ $.each(_specialFilters, function(groupName, btnValue) {
|
|
|
+ if (btnValue.length > 0) {
|
|
|
+ exportUrl += '&sf_' + groupName + '=' + btnValue;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (priv.options.forceFilterInit) {
|
|
|
+ $.map(priv.options.forceFilterInit, function (fltrProps, fltr) {
|
|
|
+ exportUrl += '&sf_' + fltr + '=' + fltrProps;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ node.attr('href', exportUrl);
|
|
|
+ };
|
|
|
+
|
|
|
/*
|
|
|
calls the webservice(if defined).
|
|
|
used only inside priv.init
|
|
|
@@ -2354,6 +2458,7 @@ class TableAjax extends ViewAjax {
|
|
|
$forceFilterInit = $this->_forceFilterInit;
|
|
|
$pageSizes = $this->_pageSizes;
|
|
|
$rowFunctions = $this->_showRowFunctionsJson();
|
|
|
+ $exportFields = $this->_showExportFieldsJson();
|
|
|
?>
|
|
|
<script>
|
|
|
jQuery(document).ready(function(){
|
|
|
@@ -2396,6 +2501,7 @@ jQuery(document).ready(function(){
|
|
|
}
|
|
|
},
|
|
|
rowFunctions: <?php echo json_encode($rowFunctions); ?>,
|
|
|
+ exportFields: <?php echo json_encode($exportFields); ?>,
|
|
|
specialFilterFunctions: <?php
|
|
|
$fltrs = $this->_dataSource->getSpecialFilters();
|
|
|
if (!empty($fltrs)) {
|