Problem with two list1 transactions on one table [message #1538] |
Tue, 12 August 2008 17:15 ![Go to next message Go to next message](/theme/default/images/down.png) |
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 message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to next message](/theme/default/images/down.png) |
AJM
Messages: 2361 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.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|