PopUp and add1 - key fields [message #5189] |
Thu, 10 December 2015 05:20 |
htManager
Messages: 439 Registered: May 2014
|
Senior Member |
|
|
I have a virtual private database with a shared table 'orga_kontakte' and a table 'orga_kontakte_adresse' with contacts of the logged-in account.
Key fields in both tables are user_id, user_seq_no and rdcaccount_id.
If I add a record in 'orga_kontakte_adresse' I have the possibility to choose from the shared table 'orga_kontakte' with a popup form. If I choose from the shared table I want to keep the values for user_id and user_seq_no and only want to change the value for rdcaccount_id. This is done in function _cm_post_popupReturn() in orga_kontakte_adresse.class.inc and I can see the right key values.
My problem is now that if I press the submit button the values are changed because of the following code:
function _cm_getInitialData ($fieldarray)
// Perform custom processing for the getInitialData method.
// $fieldarray contains data from the initial $where clause.
{
{
// get next available number for user_seq_no
$where = "user_id='{$_SESSION['logon_user_id']}'";
$query = "SELECT max(user_seq_no) FROM $this->tablename WHERE $where";
$count = $this->getCount($query);
$fieldarray['user_id'] = $_SESSION['logon_user_id'];
$fieldarray['user_seq_no'] = $count + 1;
} // if
// set these fields to 'noedit' (read only)
$this->fieldspec['user_id']['noedit'] = 'y';
$this->fieldspec['user_seq_no']['noedit'] = 'y';
return $fieldarray;
} // _cm_getInitialData
This code is correct if the popup form is not used and the new contact is only for this account.
Can I insert a condition clause after $count = $this->getCount($query); to decide if the popup was called or not? And if yes with which function/variable can I do this?
The purpose of this is to keep trace of the contacts in the shared table.
|
|
|