diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index a3d93608ebf..bb6358ed160 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -1518,7 +1518,7 @@ else
}
print '';
- // Date when
+ // Date when (next invoice generation)
print '
| ';
if ($action == 'date_when' || $object->frequency > 0)
{
@@ -1534,7 +1534,14 @@ else
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached');
}
//var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
- if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
+ if (! $object->isMaxNbGenReached())
+ {
+ if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
+ }
+ else
+ {
+ print img_info($langs->trans("MaxNumberOfGenerationReached"));
+ }
print ' | ';
print '
';
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 0966807facd..306106d4889 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -598,11 +598,18 @@ if ($resql)
// Date next generation
if (! empty($arrayfields['f.date_when']['checked']))
{
- print '';
- print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').'');
- if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
- print ' | ';
- if (! $i) $totalarray['nbfield']++;
+ print '';
+ print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').'');
+ if (! $invoicerectmp->isMaxNbGenReached())
+ {
+ if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
+ }
+ else
+ {
+ print img_info($langs->trans("MaxNumberOfGenerationReached"));
+ }
+ print ' | ';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['f.datec']['checked']))
{
@@ -629,7 +636,11 @@ if ($resql)
print '';
if ($user->rights->facture->creer && empty($invoicerectmp->suspended))
{
- if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
+ if ($invoicerectmp->isMaxNbGenReached())
+ {
+ print $langs->trans("MaxNumberOfGenerationReached");
+ }
+ elseif (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{
print '';
print $langs->trans("CreateBill").'';
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 668090129ff..3e5aaca5198 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -521,3 +521,4 @@ BillCreated=%s bill(s) created
StatusOfGeneratedDocuments=Status of document generation
DoNotGenerateDoc=Do not generate document file
AutogenerateDoc=Auto generate document file
+MaxNumberOfGenerationReached=Max number of gen. reached
|