Fix: L'objet user n'était pas intégralement passé sur les fonctions de changement etat facture
This commit is contained in:
parent
8a0e6cf691
commit
46a8b91622
@ -255,6 +255,8 @@ class BonPrelevement
|
|||||||
*/
|
*/
|
||||||
function set_credite()
|
function set_credite()
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$error == 0;
|
$error == 0;
|
||||||
|
|
||||||
if ($this->db->begin())
|
if ($this->db->begin())
|
||||||
@ -277,11 +279,11 @@ class BonPrelevement
|
|||||||
|
|
||||||
for ($i = 0 ; $i < sizeof($facs) ; $i++)
|
for ($i = 0 ; $i < sizeof($facs) ; $i++)
|
||||||
{
|
{
|
||||||
$fac = new Facture($this->db);
|
|
||||||
|
|
||||||
/* Tag la facture comme impayée */
|
/* Tag la facture comme impayée */
|
||||||
dolibarr_syslog("BonPrelevement::set_credite set_payed fac ".$facs[$i]);
|
dolibarr_syslog("BonPrelevement::set_credite set_payed fac ".$facs[$i]);
|
||||||
$fac->set_payed($facs[$i]);
|
$fac = new Facture($this->db);
|
||||||
|
$fac->fetch($facs[$i]);
|
||||||
|
$result = $fac->set_payed($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -304,15 +304,15 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
|||||||
if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
|
if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
|
||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new Facture($db);
|
||||||
$result = $fac->set_payed($_GET['facid']);
|
$fac->fetch($_GET['facid']);
|
||||||
|
$result = $fac->set_payed($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'setremise' && $user->rights->facture->creer)
|
if ($_POST['action'] == 'setremise' && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new Facture($db);
|
||||||
$fac->fetch($_GET['facid']);
|
$fac->fetch($_GET['facid']);
|
||||||
|
$result = $fac->set_remise($user, $_POST['remise']);
|
||||||
$fac->set_remise($user, $_POST['remise']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'addligne' && $user->rights->facture->creer)
|
if ($_POST['action'] == 'addligne' && $user->rights->facture->creer)
|
||||||
@ -391,7 +391,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
|||||||
if ($user->rights->facture->supprimer )
|
if ($user->rights->facture->supprimer )
|
||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new Facture($db);
|
||||||
$fac->delete($_GET['facid']);
|
$result = $fac->delete($_GET['facid']);
|
||||||
$_GET['facid'] = 0 ;
|
$_GET['facid'] = 0 ;
|
||||||
Header('Location: facture.php');
|
Header('Location: facture.php');
|
||||||
exit;
|
exit;
|
||||||
@ -403,7 +403,8 @@ if ($_POST['action'] == 'confirm_canceled' && $_POST['confirm'] == 'yes')
|
|||||||
if ($user->rights->facture->supprimer )
|
if ($user->rights->facture->supprimer )
|
||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new Facture($db);
|
||||||
$result = $fac->set_canceled($_GET['facid']);
|
$fac->fetch($_GET['facid']);
|
||||||
|
$result = $fac->set_canceled();
|
||||||
$_GET['facid'] = 0 ;
|
$_GET['facid'] = 0 ;
|
||||||
Header('Location: facture.php');
|
Header('Location: facture.php');
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -692,13 +692,18 @@ class Facture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme payée complètement
|
* \brief Tag la facture comme payée complètement + appel trigger BILL_PAYED
|
||||||
* \param rowid id de la facture à modifier
|
* \param user Objet utilisateur qui modifie
|
||||||
|
* \return int <0 si ok, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_payed($rowid)
|
function set_payed($user)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=1 WHERE rowid = '.$rowid ;
|
global $conf,$langs;
|
||||||
$resql = $this->db->query( $sql);
|
|
||||||
|
dolibarr_syslog("Facture.class.php::set_payed rowid=".$this->id);
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
|
$sql.= ' SET paye=1 WHERE rowid = '.$this->id ;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -710,17 +715,36 @@ class Facture
|
|||||||
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme non payée complètement
|
* \brief Tag la facture comme non payée complètement + appel trigger BILL_UNPAYED
|
||||||
* \param rowid id de la facture à modifier
|
* \param user Objet utilisateur qui modifie
|
||||||
*/
|
* \return int <0 si ok, >0 si ok
|
||||||
function set_unpayed($rowid)
|
*/
|
||||||
|
function set_unpayed($user)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Facture.class.php::set_unpayed rowid=".$rowid);
|
global $conf,$langs;
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=0 WHERE rowid = '.$rowid ;
|
|
||||||
$resql = $this->db->query( $sql);
|
dolibarr_syslog("Facture.class.php::set_unpayed rowid=".$this->id);
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
|
$sql.= ' SET paye=0 WHERE rowid = '.$this->id;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
|
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('BILL_UNPAYED',$this,$user,$langs,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -734,12 +758,17 @@ class Facture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme abandonnée + appel trigger BILL_CANCEL
|
* \brief Tag la facture comme abandonnée + appel trigger BILL_CANCEL
|
||||||
* \param rowid id de la facture à modifier
|
* \param user Objet utilisateur qui modifie
|
||||||
*/
|
* \return int <0 si ok, >0 si ok
|
||||||
function set_canceled($rowid)
|
*/
|
||||||
|
function set_canceled($user)
|
||||||
{
|
{
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set fk_statut=3 WHERE rowid = '.$rowid;
|
global $conf,$langs;
|
||||||
|
|
||||||
|
dolibarr_syslog("Facture.class.php::set_canceled rowid=".$this->id);
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
|
$sql.= ' SET fk_statut=3 WHERE rowid = '.$this->id;
|
||||||
$resql = $this->db->query( $sql);
|
$resql = $this->db->query( $sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -752,14 +781,16 @@ class Facture
|
|||||||
$result=$interface->run_triggers('BILL_CANCEL',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('BILL_CANCEL',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
|
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
|
||||||
* \param rowid id de la facture à valider
|
* \param rowid Id de la facture à valider
|
||||||
* \param user utilisateur qui valide la facture
|
* \param user Utilisateur qui valide la facture
|
||||||
* \param soc societe
|
* \param soc Objet societe
|
||||||
* \param force_number force le numéro de facture
|
* \param force_number Référence à forcer de la facture
|
||||||
*/
|
*/
|
||||||
function set_valid($rowid, $user, $soc, $force_number='')
|
function set_valid($rowid, $user, $soc, $force_number='')
|
||||||
{
|
{
|
||||||
@ -817,7 +848,7 @@ class Facture
|
|||||||
|
|
||||||
/* Validation de la facture */
|
/* Validation de la facture */
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture ';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture ';
|
||||||
$sql .= " SET facnumber='$numfa', fk_statut = 1, fk_user_valid = $user->id";
|
$sql.= " SET facnumber='".$numfa."', fk_statut = 1, fk_user_valid = ".$user->id;
|
||||||
|
|
||||||
/* Si l'option est activée on force la date de facture */
|
/* Si l'option est activée on force la date de facture */
|
||||||
if ($conf->global->FAC_FORCE_DATE_VALIDATION)
|
if ($conf->global->FAC_FORCE_DATE_VALIDATION)
|
||||||
@ -829,7 +860,11 @@ class Facture
|
|||||||
}
|
}
|
||||||
$sql .= ' WHERE rowid = '.$rowid;
|
$sql .= ' WHERE rowid = '.$rowid;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->facnumber=$numfa;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Facture::set_valid() Echec - 10");
|
dolibarr_syslog("Facture::set_valid() Echec - 10");
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
|
|||||||
@ -53,22 +53,22 @@ $action=isset($_GET['action'])?$_GET['action']:$_POST['action'];
|
|||||||
|
|
||||||
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == yes && $user->rights->fournisseur->facture->valider)
|
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == yes && $user->rights->fournisseur->facture->valider)
|
||||||
{
|
{
|
||||||
$facturefourn=new FactureFournisseur($db);
|
$facturefourn=new FactureFournisseur($db);
|
||||||
$facturefourn->fetch($_GET['facid']);
|
$facturefourn->fetch($_GET['facid']);
|
||||||
|
|
||||||
$facturefourn->set_valid($user->id);
|
$facturefourn->set_valid($user->id);
|
||||||
|
|
||||||
Header('Location: fiche.php?facid='.$_GET['facid']);
|
Header('Location: fiche.php?facid='.$_GET['facid']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_GET['action'] == 'payed')
|
if ($_GET['action'] == 'payed')
|
||||||
{
|
{
|
||||||
$facturefourn=new FactureFournisseur($db);
|
$facturefourn=new FactureFournisseur($db);
|
||||||
$facturefourn->fetch($_GET['facid']);
|
$facturefourn->fetch($_GET['facid']);
|
||||||
|
|
||||||
$facturefourn->set_payed($user->id);
|
$facturefourn->set_payed($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['action'] == 'deletepaiement')
|
if($_GET['action'] == 'deletepaiement')
|
||||||
|
|||||||
@ -268,30 +268,39 @@ class FactureFournisseur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme payée complètement
|
* \brief Tag la facture comme payée complètement
|
||||||
* \param userid utilisateur qui modifie l'état
|
* \param user Objet utilisateur qui modifie
|
||||||
*/
|
* \return int <0 si ko, >0 si ok
|
||||||
function set_payed($userid)
|
*/
|
||||||
|
function set_payed($user)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set paye = 1 WHERE rowid = ".$this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
||||||
$result = $this->db->query( $sql);
|
$sql.= " SET paye = 1";
|
||||||
if (! $result) {
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
dolibarr_print_error($this->db);
|
$result = $this->db->query($sql);
|
||||||
}
|
if (! $result)
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme validée et valide la facture
|
* \brief Tag la facture comme validée et valide la facture
|
||||||
* \param userid utilisateur qui valide la facture
|
* \param user Objet utilisateur qui modifie
|
||||||
*/
|
* \return int <0 si ko, >0 si ok
|
||||||
function set_valid($userid)
|
*/
|
||||||
|
function set_valid($user)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn set fk_statut = 1, fk_user_valid = $userid WHERE rowid = ".$this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
|
||||||
$result = $this->db->query( $sql);
|
$sql.= " SET fk_statut = 1, fk_user_valid = ".$user->id;
|
||||||
if (! $result) {
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
dolibarr_print_error($this->db);
|
$result = $this->db->query( $sql);
|
||||||
}
|
if (! $result) {
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user