From 83c369cc0f1f9b0fe50dfdea91e8e719df7d04d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 20 May 2019 13:02:33 +0200 Subject: [PATCH] Add $array_to_check for property in invoice instead of thirdparty --- htdocs/compta/facture/card.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 329ecbbedcc..6cef63af90a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -477,7 +477,7 @@ if (empty($reshook)) // Check parameters - // Check for mandatory fields defined into setup + // Check for mandatory fields in thirdparty (defined into setup) $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); foreach($array_to_check as $key) { @@ -518,6 +518,23 @@ if (empty($reshook)) } } + // Check for mandatory fields in invoice + $array_to_check=array('REF_CUSTOMER'=>'RefCustomer'); + foreach($array_to_check as $key => $val) + { + $keymin=strtolower($key); + $vallabel=$object->$keymin; + + // Check for mandatory + $keymandatory ='INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; + if (! $vallabel && ! empty($conf->global->$keymandatory)) + { + $langs->load("errors"); + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); + } + } + // Check for warehouse if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) {