ICard and javascript improve
This commit is contained in:
parent
c34542867e
commit
8804860044
5 changed files with 40 additions and 66 deletions
|
|
@ -538,7 +538,7 @@ function compute_ledger(p_ctl_nb) {
|
|||
|
||||
id$('e_quant' + p_ctl_nb).value = trim(id$('e_quant' + p_ctl_nb).value);
|
||||
var quantity = id$('e_quant' + p_ctl_nb).value;
|
||||
let other_tax = id$("other_tax");
|
||||
let other_tax = document.getElementById("other_tax");
|
||||
let other_tax_id = (other_tax && other_tax.checked) ? other_tax.value : -1;
|
||||
|
||||
var querystring = {
|
||||
|
|
@ -581,7 +581,7 @@ function refresh_ledger() {
|
|||
id_tva = id$("tva");
|
||||
id_htva = id$("htva");
|
||||
id_tvac = id$("tvac");
|
||||
id_other_tax = id$("other_tax_amount");
|
||||
id_other_tax = document.getElementById("other_tax_amount");
|
||||
if (id_tva)
|
||||
id_tva.innerHTML = Math.round(tva * 100) / 100;
|
||||
if (id_htva)
|
||||
|
|
@ -666,7 +666,7 @@ function compute_all_ledger() {
|
|||
if (document.getElementById('tvac_march' + i))
|
||||
tvac += id$('tvac_march' + i).value * 1;
|
||||
}
|
||||
id_other_tax = id$("other_tax_amount");
|
||||
id_other_tax = document.getElementById("other_tax_amount");
|
||||
if (document.getElementById('tva')) id$('tva').innerHTML = Math.round(tva * 100) / 100;
|
||||
if (document.getElementById ('htva'))
|
||||
id$('htva').innerHTML = Math.round(htva * 100) / 100;
|
||||
|
|
|
|||
|
|
@ -27,29 +27,21 @@
|
|||
|
||||
/**
|
||||
* clean the row (the label, price and vat)
|
||||
* @param p_ctl the calling ctrl
|
||||
* @param {string} p_ctl the calling ctrl
|
||||
*/
|
||||
function clean_Fid(p_ctl)
|
||||
{
|
||||
nSell=p_ctl+"_price";
|
||||
nTvaAmount=p_ctl+"_tva_amount";
|
||||
nBuy=p_ctl+"_price";
|
||||
nTva_id=p_ctl+"_tva_id";
|
||||
if ( document.getElementById(nSell) )
|
||||
{
|
||||
id$(nSell).value="";
|
||||
|
||||
document.getElementById(p_ctl).value='';
|
||||
var aField=['_price','_tva_amount','_tva_id'];
|
||||
for ( field of aField) {
|
||||
let obj=document.getElementById(p_ctl+field);
|
||||
if ( obj ) {obj.value='0'}
|
||||
}
|
||||
if ( document.getElementById(nBuy) )
|
||||
{
|
||||
id$(nBuy).value="";
|
||||
}
|
||||
if ( document.getElementById(nTva_id) )
|
||||
{
|
||||
id$(nTva_id).value="-1";
|
||||
}
|
||||
if ( document.getElementById(nTvaAmount))
|
||||
{
|
||||
id$(nTvaAmount).value=0;
|
||||
var aField=['_label'];
|
||||
for ( field of aField) {
|
||||
let obj=document.getElementById(p_ctl+field);
|
||||
if ( obj ) {obj.value=''}
|
||||
}
|
||||
}
|
||||
function errorFid(request,json)
|
||||
|
|
@ -58,7 +50,7 @@ function errorFid(request,json)
|
|||
}
|
||||
/**
|
||||
* this function fills the data from fid.php,
|
||||
* @param {object} p_ctl : field of the input,
|
||||
* @param {object or string} p_ctl : field of the input, : object or string
|
||||
* possible object member
|
||||
* - label field to update with the card's name
|
||||
* - price field to update with the card's price
|
||||
|
|
@ -68,11 +60,15 @@ function errorFid(request,json)
|
|||
*/
|
||||
function ajaxFid(p_ctl)
|
||||
{
|
||||
debugger
|
||||
try
|
||||
{
|
||||
var gDossier=id$('gDossier').value;
|
||||
var jrn = (p_ctl.jrn) ? p_ctl.jrn.value:-1;
|
||||
p_ctl.value=p_ctl.value.toUpperCase();
|
||||
// if p_ctl is a string that find the object
|
||||
var dome =id$(p_ctl);
|
||||
|
||||
var jrn = (dome.jrn) ? dome.jrn.value:-1;
|
||||
dome.value=dome.value.toUpperCase();
|
||||
|
||||
if ( jrn == undefined && document.getElementById('p_jrn')!=undefined)
|
||||
{
|
||||
|
|
@ -80,40 +76,40 @@ function ajaxFid(p_ctl)
|
|||
}
|
||||
|
||||
|
||||
if ( trim(p_ctl.value)=="" )
|
||||
if ( trim(dome.value)=="" )
|
||||
{
|
||||
nLabel=id$(p_ctl).label;
|
||||
nLabel=id$(dome).label;
|
||||
if (document.getElementById(nLabel) )
|
||||
{
|
||||
id$(nLabel).value="";
|
||||
id$(nLabel).innerHTML=" ";
|
||||
clean_Fid(p_ctl);
|
||||
clean_Fid(dome.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
var queryString="FID="+trim(id$(p_ctl).value);
|
||||
if ( p_ctl.label)
|
||||
var queryString="FID="+trim(dome.value);
|
||||
if ( dome.label)
|
||||
{
|
||||
queryString+='&l='+p_ctl.label;
|
||||
queryString+='&l='+dome.label;
|
||||
}
|
||||
if ( p_ctl.tvaid)
|
||||
if ( dome.tvaid)
|
||||
{
|
||||
queryString+='&t='+p_ctl.tvaid;
|
||||
queryString+='&t='+dome.tvaid;
|
||||
}
|
||||
if ( p_ctl.price)
|
||||
if ( dome.price)
|
||||
{
|
||||
queryString+='&p='+p_ctl.price;
|
||||
queryString+='&p='+dome.price;
|
||||
}
|
||||
if ( p_ctl.purchase)
|
||||
if ( dome.purchase)
|
||||
{
|
||||
queryString+='&b='+p_ctl.purchase;
|
||||
queryString+='&b='+dome.purchase;
|
||||
}
|
||||
if ( p_ctl.typecard)
|
||||
if ( dome.typecard)
|
||||
{
|
||||
queryString+='&d='+p_ctl.typecard;
|
||||
queryString+='&d='+dome.typecard;
|
||||
}
|
||||
queryString=queryString+"&j="+jrn+'&gDossier='+gDossier;
|
||||
queryString=queryString+'&ctl='+p_ctl.id;
|
||||
queryString=queryString+'&ctl='+dome.id;
|
||||
queryString=encodeURI(queryString);
|
||||
|
||||
var action=new Ajax.Request (
|
||||
|
|
|
|||
|
|
@ -516,29 +516,7 @@ function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label)
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* clean the row (the label, price and vat)
|
||||
* @param p_ctl the calling ctrl
|
||||
*/
|
||||
function clean_Fid(p_ctl)
|
||||
{
|
||||
nSell=p_ctl+"_price";
|
||||
nBuy=p_ctl+"_price";
|
||||
nTva_id=p_ctl+"_tva_id";
|
||||
if ( document.getElementById(nSell) )
|
||||
{
|
||||
id$(nSell).value="";
|
||||
}
|
||||
if ( document.getElementById(nBuy) )
|
||||
{
|
||||
id$(nBuy).value="";
|
||||
}
|
||||
if ( document.getElementById(nTva_id) )
|
||||
{
|
||||
id$(nTva_id).value="-1";
|
||||
}
|
||||
|
||||
}
|
||||
function errorFid(request,json)
|
||||
{
|
||||
alert_box(content[53]);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ var width = viewport.width; // Usable window width
|
|||
var height = viewport.height;
|
||||
|
||||
/**
|
||||
* return undefined if nothing is found , otherwise return the DOM elemnt
|
||||
* return undefined if nothing is found , otherwise return the DOM elemnt, try to find an DOM Element inside p_element
|
||||
* @param {type} p_name_dom
|
||||
* @param {type} name_child
|
||||
* @returns {undefined}
|
||||
|
|
@ -125,8 +125,8 @@ function trim(s) {
|
|||
*/
|
||||
function id$(ID) {
|
||||
if (ID instanceof Object ) return ID;
|
||||
if (document.getElementById) {
|
||||
return (document.getElementById(ID)||console.error(`id$ not found ${ID}`)) ;
|
||||
if (document.getElementById(ID)) {
|
||||
document.getElementById(ID);
|
||||
} else if (document.all) {
|
||||
return document.all[ID];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ class ICard extends HtmlInput
|
|||
}
|
||||
|
||||
$input='<div class="d-none d-lg-inline">'.
|
||||
Icon_Action::clean_zone(uniqid("remove"),"$('{$this->id}').value=''").
|
||||
Icon_Action::clean_zone(uniqid("remove"),"clean_Fid('{$this->id}');compute_all_ledger();").
|
||||
"</div>";
|
||||
|
||||
$input.=sprintf('
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue