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 */
|
||||
/******************************************************************************/
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
@ -2777,7 +2796,12 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
// Récurrente
|
||||
// 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
|
||||
if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0)
|
||||
{
|
||||
if (! $facidnext)
|
||||
|
||||
@ -80,7 +80,7 @@ class Facture extends CommonObject
|
||||
var $paye;
|
||||
//! id facture source si facture de remplacement ou avoir
|
||||
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
|
||||
var $close_code;
|
||||
//! Commentaire si mis a paye sans paiement complet
|
||||
@ -338,9 +338,10 @@ class Facture extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
\brief Création de la facture en base depuis une autre
|
||||
\param user Object utilisateur qui crée
|
||||
\return int <0 si ko, >0 si ok
|
||||
\brief Create a new invoice in database from current invoice
|
||||
\param user Object user that ask creation
|
||||
\param invertdetail Reverse sign of amounts for lines
|
||||
\return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function create_clone($user,$invertdetail=0)
|
||||
{
|
||||
@ -367,13 +368,13 @@ class Facture extends CommonObject
|
||||
if ($invertdetail)
|
||||
{
|
||||
foreach($facture->lignes as $i => $line)
|
||||
{
|
||||
$facture->lignes[$i]->subprice = -$facture->lignes[$i]->subprice;
|
||||
$facture->lignes[$i]->price = -$facture->lignes[$i]->price;
|
||||
$facture->lignes[$i]->total_ht = -$facture->lignes[$i]->total_ht;
|
||||
$facture->lignes[$i]->total_tva = -$facture->lignes[$i]->total_tva;
|
||||
$facture->lignes[$i]->total_ttc = -$facture->lignes[$i]->total_ttc;
|
||||
}
|
||||
{
|
||||
$facture->lignes[$i]->subprice = -$facture->lignes[$i]->subprice;
|
||||
$facture->lignes[$i]->price = -$facture->lignes[$i]->price;
|
||||
$facture->lignes[$i]->total_ht = -$facture->lignes[$i]->total_ht;
|
||||
$facture->lignes[$i]->total_tva = -$facture->lignes[$i]->total_tva;
|
||||
$facture->lignes[$i]->total_ttc = -$facture->lignes[$i]->total_ttc;
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("Facture::create_clone invertdetail=".$invertdetail." socid=".$this->socid." nboflines=".sizeof($facture->lignes));
|
||||
@ -913,8 +914,9 @@ class Facture extends CommonObject
|
||||
|
||||
/**
|
||||
* \brief Tag la facture comme non payée complètement + appel trigger BILL_UNPAYED
|
||||
* Fonction utilisée quand un paiement prélevement est refusé.
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* Fonction utilisée quand un paiement prélevement est refusé,
|
||||
* ou quand une facture annulée et réouverte.
|
||||
* \param user Object user that change status
|
||||
* \return int <0 si ok, >0 si ok
|
||||
*/
|
||||
function set_unpayed($user)
|
||||
@ -923,10 +925,11 @@ class Facture extends CommonObject
|
||||
|
||||
dolibarr_syslog("Facture::set_unpayed rowid=".$this->id, LOG_DEBUG);
|
||||
$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;
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
dolibarr_syslog("Facture::set_unpayed sql=".$sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
|
||||
|
||||
@ -114,7 +114,7 @@ class modFacture extends DolibarrModules
|
||||
|
||||
$r++;
|
||||
$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][3] = 0;
|
||||
$this->rights[$r][4] = 'creer';
|
||||
|
||||
@ -103,6 +103,7 @@ Show=Show
|
||||
Search=Search
|
||||
Valid=Valid
|
||||
Approve=Approve
|
||||
ReOpen=Re-Open
|
||||
Upload=Send file
|
||||
Select=Select
|
||||
Choose=Choose
|
||||
|
||||
@ -78,6 +78,7 @@ Show=Voir
|
||||
Search=Rechercher
|
||||
Valid=Valider
|
||||
Approve=Approuver
|
||||
ReOpen=Réouvrir
|
||||
Upload=Envoyer fichier
|
||||
Select=Sélectionner
|
||||
Choose=Choisir
|
||||
|
||||
@ -104,6 +104,7 @@ Show=Voir
|
||||
Search=Rechercher
|
||||
Valid=Valider
|
||||
Approve=Approuver
|
||||
ReOpen=Réouvrir
|
||||
Upload=Envoyer fichier
|
||||
Select=Sélectionner
|
||||
Choose=Choisir
|
||||
|
||||
Loading…
Reference in New Issue
Block a user