diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index e54ac0bc31a..e081b126dfe 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -302,7 +302,7 @@ if (empty($reshook)) {
$object->public = GETPOST("public", 'alpha');
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) {
$error++;
}
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 9512492004c..2f3fd19240a 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -166,7 +166,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
$ret = $object->update($user);
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 38969d65182..8b0af655706 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -150,7 +150,7 @@ if ($action == 'update' && $user->rights->asset->write)
$object->note = trim($comment);
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
$ret = $object->update($user);
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index f4b7e12cc30..999956e574a 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -95,7 +95,7 @@ if ($action == 'update' && $user->rights->categorie->creer) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
}
if (!$error && empty($object->error)) {
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
if (!$error && $object->update($user) > 0) {
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 2a0371d4615..e14878f5cfc 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -560,7 +560,7 @@ if (empty($reshook) && $action == 'update')
}
// 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 (!$error) {
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index 30e483fdfa9..6832a92216b 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -239,7 +239,7 @@ if ($action == 'update')
if (!$error)
{
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
}
if (!$error)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 71419fb7676..c517ddb2961 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1593,6 +1593,11 @@ if (empty($reshook))
$discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id;
$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);
if ($discountid > 0) {
$result = $object->insert_discount($discountid); // This include link_to_invoice
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index 0a07db12cbd..6b8758bc472 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -108,14 +108,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer)
* View
*/
-if (empty($object->id)) {
- llxHeader();
- $langs->load('errors');
- echo '
'.$langs->trans("ErrorRecordNotFound").'
';
- llxFooter();
- exit;
-}
-
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl);
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 06b5bb36c40..0c95ecb7fd4 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -403,7 +403,7 @@ if (empty($reshook))
$object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty
// 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 (!$error)
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 1ee8dc4b0f2..70b79ffbefc 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1232,6 +1232,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
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)
{
$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 ($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();
} else {
$db->rollback();
diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php
index ceb221b4870..593f4fa4dbc 100644
--- a/htdocs/core/ajax/objectonoff.php
+++ b/htdocs/core/ajax/objectonoff.php
@@ -78,5 +78,9 @@ if (($action == 'set') && !empty($id)) {
$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);
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index aede17c657b..6cee5a01b67 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -2004,7 +2004,8 @@ class ExtraFields
foreach ($extralabels as $key => $value)
{
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];
if ($key_type == 'separate') continue;
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index dd7de85430e..104c0d72bd1 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -159,7 +159,7 @@ if ($action == 'update')
$object->modepaymentid = (int) GETPOST('modepayment', 'int');
// 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 ($object->update($user) > 0) {
diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang
index eb2cd89adf1..ef96e72cc9d 100644
--- a/htdocs/langs/en_US/holiday.lang
+++ b/htdocs/langs/en_US/holiday.lang
@@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
HolidaysToApprove=Holidays to approve
NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays
+ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted
diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index a708ace0c22..813c765aa6f 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -172,9 +172,9 @@ if (empty($reshook))
$object->phone = GETPOST("phone");
$object->fax = GETPOST("fax");
- // Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
+ if ($ret < 0) $error++;
if (!$error) {
$ret = $object->update($id, $user);
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index df63c805948..3f496de2f66 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -266,7 +266,7 @@ if (empty($reshook))
$object->usage_organize_event = (GETPOST('usage_organize_event', 'alpha') == 'on' ? 1 : 0);
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
}
diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php
index 1b086ee2c69..54d6d09b230 100644
--- a/htdocs/projet/tasks/task.php
+++ b/htdocs/projet/tasks/task.php
@@ -102,7 +102,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer)
$object->progress = price2num(GETPOST('progress', 'alphanohtml'));
// 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 (!$error)
diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php
index 0909dd93b8e..a215e5734bc 100644
--- a/htdocs/resource/card.php
+++ b/htdocs/resource/card.php
@@ -149,7 +149,7 @@ if (empty($reshook))
$object->country_id = $country_id;
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) {
$error++;
}
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index aafdea49a80..5314fd16a73 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -444,7 +444,7 @@ if (empty($reshook)) {
}
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) {
$error++;
}
diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php
index 68d9639990c..550c71bf364 100644
--- a/htdocs/user/group/card.php
+++ b/htdocs/user/group/card.php
@@ -207,7 +207,7 @@ if (empty($reshook)) {
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));
// 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 (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0;