customize the actions button in detailview

Hello everyOne.
I want to know how can i custom the actions button in detailview.
In this moment my action_menu btn of Contract module is look like:
actionBtnDetailView_EN.PNG
So my need :
- Hide viewChange_log btn for all users EXCEPT ADMIN
- if (status_ctr == 'Signed'){
               hide edit btn;
               hide delete btn;
   }

Thank u for ur help

Parents Reply Children
  • Hi Soukina,

    You can do this by just extending the detail view of your module.

    create a new view.detail.php file in the following path custom/modules/<YourMODULE>/views/view.detail.php

    add the below code

    <?php

    require_once('include/MVC/View/views/view.detail.php');

    class <YourMODULE>ViewDetail extends ViewDetail{

         //override the desplay() method

         function display(){

                   parent::display();

                   global $current_user;

                   $is_admin = $current_user->is_admin;

                     echo $script=<<<EOC

                     <script>

                          $('.ab').click(function(){

                               var is_admin = "$is_admin";

                                //hide view change log for non admin users

                               if(!is_admin){

                                    $('#btn_view_change_log').hide();

                               }

                          });

                     </script>

    EOC;

         }

    }

    Same way you can hide edit and delete button based on the  value of field 'status_ctr'. To get the value of any field in the view.detail.php file you can use $this->bean->field_name. In your case $this->bean->status_ctr

    Hope it helps!

    -Shijin Krishna