Jump to content

Can Not Get Employee Id


Recommended Posts

I have a custom module which is working great.  I wanted to add a logging system which tracks who was logged in and what action they are taking within the module.

 

I have a jquery ajax request to a php file when an action is taken.  Everything logs correctly but the employee id is always empty.

 

At the top of my php file I have.

require_once(dirname(__FILE__).'/../../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../../config/settings.inc.php');

global $smarty;
global $cookie;

$context = Context::getContext();

But $context->employee->id always empty.  Am I doing something wrong?

Link to comment
Share on other sites

Thanks for the reply.  This module is for the BO only.

 

When I output the cookie information, I do not see anything relating to the employee ID.

 

Also 

$this->context->employee->logged ? $this->context->employee->id

does not do anything for me.

 

Here is my simple php file which is called from the ajax request.

require_once(dirname(__FILE__).'/../../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../../config/settings.inc.php');

global $smarty;
global $cookie;

$context = Context::getContext();

$test = "BEGIN<BR>";
$test .= $context->cookie->id_employee;
$test .= "<br>";
$test .= $cookie->id_employee;
$test .= "<br>";
$test .= $context->employee->id;

echo json_encode(array($test ));

The only thing I get back is the "BEGIN" part. 

Link to comment
Share on other sites

ndiaga,

 

Thanks for the suggestion, however, that did not work either.  I started looking into the admin index.php file.  And noticed I was not declaring

_PS_ADMIN_DIR_
PS_ADMIN_DIR

 

Once I declared these, my variables came in.

 

Thanks for all the help!

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...