noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
Functions
ajax_fiche.js File Reference

This file permit to use the AJAX function to fill up info from fiche. More...

Go to the source code of this file.

Functions

function ajax_card (p_dossier, f_id, p_operation, ctl, page)
 this function get data from ajax_card.php and fill the hidden div with the return html string
function ajax_error_saldo (request, json)
function ajax_get_failure (request, json)
 callback function for ajax_get when fails
function ajax_get_success (request, json)
 callback function for ajax_get when successuf
function ajax_saldo (p_ctl)
 this function get the saldo
function ajax_success_saldo (request, json)
 callback function for ajax
function ajaxFid (p_ctl)
 this function fills the data from fid.php,
function clean_Fid (p_ctl)
 clean the row (the label, price and vat)
function errorFid (request, json)
function successFid (request, json)
 callback function for ajax

Detailed Description

This file permit to use the AJAX function to fill up info from fiche.

Definition in file ajax_fiche.js.


Function Documentation

function ajax_card (   p_dossier,
  f_id,
  p_operation,
  ctl,
  page 
)

this function get data from ajax_card.php and fill the hidden div with the return html string

Parameters:
p_dossier
f_idfiche.f_id
p_operationwhat to do : op : history of operation
ctl: id of the div to show
page

Definition at line 228 of file ajax_fiche.js.

References ajax_get_failure(), ajax_get_success(), and show.

{
    $(ctl).show();
    var queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl;
    var action = new Ajax.Request(
                 "ajax_card.php" , { method:'get', parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success}
                 );
}
function ajax_error_saldo (   request,
  json 
)

Definition at line 184 of file ajax_fiche.js.

References alert().

Referenced by ajax_saldo().

{
    alert('erreur : ajax solde ');
}
function ajax_get_failure (   request,
  json 
)

callback function for ajax_get when fails

Definition at line 246 of file ajax_fiche.js.

References alert().

Referenced by ajax_card().

{
    alert("Ajax do not work for ajax_get");

}
function ajax_get_success (   request,
  json 
)

callback function for ajax_get when successuf

Definition at line 238 of file ajax_fiche.js.

References show.

Referenced by ajax_card().

{
    var answer=request.responseText.evalJSON(false);
    $(answer.ctl).show();
    $(answer.ctl).innerHTML=answer.html;
}
function ajax_saldo (   p_ctl)

this function get the saldo

Parameters:
p_ctlthe ctrl where we take the quick_code

Definition at line 191 of file ajax_fiche.js.

References ajax_error_saldo(), ajax_success_saldo(), jrn, trim(), and value.

Referenced by fill_fin_data(), and fill_fin_data_onchange().

{
    var gDossier=$('gDossier').value;
    var ctl_value=trim($(p_ctl).value);
    var jrn=$('p_jrn').value;
    queryString="FID="+ctl_value+"&op=saldo";
    queryString=queryString+'&gDossier='+gDossier+'&j='+jrn;
    queryString=queryString+'&ctl='+ctl_value;
    /*  alert(queryString); */
    var action=new Ajax.Request (
                   "ajax_misc.php",
                   {
                   method:'get',
                   parameters:queryString,
                   onFailure:ajax_error_saldo,
                   onSuccess:ajax_success_saldo
                   }

               );

}
function ajax_success_saldo (   request,
  json 
)

callback function for ajax

Parameters:
request: object request
json: json answer

Definition at line 215 of file ajax_fiche.js.

References value.

Referenced by ajax_saldo().

{
    var answer=request.responseText.evalJSON(true);
    $('first_sold').value=answer.saldo;

}
function ajaxFid (   p_ctl)

this function fills the data from fid.php,

Parameters:
p_ctlobject : field of the input, possible object member
  • label field to update with the card's name
  • price field to update with the card's price
  • tvaid field to update with the card's tva_id
  • jrn field to force the ledger
See also:
successFid errorFid fid.php

Definition at line 67 of file ajax_fiche.js.

References alert(), clean_Fid(), errorFid(), jrn, label, successFid(), trim(), and value.

Referenced by fill_data(), fill_data_onchange(), fill_fin_data(), fill_fin_data_onchange(), ICard::test_me(), and update_value().

{
        try
        {
        var gDossier=$('gDossier').value;
    var jrn=$(p_ctl).jrn;
    $(p_ctl).value=$(p_ctl).value.toUpperCase();
    if ( jrn == undefined )
    {
        if ($('p_jrn')!=undefined)
        {
            jrn=$('p_jrn').value;
        }
    }
    if ( jrn == undefined )
    {
        jrn=-1;
    }
    if ( trim($(p_ctl).value)=="" )
    {
        nLabel=$(p_ctl).label;
        if ($(nLabel) )
        {
            $(nLabel).value="";
            $(nLabel).innerHTML=" ";
            clean_Fid(p_ctl);
            return;
        }
    }
    var queryString="FID="+trim($(p_ctl).value);
    if ( $(p_ctl).label)
    {
        queryString+='&l='+$(p_ctl).label;
    }
    if ( $(p_ctl).tvaid)
    {
        queryString+='&t='+$(p_ctl).tvaid;
    }
    if ( $(p_ctl).price)
    {
        queryString+='&p='+$(p_ctl).price;
    }
    if ( $(p_ctl).purchase)
    {
        queryString+='&b='+$(p_ctl).purchase;
    }
    if ( $(p_ctl).typecard)
    {
        queryString+='&d='+$(p_ctl).typecard;
    }
    queryString=queryString+"&j="+jrn+'&gDossier='+gDossier;
    queryString=queryString+'&ctl='+p_ctl.id;

    var action=new Ajax.Request (
                   "fid.php",
                   {
                   method:'get',
                   parameters:queryString,
                   onFailure:errorFid,
                   onSuccess:successFid
                   }

               );
        }catch (e)  {
                alert(e.message);
                alert(p_ctl);
        }

}
function clean_Fid (   p_ctl)

clean the row (the label, price and vat)

Parameters:
p_ctlthe calling ctrl

Definition at line 31 of file ajax_fiche.js.

References value.

Referenced by ajaxFid().

{
    nSell=p_ctl+"_price";
    nTvaAmount=p_ctl+"_tva_amount";
    nBuy=p_ctl+"_price";
    nTva_id=p_ctl+"_tva_id";
    if ( $(nSell) )
    {
        $(nSell).value="";
    }
    if ( $(nBuy) )
    {
        $(nBuy).value="";
    }
    if ( $(nTva_id) )
    {
        $(nTva_id).value="-1";
    }
    if ( $(nTvaAmount))
    {
        $(nTvaAmount).value=0;
    }
}
function errorFid (   request,
  json 
)
function successFid (   request,
  json 
)

callback function for ajax

Parameters:
request: object request
json: json answer
 {"answer":"ok",
 "flabel":"none",
 "name":"Chambre de commerce",
 "ftva_id":"none",
 "tva_id":" ",
 "fPrice_sale":"none",
 "sell":" ",
 "fPrice_purchase":"none",
 "buy":" "}

Definition at line 151 of file ajax_fiche.js.

References set_value().

Referenced by ajaxFid().

{
    var answer=request.responseText.evalJSON(true);
    var flabel=answer.flabel;
    if ( answer.answer=='nok' )
    {
        set_value(flabel," Fiche inexistante");
        return;
    }

    var ftva_id=answer.ftva_id;
    var fsale=answer.fPrice_sale;
    var fpurchase=answer.fPrice_purchase;

    if ( ftva_id != 'none')
    {
        set_value(ftva_id,answer.tva_id);
    }
    if ( flabel != 'none')
    {
        set_value(flabel,answer.name);
    }
    if ( fsale != 'none')
    {
        set_value(fsale,answer.sell);
    }
    if ( fpurchase != 'none')
    {
        set_value(fpurchase,answer.buy);
    }


}
 All Data Structures Namespaces Files Functions Variables Enumerations