diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 8c87e754bc4..5ac8438f2ad 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -75,6 +75,10 @@ $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); $hookmanager->initHooks(array('ordersuppliercard')); $object = new CommandeFournisseur($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || ! empty($ref)) @@ -692,6 +696,46 @@ else if ($action == 'remove_file' && $object->id > 0 && $user->rights->fournisse else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); } +elseif ($action == 'update_extras') +{ + // Fill array 'array_options' with data from add form + $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + + if($ret < 0) + $error++; + + if(!$error) { + + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('supplierorderdao')); + $parameters=array('id'=>$object->id); + + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + + $result=$object->insertExtraFields(); + + if ($result < 0) + { + $error++; + } + + } + } + else if ($reshook < 0) $error++; + } + else + { + $action = 'edit_extras'; + } +} + /* * Create an order */ @@ -718,6 +762,9 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer) $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + $id = $object->create($user); if ($id < 0) { @@ -1072,7 +1119,12 @@ if ($action=="create") // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + // Bouton "Create Draft" print "\n"; @@ -1089,7 +1141,9 @@ elseif (! empty($object->id)) $title=$langs->trans("SupplierOrder"); dol_fiche_head($head, 'card', $title, 0, 'order'); - + + $res=$object->fetch_optionals($object->id,$extralabels); + /* * Confirmation de la suppression de la commande */ @@ -1355,6 +1409,69 @@ elseif (! empty($object->id)) $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + if ($action == 'edit_extras') + { + print '