Fix: Bons paramètres des fontions sql
This commit is contained in:
parent
6365f76bb3
commit
0ecc52d176
@ -282,6 +282,7 @@ class Facture
|
|||||||
* \brief Recupére l'objet facture et ses lignes de factures
|
* \brief Recupére l'objet facture et ses lignes de factures
|
||||||
* \param rowid id de la facture a récupérer
|
* \param rowid id de la facture a récupérer
|
||||||
* \param societe_id id de societe
|
* \param societe_id id de societe
|
||||||
|
* \return int 1 si ok, < 0 si erreur
|
||||||
*/
|
*/
|
||||||
function fetch($rowid, $societe_id=0)
|
function fetch($rowid, $societe_id=0)
|
||||||
{
|
{
|
||||||
@ -295,7 +296,6 @@ class Facture
|
|||||||
$sql .= ", f.fk_mode_reglement";
|
$sql .= ", f.fk_mode_reglement";
|
||||||
$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 .= " 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)
|
||||||
{
|
{
|
||||||
$sql .= " AND f.fk_soc = ".$societe_id;
|
$sql .= " AND f.fk_soc = ".$societe_id;
|
||||||
@ -307,7 +307,7 @@ class Facture
|
|||||||
if ($this->db->num_rows($result))
|
if ($this->db->num_rows($result))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->id = $rowid;
|
$this->id = $rowid;
|
||||||
$this->datep = $obj->dp;
|
$this->datep = $obj->dp;
|
||||||
$this->date = $obj->df;
|
$this->date = $obj->df;
|
||||||
@ -329,7 +329,6 @@ class Facture
|
|||||||
$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;
|
$this->mode_reglement = $obj->fk_mode_reglement;
|
||||||
|
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
@ -337,7 +336,6 @@ class Facture
|
|||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes
|
* Lignes
|
||||||
@ -349,7 +347,7 @@ class Facture
|
|||||||
$result2 = $this->db->query($sql);
|
$result2 = $this->db->query($sql);
|
||||||
if ($result2)
|
if ($result2)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($result2);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
@ -370,28 +368,30 @@ class Facture
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($result2);
|
||||||
|
$this->db->free($result);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dolibarr_print_error($this->db);
|
|
||||||
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid, Erreur dans fetch des lignes");
|
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid, Erreur dans fetch des lignes");
|
||||||
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dolibarr_print_error($this->db);
|
|
||||||
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid numrows=0");
|
dolibarr_syslog("Erreur Facture::Fetch rowid=$rowid numrows=0");
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dolibarr_print_error($this->db);
|
|
||||||
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");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recupére l'objet client lié à la facture
|
* \brief Recupére l'objet client lié à la facture
|
||||||
@ -832,7 +832,7 @@ class Facture
|
|||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
@ -845,7 +845,7 @@ class Facture
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($result);
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -1122,9 +1122,10 @@ class Facture
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as c";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as c";
|
||||||
$sql .= " WHERE c.rowid = ".$id;
|
$sql .= " WHERE c.rowid = ".$id;
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows())
|
if ($this->db->num_rows($result))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
@ -1146,7 +1147,8 @@ class Facture
|
|||||||
//$this->date_validation = $obj->datev; \todo La date de validation n'est pas encore gérée
|
//$this->date_validation = $obj->datev; \todo La date de validation n'est pas encore gérée
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->db->free();
|
|
||||||
|
$this->db->free($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1316,11 +1318,13 @@ class FactureLigne
|
|||||||
$this->date_start = $objp->date_start;
|
$this->date_start = $objp->date_start;
|
||||||
$this->date_end = $objp->date_end;
|
$this->date_end = $objp->date_end;
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
$this->db->free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,6 @@ class Societe {
|
|||||||
|
|
||||||
function Societe($DB, $id=0)
|
function Societe($DB, $id=0)
|
||||||
{
|
{
|
||||||
global $config;
|
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->creation_bit = 0;
|
$this->creation_bit = 0;
|
||||||
|
|
||||||
@ -397,11 +396,12 @@ class Societe {
|
|||||||
$sql .= " AND s.fk_pays = p.rowid";
|
$sql .= " AND s.fk_pays = p.rowid";
|
||||||
$sql .= " AND s.fk_forme_juridique = fj.code";
|
$sql .= " AND s.fk_forme_juridique = fj.code";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows())
|
if ($this->db->num_rows($result))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->date_update = $obj->date_update;
|
$this->date_update = $obj->date_update;
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ class Societe {
|
|||||||
$result = -2;
|
$result = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user