How to hide buttons on form?

Matthijs

Member
Hi,

for my users, I would like to remove/hide these bottons from the form, how can I do that?

thanks for any help!
buttons.png

Your current DaDaBIK version​

You are using DaDaBIK version 11.9-Elba enterprise, installed on 04-30-2023 (installation code: 18828644e443ac0e33), the latest version of DaDaBIK is 11.9-Elba released on 03-23-2023

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.19

mysql version: 10.6.13-MariaDB

Web server: Apache/2

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
 

Matthijs

Member
Hi, I found a solution:
$import_from_csv_feature = 0;
$enable_report_generation = 0;
$enable_pivot_generation = 0;
$export_to_pdf_feature = 0;

But this is for everything. So I suppose it is not possible to remove for a specific from?
 

eugenio

Administrator
Staff member
I haven't tested it but you should be able to add some if statements in your config_custom.php file and set your parameters according to the current table name, e.g.

PHP:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'customers'){
$import_from_csv_feature = 0;
.....
}
 

juergen_mueller

DaDaBIK Guru
Is it possible to limit this condition to a certain user(group)? E.g. like

Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && $current_id_group = 2)
{
$enable_pivot_generation = 0;
}

I tried but the pivot generation will be disabled for all user groups. Where did I make the mistake?
 

eugenio

Administrator
Staff member
Hi Juergen, I think you just missed an = sign (= instead of ==). I would also add an isset($current_id_group) before.

Best,
 

juergen_mueller

DaDaBIK Guru
I tried these 2 codes:

Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && isset($current_id_group) == 2)
{
$enable_pivot_generation = 0;
}
and
Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && isset($current_id_group) && $current_id_group == 2)
{
$enable_pivot_generation = 0;
}

Best
 

eugenio

Administrator
Staff member
I haven't tested but the second version is correct, I don't see mistakes, are you sure this second version doesn't work?
If you enable parse error in your system, you will see more details about the error.
I would also try to remove alternatively, various parts of the if statement to see what is causing the problem.
 

juergen_mueller

DaDaBIK Guru
To be precise: The first code doesn't have an effect at all, pivot generation its enabled for all
The second results in a blank page.

I'll try your proposals and send a feedback
 

juergen_mueller

DaDaBIK Guru
This code works as expected, no privot_generation for all groups:

Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions')
{
$enable_pivot_generation = 0;
}

This one does not have any effect at all (no blank page anymore), pivot_generation remains enabled for all groups:

Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && isset($current_id_group) && $current_id_group == 2)
{
$enable_pivot_generation = 0;
}

Best
 

eugenio

Administrator
Staff member
Ok, I see the problem, in config_template the current_id_group is not set yet.
Use this variable instead: $_SESSION['logged_user_infos_ar']['id_group']

Best,
 

eugenio

Administrator
Staff member
isset($_SESSION['logged_user_infos_ar']['id_group']) && $_SESSION['logged_user_infos_ar']['id_group'] == 2
 

juergen_mueller

DaDaBIK Guru
Good morning

I use this code now:
Code:
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && isset($_SESSION['logged_user_infos_ar']['id_group']) && $_SESSION['logged_user_infos_ar']['id_group'] == 2)
{
$enable_pivot_generation = 0;
$enable_report_generation = 0;
}

However, pivot and report generation for this group and this table are still available.

Best,
 

juergen_mueller

DaDaBIK Guru
When enabling error reporting I get this message:

Code:
Notice: session_start(): Ignoring session_start() because a session is already active in /MYPATH/include/header.php on line 15
 

juergen_mueller

DaDaBIK Guru
Hello again
I identified the last error message. It's related to WebYep, a flat file CMS I use to integrate text, messages etc. into my DaDaBIK app. However, even disabling the session start, the code to disable / enable the pivot or report generation remains without effect (reports are still available)

Best,

PS: I also tried
Code:
if(isset($_SESSION['logged_user_infos_ar']['id_group']) && $_SESSION['logged_user_infos_ar']['id_group'] == 2)
{
$enable_pivot_generation = 0;
$enable_report_generation = 0;
}
However, no effect at all
 
Last edited:

eugenio

Administrator
Staff member
You are right, it can't work because even $_SESSION is not available (yet) in config_custom.php.
You need to move the code to the startup function, it will work there.

However, at the beginning of the startup function you should also add

global $enable_pivot_generation, $enable_report_generation;
 

juergen_mueller

DaDaBIK Guru
Perfect. Thanks, Eugenio. This is the code that works (for those who might be interested)
Code:
$custom_startup_function = 'dadabik_startup';
function dadabik_startup (){
global $enable_pivot_generation,$enable_report_generation;
if (isset($_GET['tablename']) && $_GET['tablename'] === 'transactions' && isset($_SESSION['logged_user_infos_ar']['id_group']) && $_SESSION['logged_user_infos_ar']['id_group'] == 2)
{
$enable_pivot_generation = 0;
$enable_report_generation = 0;
}
}
Best
 

nferrara

New member
Hello
I am very interested
where should we install this function?
in the include/custom_functions directory?
the only modification I made: 'id_group'] == 4 (my non-admin group) instead of your 'id_group'] == 2
but it doesn't work!
Thanks
Nicole
 

eugenio

Administrator
Staff member
In:
/include/custom_functions.php

check the documentation about the custom startup function

Best,
 
Top