Ajout possibilité d'éditer et de supprimer une facture validé sans paiement d'effectué
This commit is contained in:
parent
faa95045f6
commit
80a6c69bcf
@ -145,6 +145,11 @@ if ($_POST["action"] == 'set_disable_repeatable')
|
|||||||
dolibarr_set_const($db, "FACTURE_DISABLE_RECUR",$_POST["disable_repeatable"]);
|
dolibarr_set_const($db, "FACTURE_DISABLE_RECUR",$_POST["disable_repeatable"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_POST["action"] == 'set_enable_editdelete')
|
||||||
|
{
|
||||||
|
dolibarr_set_const($db, "FACTURE_ENABLE_EDITDELETE",$_POST["enable_editdelete"]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
|
if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
|
||||||
{
|
{
|
||||||
if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:''));
|
if (! dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],0,isset($_POST["constnote"])?$_POST["constnote"]:''));
|
||||||
@ -502,6 +507,19 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
// Active la possibilité d'éditer/supprimer une facture validée sans paiement
|
||||||
|
$var=! $var;
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
|
print '<input type="hidden" name="action" value="set_enable_editdelete">';
|
||||||
|
print '<tr '.$bc[$var].'><td>';
|
||||||
|
print $langs->trans("EnableEditDeleteValidInvoice");
|
||||||
|
print '</td><td width="60" align="center">';
|
||||||
|
print $html->selectyesno("enable_editdelete",$conf->global->FACTURE_ENABLE_EDITDELETE,1);
|
||||||
|
print '</td><td align="right">';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print "</td></tr>\n";
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -161,6 +161,16 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->global->FACTURE_ENABLE_EDITDELETE)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Repasse la facture en mode brouillon
|
||||||
|
*/
|
||||||
|
$fac = new Facture($db);
|
||||||
|
$fac->fetch($_GET['facid']);
|
||||||
|
$fac->reopen($user);
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||||
{
|
{
|
||||||
if ($user->rights->facture->creer)
|
if ($user->rights->facture->creer)
|
||||||
@ -1361,7 +1371,16 @@ else
|
|||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'valid')
|
if ($_GET['action'] == 'valid')
|
||||||
{
|
{
|
||||||
$numfa = $fac->getNextNumRef($soc);
|
// on vérifie si la facture est en numérotation provisoire
|
||||||
|
$facref = substr($fac->ref, 1, 4);
|
||||||
|
if ($facref == PROV)
|
||||||
|
{
|
||||||
|
$numfa = $fac->getNextNumRef($soc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$numfa = $fac->ref;
|
||||||
|
}
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$langs->trans('ConfirmValidateBill',$numfa),'confirm_valid');
|
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('ValidateBill'),$langs->trans('ConfirmValidateBill',$numfa),'confirm_valid');
|
||||||
print '<br />';
|
print '<br />';
|
||||||
}
|
}
|
||||||
@ -2074,6 +2093,16 @@ else
|
|||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
// Editer une facture déjà validée et sans paiement
|
||||||
|
if ($fac->statut == 1)
|
||||||
|
{
|
||||||
|
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
|
||||||
|
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0))
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Récurrente
|
// Récurrente
|
||||||
if (! $conf->global->FACTURE_DISABLE_RECUR)
|
if (! $conf->global->FACTURE_DISABLE_RECUR)
|
||||||
{
|
{
|
||||||
@ -2104,11 +2133,37 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supprimer
|
// on vérifie si la facture est en numérotation provisoire
|
||||||
if ($fac->statut == 0 && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
|
$facref = substr($fac->ref, 1, 4);
|
||||||
{
|
if ($facref == PROV)
|
||||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
{
|
||||||
}
|
// Supprimer
|
||||||
|
if ($fac->statut == 0 && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($conf->global->FACTURE_ENABLE_EDITDELETE)
|
||||||
|
{
|
||||||
|
if ($fac->statut == 0 && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
|
||||||
|
{
|
||||||
|
// On ne peut supprimer que la dernière facture validée
|
||||||
|
// pour ne pas avoir de trou dans les numéros
|
||||||
|
$sql = "SELECT MAX(facnumber)";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$maxfacnumber = $db->fetch_row($resql);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($maxfacnumber[0] == $fac->ref)
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Envoyer
|
// Envoyer
|
||||||
if ($fac->statut == 1 && $user->rights->facture->envoyer)
|
if ($fac->statut == 1 && $user->rights->facture->envoyer)
|
||||||
|
|||||||
@ -830,15 +830,22 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
// on vérifie si la facture est en numérotation provisoire
|
||||||
|
$facref = substr($this->ref, 1, 4);
|
||||||
|
|
||||||
$action_notify = 2; // ne pas modifier cette valeur
|
$action_notify = 2; // ne pas modifier cette valeur
|
||||||
if ($force_number)
|
if ($force_number)
|
||||||
{
|
{
|
||||||
$numfa = $force_number;
|
$numfa = $force_number;
|
||||||
}
|
}
|
||||||
else
|
else if ($facref == PROV)
|
||||||
{
|
{
|
||||||
$numfa = $this->getNextNumRef($soc);
|
$numfa = $this->getNextNumRef($soc);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$numfa = $this->ref;
|
||||||
|
}
|
||||||
|
|
||||||
$this->update_price($this->id);
|
$this->update_price($this->id);
|
||||||
|
|
||||||
@ -868,22 +875,26 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref)
|
// On vérifie si la facture était une provisoire
|
||||||
// afin de ne pas perdre les fichiers attachés
|
if ($facref == PROV)
|
||||||
$facref = sanitize_string($this->ref);
|
|
||||||
$snumfa = sanitize_string($numfa);
|
|
||||||
$dirsource = $conf->facture->dir_output.'/'.$facref;
|
|
||||||
$dirdest = $conf->facture->dir_output.'/'.$snumfa;
|
|
||||||
if (file_exists($dirsource))
|
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Facture::set_valid() renommage rep ".$dirsource." en ".$dirdest);
|
// On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref)
|
||||||
|
// afin de ne pas perdre les fichiers attachés
|
||||||
|
$facref = sanitize_string($this->ref);
|
||||||
|
$snumfa = sanitize_string($numfa);
|
||||||
|
$dirsource = $conf->facture->dir_output.'/'.$facref;
|
||||||
|
$dirdest = $conf->facture->dir_output.'/'.$snumfa;
|
||||||
|
if (file_exists($dirsource))
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Facture::set_valid() renommage rep ".$dirsource." en ".$dirdest);
|
||||||
|
|
||||||
if (rename($dirsource, $dirdest))
|
if (rename($dirsource, $dirdest))
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Renommage ok");
|
dolibarr_syslog("Renommage ok");
|
||||||
// Suppression ancien fichier PDF dans nouveau rep
|
// Suppression ancien fichier PDF dans nouveau rep
|
||||||
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
|
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -932,14 +943,16 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// On vérifie si la facture était une provisoire
|
||||||
|
if ($facref == PROV)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Pour chaque produit, on met a jour indicateur nbvente
|
* Pour chaque produit, on met a jour indicateur nbvente
|
||||||
* On crée ici une dénormalisation des données pas forcément utilisée.
|
* On crée ici une dénormalisation des données pas forcément utilisée.
|
||||||
*/
|
*/
|
||||||
$sql = 'SELECT fk_product FROM '.MAIN_DB_PREFIX.'facturedet';
|
$sql = 'SELECT fk_product FROM '.MAIN_DB_PREFIX.'facturedet';
|
||||||
$sql.= ' WHERE fk_facture = '.$this->id;
|
$sql.= ' WHERE fk_facture = '.$this->id;
|
||||||
$sql.= ' AND fk_product > 0';
|
$sql.= ' AND fk_product > 0';
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -958,6 +971,7 @@ class Facture extends CommonObject
|
|||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($error == 0)
|
if ($error == 0)
|
||||||
{
|
{
|
||||||
@ -976,11 +990,11 @@ class Facture extends CommonObject
|
|||||||
* \todo Mettre notifications dans triggers
|
* \todo Mettre notifications dans triggers
|
||||||
*/
|
*/
|
||||||
$facref = sanitize_string($this->ref);
|
$facref = sanitize_string($this->ref);
|
||||||
$filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
|
$filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
|
||||||
$mesg = 'La facture '.$this->ref." a été validée.\n";
|
$mesg = 'La facture '.$this->ref." a été validée.\n";
|
||||||
|
|
||||||
$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);
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
@ -995,6 +1009,25 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function reopen($userid)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0";
|
||||||
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@ -129,11 +129,18 @@ class modFacture extends DolibarrModules
|
|||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 12;
|
$this->rights[$r][0] = 12;
|
||||||
$this->rights[$r][1] = 'Créer/modifier les factures';
|
$this->rights[$r][1] = 'Créer 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';
|
||||||
|
|
||||||
|
$r++;
|
||||||
|
$this->rights[$r][0] = 13;
|
||||||
|
$this->rights[$r][1] = 'Modifier les factures';
|
||||||
|
$this->rights[$r][2] = 'a';
|
||||||
|
$this->rights[$r][3] = 0;
|
||||||
|
$this->rights[$r][4] = 'modifier';
|
||||||
|
|
||||||
$r++;
|
$r++;
|
||||||
$this->rights[$r][0] = 14;
|
$this->rights[$r][0] = 14;
|
||||||
$this->rights[$r][1] = 'Valider les factures';
|
$this->rights[$r][1] = 'Valider les factures';
|
||||||
|
|||||||
@ -142,7 +142,8 @@ Module700Desc=Donations' management
|
|||||||
Module1780Name=Categories
|
Module1780Name=Categories
|
||||||
Module1780Desc=Categories' management
|
Module1780Desc=Categories' management
|
||||||
Permission11=Read invoices
|
Permission11=Read invoices
|
||||||
Permission12=Create/modify invoices
|
Permission12=Create invoices
|
||||||
|
Permission13=Modify invoices
|
||||||
Permission14=Validate invoices
|
Permission14=Validate invoices
|
||||||
Permission15=Send invoices by email
|
Permission15=Send invoices by email
|
||||||
Permission16=Create payments for invoices
|
Permission16=Create payments for invoices
|
||||||
@ -404,6 +405,7 @@ CreditNotes=Credit notes
|
|||||||
ForceInvoiceDate=Force invoice date to validation date
|
ForceInvoiceDate=Force invoice date to validation date
|
||||||
DisableRepeatable=Disable repeatable invoices
|
DisableRepeatable=Disable repeatable invoices
|
||||||
SuggestedPaymentModesIfNotDefinedInInvoice=Suggested Payments mode on invoices if not explicitely defined
|
SuggestedPaymentModesIfNotDefinedInInvoice=Suggested Payments mode on invoices if not explicitely defined
|
||||||
|
EnableEditDeleteValidInvoice=Enable the possibility to edit/delete valid invoice with no payment
|
||||||
##### Proposals #####
|
##### Proposals #####
|
||||||
PropalSetup=Commercial proposals module setup
|
PropalSetup=Commercial proposals module setup
|
||||||
CreateForm=Create forms
|
CreateForm=Create forms
|
||||||
|
|||||||
@ -142,7 +142,8 @@ Module700Desc=Gestion des dons
|
|||||||
Module1780Name=Catégories
|
Module1780Name=Catégories
|
||||||
Module1780Desc=Gestion des catégories
|
Module1780Desc=Gestion des catégories
|
||||||
Permission11=Consulter les factures
|
Permission11=Consulter les factures
|
||||||
Permission12=Créer/modifier les factures
|
Permission12=Créer les factures
|
||||||
|
Permission13=Modifier les factures
|
||||||
Permission14=Valider les factures
|
Permission14=Valider les factures
|
||||||
Permission15=Envoyer les factures par courriel
|
Permission15=Envoyer les factures par courriel
|
||||||
Permission16=Émettre des paiements sur les factures
|
Permission16=Émettre des paiements sur les factures
|
||||||
@ -404,6 +405,7 @@ CreditNotes=Avoirs
|
|||||||
ForceInvoiceDate=Forcer la date de facture à la date de validation
|
ForceInvoiceDate=Forcer la date de facture à la date de validation
|
||||||
DisableRepeatable=Désactiver les factures récurrentes
|
DisableRepeatable=Désactiver les factures récurrentes
|
||||||
SuggestedPaymentModesIfNotDefinedInInvoice=Modes de paiements suggérés sur les factures si non défini explicitement
|
SuggestedPaymentModesIfNotDefinedInInvoice=Modes de paiements suggérés sur les factures si non défini explicitement
|
||||||
|
EnableEditDeleteValidInvoice=Activer la possibilité d'éditer/supprimer une facture validée sans paiement
|
||||||
##### Proposals #####
|
##### Proposals #####
|
||||||
PropalSetup=Configuration du module Propositions Commerciales
|
PropalSetup=Configuration du module Propositions Commerciales
|
||||||
CreateForm=Création formulaire
|
CreateForm=Création formulaire
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user