The z4m_dbexport module exports the SQL table data of the ZnetDK 4 Mobile starter application in Excel format in one click.
Note
This module embeds and uses PHP_XLSXWriter to generate the Excel file.
This module is published under the version 3 of GPL General Public Licence.
This module contains the z4m_dbexport
view to declare within the menu.php
of the application.
This view is very simple and just shows a download button to get App's data in Excel format.
Each sheet of the downloaded spreadsheet contains data of one SQL table.
- ZnetDK 4 Mobile version 2.9 or higher,
- A MySQL database is configured to store the application data,
- PHP version 7.4 or higher,
- Authentication is enabled
(
CFG_AUTHENT_REQUIRED
isTRUE
in the App'sconfig.php
).
- Add a new subdirectory named
z4m_dbexport
within the./engine/modules/
subdirectory of your ZnetDK 4 Mobile starter App, - Copy module's code in the new
./engine/modules/z4m_dbexport/
subdirectory, or from your IDE, pull the code from this module's GitHub repository, - Edit the App's
menu.php
located in the./applications/default/app/
subfolder and add a new menu item definition for the viewz4m_dbexport
. For example:
\MenuManager::addMenuItem(NULL, 'z4m_dbexport', MOD_Z4M_DBEXPORT_MENU_LABEL, 'fa-cloud-download');
- Edit the App's
config.php
located in the./applications/default/app/
subfolder and declare theMOD_Z4M_DBEXPORT_SELECTED_TABLES
orMOD_Z4M_DBEXPORT_EXCLUDED_TABLES
PHP constant to set SQL tables to include in or to exclude from the export file. For example:
// Only the two tables below will be exported:
define('MOD_Z4M_DBEXPORT_SELECTED_TABLES', ['my_table_one', 'my_table_two']);
// All the tables will be exported except the two tables below:
define('MOD_Z4M_DBEXPORT_SELECTED_TABLES', ['zdk_users', 'zdk_profiles']);
- Go to the Data export menu and click the Download... button to get App's SQL table data in a Excel spreadsheet file.
Once the Data export menu item is added to the application, you can restrict
its access via a user profile.
For example:
- Create a user profile named
Admin
from the Authorizations | Profiles menu, - Select for this new profile, the Data export menu item,
- Finally for each allowed user, add them the
Admin
profile from the Authorizations | Users menu.
This module is translated in French, English and Spanish languages.
To translate this module in another language or change the standard
translations:
- Copy in the clipboard the PHP constants declared within the
locale_en.php
script of the module, - Paste them from the clipboard within the
locale.php
script of your application, - Finally, translate each text associated with these PHP constants into your own language.
See CHANGELOG.md file.
Your contribution to the ZnetDK 4 Mobile project is welcome. Please refer to the CONTRIBUTING.md file.