diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 2f69a3936c9..919c0372a21 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -5719,32 +5719,32 @@ if ($action == 'create') {
$isErasable = $object->is_erasable();
$params = array(
'attr' => array(
- 'title' => '',
'class' => 'classfortooltip'
)
);
if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
$enableDelete = false;
$deleteHref = '#';
+ $htmltooltip = '';
if ($isErasable == -4) {
- $params['attr']['title'] = $langs->trans('DisabledBecausePayments');
+ $htmltooltip = $langs->trans('DisabledBecausePayments');
} elseif ($isErasable == -3) {
- $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice');
+ $htmltooltip = $langs->trans('DisabledBecauseNotLastSituationInvoice');
} elseif ($isErasable == -2) {
- $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice');
+ $htmltooltip = $langs->trans('DisabledBecauseNotLastInvoice');
} elseif ($isErasable == -1) {
- $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping');
+ $htmltooltip = $langs->trans('DisabledBecauseDispatchedInBookkeeping');
} elseif ($isErasable <= 0) { // Any other cases
- $params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable');
+ $htmltooltip = $langs->trans('DisabledBecauseNotErasable');
} elseif ($objectidnext) {
- $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice');
+ $htmltooltip = $langs->trans('DisabledBecauseReplacedInvoice');
} else {
$deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken();
$enableDelete = true;
}
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params);
+ print dolGetButtonAction($htmltooltip, $langs->trans('Delete'), 'delete', $deleteHref, '', $enableDelete, $params);
} else {
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false);
+ print dolGetButtonAction($langs->trans('Delete'), $langs->trans('Delete'), 'delete', '#', '', false);
}
}
print '';
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 040267e0259..6c278f4764d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -10567,7 +10567,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* @param array $params = [ // Various params for future : recommended rather than adding more function arguments
* 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want
- * 'class' => '', // to add more css class to the button class attribute
+ * 'class' => 'reposition', // to add more css class to the button class attribute
* 'classOverride' => '' // to replace class attribute of the button
* ],
* 'confirm' => [
@@ -10614,7 +10614,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
if (empty($userRight)) {
$attr['class'] = 'butActionRefused';
$attr['href'] = '';
- $attr['title'] = $langs->trans('NotEnoughPermissions');
+ $attr['title'] = (($label && $text && $label != $text) ? $label : $langs->trans('NotEnoughPermissions'));
}
if (!empty($id)) {
@@ -10670,7 +10670,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
$TCompiledAttr = array();
foreach ($attr as $key => $value) {
- $TCompiledAttr[] = $key.'="'.$value.'"';
+ $TCompiledAttr[] = $key.'= "'.$value.'"';
}
$compiledAttributes = empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 372e1b1e458..44337454772 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -3784,21 +3784,26 @@ if ($action == 'create') {
// Delete
$isErasable = $object->is_erasable();
- if ($action != 'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
- //var_dump($isErasable);
+ if ($action != 'confirm_edit' && ($usercandelete || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
+ $enableDelete = false;
+ $htmltooltip = '';
+ $params = (empty($conf->use_javascript_ajax) ? array() : array('attr' => array('class' => 'reposition')));
+ //var_dump($isErasable); var_dump($params);
if ($isErasable == -4) {
- print ''.$langs->trans('Delete').'';
+ $htmltooltip = $langs->trans("DisabledBecausePayments");
} elseif ($isErasable == -3) { // Should never happen with supplier invoice
- print ''.$langs->trans('Delete').'';
+ $htmltooltip = $langs->trans("DisabledBecauseNotLastSituationInvoice");
} elseif ($isErasable == -2) { // Should never happen with supplier invoice
- print ''.$langs->trans('Delete').'';
+ $htmltooltip = $langs->trans("DisabledBecauseNotLastInvoice");
} elseif ($isErasable == -1) {
- print ''.$langs->trans('Delete').'';
+ $htmltooltip = $langs->trans("DisabledBecauseDispatchedInBookkeeping");
} elseif ($isErasable <= 0) { // Any other cases
- print ''.$langs->trans('Delete').'';
+ $htmltooltip = $langs->trans("DisabledBecauseNotErasable");
} else {
- print 'id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'';
+ $enableDelete = true;
+ $htmltooltip = '';
}
+ print dolGetButtonAction($htmltooltip, $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), $object->id, $enableDelete, $params);
}
print '';
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 7ea8295a346..f13baf06446 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -13,6 +13,7 @@ BillsStatistics=Customers invoices statistics
BillsStatisticsSuppliers=Vendors invoices statistics
DisabledBecauseDispatchedInBookkeeping=Disabled because invoice was dispatched into bookkeeping
DisabledBecauseNotLastInvoice=Disabled because invoice is not erasable. Some invoices were recorded after this one and it will create holes in the counter.
+DisabledBecauseNotLastSituationInvoice=Disabled because invoice is not erasable. This invoice is not the last one in situation invoice cycle.
DisabledBecauseNotErasable=Disabled because cannot be erased
InvoiceStandard=Standard invoice
InvoiceStandardAsk=Standard invoice