Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
51dc95fbda
@ -305,7 +305,7 @@ if (empty($reshook)) {
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
$last_of_type = $object->willBeLastOfSameType();
|
$last_of_type = $object->willBeLastOfSameType(true);
|
||||||
if (empty($object->date_validation) && !$last_of_type[0]) {
|
if (empty($object->date_validation) && !$last_of_type[0]) {
|
||||||
setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors');
|
setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors');
|
||||||
$action = '';
|
$action = '';
|
||||||
|
|||||||
@ -3009,7 +3009,7 @@ class Facture extends CommonInvoice
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
$last_of_type = $this->willBeLastOfSameType();
|
$last_of_type = $this->willBeLastOfSameType(true);
|
||||||
if (!$last_of_type[0]) {
|
if (!$last_of_type[0]) {
|
||||||
$this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day'));
|
$this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day'));
|
||||||
return -1;
|
return -1;
|
||||||
@ -5567,9 +5567,10 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* See if current invoice date is posterior to the last invoice date among validated invoices of same type.
|
* See if current invoice date is posterior to the last invoice date among validated invoices of same type.
|
||||||
|
* @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function willBeLastOfSameType()
|
public function willBeLastOfSameType($allow_validated_drafts = false)
|
||||||
{
|
{
|
||||||
// get date of last validated invoices of same type
|
// get date of last validated invoices of same type
|
||||||
$sql = "SELECT datef";
|
$sql = "SELECT datef";
|
||||||
@ -5586,7 +5587,12 @@ class Facture extends CommonInvoice
|
|||||||
$last_date = $this->db->jdate($obj->datef);
|
$last_date = $this->db->jdate($obj->datef);
|
||||||
$invoice_date = $this->date;
|
$invoice_date = $this->date;
|
||||||
|
|
||||||
return [$invoice_date >= $last_date, $last_date];
|
$is_last_of_same_type = $invoice_date >= $last_date;
|
||||||
|
if ($allow_validated_drafts) {
|
||||||
|
$is_last_of_same_type = $is_last_of_same_type || (!strpos($this->ref, 'PROV') && $this->status == self::STATUS_DRAFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$is_last_of_same_type, $last_date];
|
||||||
} else {
|
} else {
|
||||||
// element is first of type to be validated
|
// element is first of type to be validated
|
||||||
return [true];
|
return [true];
|
||||||
|
|||||||
@ -615,6 +615,9 @@ class Export
|
|||||||
} else {
|
} else {
|
||||||
$filename = "export_".$datatoexport;
|
$filename = "export_".$datatoexport;
|
||||||
}
|
}
|
||||||
|
if (!empty($conf->global->EXPORT_NAME_WITH_DT)) {
|
||||||
|
$filename .= dol_print_date(dol_now(), '%Y%m%d%_%H%M');
|
||||||
|
}
|
||||||
$filename .= '.'.$objmodel->getDriverExtension();
|
$filename .= '.'.$objmodel->getDriverExtension();
|
||||||
$dirname = $conf->export->dir_temp.'/'.$user->id;
|
$dirname = $conf->export->dir_temp.'/'.$user->id;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user