Merge pull request #3511 from marcosgdf/bug-3423

FIX #3423 Not possible update values of extrafields in Facture
This commit is contained in:
Laurent Destailleur 2015-09-13 19:07:15 +02:00
commit 0ef297582b

View File

@ -1722,61 +1722,7 @@ if (empty($reshook))
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$action = ''; $action = '';
} }
} } elseif ($action == 'update_extras') {
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
{
if ($action == 'addcontact')
{
$result = $object->fetch($id);
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0) {
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
exit();
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
} else {
setEventMessage($object->error, 'errors');
}
}
}
// bascule du statut d'un contact
else if ($action == 'swapstatut')
{
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
}
// Efface un contact
else if ($action == 'deletecontact')
{
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0) {
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
exit();
} else {
dol_print_error($db);
}
}
if ($action == 'update_extras')
{
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
@ -1801,6 +1747,48 @@ if (empty($reshook))
if ($error) if ($error)
$action = 'edit_extras'; $action = 'edit_extras';
} }
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) {
if ($action == 'addcontact') {
$result = $object->fetch($id);
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit();
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
} else {
setEventMessage($object->error, 'errors');
}
}
} // bascule du statut d'un contact
elseif ($action == 'swapstatut') {
if ($object->fetch($id)) {
$result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
} // Efface un contact
elseif ($action == 'deletecontact') {
$object->fetch($id);
$result = $object->delete_contact($lineid);
if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit();
} else {
dol_print_error($db);
}
}
} }
} }