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.