Lock or Freeze records with value from field

Wish to see a specific feature/change in future releases? Feel free to post it here, and if it gets enough "likes", we'd definitely include it in future releases!
Post Reply
Leving Tinoco
Posts: 12
Joined: 2018-01-04 18:39
Location: Canada

Lock or Freeze records with value from field

Post by Leving Tinoco » 2021-01-09 08:02

Recently i have been working on new project to lock or read-only records in base a results of SQL statement, I have a fields call "lock_r" define this fields to prevent records edit after report present to the manager, keeping integrity of the information after time.

I think will be great implement this on the Hooks function for future release of Appgini.

so far I have this:

ts_project.php hook file

Code: Select all

function ts_projects_dv_readonly($selectedID) {
    $readonly = (sqlValue("select lock_r from ts_projects where id={$selectedID}") === 1 ? true : false);
    return $readonly;
}
in the file ts_project_dml.php

inside of the function ts_projects_form between the

Code: Select all

$combo_employees->Render(); 

ob_start();
I add this code->

Code: Select all

 $combo_employees->Render();

    if (function_exists('ts_projects_dv_readonly')) {
        if (ts_projects_dv_readonly($selected_id)) {
            $AllowUpdate = 0;
            $AllowInsert = 0;
        }
    }

    ob_start();
I guess my request is if possible generate this function in future Appgini release?


Best regards;

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Lock or Freeze records with value from field

Post by onoehring » 2021-01-11 13:51

Hi,

thanks for posting. Maybe the Advanced Customizations > Hooks (viewforum.php?f=7) would be even better.

If you want to lock single fields for specific usergroups, please check out my Field Permissions ( viewtopic.php?f=4&t=3308 )

Olaf

Post Reply