Fix: No way to delete a supplier invoice if not a draft
This commit is contained in:
parent
329b0255c5
commit
33dac25ce4
@ -96,9 +96,16 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
|||||||
{
|
{
|
||||||
$facturefourn = new FactureFournisseur($db);
|
$facturefourn = new FactureFournisseur($db);
|
||||||
$factfournid = $_GET['facid'];
|
$factfournid = $_GET['facid'];
|
||||||
$facturefourn->delete($factfournid);
|
$result=$facturefourn->delete($factfournid);
|
||||||
Header('Location: index.php');
|
if ($result > 0)
|
||||||
exit;
|
{
|
||||||
|
Header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$facturefourn->error.'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -333,20 +333,21 @@ class FactureFournisseur extends Facture
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime la facture
|
* \brief Delete invoice in database
|
||||||
* \param rowid id de la facture <EFBFBD> supprimer
|
* \param rowid Id of invoice to delete
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function delete($rowid)
|
function delete($rowid)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
|
||||||
dolibarr_syslog("FactureFournisseur sql=".$sql);
|
dolibarr_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid.' AND fk_statut = 0';
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
|
||||||
dolibarr_syslog("FactureFournisseur sql=".$sql);
|
dolibarr_syslog("FactureFournisseur sql=".$sql, LOG_DEBUG);
|
||||||
$resql2 = $this->db->query($sql);
|
$resql2 = $this->db->query($sql);
|
||||||
if ($resql2)
|
if ($resql2)
|
||||||
{
|
{
|
||||||
@ -357,14 +358,16 @@ class FactureFournisseur extends Facture
|
|||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dolibarr_syslog("FactureFournisseur::delete ".$this->error);
|
dolibarr_syslog("FactureFournisseur::delete ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dolibarr_syslog("FactureFournisseur::delete ".$this->error);
|
dolibarr_syslog("FactureFournisseur::delete ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -844,7 +844,7 @@ class Propal extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Propal::Fetch Error ".$this->error, LOG_ERROR);
|
dolibarr_syslog("Propal::Fetch Error ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user