diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 155f4164890..e3810b53cd4 100755
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -181,8 +181,8 @@ if ($_GET["id"] > 0)
print '';
- // Affiche forumlaire upload
- if (defined('MAIN_UPLOAD_DOC') && $conf->upload)
+ // Affiche formulaire upload
+ if ($conf->upload)
{
print_titre($langs->trans('AttachANewFile'));
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 52d81c481c0..c776e6706ce 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -541,7 +541,7 @@ if ($_GET['action'] == 'deleteline' && $user->rights->facture->creer && !$conf->
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
{
- if ($user->rights->facture->supprimer )
+ if ($user->rights->facture->supprimer)
{
$fac = new Facture($db);
$result = $fac->delete($_GET['facid']);
@@ -2106,7 +2106,7 @@ else
if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
{
print '
';
-
+
// Editer une facture déjà validée, sans paiement effectué et pas exporté en compta
if ($fac->statut == 1)
{
@@ -2119,20 +2119,20 @@ else
$ventilExportCompta++;
}
}
-
+
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0))
{
print '
'.$langs->trans('Edit').'';
}
}
-
+
// Récurrente
if (! $conf->global->FACTURE_DISABLE_RECUR)
{
print '
'.$langs->trans("ChangeIntoRepeatableInvoice").'';
}
-
+
// Valider
if ($fac->statut == 0 && $num_lignes > 0)
{
@@ -2156,80 +2156,55 @@ else
}
}
}
-
- // on vérifie si la facture est en numérotation provisoire
- $facref = substr($fac->ref, 1, 4);
- if ($facref == PROV)
- {
- // Supprimer
- if ($fac->statut == 0 && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
- {
- print '
id.'&action=delete">'.$langs->trans('Delete').'';
- }
- }
- 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);
- }
-
- // On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
- $ventilExportCompta = 0 ;
- for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
- {
- if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
- {
- $ventilExportCompta++;
- }
- }
-
- if ($maxfacnumber[0] == $fac->ref && $ventilExportCompta == 0)
- {
- print '
id.'&action=delete">'.$langs->trans('Delete').'';
- }
- }
- }
-
+
+ // On vérifie si la facture est supprimable. Si oui, on propose bouton supprimer
+ if ($fac->is_erasable() && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
+ {
+ print '
id.'&action=delete">'.$langs->trans('Delete').'';
+ }
+
// Envoyer
if ($fac->statut == 1 && $user->rights->facture->envoyer)
{
print '
'.$langs->trans('SendByMail').'';
}
-
+
// Envoyer une relance
if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer)
{
print '
'.$langs->trans('SendRemindByMail').'';
}
-
+
// Emettre paiement
if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement)
{
print '
'.$langs->trans('DoPaiement').'';
}
-
+
// Classer 'payé'
- if ($fac->statut == 1 && price($resteapayer) <= 0
- && $fac->paye == 0 && $user->rights->facture->paiement)
+ if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement
+ && price($resteapayer) <= 0)
{
print '
'.$langs->trans('ClassifyPayed').'';
}
-
- // Classer 'abandonnée' (possible si validée et pas encore classer payée)
- if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement)
+
+ // Classer 'fermée' (possible si validée et pas encore classer payée)
+ if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement
+ && price($resteapayer) > 0)
{
- print '
'.$langs->trans('ClassifyCanceled').'';
- }
+ if ($totalpaye > 0)
+ {
+ print '
'.$langs->trans('ClassifyPayedPartially').'';
+ }
+ else
+ {
+ print '
'.$langs->trans('ClassifyCanceled').'';
+ // \todo
+ // Ajouter bouton "Annuler et Créer facture remplacement"
+ }
+ }
+
print '
';
}
diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php
index e8505133166..51d83b0aed3 100644
--- a/htdocs/conf/conf.class.php
+++ b/htdocs/conf/conf.class.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2003 Xavier Dutoit