Page 1 of 1

Finding table name in ListOptions_Rendered event

Posted: Wed Feb 28, 2024 9:27 am
by daveb

I am trying to find the name of my table in the LIstOptionsRendered event

The table is activebal and contains

Username varchar (5)
Activated varchar(1)
Balance decimal (8,2)

I have built column headers and body but can not find the link to the table name to complete the entries

function ListOptions_Load() {
    global $flighttable;
	global $actypes;
//  Find all AC types to be listed on output 
//  - use Activated types and those with a report code > 0
	$Mysql  = "SELECT Code1, Value1 FROM parameters WHERE (Type = 'ACTYPE' AND Value1 <> 0 " ; 
	$Mysql .= " AND Activated = 'Y' ) ORDER by Value1" ;                                  
	$rswrk = ExecuteRows($Mysql);
	$i = 1;
//   Store codes in Header
    foreach ($rswrk as $x)
      {
   	    $this->ListOptions->Add($i);
		$this->ListOptions->Items[$i]->Header = $x["Code1"];
        $actypes[$i] = $x["Code1"];
        $i++;
      }
//   save number of entries
    $flighttable['counter'] = $i;

and

// ListOptions Rendered event
function ListOptions_Rendered()
{
    // Example:
    //$this->ListOptions["new"]->Body = "xxx";

global $flighttable;
global $actypes; 

//    Shade alternate lines on list
	      for ($cntwrk = 1; $cntwrk < $flighttable['counter'];$cntwrk++)
		  {
               $cntwrk2 = fmod($cntwrk,2);
               if ($cntwrk2 == 1) $this->ListOptions->Items[$cntwrk]->CssStyle = "background-color: #00aaaa"; 
                 }
         $m = "PAULM";
//      $m =  $this->Fields['Username']->CurrentValue;
//      $m = getUsername();
//      $m = $GLOBALS["activebal"]->Username->CurrentValue;

        $Mysql  = "SELECT Permission, Actype FROM permissions WHERE (Activated = 'Y' AND Member =  '";
        $Mysql .= $m . "') ORDER BY Actype ";
    	$rswrk = ExecuteRows($Mysql);
  	foreach ($rswrk as $x)
	 {
       for ($cntwrk = 1; $cntwrk < $flighttable['counter'];$cntwrk++)
        {
	    	if ($actypes[$cntwrk] == $x["Actype"])
	    	  {
        		$this->ListOptions->Items[$cntwrk]->Body = $x["Permission"];
	    	  }
        } 	
	 } 
}

Works fine when I put a value in $m but can't find the correct reference for the table name / field content. The $GLOBALS option worked in PHP2018/PHP7.4

Thanks for any help you can give me.

Dave


Re: Finding table name in ListOptions_Rendered event

Posted: Wed Feb 28, 2024 9:55 am
by arbei

What did you mean by "finding table name"? Isn't it just "activebal"?

If you try to get the field value of the field 'Username' of the current table, you may use $this->Username->CurrentValue. However, double check the field variable name first.


Re: Finding table name in ListOptions_Rendered event

Posted: Wed Feb 28, 2024 9:55 pm
by daveb

Thanks for the answer - I had missed that my fieldname was renamed _Username - works fine now.