Page 1 of 1

Having a Problem getting a Global Variable

Posted: 2023-09-22 10:26
by ddonohue
Hi

I have 2 problems at the moment
Firstly I have a database controlling wine storage where I would like the clients to log into the database and see the following
1) No of pallets sorted by the winetype and vintage
2) no of pallets sorted by the destination
3) No of pallets sorted by the category (type of Storage 'L/D' lying down bottles, 'S/U' standing up bottles '3H' 3 Pallets high )

I created in _globals.php the following
function login_ok($memberInfo, &$args) {
$logFile = 'members.log';
$usrindex = $memberInfo['custom'][0]; */= (custindex) */
$usrname = $memberInfo['custom'][1]; */= (custname) */
$ip = $memberInfo['IP'];
$date = date('m/d/Y');
$time = date('h:i:s a');
file_put_contents($logFile, "$date, $time,$usrindex,$usrname \n", FILE_APPEND);
return ' ' ;
}
so how do I get in the SQL "WHERE custindex = '$usrindex' "?
With the login the client show only get to see his pallets/


thanks for your help

David
Products.PNG
Products.PNG (54.43 KiB) Viewed 3564 times

Re: Having a Problem getting a Global Variable

Posted: 2023-10-01 19:18
by pbottcher
Hi,

you reference 2 problems. But I'm not even clear on one of them. Can you specify this in more details?

From what you write I would assume that you store in$memberInfo['custom'][0]; a custindex that you have in your product table as well.

If you try to display only the product for the user which match his custindex you can use the _init hook (hooks -> TABLENAME.php -> TABLENAME_init)

Here you can use some code like:

Code: Select all

	$usrindex = $memberInfo['custom'][0];

	$options->QueryWhere = $options->QueryWhere ? $options->QueryWhere . " AND " : " WHERE ";
	$options->QueryWhere .= "custindex = {$userindex}";
assuming your field is named custindex

Re: Having a Problem getting a Global Variable

Posted: 2023-10-04 21:25
by ddonohue
HI

thanks a lot for your help and you are right.

I also solved the problem using the filter as follows

Code: Select all

	function products_init(&$options, $memberInfo, &$args) {
		$idx = $memberInfo['custom'][0];
		$idx1 = $memberInfo['custom'][1];
		
		if(!$_POST['FilterField'][1] && !$_GET['FilterField'][1]){
			
			addFilter(1, 'and', 6, 'equal-to', $memberInfo['custom'][0]);
			
		}
			 	
regards

David