Fix: bug #14364 overview: mode de reglement non pris en compte facture
This commit is contained in:
parent
162e29e787
commit
7409b96ac6
@ -55,6 +55,8 @@ class Facture
|
|||||||
var $propalid;
|
var $propalid;
|
||||||
var $projetid;
|
var $projetid;
|
||||||
var $prefixe_facture;
|
var $prefixe_facture;
|
||||||
|
var $cond_reglement;
|
||||||
|
var $mode_reglement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* \brief Constructeur de la classe
|
||||||
@ -330,10 +332,11 @@ class Facture
|
|||||||
$sql = "SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent";
|
$sql = "SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent";
|
||||||
$sql .= ",".$this->db->pdate("f.datef")." as df,f.fk_projet";
|
$sql .= ",".$this->db->pdate("f.datef")." as df,f.fk_projet";
|
||||||
$sql .= ",".$this->db->pdate("f.date_lim_reglement")." as dlr";
|
$sql .= ",".$this->db->pdate("f.date_lim_reglement")." as dlr";
|
||||||
$sql .= ", c.rowid as cond_regl_id, c.libelle, c.libelle_facture";
|
|
||||||
$sql .= ", f.note, f.paye, f.fk_statut, f.fk_user_author";
|
$sql .= ", f.note, f.paye, f.fk_statut, f.fk_user_author";
|
||||||
$sql .= ", f.fk_mode_reglement";
|
$sql .= ", f.fk_mode_reglement, p.code as mode_reglement_code, p.libelle as mode_reglement_libelle";
|
||||||
|
$sql .= ", f.fk_cond_reglement, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_facture";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."cond_reglement as c";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."cond_reglement as c";
|
||||||
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON f.fk_mode_reglement = p.id";
|
||||||
$sql .= " WHERE f.rowid=$rowid AND c.rowid = f.fk_cond_reglement";
|
$sql .= " WHERE f.rowid=$rowid AND c.rowid = f.fk_cond_reglement";
|
||||||
if ($societe_id > 0)
|
if ($societe_id > 0)
|
||||||
{
|
{
|
||||||
@ -361,14 +364,16 @@ class Facture
|
|||||||
$this->socidp = $obj->fk_soc;
|
$this->socidp = $obj->fk_soc;
|
||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->date_lim_reglement = $obj->dlr;
|
$this->date_lim_reglement = $obj->dlr;
|
||||||
$this->cond_reglement_id = $obj->cond_regl_id;
|
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||||
$this->cond_reglement = $obj->libelle;
|
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||||
$this->cond_reglement_facture = $obj->libelle_facture;
|
$this->mode_reglement = $obj->mode_reglement_libelle;
|
||||||
|
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||||
|
$this->cond_reglement = $obj->cond_reglement_libelle;
|
||||||
|
$this->cond_reglement_facture = $obj->cond_reglement_libelle_facture;
|
||||||
$this->projetid = $obj->fk_projet;
|
$this->projetid = $obj->fk_projet;
|
||||||
$this->note = stripslashes($obj->note);
|
$this->note = stripslashes($obj->note);
|
||||||
$this->user_author = $obj->fk_user_author;
|
$this->user_author = $obj->fk_user_author;
|
||||||
$this->lignes = array();
|
$this->lignes = array();
|
||||||
$this->mode_reglement = $obj->fk_mode_reglement;
|
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
@ -437,6 +442,7 @@ class Facture
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid Erreur dans fetch de la facture");
|
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid Erreur dans fetch de la facture");
|
||||||
|
$this->error=$this->db->error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,12 @@ class Form
|
|||||||
var $db;
|
var $db;
|
||||||
var $errorstr;
|
var $errorstr;
|
||||||
|
|
||||||
|
var $cache_types_paiements_code=array();
|
||||||
|
var $cache_types_paiements_libelle=array();
|
||||||
|
var $cache_conditions_paiements_code=array();
|
||||||
|
var $cache_conditions_paiements_libelle=array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Constructeur
|
\brief Constructeur
|
||||||
\param DB handler d'accès base de donnée
|
\param DB handler d'accès base de donnée
|
||||||
@ -61,7 +67,6 @@ class Form
|
|||||||
* \param selected code forme juridique a présélectionné
|
* \param selected code forme juridique a présélectionné
|
||||||
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
|
* \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function select_departement($selected='',$pays_code=0)
|
function select_departement($selected='',$pays_code=0)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
@ -484,48 +489,160 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge dans cache la liste des conditions de paiements possibles
|
||||||
|
* \param selected Condition de paiement présélectionnée
|
||||||
|
* \param htmlname Nom de la zone select
|
||||||
|
* \param filtretype Pour filtre
|
||||||
|
*/
|
||||||
|
function load_cache_conditions_paiements()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
dolibarr_syslog('html.form.class.php::load_cache_conditions_paiements');
|
||||||
|
$sql = "SELECT rowid, libelle";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement";
|
||||||
|
$sql.= " WHERE actif=1";
|
||||||
|
$sql.= " ORDER BY sortorder";
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||||
|
$libelle=($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->libelle!='-'?$obj->libelle:''));
|
||||||
|
$this->cache_conditions_paiements_code[$obj->rowid]=$obj->code;
|
||||||
|
$this->cache_conditions_paiements_libelle[$obj->rowid]=$libelle;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge dans cache la liste des types de paiements possibles
|
||||||
|
* \param selected Type de praiement présélectionné
|
||||||
|
* \param htmlname Nom de la zone select
|
||||||
|
* \param filtretype Pour filtre
|
||||||
|
*/
|
||||||
|
function load_cache_types_paiements()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
dolibarr_syslog('html.form.class.php::load_cache_types_paiements');
|
||||||
|
$sql = "SELECT id, code, libelle, type";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
|
||||||
|
$sql.= " WHERE active > 0";
|
||||||
|
$sql.= " ORDER BY id";
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
||||||
|
$libelle=($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->libelle!='-'?$obj->libelle:''));
|
||||||
|
$this->cache_types_paiements_code[$obj->id]=$obj->code;
|
||||||
|
$this->cache_types_paiements_libelle[$obj->id]=$libelle;
|
||||||
|
$this->cache_types_paiements_type[$obj->id]=$obj->type;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne la liste des types de paiements possibles
|
* \brief Retourne la liste des types de paiements possibles
|
||||||
* \param selected Type de praiement présélectionné
|
* \param selected Type de praiement présélectionné
|
||||||
* \param htmlname Nom de la zone select
|
* \param htmlname Nom de la zone select
|
||||||
* \param filtretype Pour filtre
|
* \param filtretype Pour filtre
|
||||||
*/
|
*/
|
||||||
function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype=-1)
|
function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$sql = "SELECT id, code, libelle";
|
// Charge le cache si premier appel
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement";
|
if (! sizeof($this->cache_conditions_paiements_code))
|
||||||
$sql.= " WHERE active > 0";
|
|
||||||
if ($filtertype >= 0) $sql.=" AND type = $filtertype";
|
|
||||||
$sql.= " ORDER BY id";
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
{
|
||||||
|
$this->load_cache_conditions_paiements();
|
||||||
|
}
|
||||||
|
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
$num = $this->db->num_rows($result);
|
foreach($this->cache_conditions_paiements_code as $id => $code)
|
||||||
$i = 0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
if ($selected == $code)
|
||||||
if ($selected == $obj->code)
|
|
||||||
{
|
{
|
||||||
print '<option value="'.$obj->id.'" selected="true">';
|
print '<option value="'.$id.'" selected="true">';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<option value="'.$obj->id.'">';
|
print '<option value="'.$id.'">';
|
||||||
}
|
}
|
||||||
// Si traduction existe, on l'utilise, sinon on prend le libellé par défaut
|
print $this->cache_conditions_paiements_libelle[$id];
|
||||||
print ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->libelle!='-'?$obj->libelle:''));
|
|
||||||
print '</option>';
|
print '</option>';
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
print "</select>";
|
print '</select>';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retourne la liste des types de paiements possibles
|
||||||
|
* \param selected Type de praiement présélectionné
|
||||||
|
* \param htmlname Nom de la zone select
|
||||||
|
* \param filtretype Pour filtre
|
||||||
|
* \param format 0=id+libelle, 1=code+code
|
||||||
|
*/
|
||||||
|
function select_types_paiements($selected='',$htmlname='paiementtype',$filtertype='',$format=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$filterarray=array();
|
||||||
|
if ($filtertype && $filtertype != '-1') $filterarray=split(',',$filtertype);
|
||||||
|
|
||||||
|
// Charge le cache si premier appel
|
||||||
|
if (! sizeof($this->cache_types_paiements_code))
|
||||||
|
{
|
||||||
|
$this->load_cache_types_paiements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//dolibarr_syslog('html.form.class.php::select_types_paiements use cache');
|
||||||
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
|
foreach($this->cache_types_paiements_code as $id => $code)
|
||||||
|
{
|
||||||
|
// On passe si on a demandé de filtrer sur des modes de paiments particulièrs
|
||||||
|
if (sizeof($filterarray) && ! in_array($this->cache_types_paiements_type[$id],$filterarray)) continue;
|
||||||
|
|
||||||
|
if ($format == 0) print '<option value="'.$id.'"';
|
||||||
|
if ($format == 1) print '<option value="'.$code.'"';
|
||||||
|
if ($selected == $code)
|
||||||
|
{
|
||||||
|
print ' selected="true"';
|
||||||
|
}
|
||||||
|
print '>';
|
||||||
|
if ($format == 0) print $this->cache_types_paiements_libelle[$id];
|
||||||
|
if ($format == 1) print $code;
|
||||||
|
print '</option>';
|
||||||
|
}
|
||||||
|
print '</select>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user