Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » Problem with two list1 transactions on one table
Problem with two list1 transactions on one table [message #1538] Tue, 12 August 2008 17:15 Go to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
I have the 'person' table, each person can be of two types (field called 'pers_type'): 'coach' or 'player'.

I'm trying to figure out how to implement this in radicore using two menus, one for persons and one for players.

I created a list1 transaction for table 'person' called 'player(list1)', this generated and assigned as a task button an add1 transaction named person(add1) amongst others.

I then created a second list1 transaction on table 'person' and called it 'coach(list1), this transaction is automatically assigned the task button person(add1).

My idea was to filter in _cm_pre_insertRecord and in _cm_initialise using the $GLOBALS['task_id'] to identify if we are in the 'coach' menu or 'player' menu, and assigning/filtering by the field 'pers_type'.
like this:
    function _cm_initialise ($where, $selection){

	if ($GLOBALS['task_id'] == 'coach(list1)'){
		$vl_tippart = 'E';
	}else{
		$vl_pers_type = 'P';
	}
	
	if (empty($where)){
    		$where = "pers_type='" .$vl_pers_type . "'";
	}else{
			$where .= "AND pers_type='" .$vl_pers_type . "'";
	}
	
	
	return $where;
}


and this:
	function _cm_pre_insertRecord($rowdata)
	{
	    if ($GLOBALS['task_id'] == 'coach(add1)'){
			$rowdata['tippart'] = 'E';
		}else{
			$rowdata['tippart'] = 'P';
		}
		return $rowdata;
	}


The problem is that I can't create a custom add1 transaction. Both coach(list1) and player(list1) use the same add1 transaction id, therefore I can't filter the records.

So how should I solve this? Easy way is to have two separate tables but I'd rather use the same table.
Re: Problem with two list1 transactions on one table [message #1540 is a reply to message #1538] Tue, 12 August 2008 19:26 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
You don't need two tables, and you don't even need all that code. There is a perfect example of what you want already built into the MENU system, as described in http://www.tonymarston.net/php-mysql/infrastructure-faq.html #faq50.

For this you will need a single LIST1 control script which is accessed by two separate tasks, with different values in the Selection (fixed) field, such as:

player(list1) => pers_type='player'
coach(list1) => pers_type='coach'

This means that although the same script is being run it will have different values in the $where string at runtime, so no need for any code in the '_cm_pre_getData()' method.

Both of these tasks can use the same ADD1 task on the navigation buttons as it will be passed the contents of the $where string and automatically load that value into the screen and set it to 'noedit' so that it cannot be modified.


Re: Problem with two list1 transactions on one table [message #1541 is a reply to message #1538] Wed, 13 August 2008 05:01 Go to previous messageGo to next message
bonzo_bcn is currently offline  bonzo_bcn
Messages: 152
Registered: June 2008
Senior Member
Thanks, I did it this way and it works.
One last thing, when you click on the 'add' button of any of both screens, is there any way to have different screen titles depending if you clicked the 'add' button in the player or coach screen?
Ideally I'd like to have the title 'Add coach' and 'Add player' when adding any of these two records.
Re: Problem with two list1 transactions on one table [message #1542 is a reply to message #1541] Wed, 13 August 2008 05:54 Go to previous message
AJM is currently offline  AJM
Messages: 2367
Registered: April 2006
Location: Surrey, UK
Senior Member
The only way to do that is to have separate tasks for 'Add Coach' and 'Add Player', but each of these tasks can use the same ADD1 controller script. Each task can then have its own separate title.

Previous Topic: Help/suggestions with record filtering by user
Next Topic: $where clause problem with list1 and read
Goto Forum:
  


Current Time: Thu Nov 21 05:04:46 EST 2024

Total time taken to generate the page: 0.00976 seconds