E-INVOICE : VATEX filter on the country

This commit is contained in:
sparkyx 2025-11-22 08:38:44 +01:00
parent 55d7fda8d1
commit 71f8a7fc82
5 changed files with 71 additions and 22 deletions

View file

@ -5075,5 +5075,30 @@ VAT_Code.prototype.select_value=function(vx_code)
}
}
VAT_Code.prototype.filter_country=function()
{
try {
var to_show="country"+id$("filter_country").value;
console.debug(`show ${to_show}`)
let a_row=id$("code_vatex_tb").rows;
// show all rows, then hide
for (let i=1;i< a_row.length;i++) {
if (id$("filter_country").value == 0 || a_row[i].hasClassName(to_show)){
a_row[i].show()
console.debug(`show row ${i}`)
}else {
a_row[i].hide()
console.debug(`hide row ${i}`)
}
}
}catch (e)
{
console.error(e.message);
return false;
}
}
noalyss=new Noalyss();

View file

@ -37,8 +37,6 @@ if ($select_code == "")
{
require_once NOALYSS_TEMPLATE."/ajax-search_vatex.php";
return;
}
@ -53,7 +51,7 @@ if ($select_code != "")
if ( ! empty ($row))
{
$answer['vx_code']=$row['vx_code'];
$answer['vx_value']=$row['vx_code'];
$answer['vx_value']=Icon_Action::trash(uniqid(),"vat_code.select_value('xx')").$row['vx_code'];
$answer['vx_description']=$row['vx_description'].span($row['vx_remark'],' class="text-muted" ');
}else {
$answer['vx_code']=$answer['vx_value']=$answer['vx_description']="";

View file

@ -1011,6 +1011,30 @@ class HtmlInput
return $sel;
}
}
/**
* @brief filter the rows in a table and keep the colored row in alternance
* @param dom_id $p_table_id table
* @param string $p_col , column to search example 0,1,2
* @param int $start_row row to always keep (header)
* @param string $p_name name of the input field
* @param string $domid domid containing the second filter, it could be an HIDDEN, TEXT, SELECT field
* @return string HTML
*/
static function filter_table_DOM($p_table_id, $p_col, $start_row, $p_name
,$domid)
{
$r="
<span>
<span class=\"icon\" >&#xf50d;</span>
<input id=\"lk_".$p_table_id."\" name=\"$p_name\" autocomplete=\"off\" class=\"input_text\" name=\"filter\" onkeyup=\"filter_table(this, '$p_table_id','$p_col',$start_row ,'$domid')\" type=\"text\" placeholder=\""._("Filtre rapide")."\">
<input type=\"button\" class=\"smallbutton\" onclick=\"$('lk_".$p_table_id."').value='';filter_table($('lk_".$p_table_id."'), '$p_table_id','$p_col',$start_row,'$domid' );\" value=\"X\">
</span>
";
$r.=' <span class="notice" style="display:none" id="info_'.$p_table_id.'"></span>';
return $r;
}
/**
* @brief filter the rows in a table and keep the colored row in alternance
* @param dom_id $p_table_id table

View file

@ -105,15 +105,15 @@ class ISmallButton extends IButton
$extra= ( isset($this->extra))?$this->extra:"";
$this->id=($this->id=="")?$this->name:$this->id;
$tab=(isset($this->tabindex))?' tabindex="'.$this->tabindex.'"':"";
$attr=$this->get_node_attribute();
$r='<input type="BUTTON" name="'.$this->name.'"'.
' class="smallbutton" '.
$this->extra.
$tab.
' id="'.$this->id.'"'.
' value="'.$this->label.'"'.
' onClick="'.$this->javascript.'"'.$extra.'>';
$attr=$this->get_js_attr();
$r.=$attr;
' onClick="'.$this->javascript.'"'.$extra." $attr ".'>';
return $r;
}

View file

@ -26,8 +26,21 @@
echo \HtmlInput::title_box(_("Choix VATEX"), $dgbox);
$a_vatex_code = $cn->get_array("select vx_code,vx_code_name,vx_description,vx_remark , vx_country from vatex_code order by 1");
$nb_vatex_code = count($a_vatex_code);
print HtmlInput::filter_table('code_vatex_tb', '0,1,2,3', 1);
//@var $os_country (ISELECT) filter table by country
$os_country=new \ISelect("filter_country");
$os_country->transform(array(
"countryeu"=>"Europe",
""=>_("Tous"),
"countryfr"=>"France"
)
);
$os_country->javascript=' onchange="vat_code.filter_country()" ';
?>
<div class="content">
<?=$os_country->input()?>
<?=HtmlInput::filter_table_DOM('code_vatex_tb', '0,1,2,3', 1,'search_vatex','filter_country')?>
<table class="result" id="code_vatex_tb">
<thead>
<td>
@ -44,24 +57,12 @@ print HtmlInput::filter_table('code_vatex_tb', '0,1,2,3', 1);
</td>
</thead>
<tbody>
<tr>
<td>
<a class="notice" href="javascript:void(0)" onclick="vat_code.select_value('xx')" class="mtitle line">
<?= _("Aucun code") ?>
</a>
</td>
<td>
</td>
<td class="notice">
<a class="notice" href="javascript:void(0)" onclick="vat_code.select_value('xx')" class="mtitle line">
<?= _("Effacer le code VATEX") ?>
</a>
</td>
</tr>
<?php
for ($i = 0; $i < $nb_vatex_code; $i++):
$class = ($i % 2 == 0) ? " odd " : " even ";
$odd= ($i % 2 == 0) ? " odd " : " even ";
$cnt=sprintf(" country%s",$a_vatex_code[$i]['vx_country']);
$class=" $odd $cnt ";
?>
<tr class="<?= $class ?>">
<td>
@ -93,3 +94,4 @@ print HtmlInput::filter_table('code_vatex_tb', '0,1,2,3', 1);
<?= \HtmlInput::button_close($dgbox) ?>
</li>
</ul>
</div>