la propale lié à une commande est classée facturée lorsque la commande l'est elle même
This commit is contained in:
parent
e8aff4dfb4
commit
3633cda7c3
@ -913,10 +913,12 @@ class Commande
|
|||||||
|
|
||||||
|
|
||||||
// -------- exp pdf //
|
// -------- exp pdf //
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Propale associée
|
* Propale associée
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT fk_propale FROM '.MAIN_DB_PREFIX.'co_pr WHERE fk_commande = '.$this->id;
|
$sql = 'SELECT cp.fk_propale';
|
||||||
|
$sql .= 'FROM '.MAIN_DB_PREFIX.'co_pr WHERE fk_commande = '.$this->id;
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows())
|
if ($this->db->num_rows())
|
||||||
@ -1537,10 +1539,18 @@ class Commande
|
|||||||
*/
|
*/
|
||||||
function classer_facturee()
|
function classer_facturee()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1';
|
||||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
|
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
|
if ($this->propale_id)
|
||||||
|
{
|
||||||
|
$propal = new Propal($this->db);
|
||||||
|
$propal->fetch($this->propale_id);
|
||||||
|
$propal->classer_facturee();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -664,7 +664,10 @@ if ($_GET["propalid"] > 0)
|
|||||||
* Factures associees
|
* Factures associees
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.fk_statut, f.paye";
|
$sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.fk_statut, f.paye";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id;
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
|
$sql .= "LEFT JOIN ".MAIN_DB_PREFIX."fa_pr as fp ON fp.fk_facture = f.rowid AND fp.fk_propal = ".$propal->id;
|
||||||
|
if ($conf->commande->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_pr as cp ON cp.fk_propale = ".$propal->id;
|
||||||
|
if ($conf->commande->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa as cf ON cf.fk_commande = cp.fk_commande AND cf.fk_facture = f.rowid";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@ -1228,6 +1228,24 @@ class Propal
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Classe la propale comme facturée
|
||||||
|
* \return int <0 si ko, >0 si ok
|
||||||
|
*/
|
||||||
|
function classer_facturee()
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4';
|
||||||
|
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user