Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into 13.0

Conflicts:
	htdocs/adherents/card.php
	htdocs/categories/edit.php
	htdocs/contact/card.php
	htdocs/core/class/extrafields.class.php
	htdocs/product/stock/card.php
This commit is contained in:
Laurent Destailleur 2021-12-08 17:56:05 +01:00
commit f1dac82a53
20 changed files with 36 additions and 26 deletions

View File

@ -302,7 +302,7 @@ if (empty($reshook)) {
$object->public = GETPOST("public", 'alpha'); $object->public = GETPOST("public", 'alpha');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
} }

View File

@ -166,7 +166,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
$object->vote = (boolean) trim($vote); $object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
$ret = $object->update($user); $ret = $object->update($user);

View File

@ -150,7 +150,7 @@ if ($action == 'update' && $user->rights->asset->write)
$object->note = trim($comment); $object->note = trim($comment);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
$ret = $object->update($user); $ret = $object->update($user);

View File

@ -95,7 +95,7 @@ if ($action == 'update' && $user->rights->categorie->creer) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
} }
if (!$error && empty($object->error)) { if (!$error && empty($object->error)) {
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error && $object->update($user) > 0) { if (!$error && $object->update($user) > 0) {

View File

@ -560,7 +560,7 @@ if (empty($reshook) && $action == 'update')
} }
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) { if (!$error) {

View File

@ -239,7 +239,7 @@ if ($action == 'update')
if (!$error) if (!$error)
{ {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
} }
if (!$error) if (!$error)

View File

@ -1593,6 +1593,11 @@ if (empty($reshook))
$discount->tva_tx = $lines[$i]->tva_tx; $discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id; $discount->fk_user = $user->id;
$discount->description = $desc; $discount->description = $desc;
$discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice);
$discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht);
$discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva);
$discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc);
$discountid = $discount->create($user); $discountid = $discount->create($user);
if ($discountid > 0) { if ($discountid > 0) {
$result = $object->insert_discount($discountid); // This include link_to_invoice $result = $object->insert_discount($discountid); // This include link_to_invoice

View File

@ -108,14 +108,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer)
* View * View
*/ */
if (empty($object->id)) {
llxHeader();
$langs->load('errors');
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
llxFooter();
exit;
}
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);

View File

@ -403,7 +403,7 @@ if (empty($reshook))
$object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) if (!$error)

View File

@ -1232,6 +1232,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
continue; continue;
} }
if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) {
$nbignored++;
setEventMessage($langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref));
continue;
}
if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) if ($objectclass == "Task" && $objecttmp->hasChildren() > 0)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id;
@ -1268,7 +1274,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
if (!$error) if (!$error)
{ {
if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); elseif ($nbok > 0) setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();

View File

@ -78,5 +78,9 @@ if (($action == 'set') && !empty($id)) {
$format = 'int'; $format = 'int';
$object->table_element = $tablename;
$object->id = $id;
$object->fields[$field] = array('type' => $format, 'enabled' => 1);
$object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey);
} }

View File

@ -2004,7 +2004,8 @@ class ExtraFields
foreach ($extralabels as $key => $value) foreach ($extralabels as $key => $value)
{ {
if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue; if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue;
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key)) continue; //when unticking boolean field, it's not set in POST
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') continue;
$key_type = $this->attributes[$object->table_element]['type'][$key]; $key_type = $this->attributes[$object->table_element]['type'][$key];
if ($key_type == 'separate') continue; if ($key_type == 'separate') continue;

View File

@ -159,7 +159,7 @@ if ($action == 'update')
$object->modepaymentid = (int) GETPOST('modepayment', 'int'); $object->modepaymentid = (int) GETPOST('modepayment', 'int');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if ($object->update($user) > 0) { if ($object->update($user) > 0) {

View File

@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
HolidaysToApprove=Holidays to approve HolidaysToApprove=Holidays to approve
NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays
ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted

View File

@ -172,9 +172,9 @@ if (empty($reshook))
$object->phone = GETPOST("phone"); $object->phone = GETPOST("phone");
$object->fax = GETPOST("fax"); $object->fax = GETPOST("fax");
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) { if (!$error) {
$ret = $object->update($id, $user); $ret = $object->update($id, $user);

View File

@ -266,7 +266,7 @@ if (empty($reshook))
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0); $object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
} }

View File

@ -102,7 +102,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
$object->progress = price2num(GETPOST('progress', 'alphanohtml')); $object->progress = price2num(GETPOST('progress', 'alphanohtml'));
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!$error) if (!$error)

View File

@ -149,7 +149,7 @@ if (empty($reshook))
$object->country_id = $country_id; $object->country_id = $country_id;
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
} }

View File

@ -444,7 +444,7 @@ if (empty($reshook)) {
} }
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
} }

View File

@ -207,7 +207,7 @@ if (empty($reshook)) {
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml'))); $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;