NEW If max nb of generation is reached, date for next gen is striked
This commit is contained in:
parent
6402d5a2e4
commit
8f24a86352
@ -823,6 +823,30 @@ class FactureRec extends CommonInvoice
|
||||
return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if maximum number of generation is reached
|
||||
*
|
||||
* @return boolean False by default, True if maximum number of generation is reached
|
||||
*/
|
||||
function isMaxNbGenReached()
|
||||
{
|
||||
$ret = false;
|
||||
if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format string to output with by striking the string if max number of generation was reached
|
||||
*
|
||||
* @param string $ret Default value to output
|
||||
* @return boolean False by default, True if maximum number of generation is reached
|
||||
*/
|
||||
function strikeIfMaxNbGenReached($ret)
|
||||
{
|
||||
// Special case to strike the date
|
||||
return ($this->isMaxNbGenReached()?'<strike>':'').$ret.($this->isMaxNbGenReached()?'</strike>':'');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all recurrents invoices (for all entities if multicompany is used).
|
||||
* A result may also be provided into this->output.
|
||||
|
||||
@ -1430,7 +1430,7 @@ else
|
||||
print '</td><td>';
|
||||
if ($action == 'date_when' || $object->frequency > 0)
|
||||
{
|
||||
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day');
|
||||
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -520,6 +520,8 @@ if ($resql)
|
||||
$invoicerectmp->frequency=$objp->frequency;
|
||||
$invoicerectmp->suspend=$objp->suspend;
|
||||
$invoicerectmp->unit_frequency=$objp->unit_frequency;
|
||||
$invoicerectmp->nb_gen_max=$objp->nb_gen_max;
|
||||
$invoicerectmp->nb_gen_done=$objp->nb_gen_done;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -603,7 +605,7 @@ if ($resql)
|
||||
if (! empty($arrayfields['f.date_when']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
|
||||
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'<strike>':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'</strike>':'') : '<span class="opacitymedium">'.$langs->trans('NA').'</span>');
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ class Form
|
||||
}
|
||||
|
||||
/**
|
||||
* Output val field for an editable field
|
||||
* Output value of a field for an editable field
|
||||
*
|
||||
* @param string $text Text of label (not used in this function)
|
||||
* @param string $htmlname Name of select field
|
||||
@ -141,9 +141,10 @@ class Form
|
||||
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
|
||||
* @param string $moreparam More param to add on a href URL
|
||||
* @param int $notabletag Do no output table tags
|
||||
* @param string $formatfunc Call a specific function to output field
|
||||
* @return string HTML edit field
|
||||
*/
|
||||
function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0)
|
||||
function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0, $formatfunc='')
|
||||
{
|
||||
global $conf,$langs,$db;
|
||||
|
||||
@ -257,6 +258,11 @@ class Form
|
||||
$ret.=$tmpcontent;
|
||||
}
|
||||
else $ret.=$value;
|
||||
|
||||
if ($formatfunc && method_exists($object, $formatfunc))
|
||||
{
|
||||
$ret=$object->$formatfunc($ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user