From 3716395a8ea29ab03141e95e34622b7d521032fb Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 22 Nov 2025 08:40:33 +0100 Subject: [PATCH] FIX : problem with VAT SELECT: cannot update the right DOMID --- html/js/noalyss_script.js | 29 +++++++++++++++++-------- include/ajax/ajax_account.php | 5 ++++- include/class/card_property.class.php | 2 +- include/class/tva_rate_mtable.class.php | 3 +++ include/lib/itva_popup.class.php | 1 + 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js index a50c93c45..a5f6c5400 100644 --- a/html/js/noalyss_script.js +++ b/html/js/noalyss_script.js @@ -609,8 +609,8 @@ function popup_select_tva(obj, p_function_callback) { if (document.getElementById('tva_select')) { removeDiv('tva_select'); } - - var queryString = "gDossier=" + obj.gDossier + "&op=dsp_tva" + "&ctl=" + obj.ctl + '&popup=' + 'tva_select'; + + var queryString = "gDossier=" + obj.getAttribute("gdossier") + "&op=dsp_tva" + "&ctl=" + obj.getAttribute("ctl") + '&popup=' + 'tva_select'; if (obj.jcode) queryString += '&code=' + obj.jcode; if (obj.compute) @@ -641,7 +641,7 @@ function popup_select_tva(obj, p_function_callback) { var nTop = posY - 200; var nLeft = "15%"; - var str_style = "top:" + nTop + "px;left:" + nLeft + ";right:" + nLeft + ";width:55em;height:auto"; + var str_style = "top:" + nTop + "px;left:" + nLeft + ";right:" + nLeft + ";width:55em;height:auto;z-index:"+get_next_layer()+';'; var popup = { 'id': 'tva_select', @@ -2202,10 +2202,11 @@ function view_action(ag_id, dossier, modify) { * @param _id : id of the table * @param colnr : string containing the column number where you're searching separated by a comma * @param start_row : first row (1 if you have table header) + * @param class 2nd filter on the CSS CLASS of the row (TR), domid of the TAG containing the classname (TagName: SELECT, HIDDEN, TEXT ) * @returns nothing * @see HtmlInput::filter_table */ -function filter_table(phrase, _id, colnr, start_row) { +function filter_table(phrase, _id, colnr, start_row,classname) { id$('info_div').innerHTML = content[65]; id$('info_div').style.display = "block"; var words = id$(phrase).value.toLowerCase(); @@ -2220,8 +2221,17 @@ function filter_table(phrase, _id, colnr, start_row) { } var ele; var tot_found = 0; - - for (var r = start_row; r < table.rows.length; r++) { + console.debug(`filter is ${classname}`) + var row_class=""; + if ( classname ) row_class=id$(classname).value; + + for (var r = start_row; r < table.rows.length; r++) + { + if ( row_class != "" && ! table.rows[r].hasClassName(row_class)) { + console.debug(`no check ${r} ${classname}`) + continue; + } + console.debug(`checked ${r} ${classname}`) var found = 0; for (var col = 0; col < aCol.length; col++) { var idx = aCol[col]; @@ -5000,6 +5010,7 @@ VAT_Code.prototype.list_vatex=function () { try { + var here=this; var dgbox = "search_vatex_div"; waiting_box(); removeDiv(dgbox); @@ -5023,7 +5034,7 @@ VAT_Code.prototype.list_vatex=function () var div_style = "position:absolute;" + ";top:" + y + "px"+";z-index:"+get_next_layer(); add_div({id: dgbox, cssclass: 'inner_box', html: loading(), style: div_style, drag: false}); $(dgbox).update(req.responseText); - + here.filter_country(); } } @@ -5078,7 +5089,7 @@ VAT_Code.prototype.select_value=function(vx_code) VAT_Code.prototype.filter_country=function() { try { - var to_show="country"+id$("filter_country").value; + var to_show=id$("filter_country").value; console.debug(`show ${to_show}`) let a_row=id$("code_vatex_tb").rows; // show all rows, then hide @@ -5093,7 +5104,7 @@ VAT_Code.prototype.filter_country=function() console.debug(`hide row ${i}`) } } - + $('lk_code_vatex_tb').value=""; }catch (e) { console.error(e.message); diff --git a/include/ajax/ajax_account.php b/include/ajax/ajax_account.php index 61d1688e6..4f0d1b4ba 100644 --- a/include/ajax/ajax_account.php +++ b/include/ajax/ajax_account.php @@ -50,7 +50,10 @@ switch ($op2) * ----------------------------------------------------------------------*/ case "sf": - $ipopup=$ctl; + if ( ! isset($ctl)) { + $ctl= uniqid(); + } + $ipopup=$ctl; $attr=sprintf('this.ctl=\'%s\';',$ipopup); $ctl.='_content'; $it=new IText('acc_query'); diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index 947955070..c1b239aee 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -224,7 +224,7 @@ class Card_Property } if ($this->ad_id == ATTR_DEF_TVA) { - $result['input'] = new ITva_Popup('popup_tva'); + $result['input'] = new ITva_Popup( "av_text" . $this->ad_id); $result['input']->table = 0; $result['input']->value = $this->av_text; $result['label']=$this->ad_text; diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php index 6e845b32f..d576dbfd4 100644 --- a/include/class/tva_rate_mtable.class.php +++ b/include/class/tva_rate_mtable.class.php @@ -206,6 +206,9 @@ class Tva_Rate_MTable extends Manage_Table_SQL { $text=\HtmlInput::hidden("vx_code",$value); echo $text; + if ( $value !="") { + $value= \Icon_Action::trash(uniqid(),"vat_code.select_value('xx')").$value; + } echo span($value,'id="vx_value"'); $js=sprintf("vat_code.list_vatex()"); echo \Icon_Action::icon_magnifier(uniqid(),$js ); diff --git a/include/lib/itva_popup.class.php b/include/lib/itva_popup.class.php index 0ef12fd72..5861610a2 100644 --- a/include/lib/itva_popup.class.php +++ b/include/lib/itva_popup.class.php @@ -61,6 +61,7 @@ class ITva_Popup extends HtmlInput $this->button = true; $this->in_table = false; $this->value = $p_value; + if ($p_id =="") $p_id= uniqid ("vat"); $this->id = $p_id; $this->filter = 'none'; }