ICARD: improve, action in javascript after cleaning the input of the qcode

This commit is contained in:
sparkyx 2025-11-22 10:48:00 +01:00
parent 1b2101c557
commit ac87e863ad
8 changed files with 27 additions and 7 deletions

View file

@ -1113,7 +1113,6 @@ class Acc_Ledger extends jrn_def_sql
$quick_code->value=(isset(${'qc_'.$i}))?${'qc_'.$i}:"";
$quick_code->readonly=$p_readonly;
$label='';
if ($quick_code->value!='')
{

View file

@ -1492,6 +1492,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$W1->name="e_march".$i;
$W1->value=$march;
$W1->table=0;
$W1->setAfter_clean("compute_all_ledger()");
$W1->set_dblclick("fill_ipopcard(this);");
$W1->set_attribute('ipopup','ipopcard');

View file

@ -1623,6 +1623,7 @@ EOF;
$W1->name = "e_march" . $i;
$W1->value = $march;
$W1->table = 0;
$W1->setAfter_clean("compute_all_ledger()");
$W1->set_attribute('typecard', 'cred');
$W1->set_dblclick("fill_ipopcard(this);");
$W1->set_attribute('ipopup', 'ipopcard');

View file

@ -196,7 +196,7 @@ class Acc_Ledger_Search
$f_qcode->javascript=sprintf(' onchange="fill_data_onchange(%s);" ',
$f_qcode->name);
$f_qcode->value=$http->request($this->div.'qcode',"string","");
$f_qcode->setAfter_clean("");
/* $f_txt_qcode=new IText('qcode');
$f_txt_qcode->value=(isset($_REQUEST['qcode']))?$_REQUEST['qcode']:'';
*/

View file

@ -158,6 +158,7 @@ class ICard extends HtmlInput
//!< $autocomplete_file , ajax file used for autocompletion (see Ajax.Autocompleter)
private $autocomplete_file;
protected $after_clean; //!< javascript to call after cleaning the INPUT TEXT
function __construct($name="", $value="", $p_id="")
{
parent::__construct($name, $value);
@ -176,8 +177,20 @@ class ICard extends HtmlInput
$this->amount_from_type=''; //!< in the follow up ,when a card is selected you take Prix Vente or Prix Achat
$this->typecard='all';
$this->autocomplete_file="fid_card.php";
$this->after_clean="";
}
/**
public function getAfter_clean()
{
return $this->after_clean;
}
public function setAfter_clean($after_clean)
{
$this->after_clean = $after_clean;
return $this;
}
/**
* Function javascript by default it is update_value called BEFORE the querystring is send in ajax
* @return type
*/
@ -475,8 +488,8 @@ class ICard extends HtmlInput
$this->dblclick=$e;
}
$input='<div class="d-none d-lg-inline">'.
Icon_Action::clean_zone(uniqid("remove"),"clean_Fid('{$this->id}');compute_all_ledger();").
$input='<div class="d-none d-lg-inline">'.
Icon_Action::clean_zone(uniqid("remove"),"clean_Fid('{$this->id}');{$this->after_clean}").
"</div>";
$input.=sprintf('

View file

@ -57,6 +57,8 @@ if ( $new|| $type=='FIN') :
<?php
$card=new ICard();
$card->name='bank';
// clean only the INPUT no javascript
$card->setAfter_clean("");
$card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4');
$card->set_dblclick("fill_ipopcard(this);");
$card->set_function('fill_data');

View file

@ -901,7 +901,9 @@ class Acc_LedgerTest extends TestCase
ob_end_clean();
\Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result);
$size=filesize(__DIR__."/file/acc_ledger-input_new.html");
$this->assertTrue($size == 16075 ," output input_new is $size not what it is expected");
$expected=15985;
$delta =$size-$expected;
$this->assertTrue($delta == 0 ," output input_new is $size expected $expected not what it is expected DELTA=$delta, file to check ".__DIR__."/file/acc_ledger-input_new.html");
}

View file

@ -89,7 +89,9 @@ class Acc_Ledger_searchTest extends TestCase
$r=$ledger->display_search_form();
\Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger_search-test_display_search_form.html", $r);
$filesize=strlen($r);
$this->assertTrue($filesize==10971,"Size of the html string for display_search_form see "
$expected=10971;
$delta =$filesize-$expected;
$this->assertTrue($delta == 0,"Size of the html string for display_search_form see delta = $delta , size=$filesize, expected=$expected "
. __DIR__."/file/acc_ledger_search-test_display_search_form.html ");
}
/**