|
|
|
|
Re: DropDown Field values - changing in runtime [message #7682 is a reply to message #7681] |
Wed, 16 February 2022 04:08   |
htManager
Messages: 452 Registered: May 2014
|
Senior Member |
|
|
Sorry, my fault. I didn't explain it right.
I have a foreign (compound) key in my table and I call a popup form to choose an occurence of this foreign table. In _cm_getExtraData() I have the code for filling the dropDown list with the values of a table consisting of the foreign key and another key field with the (detail) values I want.
As far as I understand, the popupReturn event doesn't fire an 'onchange' trigger and that's why the _cm_updateFieldarray() method will not be fired.
Using a dropdown field for a compound key as desribed in FAQ 138 was the last time too difficult for me. But I will try it again.
It is possible to fire an 'onchange' trigger in the _cm_popupReturn() method after filling in the selected values in $fieldarray? Or is there a better solution for this problem?
[Updated on: Wed, 16 February 2022 06:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: DropDown Field values - changing in runtime [message #7692 is a reply to message #7691] |
Sun, 06 March 2022 06:01   |
htManager
Messages: 452 Registered: May 2014
|
Senior Member |
|
|
This is the definition of the column:
$fieldspec['ma_ausruestung_preis_eigenanteil']= array('type' => 'numeric',
'size' => 12,
'precision' => 11,
'scale' => 2,
'minvalue' => 0,
'maxvalue' => 999999999.99,
'default' => '0.00');
If I set $this->fieldspec['ma_ausruestung_preis_eigenanteil']['noedit'] = 'y' in _cm_changeConfig() everything works fine and the value will not be increased.
This is the content of $postarray and $fieldarray in _cm_updateFieldArray()
C:\xampp\htdocs\radicore\htm\classes\orga_mannschaften_konta kte_ausruestung.class.inc:732:
array (size=8)
this is the composed value from the lookup table, existing of the three foreign key values
'gr_art_dropdown' => string '&SCH-DE&D&1' (length=11)
'gr_art_ausr' => string 'S' (length=1)
'ma_ausruestung_ausgabe' => string 'on' (length=2)
'ma_ausruestung_ausgabe_datum' => string '2022-02-19' (length=10)
this is the value which will be increased to 5000.00, 500000.00, 50000000.00, .... each time I change the dropdown field value
'ma_ausruestung_preis_eigenanteil' => string '50.00' (length=5)
'ma_ausruestung_preis_eigenanteil_bezahlt' => string 'on' (length=2)
'ma_ausruestung_preis_eigenanteil_bezahlt_datum' => string '2022-02-19' (length=10)
'ma_ausruestung_trikot_no' => string 'EA' (length=2)
C:\xampp\htdocs\radicore\htm\classes\orga_mannschaften_konta kte_ausruestung.class.inc:733:
array (size=39)
'verbaende_art_id' => string 'LV' (length=2)
'verbaende_kuerzel' => string 'HV S' (length=4)
'vereine_kuerzel' => string 'HVS' (length=3)
'saison_id' => string '2021/2022' (length=9)
'mannschaften_id' => string '2007W' (length=5)
'user_id' => string 'HVS' (length=3)
'user_seq_no' => string '2' (length=1)
'ausruestung_id' => string 'TSHIRT' (length=6)
'ausruestung_anr' => string '2007W-SC-HVS' (length=12)
'rdcaccount_id' => string '7' (length=1)
'ma_ausruestung_kontakt_name' => string 'Alizada' (length=7)
'ma_ausruestung_kontakt_vorname' => string 'Emilia' (length=6)
'ma_ausruestung_marke' => string 'Adidas' (length=6)
'ma_ausruestung_modell' => string 'T 4711' (length=6)
'ma_ausruestung_desc' => string 'T-Shirt Sommercamp 2021 - 2007w' (length=31)
this is the value from the lookup table
'gr_art_dropdown' => string '&KLD-DE&D&1' (length=11)
these are the foreign keys values coming from 'gr_art_dropdown'
'gr_art' => string 'KLD-DE' (length=6)
'gr_art_sub' => string 'D' (length=1)
'gr_art_rdc' => string '1' (length=1)
'gr_art_ausr' => string 'S' (length=1)
'ma_ausruestung_farbe' => string 'rot' (length=3)
'ma_ausruestung_farbnummer' => null
'ma_ausruestung_preis_netto' => string '0.00' (length=4)
'ma_ausruestung_preis_rabatt' => string '0.000' (length=5)
'ma_ausruestung_preis_rabatt_berechnen' => string '0' (length=1)
'ma_ausruestung_preis_mwst' => string '0.00' (length=4)
'ma_ausruestung_preis_mwst_berechnen' => string '0' (length=1)
'ma_ausruestung_preis_brutto' => string '0.00' (length=4)
this is the value which will be increased to 5000.00, 500000.00, 50000000.00, .... each time I change the dropdown field value
'ma_ausruestung_preis_eigenanteil' => string '50.00' (length=5)
'ma_ausruestung_preis_eigenanteil_bezahlt' => string '1' (length=1)
'ma_ausruestung_preis_eigenanteil_bezahlt_datum' => string '2022-02-19' (length=10)
'ma_ausruestung_preis_berechnen' => string '0' (length=1)
'ma_ausruestung_pfad_bild' => null
'ma_ausruestung_pfad_video' => null
'ma_ausruestung_barcode' => null
'ma_ausruestung_trikot_no' => string 'EA' (length=2)
'ma_ausruestung_ausgabe' => string '1' (length=1)
'ma_ausruestung_ausgabe_datum' => string '2022-02-19' (length=10)
'ausruestungs_groesse_art_desc' => string 'Kleider-Größen Damen (EU/DE)' (length=30)
|
|
|
Re: DropDown Field values - changing in runtime [message #7694 is a reply to message #7692] |
Wed, 09 March 2022 04:36   |
AJM
Messages: 2378 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
According to your sample code the column with the dropdown list is 'ma_ausruestung_preis_eigenanteil', but you have not shown the contents of $this->lookup_data['ma_ausruestung_preis_eigenanteil']. This is an associative array, so I am interested in seeing the keys and the values. You have also not explained how the column 'gr_art_dropdown' fits into the picture. Where is the code which splits your multi-part value into a series of separate values?
[Updated on: Wed, 09 March 2022 04:37] Report message to a moderator
|
|
|
Re: DropDown Field values - changing in runtime [message #7695 is a reply to message #7694] |
Wed, 09 March 2022 05:09   |
htManager
Messages: 452 Registered: May 2014
|
Senior Member |
|
|
Sorry for my English and how I try to explain what I mean.
The field gr_art_dropdown ('Größe (Art) auswählen')is a field with a dropdown list. It will be filled with the description of the size categories (shoes, cloths, etc.).
The field gr_art_ausr ('Größe') is the field where you can choose the right size of the chosen category.
The field ma_ausruestung_preis_eigenanteil ('Eigenanteil') is the field which holds the part of the total cost which will be payed by the team member.
I added two screen shots: the initial and a changed one. Hopefully you can see what I tried to explain. I added the code of the _cm_getValRep() method of the table from where the values come.
In the screenshot you see in 'Größe (Art) auswählen' the category of the size (shoes, cloth, etc.). And in 'Größe' the selectable values. In 'Eigenanteil' you see the value of the money (50.00, 5000,00).
In the green circle you can see the individual values of the compound foreign key which identify the key for filling the field 'Größe' with the right values.
// ************************************************************ ****************
function _cm_getValRep ($item=null, $where=null, $orderby=null)
// get Value/Representation list as an associative array.
{
$array = array();
switch ($item) {
case 'groessen_art_ausr_kopf' :
// get data from the database
$this->sql_select = 'gr_art, gr_art_sub, rdcaccount_id, ausruestungs_groesse_art_desc';
$this->sql_orderby = 'ausruestungs_groesse_art_desc';
$this->sql_ordery_seq = 'asc';
$data = $this->getData($where);
// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {
$key = '&' . $rowdata['gr_art'] . '&' . $rowdata['gr_art_sub'] . '&' . $rowdata['rdcaccount_id'];
$array[$key] = $rowdata['ausruestungs_groesse_art_desc'];
} // foreach
return $array;
case 'groessen_art_ausr_detail' :
// ermittelt den Primärschlüssel
if (isset($GLOBALS['gr_key_array'])) {
$primary_key_values = $GLOBALS['gr_key_array'];
} else {
$primary_key_values['1'] = $GLOBALS['fieldarray']['gr_art'];
$primary_key_values['2'] = $GLOBALS['fieldarray']['gr_art_sub'];
$primary_key_values['3'] = $GLOBALS['fieldarray']['gr_art_rdc'];
}
// get data from the database
$this->sql_select = 'orga_groessen_ausr_detail.gr_art_ausr, orga_groessen_ausr_detail.argroesse_desc';
$this->sql_from = "orga_groessen_ausr " .
" LEFT JOIN orga_groessen_ausr_detail ON (" .
"orga_groessen_ausr_detail.gr_art = orga_groessen_ausr.gr_art AND " .
"orga_groessen_ausr_detail.gr_art_sub = orga_groessen_ausr.gr_art_sub AND " .
"orga_groessen_ausr_detail.rdcaccount_id = orga_groessen_ausr.rdcaccount_id)";
$this->sql_orderby = 'argroesse_desc';
$this->sql_ordery_seq = 'asc';
$where = "gr_art = '{$primary_key_values['1']}' AND " .
"orga_groessen_ausr_detail.gr_art_sub = '{$primary_key_values['2']}' AND " .
"orga_groessen_ausr_detail.rdcaccount_id = '{$primary_key_values['3']}'";
$data = $this->getData($where);
// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {
$rowvalues = array_values($rowdata);
$array[$rowvalues[0]] = $rowvalues[0] . ' - ' . $rowvalues[1];
} // foreach
return $array;
} // switch
return $array;
} // _cm_getValRep
[Updated on: Wed, 09 March 2022 09:03] Report message to a moderator
|
|
|
|
Re: DropDown Field values - changing in runtime [message #7697 is a reply to message #7696] |
Fri, 11 March 2022 09:53   |
htManager
Messages: 452 Registered: May 2014
|
Senior Member |
|
|
I split the compound key into its component parts in _cm_updateFieldArray() with the following code:
$str_gr_art = $postarray['gr_art_dropdown'];
if (isset($postarray['gr_art_dropdown'])) {
$gr_key_array = explode('&', $str_gr_art);
// weist die Daten $GLOBALS zu
$GLOBALS['gr_key_array'] = $gr_key_array;
// liest die Schlüsselwerte der ausgewählten Größe ein
$fieldarray['gr_art'] = $gr_key_array[1];
$fieldarray['gr_art_sub'] = $gr_key_array[2];
$fieldarray['gr_art_rdc'] = $gr_key_array[3];
// ermittelt die Größen-Werte aus orga_groessen_ausr_detail
$dbobject =& RDCsingleton::getInstance('orga_groessen_ausr_detail'); // Instanz für Lookup-Tabelle
$dbobject->sql_select = 'gr_art_ausr, argroesse_desc';
$where = "gr_art='{$fieldarray['gr_art']}' AND " .
"gr_art_sub='{$fieldarray['gr_art_sub']}' AND " .
"rdcaccount_id='{$fieldarray['gr_art_rdc']}'";
// sortiert die Daten
$dbobject->sql_orderby = 'argroesse_desc';
$data = $dbobject->getData ($where);
// weist die Werte der Lookup-Variablen zu
foreach ($data as $row => $rowdata) {
$rowvalues = array_values($rowdata);
$array[$rowvalues[0]] = $rowvalues[0] . ' - ' . $rowvalues[1];
} // foreach
}
But the code is in my opinion not the problem. The numeric field has the same behaviour even if I set the above code in /* */
If I change the value of the numeric field before changing the dropdown field from 50,00 to 50,0, the numeric field will be increased to 500,00. If I change the value to 5 the value will not be increased but changed to 5,00. 5,0000 will be changed to 50.0000,00 and so on.
Changing the value of the numeric field to 5.00 (. instead of ,) increases the value by the factor of 100 and so on..
If I delete the code "$this->fieldspec['gr_art_dropdown']['javascript'] = array('onchange' => 'this.form.submit();');" in _cm_changeConfig(), nothing happens, the numeric field doesn't change the value.
[Updated on: Sat, 12 March 2022 09:18] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|