Hello good morning.
I need help...
I would like to know if I can add a code "X"
so that when the user selects "status" OFF and saves, all the fields are blocked, and that he himself cannot unlock, but only the administrator can unlock.
Could this be done?
ON -
OFF (block)
Excuse my English...
Thank you so much
Saves and all the fields are blocked
Saves and all the fields are blocked
- Attachments
-
- employees.png (12.85 KiB) Viewed 1667 times
Luis Ramirez R.
Re: Saves and all the fields are blocked
Hi,
you could use the _footer hook (case 'detailview':) to check if the status = OFF and if the group of the user != Admins then disable all input fields.
There might be a bit more to do, but I hope this give you a starting point.
you could use the _footer hook (case 'detailview':) to check if the status = OFF and if the group of the user != Admins then disable all input fields.
There might be a bit more to do, but I hope this give you a starting point.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Saves and all the fields are blocked
Hi Luis,
Just sharing what I am doing to achieve similar result.
The following code I put in "before update function" in hooks/TABLENAME.php (in my case, the file is hooks/purchase_order.php)
with this code, only users from Admins and Manager groups can make changes to Approved or Completed purchase orders.
You can change the query, groups & strings values as per your requirement.
Hope this help.
Have a nice day.
Just sharing what I am doing to achieve similar result.
The following code I put in "before update function" in hooks/TABLENAME.php (in my case, the file is hooks/purchase_order.php)
Code: Select all
function purchase_order_before_update(&$data, $memberInfo, &$args) {
// ONLY allow users from selected group(s) to update purchase_order with Approved or Completed status
$memberInfo = getMemberInfo();
$authorized = array('Admins', 'Manager');
if (!in_array($memberInfo['group'], $authorized)) {
$id = $data['selectedID'];
$status = sqlValue("SELECT `status` FROM `purchase_order` WHERE `id`='$id'");
$string1 = 'Approved';
$string2 = 'Completed';
// if the record status is Approved or Completed, don't allow updating it
if ($status == $string1 || $status == $string2) {
$args['error_message'] = 'You are not authorized to make the changes to Approved or Completed PO.';
return false;
}
}
return TRUE;
}
You can change the query, groups & strings values as per your requirement.
Hope this help.
Have a nice day.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.