diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index d188b055e5..7d9d728dc1 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -122,6 +122,7 @@ "PREVIOUS":"Previous", "SALE_DETAILS":"Sale Details", "SAVE_SUCCESS":"Save success", +"EXPORT_SUCCESS": "Successfully exported", "SEARCH":"Search", "SHOWING":"Showing", "TRANSACTION_REVER_SUCCESS":"This transaction was reversed with success", @@ -241,6 +242,14 @@ "FATHER_NAME":"Father's Name", "FAX":"Fax", "FEMALE":"Female", +"RECORDS":"Records (Rows)", +"FILE_NAME":"File Name", +"COLS_ALL":"All columns", +"COLS_VISIBLE":"Visible columns", +"COLS_SELECTED":"Selected columns", +"ROWS_ALL":"All records", +"ROWS_VISIBLE":"Visible records", +"ROWS_SELECTED":"Selected records", "FINANCIAL_DETAIL":"Current balance, the posting journal is included:", "FINANCIAL_STATUS":"Financial Status", "FIRST_NAME":"First Name", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index 9956aa64aa..b96df1e5b7 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -122,6 +122,7 @@ "PREVIOUS":"Précédent", "SALE_DETAILS":"Détaille de la Facture", "SAVE_SUCCESS":"Enregistrement avec succès", +"EXPORT_SUCCESS": "Exportation avec succes", "SEARCH":"Recherche", "SHOWING":"Aperçue", "TRANSACTION_REVER_SUCCESS":"Cette transaction a été Annulée avec succès", @@ -206,6 +207,9 @@ "DEBTOR_GROUP":"Groupe Débiteur", "DEBTOR_GROUP_FORM":"Formulaire d'enregistrement de groupe débiteur", "DEBTOR_CREDITOR":"Débiteur/Créditeur", +"DEFAULTS" : "Filtre par defaut", +"SEARCH_QUERRIES" : "Recherche", +"LIMIT":"Limite", "DEFINE_UNTIL_DATE":"Définir une date limite", "DESCRIPTION":"Description", "DETAILS":"Details", @@ -241,6 +245,14 @@ "FATHER_NAME":"Nom du Père", "FAX":"Fax", "FEMALE":"Femme", +"RECORDS":"Enregistrements (Lignes)", +"FILE_NAME":"Nom de fichier", +"COLS_ALL":"Toutes les colonnes", +"COLS_VISIBLE":"Les colonnes visibles", +"COLS_SELECTED":"Les colonnes selectionnées", +"ROWS_ALL":"Tous les enregistrements", +"ROWS_VISIBLE":"Les enregistrements visibles", +"ROWS_SELECTED":"Les enregistrements selectionnés", "FINANCIAL_DETAIL":"Balance actuelle, journal de saisie inclue :", "FINANCIAL_STATUS":"Situation Financière", "FIRST_NAME":"Prenom", diff --git a/client/src/i18n/fr/periods.json b/client/src/i18n/fr/periods.json index 1b199b9968..7511419efe 100644 --- a/client/src/i18n/fr/periods.json +++ b/client/src/i18n/fr/periods.json @@ -2,10 +2,10 @@ "PERIODS" : { "TODAY" : "Aujourd'hui", "THIS_WEEK" : "Cette semaine", - "THIS_MONTH" : "Ce Mois", - "THIS_YEAR" : "Cette Année", + "THIS_MONTH" : "Ce mois", + "THIS_YEAR" : "Cette année", "YESTERDAY" : "Hier", - "LAST_WEEK" : "Semaine derniére", + "LAST_WEEK" : "Semaine derniere", "LAST_MONTH" : "Mois dernier", "LAST_YEAR" : "Année derniére", "ALL_TIME" : "Tout le temps", diff --git a/client/src/i18n/fr/posting_journal.json b/client/src/i18n/fr/posting_journal.json index ac4062f9af..61f7a902d0 100644 --- a/client/src/i18n/fr/posting_journal.json +++ b/client/src/i18n/fr/posting_journal.json @@ -61,7 +61,7 @@ "MISSING_DATES":"Date(s) manquante(s)", "MISSING_DOCUMENT_ID":"Ligne(s) sans ID Document", "MISSING_ENTITY":"Ligne(s) sans ID entite", -"MISSING_FISCAL_OR_PERIOD":"Annee fiscale ou periode omise", +"MISSING_FISCAL_OR_PERIOD":"Année fiscale ou periode omise", "MULTIPLE_CANCELLING":"Annulation multiple. Cette transaction a deja été annulée", "SINGLE_LINE_TRANSACTION":"Transaction(s) avec une ligne", "EDIT_INVALID_ACCOUNT":"Transaction avec des comptes non valides", diff --git a/client/src/js/app.js b/client/src/js/app.js index beccbb8029..d92816523b 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -5,7 +5,8 @@ var bhima = angular.module('bhima', [ 'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid', 'ui.grid.selection', 'ui.grid.autoResize', 'ui.grid.resizeColumns', 'ui.grid.edit', 'ui.grid.grouping', 'ui.grid.treeView', 'ui.grid.cellNav', - 'ui.grid.pagination', 'ui.grid.moveColumns', 'angularMoment', 'ngMessages', + 'ui.grid.pagination', 'ui.grid.moveColumns', 'ui.grid.exporter', + 'angularMoment', 'ngMessages', 'growlNotifications', 'ngAnimate', 'ngSanitize', 'ui.select', 'ngTouch', 'ui.router.state.events', ]); diff --git a/client/src/js/services/grid/GridExport.js b/client/src/js/services/grid/GridExport.js new file mode 100644 index 0000000000..42d6ef882c --- /dev/null +++ b/client/src/js/services/grid/GridExport.js @@ -0,0 +1,56 @@ +angular.module('bhima.services') + .service('GridExportService', GridExportService); + +GridExportService.$inject = ['$uibModal', 'util']; + +function GridExportService(Modal, util) { + + /** + * @constructor + */ + function GridExport(gridOptions, defaultRowKey, defaultColKey) { + + this.gridOptions = gridOptions; + this.ROWS = defaultRowKey; + this.COLS = defaultColKey; + + util.after(gridOptions, 'onRegisterApi', function onRegisterApi(api) { + this.api = api; + }.bind(this)); + } + + /** + * @method run + * @description run the export tool + */ + GridExport.prototype.run = function run() { + var gridApi = this.api; + var gridOptions = this.gridOptions; + var rows = this.ROWS; + var cols = this.COLS; + + var request = { + api: gridApi, + options: gridOptions, + rows: rows, + cols: cols, + }; + + var params = { + templateUrl : 'modules/templates/modals/export.modal.html', + controller : 'ExportGridModalController', + controllerAs : '$ctrl', + size : 'md', + backdrop : 'static', + animation : false, + resolve : { + data : function dataProvider() { return request; }, + }, + }; + + var instance = Modal.open(params); + return instance.result; + } + + return GridExport; +} diff --git a/client/src/modules/journal/journal.html b/client/src/modules/journal/journal.html index 3a0c562ed8..1e0d6c7a01 100644 --- a/client/src/modules/journal/journal.html +++ b/client/src/modules/journal/journal.html @@ -120,7 +120,8 @@ ui-grid-selection ui-grid-cellNav ui-grid-edit - ui-grid-grouping> + ui-grid-grouping + ui-grid-exporter> +
+
+ +
+
+
+ +  + diff --git a/client/src/modules/journal/modals/trialBalanceMain.body.js b/client/src/modules/journal/modals/trialBalanceMain.body.js index 064b90bd80..ecc70cf9c5 100644 --- a/client/src/modules/journal/modals/trialBalanceMain.body.js +++ b/client/src/modules/journal/modals/trialBalanceMain.body.js @@ -4,7 +4,7 @@ angular.module('bhima.controllers') TrialBalanceMainBodyController.$inject = [ 'SessionService', 'TrialBalanceService', 'NotifyService', '$state', 'uiGridConstants', 'uiGridGroupingConstants', '$filter', - 'AccountService', + 'AccountService', 'GridExportService', ]; /** @@ -14,7 +14,9 @@ TrialBalanceMainBodyController.$inject = [ * This controller provides a tool to view the main state of trial balance * The main state let you post transaction into the general ledger */ -function TrialBalanceMainBodyController(Session, TrialBalance, Notify, $state, uiGridConstants, uiGridGroupingConstants, $filter, Accounts) { +function TrialBalanceMainBodyController(Session, TrialBalance, Notify, + $state, uiGridConstants, uiGridGroupingConstants, $filter, + Accounts, GridExport) { var vm = this; var currencyId = Session.enterprise.currecny_id; var $currency = $filter('currency'); @@ -94,6 +96,7 @@ function TrialBalanceMainBodyController(Session, TrialBalance, Notify, $state, u vm.enterprise = Session.enterprise; vm.dataByTrans = records; + vm.exportGrid = exportGrid; vm.hasError = false; vm.gridOptions = { @@ -107,6 +110,9 @@ function TrialBalanceMainBodyController(Session, TrialBalance, Notify, $state, u onRegisterApi : function (api) { gridApi = api; }, }; + + var exportation = new GridExport(vm.gridOptions, 'all', 'visible'); + /** * @function : fetchDataByAccount * @description : @@ -257,5 +263,12 @@ function TrialBalanceMainBodyController(Session, TrialBalance, Notify, $state, u fetchDataByAccount(); } + /** + * Export to csv + */ + function exportGrid() { + exportation.run(); + } + startup(); } diff --git a/client/src/modules/templates/modals/export.modal.html b/client/src/modules/templates/modals/export.modal.html new file mode 100644 index 0000000000..c54dc4e1ef --- /dev/null +++ b/client/src/modules/templates/modals/export.modal.html @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/client/src/modules/templates/modals/export.modal.js b/client/src/modules/templates/modals/export.modal.js new file mode 100644 index 0000000000..3372749b53 --- /dev/null +++ b/client/src/modules/templates/modals/export.modal.js @@ -0,0 +1,46 @@ +angular.module('bhima.controllers') + .controller('ExportGridModalController', ExportGridModalController); + +ExportGridModalController.$inject = [ + '$uibModalInstance', 'uiGridConstants', '$filter', + 'moment', 'bhConstants', 'data', +]; + +function ExportGridModalController(Instance, uiGridConstants, $filter, + moment, bhConstants, Data) { + var vm = this; + + var gridOptions = Data.options || {}; + var gridApi = Data.api || {}; + var filename = Data.filename || 'Export ' + moment().format('YYYY-MM-DD'); + var ROWS = Data.rows || 'visible'; + var COLS = Data.cols || 'visible'; + + // bind with view + vm.exportColType = COLS; + vm.exportRowType = ROWS; + + // expose to the view + vm.exportGrid = exportGrid; + vm.dismiss = Instance.dismiss; + + /** + * Export to csv + */ + function exportGrid() { + var myElement = angular.element(document.querySelectorAll('.ui-grid-exporter-csv-link')); + filename = vm.filename || filename; + gridOptions.exporterCsvFilename = filename.concat('.csv'); + gridOptions.exporterHeaderFilter = exporterHeaderFilter; + gridOptions.exporterOlderExcelCompatibility = true; + gridApi.exporter.csvExport(vm.exportRowType, vm.exportColType, myElement); + Instance.close(true); + } + + /** + * Exporter apply header filter + */ + function exporterHeaderFilter(displayName) { + return $filter('translate')(displayName); + } +}