Jump to content

hide the button: view - for the list of orders in the administration panel


ravspw1

Recommended Posts

For example, this code is sufficient in the module:

public function hookActionAdminControllerSetMedia($params)
{
	if($this->context->controller->controller_name == 'AdminOrders' && !Tools::getValue('id_order'))
    {
        /* array disable employee by id */
        $disabledViewEmployee = array('2', '3', '4');

        /* get current employee logged */
        $currentEmployee = $this->context->employee->id;

        /* default value */
        $disable = false;

        if (in_array($currentEmployee, $disabledViewEmployee)){
            $disable = true;
        }

        /* custom javascript */
        $this->context->controller->addJs('modules/'.$this->name.'/js/adminOrders.js');

        /* variable for javascript */
		$jsDef = array('employe_disable_view' => $disable);

        Media::addJsDef($jsDef);

	}
}

 

And custom JavaScript ....adminOrders.js:

$(document).ready(function(){
    /* params from module */
    if (employe_disable_view == true){
        document.querySelectorAll('.grid-view-row-link').forEach(function(el) {
            el.style.display = 'none';
        });
    }
});

 

Edited by 4you.software (see edit history)
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...