Save to excel

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
kerelov
Veteran Member
Posts: 42
Joined: 2020-04-17 21:20
Location: Bulgaria

Save to excel

Post by kerelov » 2022-04-26 12:07

Hi Guys,
I was wandering is there a way to directly save tables to excel without going trough the CSV. It is problematic for old versions of excel to import every time the CSV files when they are too many, it happens very slow with customizing every time delimiter and so on. So I was wandering if somebody already made a solution.
Thanks

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: Save to excel

Post by D Oliveira » 2022-04-26 13:05


Alisson
Veteran Member
Posts: 81
Joined: 2017-02-25 20:32

Re: Save to excel

Post by Alisson » 2022-04-27 00:26

I've been using the Tabulator javascript library to export data with good results.
This is an example that can be achieve with no installing at all, just a single page.

Create a custom page in the hooks folder and name it export.php and paste the code below.

Code: Select all

<?php
    define('PREPEND_PATH', '../');
    include(PREPEND_PATH."lib.php");
    include(PREPEND_PATH."header.php");

    $table_perms = getTablePermissions('yourTableName'); //Change your table name here ********************
    if(!$table_perms['view']) die('// Access denied!');

    $query = sql("SELECT * FROM yourTableName", $eo); //Change your table name here ********************
    
    $json_array = array();  
    while($row = mysqli_fetch_assoc($query))  
    {  
        $data[] = $row;
    }  
    $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
?> 

<link href="https://unpkg.com/tabulator-tables/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables/dist/js/tabulator.min.js"></script>

<body>
	<div class="input-group">
		<select class="form-control form-control-sm" id="exportSelector">
			<option value="">Export as...</option>
			<option value="print"> PRINT</option>
			<option value="csv"> CSV</option>
			<option value="xlsx"> XLS</option>
			<option value="json"> JSON</option>
			<option value="pdf"> PDF</option>
			<option value="view"> View PDF</option>
		</select>
	</div>
	<div id="table"></div>
</body>

<script>
    var tabledata = <?php echo $json;?>;
    var table = new Tabulator("#table", {
			data:tabledata,
			reactiveData:true,
			height: "auto",
			paginationSize: 30,
			paginationSizeSelector:[50,100,200],
			clipboard:true,
			clipboardPasteAction:"replace",
			clipboardCopyConfig:{
				columnHeaders:false,
				columnGroups:false,
				rowGroups:false,
				columnCalcs:false,
				dataTree:false,
				formatCells:false,
			},
			printAsHtml:true,
			printStyled:true,
			printConfig:{
				columnHeaders:true,
				columnGroups:false,
				rowGroups:true,
				columnCalcs:false,
				dataTree:false,
				formatCells:true,
			},
			layout:"fitColumns",
			responsiveLayout:"collapse",
			initialSort:[
				{column:"done", dir:"desc"},
			],
			pagination:"local",
			groupStartOpen:false,
			groupToggleElement:"header",
			movableColumns: true,
					autoColumns:true, 
			});

			var activities = document.getElementById("exportSelector")
			activities.addEventListener("change", function() {
				if(activities.value == "print") {
					table.print(false, true)
				}
				if(activities.value == "csv") {
					table.download("csv", "data.csv")
				}
				if(activities.value == "json") {
					table.download("json", "data.json")
				}
				if(activities.value == "xlsx") {
					table.download("xlsx", "data.xlsx", {sheetName:"Data Export"})
				}
				if(activities.value == "pdf") {
					table.download("pdf", "data.pdf")
				}
				if(activities.value == "view") {
					table.downloadToTab("pdf", "data.pdf")
				}
			});

</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.20/jspdf.plugin.autotable.min.js"></script>
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
<style type="text/css" media="print">
	@page { size: landscape; }
</style>
In lines lines 6 and 9 change "yourTableName" to the name of your database. That's all!!!
When you open the page in your browser, just click on "Export as", There are option to:
Print,
Download CSV,
Download PDF,
Download XLSX,
Download JSON
Download PDF
View PDF.

Hope it helps.

kerelov
Veteran Member
Posts: 42
Joined: 2020-04-17 21:20
Location: Bulgaria

Re: Save to excel

Post by kerelov » 2022-05-09 17:24

Thanks. This works perfectly.

Alisson wrote:
2022-04-27 00:26
I've been using the Tabulator javascript library to export data with good results.
This is an example that can be achieve with no installing at all, just a single page.

Create a custom page in the hooks folder and name it export.php and paste the code below.

Code: Select all

<?php
    define('PREPEND_PATH', '../');
    include(PREPEND_PATH."lib.php");
    include(PREPEND_PATH."header.php");

    $table_perms = getTablePermissions('yourTableName'); //Change your table name here ********************
    if(!$table_perms['view']) die('// Access denied!');

    $query = sql("SELECT * FROM yourTableName", $eo); //Change your table name here ********************
    
    $json_array = array();  
    while($row = mysqli_fetch_assoc($query))  
    {  
        $data[] = $row;
    }  
    $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
?> 

<link href="https://unpkg.com/tabulator-tables/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables/dist/js/tabulator.min.js"></script>

<body>
	<div class="input-group">
		<select class="form-control form-control-sm" id="exportSelector">
			<option value="">Export as...</option>
			<option value="print"> PRINT</option>
			<option value="csv"> CSV</option>
			<option value="xlsx"> XLS</option>
			<option value="json"> JSON</option>
			<option value="pdf"> PDF</option>
			<option value="view"> View PDF</option>
		</select>
	</div>
	<div id="table"></div>
</body>

<script>
    var tabledata = <?php echo $json;?>;
    var table = new Tabulator("#table", {
			data:tabledata,
			reactiveData:true,
			height: "auto",
			paginationSize: 30,
			paginationSizeSelector:[50,100,200],
			clipboard:true,
			clipboardPasteAction:"replace",
			clipboardCopyConfig:{
				columnHeaders:false,
				columnGroups:false,
				rowGroups:false,
				columnCalcs:false,
				dataTree:false,
				formatCells:false,
			},
			printAsHtml:true,
			printStyled:true,
			printConfig:{
				columnHeaders:true,
				columnGroups:false,
				rowGroups:true,
				columnCalcs:false,
				dataTree:false,
				formatCells:true,
			},
			layout:"fitColumns",
			responsiveLayout:"collapse",
			initialSort:[
				{column:"done", dir:"desc"},
			],
			pagination:"local",
			groupStartOpen:false,
			groupToggleElement:"header",
			movableColumns: true,
					autoColumns:true, 
			});

			var activities = document.getElementById("exportSelector")
			activities.addEventListener("change", function() {
				if(activities.value == "print") {
					table.print(false, true)
				}
				if(activities.value == "csv") {
					table.download("csv", "data.csv")
				}
				if(activities.value == "json") {
					table.download("json", "data.json")
				}
				if(activities.value == "xlsx") {
					table.download("xlsx", "data.xlsx", {sheetName:"Data Export"})
				}
				if(activities.value == "pdf") {
					table.download("pdf", "data.pdf")
				}
				if(activities.value == "view") {
					table.downloadToTab("pdf", "data.pdf")
				}
			});

</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.20/jspdf.plugin.autotable.min.js"></script>
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
<style type="text/css" media="print">
	@page { size: landscape; }
</style>
In lines lines 6 and 9 change "yourTableName" to the name of your database. That's all!!!
When you open the page in your browser, just click on "Export as", There are option to:
Print,
Download CSV,
Download PDF,
Download XLSX,
Download JSON
Download PDF
View PDF.

Hope it helps.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Save to excel

Post by Moh Youba » 2022-05-28 15:35

Hello

Please, can you please share sceenshot, I create exporte.php, change database name, but do not see the option.
Using AppGini 22.13

Thank you

angus
Veteran Member
Posts: 128
Joined: 2020-05-28 22:27

Re: Save to excel

Post by angus » 2023-01-09 21:55

this works great, thanks!
Alisson wrote:
2022-04-27 00:26
I've been using the Tabulator javascript library to export data with good results.
This is an example that can be achieve with no installing at all, just a single page.

Create a custom page in the hooks folder and name it export.php and paste the code below.

Code: Select all

<?php
    define('PREPEND_PATH', '../');
    include(PREPEND_PATH."lib.php");
    include(PREPEND_PATH."header.php");

    $table_perms = getTablePermissions('yourTableName'); //Change your table name here ********************
    if(!$table_perms['view']) die('// Access denied!');

    $query = sql("SELECT * FROM yourTableName", $eo); //Change your table name here ********************
    
    $json_array = array();  
    while($row = mysqli_fetch_assoc($query))  
    {  
        $data[] = $row;
    }  
    $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
?> 

<link href="https://unpkg.com/tabulator-tables/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables/dist/js/tabulator.min.js"></script>

<body>
	<div class="input-group">
		<select class="form-control form-control-sm" id="exportSelector">
			<option value="">Export as...</option>
			<option value="print"> PRINT</option>
			<option value="csv"> CSV</option>
			<option value="xlsx"> XLS</option>
			<option value="json"> JSON</option>
			<option value="pdf"> PDF</option>
			<option value="view"> View PDF</option>
		</select>
	</div>
	<div id="table"></div>
</body>

<script>
    var tabledata = <?php echo $json;?>;
    var table = new Tabulator("#table", {
			data:tabledata,
			reactiveData:true,
			height: "auto",
			paginationSize: 30,
			paginationSizeSelector:[50,100,200],
			clipboard:true,
			clipboardPasteAction:"replace",
			clipboardCopyConfig:{
				columnHeaders:false,
				columnGroups:false,
				rowGroups:false,
				columnCalcs:false,
				dataTree:false,
				formatCells:false,
			},
			printAsHtml:true,
			printStyled:true,
			printConfig:{
				columnHeaders:true,
				columnGroups:false,
				rowGroups:true,
				columnCalcs:false,
				dataTree:false,
				formatCells:true,
			},
			layout:"fitColumns",
			responsiveLayout:"collapse",
			initialSort:[
				{column:"done", dir:"desc"},
			],
			pagination:"local",
			groupStartOpen:false,
			groupToggleElement:"header",
			movableColumns: true,
					autoColumns:true, 
			});

			var activities = document.getElementById("exportSelector")
			activities.addEventListener("change", function() {
				if(activities.value == "print") {
					table.print(false, true)
				}
				if(activities.value == "csv") {
					table.download("csv", "data.csv")
				}
				if(activities.value == "json") {
					table.download("json", "data.json")
				}
				if(activities.value == "xlsx") {
					table.download("xlsx", "data.xlsx", {sheetName:"Data Export"})
				}
				if(activities.value == "pdf") {
					table.download("pdf", "data.pdf")
				}
				if(activities.value == "view") {
					table.downloadToTab("pdf", "data.pdf")
				}
			});

</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.20/jspdf.plugin.autotable.min.js"></script>
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
<style type="text/css" media="print">
	@page { size: landscape; }
</style>
In lines lines 6 and 9 change "yourTableName" to the name of your database. That's all!!!
When you open the page in your browser, just click on "Export as", There are option to:
Print,
Download CSV,
Download PDF,
Download XLSX,
Download JSON
Download PDF
View PDF.

Hope it helps.
AppGini 22.13

jfischer
Posts: 23
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Save to excel

Post by jfischer » 2023-01-10 13:25

Hello Alisson

@Alisson The script is first class what you have done there! A big thank you from me!

Best regards
Joseph

Alisson
Veteran Member
Posts: 81
Joined: 2017-02-25 20:32

Re: Save to excel

Post by Alisson » 2023-01-13 05:27

Glad to help. ;)

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-01-30 09:31

Hi Guys,

thank you for posting this Alisson!

I have made the changes as described - and save it as a PHP file in the HOOKS folder.
When I open my database online with my browser - I cannot see the new EXPORT link...
The only option I have is EXPORT TO CSV - which is the default one...

So, I'm guessing that I have missed something..
.
I'd really love to have this option - so any help would be much appreciated!

Cheers!

Sinisa

jfischer
Posts: 23
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Save to excel

Post by jfischer » 2023-02-01 09:14

Hello Sinisa

Insert the code with your link in header-extra.php to the export file, you will then see the top right next to the "Export" button and the link to the export file below.

Code: Select all

<script>
var navbar = AppGiniHelper.common.getNavbar();
var dropdown = navbar.addDropdown("Export", "question-sign", NavPosition.Right);
dropdown.addLink("Your Export-File-Name", "https://www.your Link.?????/", "_help", "_blank");
</script>

kind regards - Figo ;)

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-01 10:25

@ Figo - thank you very much!

In the code-line:
dropdown.addLink("Your Export-File-Name", "https://www.your Link.?????/", "_help", "_blank");

What exactly I should enter for: ""Your Export-File-Name"?

Figo, I'll highly appreciated if you could answer me the above "dumb" question!

Cheers!

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Save to excel

Post by jsetzer » 2023-02-01 10:52

What exactly I should enter for: ""Your Export-File-Name"?
That's up to you. It is just the caption (text) for the menu item in the newly created "Export"-drop down menu on the right hand side of the top navbar.

Docs for custom menus and menuitems:
http://www.appgini.de/docs/Javascript-L ... items.html
See paragraph "Add Custom Dropdown Menu"

@all contributers above: thanks for sharing sample code for that helpful library!
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-01 13:04

@ jsetzer

Thank you very much for the explanation and for the link!

Best!

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-01 13:57

Hi jsetzer and others!

I did what you have suggested but I cannot even see the drop-down menu at the navigation bar... which is strange...
no_drop_down_menu.png
no_drop_down_menu.png (37.58 KiB) Viewed 5016 times
I'm loged in as an admin.

Here is what I did:

(All files are saved in the HOOKS folder:)

1 - I have saved Alisson's code to the EXPORT.PHP file (as directed - I've changed the table name to my database name, OMITTING the .sql extension);

2 - In the HEADER-EXTRAS.PHP file

I've added the Figo's code - where I have changed the link's caption and the URL which must link to the EXPORT.PHP file on my website. So, the link to my export.php file is something like this: https://www.mysite.com/dbproject/hooks/export.php

Thank you in advance for any help...
Cheers!

jfischer
Posts: 23
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Save to excel

Post by jfischer » 2023-02-01 15:13

Hello Sinisa

You don't need to change anything in the database name. What you have to do is:
1. A file named, eg. if you manage books, you have export-buecher.php. Alisson's code is in there. Change the

Code: Select all

"" 'yourTableName'); //Change your table name here "" 
in books by 2x in the code.

2. Then you write my code in the header-extra.php like this:

Code: Select all

("Books export to Excel", "https://www.your-domain.it/dbprojekt/hooks/export-buecher.php",
and then it should work.
I hope the google translation works!

Kind regards Figo

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-01 16:11

Hi jfisher,

Thank you for your help and for your explanation!

Let me see if I got your right:

In the Alisson's code that goes into (in the export.php file):

"" 'yourTableName'); //Change your table name here ""

Instead of the "YourTableName" - I can put ANYTHING I want?

In other words - I don't have to put the exact name of my MySQL database that I use in the project?

So, I can put "books", "customers" or whatever text I want..?

-----------------------
Beside the above - the thing that bugs me that the drop-down menu should be visible - the coding (below) that goes in the HEADER-EXTRAS.php should create the drop-down menu.

Even if the link URL is wrong - the drop-down menu should be visible...but, in my case, it's not.

The code for showing drop-down menu:

<script>
var navbar = AppGiniHelper.common.getNavbar();
var dropdown = navbar.addDropdown("Export", "question-sign", NavPosition.Right);
dropdown.addLink("Your Export-File-Name", "https://www.mysite.com/dbproject/hooks/export.php", "_help", "_blank");
</script>

Could you give me your comment about this also?
Thank you in advance!
Sinisa

jfischer
Posts: 23
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Save to excel

Post by jfischer » 2023-02-02 14:58

Hello Sinisa

for example "books"
1. in "" 'Buecher'); write the table name which table you want to see as Excel or PDF.

2. The basic requirement is the great plugin "AppGiniHelper" from Mr. Setzer. Nothing else will happen without him.
For example: you want to see the books file as EXCEL or PDF

Code: Select all

<script>
var navbar = AppGiniHelper.common.getNavbar();
var dropdown = navbar.addDropdown("Export", "question-sign", NavPosition.Right);
dropdown.addLink("Your Export-File-Name", "https://www.mysite.com/dbproject/hooks/[b]buecher_export.php[/b]", "_help", "_blank");
</script>
Kind regards Figo

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-03 09:15

@ jfisher

Thank you very much for your help!

So, this is important and it should be clearly stated that this AppGiniHelper script is needed for the drop-down menu to work.
You are first here to even mention it - for the novice users and/or occasional users of the AppGini application - this is not commonly known...

I'll highly appreciated that when someone is posting helpful scripts and tips in this forum to have in mind that many people here are not coders nor professional users of AppGini app - so I believe that some kind of a list of the required elements/plugins for the respected script to work will be most helpful.

If someone wants to buy it - here is the link for the AppGiniHelper plugin (49.90 USD):
https://bigprof.com/appgini/application ... per-js-lib

I must say that I will give up of implementing this on my personal DB app - but it's good to know that something like this exists and it's fairly easy to implement.

Thank you all for your time!

BR, Sinisa

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Save to excel

Post by jsetzer » 2023-02-03 09:36

I'd like to add that noone has to purchase any 3rd Party plugins. You can always use standard AppGini functions and hooks + some PHP (+ perhaps some Javascript) and create navMenu items or links or buttons, pointing to your custom page, by yourself.

It is everyone's personal make-or-buy decision.

The table libraries named above (and Tabulator's export functionality) will definitely work without the addon! Just create your custom page and open it in your browser.

For adding custom navbar menu items with AppGini built-in features check out the AppGini documentation for links-navmenu.php.

Personally*, I think for non-programmers it is easier and faster to just use such an existing, working, tested function like the one mentioned above than to learn the required skills. But this is just my personal opinion.

* Disclaimer: I am the programmer of the AppGini extension mentioned above.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Alisson
Veteran Member
Posts: 81
Joined: 2017-02-25 20:32

Re: Save to excel

Post by Alisson » 2023-02-04 20:26

Hi Sinisa,

My code does not create any links in the appini app generated, you need to access the page directly.
Ex. if you website is "https://www.sinisa.com" you need to add this "https://www.sinisa.com/hooks/export.php" to see the page.

If you want to add a shortcut in the navbar use the "links-navmenu.php"
if you wnat it in the main page, use the "links-home.php"
they are both in the hooks folder.

For the navbar menu just add this to the "links-navmenu.php":

Code: Select all

	$navLinks[] = array(
		'url' => 'hooks/export.php', 
		'title' => 'Your Title', 
		'groups' => array('*'),
		'icon' => 'resources/table_icons/export.png',
		'table_group' => 0,
	);
This will create a link in the navabar menu on top of your page.

If you need a a link in the main page add this to your "links-home.php"

Code: Select all

	$homeLinks[] = array(
		'url' => './hooks/export.php', 
		'title' => 'Export',
		'description' => 'Export data',
		'groups' => array('*'), 
		'panel_classes' => 'panel-primary',
		'link_classes' => 'btn-primary',
		'icon' => 'resources/table_icons/export.png',
		'table_group' => 'Your group name here'
	);	
This is a basic and simple code to export data for a single database, but you can add another dropdown in the code that can be used to select different databases, making it more dynamic.

Hope this help.

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-06 12:30

@ jsetzer

Thank you very much for the additional explanation! I'd most certainly buy your plug-in if I'd be using the AppGini for any kind of "professional" work... Yes, I'm aware that this could be done by coding... but I don't doubt that I'll use your plug-in instead...

@ Alisson
Thank you for your time and explaining me where & how I should code that the link for the EXPORT.PHP page appears in the menu!
BTW - instead round brackets () I had to put square brackets [ ] in the navbar links code to work.

OK - I now have a EXPORT.PHP link in the menu.

My question regarding the PHP code for EXPORT.PHP page...

Specifically - the line below:

$table_perms = getTablePermissions('yourTableName'); //Change your table name here ********************

What exactly I must put for: 'yourTableName'?

The name of the table from my project that I want to export as an Excel file?

Or, should I put there my database name (which contains all the tables from my project)?

Alisson, if you could clarify this line of code I'll highly appreciated this!

BR, Sinisa

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Save to excel

Post by jsetzer » 2023-02-06 13:57

What exactly I must put for: 'yourTableName'?
Your table name (in quotes) for example 'cars'
The name of the table from my project?
The name of exactly one (=1) table.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-07 09:12

@ jsetzer

Thank you very, very much - it works quite well! Very nice solution!

@ jsetzer & Alisson
Is there are way to make this option available only for the Admin area?

I'm guessing - the link for the EXPORT.PHP should be somehow hidden from the other users and/or this EXPORT.php link could be placed only in the ADMIN area of the application?

If there is a way to do this - could you guys show us how to do this and make this nice "plugin" even more better?

Thank you in advance!

BR, Sinisa

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Save to excel

Post by jsetzer » 2023-02-07 10:10

Is there are way to make this option available only for the Admin area?
There are no hooks for inserting pages into Admin Area (except plugins). What you can (and should) do is: you can hide navbar menu items and deny direct page access for non admins:

Menu Item

The docs for navlinks has been mentioned somewhere above. There you will see how to restrict access to the menu item and allow for example only Admins group.

Deny direct page access

In your export.php script check get LoggedAdmin() somewhere after including lib.php:

Code: Select all

if (!getLoggedAdmin()) die('Permission denied.');
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Save to excel

Post by sblasic » 2023-02-08 10:20

@ jsetzer

Thank you very much for your time!

The non-admin access restriction works fine - cheers!

The only thing that still bugs me is hiding of the menu-item for the non-admins...

I have checked the documentation you have posted:

http://www.appgini.de/docs/Javascript-L ... ustom-link

But since I'm not using your AppGiniHelper plug-in - I don't know how to implement the code - what is the right syntax- and hide this EXPORT.php link in the drop-down menu for the regular users...

Code: Select all

$navLinks[] = [
		'url' => 'https://www.mysite.com/hooks/export.php', 
		'title' => 'Export to XLS', 
		'groups' => array('*'),
		'icon' => 'resources/table_icons/export.png',
		'table_group' => 0,
	];
@ jsetzer thanking you in advance for your input!

Best!
Sinisa

Post Reply