Qual: On effectue la creation des factures en transactions
This commit is contained in:
parent
c8a4194ceb
commit
5501665e65
@ -212,19 +212,29 @@ class Facture
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateprice($this->id);
|
$result=$this->updateprice($this->id);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$interface->run_triggers('BILL_CREATE',$this,$user,$lang,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
dolibarr_print_error($this->db);
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -557,6 +567,8 @@ class Facture
|
|||||||
*/
|
*/
|
||||||
function delete($rowid)
|
function delete($rowid)
|
||||||
{
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_tva_sum WHERE fk_facture = $rowid;";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_tva_sum WHERE fk_facture = $rowid;";
|
||||||
|
|
||||||
if ( $this->db->query( $sql) )
|
if ( $this->db->query( $sql) )
|
||||||
@ -584,36 +596,53 @@ class Facture
|
|||||||
{
|
{
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture WHERE rowid = $rowid AND fk_statut = 0;";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture WHERE rowid = $rowid AND fk_statut = 0;";
|
||||||
|
$resql=$this->db->query($sql) ;
|
||||||
|
|
||||||
$this->db->query( $sql) ;
|
if ($resql)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$interface->run_triggers('BILL_DELETE',$this,$user,$lang,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
$this->db->rollback();
|
||||||
}
|
return -6;
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
$this->db->rollback();
|
||||||
|
return -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
$this->db->rollback();
|
||||||
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,11 +753,10 @@ class Facture
|
|||||||
$numfa = facture_get_num($soc, $this->prefixe_facture); // définit dans includes/modules/facture
|
$numfa = facture_get_num($soc, $this->prefixe_facture); // définit dans includes/modules/facture
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->begin())
|
$this->db->begin();
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Lecture de la remise exceptionnelle
|
* Lecture de la remise exceptionnelle
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT rowid, rc.amount_ht, fk_soc, fk_user";
|
$sql = "SELECT rowid, rc.amount_ht, fk_soc, fk_user";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
|
||||||
@ -736,7 +764,6 @@ class Facture
|
|||||||
$sql .= " AND fk_facture IS NULL";
|
$sql .= " AND fk_facture IS NULL";
|
||||||
|
|
||||||
$resql = $this->db->query($sql) ;
|
$resql = $this->db->query($sql) ;
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$nurmx = $this->db->num_rows($resql);
|
$nurmx = $this->db->num_rows($resql);
|
||||||
@ -781,17 +808,7 @@ class Facture
|
|||||||
$sql .= " WHERE rowid = $rowid ;";
|
$sql .= " WHERE rowid = $rowid ;";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if (! $resql)
|
||||||
{
|
|
||||||
// Appel des triggers
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$ret=$interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);
|
|
||||||
// Fin appel triggers
|
|
||||||
|
|
||||||
if ($ret < 0) $error++;
|
|
||||||
}
|
|
||||||
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);
|
||||||
@ -826,6 +843,12 @@ class Facture
|
|||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -838,20 +861,14 @@ class Facture
|
|||||||
|
|
||||||
$notify = New Notify($this->db);
|
$notify = New Notify($this->db);
|
||||||
$notify->send($action_notify, $this->socidp, $mesg, "facture", $rowid, $filepdf);
|
$notify->send($action_notify, $this->socidp, $mesg, "facture", $rowid, $filepdf);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error == 0)
|
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user