Fix: A bandonned invoice can be reopened (if badcustomer or other reason)
This commit is contained in:
parent
db953b2606
commit
a3f0ad5702
@ -67,8 +67,27 @@ $NBLINES=4;
|
|||||||
/* Actions */
|
/* Actions */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
if ($_GET['action'] == 'reopen' && $user->rights->facture->creer)
|
||||||
|
{
|
||||||
|
$fac = new Facture($db);
|
||||||
|
$result = $fac->fetch($_GET['facid']);
|
||||||
|
if ($fac->statut == 3 && ($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon'))
|
||||||
|
{
|
||||||
|
$result = $fac->set_unpayed($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET['facid']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$fac->error.'</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Suppression de la facture
|
// Suppression de la facture
|
||||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->supprimer)
|
||||||
{
|
{
|
||||||
if ($user->rights->facture->supprimer)
|
if ($user->rights->facture->supprimer)
|
||||||
{
|
{
|
||||||
@ -2777,6 +2796,11 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reopen a classified invoice
|
||||||
|
if ($fac->statut == 3 && ($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon'))
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=reopen">'.$langs->trans('ReOpen').'</a>';
|
||||||
|
}
|
||||||
// Récurrente
|
// Récurrente
|
||||||
if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0)
|
if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -80,7 +80,7 @@ class Facture extends CommonObject
|
|||||||
var $paye;
|
var $paye;
|
||||||
//! id facture source si facture de remplacement ou avoir
|
//! id facture source si facture de remplacement ou avoir
|
||||||
var $fk_facture_source;
|
var $fk_facture_source;
|
||||||
//! Fermeture apres paiement partiel: discount_vat, bad_customer, abandon
|
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
|
||||||
//! Fermeture alors que aucun paiement: replaced (si remplacé), abandon
|
//! Fermeture alors que aucun paiement: replaced (si remplacé), abandon
|
||||||
var $close_code;
|
var $close_code;
|
||||||
//! Commentaire si mis a paye sans paiement complet
|
//! Commentaire si mis a paye sans paiement complet
|
||||||
@ -338,8 +338,9 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Création de la facture en base depuis une autre
|
\brief Create a new invoice in database from current invoice
|
||||||
\param user Object utilisateur qui crée
|
\param user Object user that ask creation
|
||||||
|
\param invertdetail Reverse sign of amounts for lines
|
||||||
\return int <0 si ko, >0 si ok
|
\return int <0 si ko, >0 si ok
|
||||||
*/
|
*/
|
||||||
function create_clone($user,$invertdetail=0)
|
function create_clone($user,$invertdetail=0)
|
||||||
@ -913,8 +914,9 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Tag la facture comme non payée complètement + appel trigger BILL_UNPAYED
|
* \brief Tag la facture comme non payée complètement + appel trigger BILL_UNPAYED
|
||||||
* Fonction utilisée quand un paiement prélevement est refusé.
|
* Fonction utilisée quand un paiement prélevement est refusé,
|
||||||
* \param user Objet utilisateur qui modifie
|
* ou quand une facture annulée et réouverte.
|
||||||
|
* \param user Object user that change status
|
||||||
* \return int <0 si ok, >0 si ok
|
* \return int <0 si ok, >0 si ok
|
||||||
*/
|
*/
|
||||||
function set_unpayed($user)
|
function set_unpayed($user)
|
||||||
@ -923,10 +925,11 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
dolibarr_syslog("Facture::set_unpayed rowid=".$this->id, LOG_DEBUG);
|
dolibarr_syslog("Facture::set_unpayed rowid=".$this->id, LOG_DEBUG);
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
$sql.= ' SET paye=0, fk_statut=1';
|
$sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
dolibarr_syslog("Facture::set_unpayed sql=".$sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class modFacture extends DolibarrModules
|
|||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 12;
|
$this->rights[$r][0] = 12;
|
||||||
$this->rights[$r][1] = 'Cr<EFBFBD>er les factures';
|
$this->rights[$r][1] = 'Creer les factures';
|
||||||
$this->rights[$r][2] = 'a';
|
$this->rights[$r][2] = 'a';
|
||||||
$this->rights[$r][3] = 0;
|
$this->rights[$r][3] = 0;
|
||||||
$this->rights[$r][4] = 'creer';
|
$this->rights[$r][4] = 'creer';
|
||||||
|
|||||||
@ -103,6 +103,7 @@ Show=Show
|
|||||||
Search=Search
|
Search=Search
|
||||||
Valid=Valid
|
Valid=Valid
|
||||||
Approve=Approve
|
Approve=Approve
|
||||||
|
ReOpen=Re-Open
|
||||||
Upload=Send file
|
Upload=Send file
|
||||||
Select=Select
|
Select=Select
|
||||||
Choose=Choose
|
Choose=Choose
|
||||||
|
|||||||
@ -78,6 +78,7 @@ Show=Voir
|
|||||||
Search=Rechercher
|
Search=Rechercher
|
||||||
Valid=Valider
|
Valid=Valider
|
||||||
Approve=Approuver
|
Approve=Approuver
|
||||||
|
ReOpen=Réouvrir
|
||||||
Upload=Envoyer fichier
|
Upload=Envoyer fichier
|
||||||
Select=Sélectionner
|
Select=Sélectionner
|
||||||
Choose=Choisir
|
Choose=Choisir
|
||||||
|
|||||||
@ -104,6 +104,7 @@ Show=Voir
|
|||||||
Search=Rechercher
|
Search=Rechercher
|
||||||
Valid=Valider
|
Valid=Valider
|
||||||
Approve=Approuver
|
Approve=Approuver
|
||||||
|
ReOpen=Réouvrir
|
||||||
Upload=Envoyer fichier
|
Upload=Envoyer fichier
|
||||||
Select=Sélectionner
|
Select=Sélectionner
|
||||||
Choose=Choisir
|
Choose=Choisir
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user